💸Generate Invoice
Generate and send invoice to task creator
Input parameters
TaskID
How to call from app
HTTP request to: /generate-invoice/TASKID
Logic (Plan)
Get all the user data for the assigned person and the task owner.
use the following api to generate a pdf:https://invoice-generator.com/developers#create-invoice-pdfExample request:https://app.gitbook.com/o/Rxgn45SRgGRWbR4O7VXE/s/CfpEDb4ZyyJ4bmPlsblL/step-4-taskflow/generate-invoiceSave the pdf file in the to the storage (Under: "invoices/TaskId")
Get the URL from the the storage and add it to the task document (InvoiceUrl="")
Implemented Logic
get task, developer & owner data
add invoiceSend: true to the task data
create invoice with this details (using invoice-generator.com format so it will be easier if decided to use their service later)
const invoice = { from: `${developerData.firstName} ${developerData.lastName} \n${developerStreetAddress}${developerLocation} ${developerPostalCode}`, to: `${ownerData.firstName} ${ownerData.lastName}`, currency: "eur", number: `${taskId}`, items: [ { name: `Task #${taskId}`, quantity: 1, unit_cost: updatedTaskData.price, }, ], fields: { tax: "%", }, tax: 0, projectId: projectDoc.id, projectName: projectData.projectName, taskId: taskId, taskName: updatedTaskData.taskName, status: "open", updatedAt: updatedTaskData.updatedAt, developerEmail: updatedTaskData.assignToEmail, taskCreator: updatedTaskData.taskCreator, };
save invoice to "invoices/TaskId"
Last updated