64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/logic/documents/builders/invoice.builder.js
|
|
|
|
module.exports = {
|
|
sheetName: "Invoice",
|
|
|
|
build: async (worksheet, data) => {
|
|
worksheet.addRow(["INVOICE"]).font = {
|
|
bold: true,
|
|
size: 18,
|
|
};
|
|
|
|
worksheet.addRow([]);
|
|
|
|
worksheet.addRow(["Invoice No", data.invoiceNo]);
|
|
worksheet.addRow(["Customer", data.customerName]);
|
|
worksheet.addRow(["Date", data.date]);
|
|
|
|
worksheet.addRow([]);
|
|
|
|
const header = worksheet.addRow([
|
|
"Description",
|
|
"Qty",
|
|
"Rate",
|
|
"Amount",
|
|
]);
|
|
|
|
header.font = { bold: true };
|
|
|
|
let total = 0;
|
|
|
|
(data.items || []).forEach((item) => {
|
|
const amount = item.qty * item.rate;
|
|
|
|
total += amount;
|
|
|
|
worksheet.addRow([
|
|
item.description,
|
|
item.qty,
|
|
item.rate,
|
|
amount,
|
|
]);
|
|
});
|
|
|
|
worksheet.addRow([]);
|
|
|
|
worksheet.addRow([
|
|
"",
|
|
"",
|
|
"TOTAL",
|
|
total,
|
|
]).font = {
|
|
bold: true,
|
|
};
|
|
},
|
|
}; |