Building Estimate & BOQ Calculator
Detail Estimate Calculation
Select items by category from the catalog to add measurement rows.
| S.N. | Description of Work | No. | Length | Breadth | Height | Quantity | Unit | Remarks | Action |
|---|
Bill of Quantities (BOQ) & Abstract of Cost
Quantities auto-summarized from Detail Estimate measurements.
| Item Code | BOQ Description / Abstract Cost Description | Unit | Total Quantity | Unit Rate (NPR) | Amount (NPR) |
|---|
Sub Total: 0.00
Vat (13%): 0.00
Grand Total: 0.00
`;let blob = new Blob([excelHTML], { type: "application/vnd.ms-excel;charset=utf-8;" });
let link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "Detail_Estimate.xls";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}function exportBOQToExcel() {
let subTotal = document.getElementById("sub-total").textContent;
let vatAmount = document.getElementById("vat-amount").textContent;
let grandTotal = document.getElementById("grand-total").textContent;let excelHTML = `
2. Bill of Quantities (BOQ) & Abstract of Cost
| Item Code | BOQ Description | Unit | Total Quantity | Unit Rate (NPR) | Amount (NPR) |
`;let boqMap = {};
estimateItems.forEach(item => {
if(!boqMap[item.code]) {
const master = itemMaster.find(m => m.code === item.code);
boqMap[item.code] = {
code: item.code,
desc: master ? master.boq : item.absDesc,
unit: item.unit,
totalQty: 0,
rate: item.rate || 0
};
}
if (!item.isSubTotal) {
boqMap[item.code].totalQty += item.qty;
}
});Object.values(boqMap).forEach(b => {
let amt = b.totalQty * b.rate;
excelHTML += `| ${b.code} | ${b.desc} | ${b.unit} | ${b.totalQty.toFixed(2)} | ${b.rate ? b.rate.toFixed(2) : ''} | ${amt.toFixed(2)} |
`;
});excelHTML += `| Sub Total | ${subTotal} |
| VAT (13%) | ${vatAmount} |
| Grand Total | ${grandTotal} |
`;let blob = new Blob([excelHTML], { type: "application/vnd.ms-excel;charset=utf-8;" });
let link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "Bill_of_Quantities_BOQ.xls";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}// --- JSON Import/Export Facility ---function exportProjectJSON() {
const projectData = {
estimateItems: estimateItems,
exportDate: new Date().toISOString()
};
let dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(projectData, null, 2));
let downloadAnchor = document.createElement('a');
downloadAnchor.setAttribute("href", dataStr);
downloadAnchor.setAttribute("download", "building_estimate_project.json");
document.body.appendChild(downloadAnchor);
downloadAnchor.click();
downloadAnchor.remove();
}function importProjectJSON(event) {
let file = event.target.files[0];
if (!file) return;let reader = new FileReader();
reader.onload = function(e) {
try {
let importedData = JSON.parse(e.target.result);
if (importedData.estimateItems && Array.isArray(importedData.estimateItems)) {
estimateItems = importedData.estimateItems;
renderEstimate();
alert("Project imported successfully!");
} else {
alert("Invalid project file format.");
}
} catch (err) {
alert("Error parsing JSON file.");
}
};
reader.readAsText(file);
event.target.value = '';
}