Files
Isuru Bimsara 81d0e65686 first commit
2026-08-14 22:46:02 +05:30

68 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/precost.builder.js
module.exports = {
sheetName: "PreCost Estimate",
build: async (worksheet, data) => {
worksheet.addRow(["PreCost Estimate"]).font = {
bold: true,
size: 16,
};
worksheet.addRow([]);
worksheet.addRow([
"Customer",
data.customerName || "",
]);
worksheet.addRow([]);
const header = worksheet.addRow([
"Item",
"Description",
"Qty",
"Unit Price",
"Total",
]);
header.font = { bold: true };
let total = 0;
(data.items || []).forEach((item) => {
const rowTotal = item.quantity * item.unit_price;
total += rowTotal;
worksheet.addRow([
item.item_name,
item.customer_remark ,
item.quantity,
item.unit_price,
rowTotal,
]);
});
worksheet.addRow([]);
worksheet.addRow([
"",
"",
"",
"Grand Total",
total,
]).font = {
bold: true,
};
},
};