@tonzxz/government-forms 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FORM_CATALOG.md +44 -0
- package/README.md +165 -0
- package/dist/definitions.d.ts +1147 -0
- package/dist/definitions.js +60 -0
- package/dist/forms/iar.d.ts +172 -0
- package/dist/forms/iar.js +6 -0
- package/dist/forms/ics.d.ts +48 -0
- package/dist/forms/ics.js +6 -0
- package/dist/forms/iirup.d.ts +54 -0
- package/dist/forms/iirup.js +6 -0
- package/dist/forms/iirusp.d.ts +32 -0
- package/dist/forms/iirusp.js +6 -0
- package/dist/forms/itr.d.ts +42 -0
- package/dist/forms/itr.js +6 -0
- package/dist/forms/par.d.ts +84 -0
- package/dist/forms/par.js +6 -0
- package/dist/forms/ppelc.d.ts +34 -0
- package/dist/forms/ppelc.js +6 -0
- package/dist/forms/pr.d.ts +27 -0
- package/dist/forms/pr.js +6 -0
- package/dist/forms/property-card.d.ts +68 -0
- package/dist/forms/property-card.js +6 -0
- package/dist/forms/ptr.d.ts +54 -0
- package/dist/forms/ptr.js +6 -0
- package/dist/forms/regspi.d.ts +32 -0
- package/dist/forms/regspi.js +6 -0
- package/dist/forms/ris.d.ts +66 -0
- package/dist/forms/ris.js +6 -0
- package/dist/forms/rlsddp.d.ts +54 -0
- package/dist/forms/rlsddp.js +6 -0
- package/dist/forms/rlsddsp.d.ts +42 -0
- package/dist/forms/rlsddsp.js +6 -0
- package/dist/forms/rpci.d.ts +32 -0
- package/dist/forms/rpci.js +6 -0
- package/dist/forms/rpcppe.d.ts +32 -0
- package/dist/forms/rpcppe.js +6 -0
- package/dist/forms/rpcsp.d.ts +32 -0
- package/dist/forms/rpcsp.js +6 -0
- package/dist/forms/rrsp.d.ts +32 -0
- package/dist/forms/rrsp.js +6 -0
- package/dist/forms/rsmi.d.ts +32 -0
- package/dist/forms/rsmi.js +6 -0
- package/dist/forms/rsmp.d.ts +33 -0
- package/dist/forms/rsmp.js +6 -0
- package/dist/forms/rspi.d.ts +32 -0
- package/dist/forms/rspi.js +6 -0
- package/dist/forms/spc.d.ts +37 -0
- package/dist/forms/spc.js +6 -0
- package/dist/forms/splc.d.ts +41 -0
- package/dist/forms/splc.js +6 -0
- package/dist/forms/stock-card.d.ts +28 -0
- package/dist/forms/stock-card.js +6 -0
- package/dist/forms/wmr.d.ts +32 -0
- package/dist/forms/wmr.js +6 -0
- package/dist/gam/components/gam-report-workbench.d.ts +40 -0
- package/dist/gam/components/gam-report-workbench.js +2 -0
- package/dist/gam/components/grand-total-computation.d.ts +10 -0
- package/dist/gam/components/grand-total-computation.js +26 -0
- package/dist/gam/components/iar-preview.d.ts +30 -0
- package/dist/gam/components/iar-preview.js +150 -0
- package/dist/gam/components/ics-preview.d.ts +31 -0
- package/dist/gam/components/ics-preview.js +114 -0
- package/dist/gam/components/iirup-preview.d.ts +42 -0
- package/dist/gam/components/iirup-preview.js +237 -0
- package/dist/gam/components/itr-preview.d.ts +31 -0
- package/dist/gam/components/itr-preview.js +180 -0
- package/dist/gam/components/par-preview.d.ts +28 -0
- package/dist/gam/components/par-preview.js +95 -0
- package/dist/gam/components/ppelc-preview.d.ts +28 -0
- package/dist/gam/components/ppelc-preview.js +128 -0
- package/dist/gam/components/property-card-preview.d.ts +21 -0
- package/dist/gam/components/property-card-preview.js +117 -0
- package/dist/gam/components/ptr-preview.d.ts +36 -0
- package/dist/gam/components/ptr-preview.js +122 -0
- package/dist/gam/components/purchase-order-page-client.d.ts +66 -0
- package/dist/gam/components/purchase-order-page-client.js +179 -0
- package/dist/gam/components/reg-spi-preview.d.ts +28 -0
- package/dist/gam/components/reg-spi-preview.js +138 -0
- package/dist/gam/components/ris-form.d.ts +13 -0
- package/dist/gam/components/ris-form.js +20 -0
- package/dist/gam/components/ris-preview.d.ts +7 -0
- package/dist/gam/components/ris-preview.js +16 -0
- package/dist/gam/components/rlsddp-preview.d.ts +34 -0
- package/dist/gam/components/rlsddp-preview.js +251 -0
- package/dist/gam/components/rlsddsp-preview.d.ts +33 -0
- package/dist/gam/components/rlsddsp-preview.js +226 -0
- package/dist/gam/components/rpci-preview.d.ts +27 -0
- package/dist/gam/components/rpci-preview.js +123 -0
- package/dist/gam/components/rpcppe-preview.d.ts +28 -0
- package/dist/gam/components/rpcppe-preview.js +133 -0
- package/dist/gam/components/rpcsp-preview.d.ts +29 -0
- package/dist/gam/components/rpcsp-preview.js +81 -0
- package/dist/gam/components/rspi-preview.d.ts +23 -0
- package/dist/gam/components/rspi-preview.js +72 -0
- package/dist/gam/components/spc-preview.d.ts +23 -0
- package/dist/gam/components/spc-preview.js +149 -0
- package/dist/gam/components/splc-entry-form.d.ts +14 -0
- package/dist/gam/components/splc-entry-form.js +6 -0
- package/dist/gam/components/splc-preview.d.ts +27 -0
- package/dist/gam/components/splc-preview.js +192 -0
- package/dist/gam/components/stock-card-preview.d.ts +14 -0
- package/dist/gam/components/stock-card-preview.js +17 -0
- package/dist/gam/config/new-report-config.d.ts +1094 -0
- package/dist/gam/config/new-report-config.js +1478 -0
- package/dist/gam/purchase-order-flow.d.ts +146 -0
- package/dist/gam/purchase-order-flow.js +173 -0
- package/dist/gam/purchase-request/workflow.d.ts +19 -0
- package/dist/gam/purchase-request/workflow.js +45 -0
- package/dist/gam/types/ris-types.d.ts +37 -0
- package/dist/gam/types/ris-types.js +1 -0
- package/dist/gam/utils/export-ics-xlsx.d.ts +28 -0
- package/dist/gam/utils/export-ics-xlsx.js +273 -0
- package/dist/gam/utils/export-par-xlsx.d.ts +18 -0
- package/dist/gam/utils/export-par-xlsx.js +181 -0
- package/dist/gam/utils/export-preview-pdf.d.ts +13 -0
- package/dist/gam/utils/export-preview-pdf.js +270 -0
- package/dist/gam/utils/export-report-xlsx.d.ts +228 -0
- package/dist/gam/utils/export-report-xlsx.js +873 -0
- package/dist/gam/utils/line-totals.d.ts +6 -0
- package/dist/gam/utils/line-totals.js +18 -0
- package/dist/gam/utils/monetary-input.d.ts +6 -0
- package/dist/gam/utils/monetary-input.js +18 -0
- package/dist/gam/utils/print-element.d.ts +8 -0
- package/dist/gam/utils/print-element.js +157 -0
- package/dist/government-form.d.ts +16 -0
- package/dist/government-form.js +45 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +50 -0
- package/dist/internal/components/configurable-form-layout.d.ts +20 -0
- package/dist/internal/components/configurable-form-layout.js +49 -0
- package/dist/internal/components/ui/badge.d.ts +7 -0
- package/dist/internal/components/ui/badge.js +34 -0
- package/dist/internal/components/ui/button.d.ts +10 -0
- package/dist/internal/components/ui/button.js +35 -0
- package/dist/internal/components/ui/calendar.d.ts +8 -0
- package/dist/internal/components/ui/calendar.js +77 -0
- package/dist/internal/components/ui/command.d.ts +19 -0
- package/dist/internal/components/ui/command.js +36 -0
- package/dist/internal/components/ui/date-input.d.ts +14 -0
- package/dist/internal/components/ui/date-input.js +33 -0
- package/dist/internal/components/ui/date-picker.d.ts +19 -0
- package/dist/internal/components/ui/date-picker.js +34 -0
- package/dist/internal/components/ui/dialog.d.ts +18 -0
- package/dist/internal/components/ui/dialog.js +38 -0
- package/dist/internal/components/ui/input-group.d.ts +18 -0
- package/dist/internal/components/ui/input-group.js +57 -0
- package/dist/internal/components/ui/input.d.ts +3 -0
- package/dist/internal/components/ui/input.js +12 -0
- package/dist/internal/components/ui/label.d.ts +3 -0
- package/dist/internal/components/ui/label.js +7 -0
- package/dist/internal/components/ui/popover.d.ts +9 -0
- package/dist/internal/components/ui/popover.js +23 -0
- package/dist/internal/components/ui/select.d.ts +17 -0
- package/dist/internal/components/ui/select.js +35 -0
- package/dist/internal/components/ui/switch.d.ts +5 -0
- package/dist/internal/components/ui/switch.js +8 -0
- package/dist/internal/components/ui/table.d.ts +10 -0
- package/dist/internal/components/ui/table.js +28 -0
- package/dist/internal/components/ui/tabs.d.ts +10 -0
- package/dist/internal/components/ui/tabs.js +29 -0
- package/dist/internal/components/ui/textarea.d.ts +3 -0
- package/dist/internal/components/ui/textarea.js +7 -0
- package/dist/internal/components/ui/tooltip.d.ts +6 -0
- package/dist/internal/components/ui/tooltip.js +17 -0
- package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.d.ts +112 -0
- package/dist/internal/contracts/modules/v1/reg-spi-reports/reg-spi-reports.schema.js +91 -0
- package/dist/internal/hooks/use-form-field-order.d.ts +7 -0
- package/dist/internal/hooks/use-form-field-order.js +43 -0
- package/dist/internal/lib/utils.d.ts +2 -0
- package/dist/internal/lib/utils.js +3 -0
- package/dist/inventory/components/inventory-item-form.d.ts +7 -0
- package/dist/inventory/components/inventory-item-form.js +5 -0
- package/dist/inventory/components/inventory-item-preview.d.ts +6 -0
- package/dist/inventory/components/inventory-item-preview.js +5 -0
- package/dist/inventory/iar.d.ts +4 -0
- package/dist/inventory/iar.js +4 -0
- package/dist/inventory/ics.d.ts +2 -0
- package/dist/inventory/ics.js +3 -0
- package/dist/inventory/iirup.d.ts +2 -0
- package/dist/inventory/iirup.js +3 -0
- package/dist/inventory/iirusp.d.ts +4 -0
- package/dist/inventory/iirusp.js +4 -0
- package/dist/inventory/index.d.ts +3 -0
- package/dist/inventory/index.js +4 -0
- package/dist/inventory/item.d.ts +3 -0
- package/dist/inventory/item.js +3 -0
- package/dist/inventory/itr.d.ts +4 -0
- package/dist/inventory/itr.js +4 -0
- package/dist/inventory/par.d.ts +2 -0
- package/dist/inventory/par.js +3 -0
- package/dist/inventory/po.d.ts +2 -0
- package/dist/inventory/po.js +2 -0
- package/dist/inventory/ppelc.d.ts +2 -0
- package/dist/inventory/ppelc.js +3 -0
- package/dist/inventory/pplc.d.ts +2 -0
- package/dist/inventory/pplc.js +4 -0
- package/dist/inventory/pr.d.ts +4 -0
- package/dist/inventory/pr.js +4 -0
- package/dist/inventory/property-card.d.ts +2 -0
- package/dist/inventory/property-card.js +3 -0
- package/dist/inventory/ptr.d.ts +2 -0
- package/dist/inventory/ptr.js +3 -0
- package/dist/inventory/regspi.d.ts +4 -0
- package/dist/inventory/regspi.js +4 -0
- package/dist/inventory/ris.d.ts +4 -0
- package/dist/inventory/ris.js +4 -0
- package/dist/inventory/rlsddp.d.ts +4 -0
- package/dist/inventory/rlsddp.js +4 -0
- package/dist/inventory/rlsddsp.d.ts +2 -0
- package/dist/inventory/rlsddsp.js +3 -0
- package/dist/inventory/rpci.d.ts +2 -0
- package/dist/inventory/rpci.js +3 -0
- package/dist/inventory/rpcppe.d.ts +2 -0
- package/dist/inventory/rpcppe.js +3 -0
- package/dist/inventory/rpcsp.d.ts +2 -0
- package/dist/inventory/rpcsp.js +3 -0
- package/dist/inventory/rrsp.d.ts +2 -0
- package/dist/inventory/rrsp.js +3 -0
- package/dist/inventory/rsmi.d.ts +4 -0
- package/dist/inventory/rsmi.js +4 -0
- package/dist/inventory/rsmp.d.ts +4 -0
- package/dist/inventory/rsmp.js +4 -0
- package/dist/inventory/rspi.d.ts +2 -0
- package/dist/inventory/rspi.js +3 -0
- package/dist/inventory/spc.d.ts +2 -0
- package/dist/inventory/spc.js +3 -0
- package/dist/inventory/splc.d.ts +3 -0
- package/dist/inventory/splc.js +4 -0
- package/dist/inventory/stock-card.d.ts +4 -0
- package/dist/inventory/stock-card.js +4 -0
- package/dist/inventory/types.d.ts +11 -0
- package/dist/inventory/types.js +1 -0
- package/dist/inventory/wmr.d.ts +4 -0
- package/dist/inventory/wmr.js +4 -0
- package/dist/lib/rpcsp-accountable-person.d.ts +1 -0
- package/dist/lib/rpcsp-accountable-person.js +10 -0
- package/dist/reports/iar/_components/create-form.d.ts +13 -0
- package/dist/reports/iar/_components/create-form.js +92 -0
- package/dist/reports/iar/_components/document-preview.d.ts +11 -0
- package/dist/reports/iar/_components/document-preview.js +131 -0
- package/dist/reports/iar/types.d.ts +97 -0
- package/dist/reports/iar/types.js +24 -0
- package/dist/reports/iirusp/_components/create-form.d.ts +17 -0
- package/dist/reports/iirusp/_components/create-form.js +118 -0
- package/dist/reports/iirusp/_components/document-preview.d.ts +8 -0
- package/dist/reports/iirusp/_components/document-preview.js +389 -0
- package/dist/reports/iirusp/types.d.ts +134 -0
- package/dist/reports/iirusp/types.js +29 -0
- package/dist/reports/iirusp/utils.d.ts +29 -0
- package/dist/reports/iirusp/utils.js +488 -0
- package/dist/reports/itr/_components/create-form.d.ts +28 -0
- package/dist/reports/itr/_components/create-form.js +90 -0
- package/dist/reports/itr/_components/document-preview.d.ts +6 -0
- package/dist/reports/itr/_components/document-preview.js +7 -0
- package/dist/reports/itr/types.d.ts +68 -0
- package/dist/reports/itr/types.js +27 -0
- package/dist/reports/itr/utils.d.ts +24 -0
- package/dist/reports/itr/utils.js +76 -0
- package/dist/reports/pr/_components/create-form.d.ts +16 -0
- package/dist/reports/pr/_components/create-form.js +52 -0
- package/dist/reports/pr/_components/document-preview.d.ts +7 -0
- package/dist/reports/pr/_components/document-preview.js +9 -0
- package/dist/reports/pr/types.d.ts +69 -0
- package/dist/reports/pr/types.js +1 -0
- package/dist/reports/pr/utils.d.ts +72 -0
- package/dist/reports/pr/utils.js +572 -0
- package/dist/reports/regspi/_components/create-form.d.ts +19 -0
- package/dist/reports/regspi/_components/create-form.js +33 -0
- package/dist/reports/regspi/_components/document-preview.d.ts +6 -0
- package/dist/reports/regspi/_components/document-preview.js +7 -0
- package/dist/reports/regspi/types.d.ts +29 -0
- package/dist/reports/regspi/types.js +24 -0
- package/dist/reports/regspi/utils.d.ts +48 -0
- package/dist/reports/regspi/utils.js +98 -0
- package/dist/reports/ris/_components/create-form.d.ts +36 -0
- package/dist/reports/ris/_components/create-form.js +149 -0
- package/dist/reports/ris/_components/document-preview.d.ts +8 -0
- package/dist/reports/ris/_components/document-preview.js +31 -0
- package/dist/reports/ris/types.d.ts +93 -0
- package/dist/reports/ris/types.js +1 -0
- package/dist/reports/rlsddp/_components/create-form.d.ts +11 -0
- package/dist/reports/rlsddp/_components/create-form.js +165 -0
- package/dist/reports/rlsddp/_components/document-preview.d.ts +8 -0
- package/dist/reports/rlsddp/_components/document-preview.js +15 -0
- package/dist/reports/rlsddp/types.d.ts +105 -0
- package/dist/reports/rlsddp/types.js +31 -0
- package/dist/reports/rrsp/components/rrsp-preview.d.ts +21 -0
- package/dist/reports/rrsp/components/rrsp-preview.js +155 -0
- package/dist/reports/rsmi/components/rsmi-create-form.d.ts +20 -0
- package/dist/reports/rsmi/components/rsmi-create-form.js +8 -0
- package/dist/reports/rsmi/components/rsmi-document-body.d.ts +15 -0
- package/dist/reports/rsmi/components/rsmi-document-body.js +12 -0
- package/dist/reports/rsmi/components/rsmi-types.d.ts +45 -0
- package/dist/reports/rsmi/components/rsmi-types.js +1 -0
- package/dist/reports/rsmi/components/rsmi-utils.d.ts +2 -0
- package/dist/reports/rsmi/components/rsmi-utils.js +18 -0
- package/dist/reports/rsmp/components/rsmp-create-modal.d.ts +5 -0
- package/dist/reports/rsmp/components/rsmp-create-modal.js +7 -0
- package/dist/reports/rsmp/components/rsmp-preview-modal.d.ts +11 -0
- package/dist/reports/rsmp/components/rsmp-preview-modal.js +47 -0
- package/dist/reports/rsmp/components/rsmp-types.d.ts +44 -0
- package/dist/reports/rsmp/components/rsmp-types.js +1 -0
- package/dist/reports/rsmp/components/rsmp-utils.d.ts +5 -0
- package/dist/reports/rsmp/components/rsmp-utils.js +41 -0
- package/dist/reports/rsmp/lib/rsmp-grouping.d.ts +14 -0
- package/dist/reports/rsmp/lib/rsmp-grouping.js +75 -0
- package/dist/reports/stock-card/_components/create-form.d.ts +13 -0
- package/dist/reports/stock-card/_components/create-form.js +39 -0
- package/dist/reports/stock-card/_components/document-preview.d.ts +7 -0
- package/dist/reports/stock-card/_components/document-preview.js +29 -0
- package/dist/reports/stock-card/types.d.ts +31 -0
- package/dist/reports/stock-card/types.js +1 -0
- package/dist/reports/stock-card/utils.d.ts +32 -0
- package/dist/reports/stock-card/utils.js +248 -0
- package/dist/reports/wmr/_components/create-form.d.ts +22 -0
- package/dist/reports/wmr/_components/create-form.js +61 -0
- package/dist/reports/wmr/_components/document-preview.d.ts +10 -0
- package/dist/reports/wmr/_components/document-preview.js +59 -0
- package/dist/reports/wmr/types.d.ts +45 -0
- package/dist/reports/wmr/types.js +1 -0
- package/dist/reports/wmr/utils.d.ts +32 -0
- package/dist/reports/wmr/utils.js +343 -0
- package/dist/styles.css +4492 -0
- package/extraction-manifest.json +620 -0
- package/package.json +197 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import * as XLSX from "xlsx-js-style";
|
|
2
|
+
export function generateWmrNo(records) {
|
|
3
|
+
const index = typeof records === "number" ? records : records.reduce((highest, record) => {
|
|
4
|
+
const match = /^REPORTS-WMR-(\d+)$/.exec(record.wmrNo);
|
|
5
|
+
return match ? Math.max(highest, Number(match[1])) : highest;
|
|
6
|
+
}, 0) + 1;
|
|
7
|
+
return `REPORTS-WMR-${String(index).padStart(4, "0")}`;
|
|
8
|
+
}
|
|
9
|
+
export function formatCurrency(value) {
|
|
10
|
+
return new Intl.NumberFormat("en-PH", { style: "currency", currency: "PHP" }).format(value);
|
|
11
|
+
}
|
|
12
|
+
export function formatDateTime(value) {
|
|
13
|
+
return new Date(value).toLocaleString("en-PH", {
|
|
14
|
+
year: "numeric",
|
|
15
|
+
month: "short",
|
|
16
|
+
day: "2-digit",
|
|
17
|
+
hour: "2-digit",
|
|
18
|
+
minute: "2-digit",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function formatDate(value) {
|
|
22
|
+
if (!value)
|
|
23
|
+
return "-";
|
|
24
|
+
return new Date(value).toLocaleDateString("en-PH", {
|
|
25
|
+
year: "numeric",
|
|
26
|
+
month: "short",
|
|
27
|
+
day: "2-digit",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export const EMPTY_ITEM = {
|
|
31
|
+
item: "",
|
|
32
|
+
quantity: "",
|
|
33
|
+
unit: "",
|
|
34
|
+
description: "",
|
|
35
|
+
recordOfSales: "",
|
|
36
|
+
officialReceiptNo: "",
|
|
37
|
+
saleDate: "",
|
|
38
|
+
amount: "",
|
|
39
|
+
};
|
|
40
|
+
export const EMPTY_BASIC_FORM = {
|
|
41
|
+
schoolStorageName: "",
|
|
42
|
+
reportDate: "",
|
|
43
|
+
sourceProcess: "",
|
|
44
|
+
wasteType: "",
|
|
45
|
+
assessedValue: "",
|
|
46
|
+
disposition: "",
|
|
47
|
+
referenceDoc: "",
|
|
48
|
+
items: [{ ...EMPTY_ITEM }],
|
|
49
|
+
};
|
|
50
|
+
export const WASTE_TYPE_OPTIONS = [
|
|
51
|
+
"Condemned Equipment",
|
|
52
|
+
"Scrap Materials",
|
|
53
|
+
"Unserviceable Property",
|
|
54
|
+
"Expired Supplies",
|
|
55
|
+
"Damaged Goods",
|
|
56
|
+
"Other Waste",
|
|
57
|
+
];
|
|
58
|
+
export const DISPOSITION_OPTIONS = [
|
|
59
|
+
"Sale",
|
|
60
|
+
"Disposal",
|
|
61
|
+
"Transfer",
|
|
62
|
+
"Destruction",
|
|
63
|
+
"Auction",
|
|
64
|
+
"Other",
|
|
65
|
+
];
|
|
66
|
+
export const SOURCE_PROCESS_OPTIONS = [
|
|
67
|
+
"Annual Inventory",
|
|
68
|
+
"Property Inspection",
|
|
69
|
+
"Disposal Committee",
|
|
70
|
+
"Condemnation",
|
|
71
|
+
"Other",
|
|
72
|
+
];
|
|
73
|
+
function cell(value, kind) {
|
|
74
|
+
return { value, kind };
|
|
75
|
+
}
|
|
76
|
+
function createRow(cells) {
|
|
77
|
+
return cells;
|
|
78
|
+
}
|
|
79
|
+
export function recordToForm(record) {
|
|
80
|
+
return {
|
|
81
|
+
schoolStorageName: record.schoolStorageName,
|
|
82
|
+
reportDate: record.reportDate,
|
|
83
|
+
sourceProcess: record.sourceProcess,
|
|
84
|
+
wasteType: record.wasteType,
|
|
85
|
+
assessedValue: String(record.assessedValue),
|
|
86
|
+
disposition: record.disposition,
|
|
87
|
+
referenceDoc: record.referenceDoc,
|
|
88
|
+
items: record.items?.length
|
|
89
|
+
? record.items.map(item => ({ ...item }))
|
|
90
|
+
: [
|
|
91
|
+
{
|
|
92
|
+
item: record.item,
|
|
93
|
+
quantity: String(record.quantity),
|
|
94
|
+
unit: record.unit || "",
|
|
95
|
+
description: record.description,
|
|
96
|
+
recordOfSales: record.recordOfSales,
|
|
97
|
+
officialReceiptNo: record.officialReceiptNo,
|
|
98
|
+
saleDate: record.saleDate,
|
|
99
|
+
amount: String(record.amount),
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function buildWmrSheetModel(record) {
|
|
105
|
+
const items = record.items?.length
|
|
106
|
+
? record.items
|
|
107
|
+
: [
|
|
108
|
+
{
|
|
109
|
+
item: record.item,
|
|
110
|
+
quantity: String(record.quantity),
|
|
111
|
+
unit: record.unit || "",
|
|
112
|
+
description: record.description,
|
|
113
|
+
recordOfSales: record.recordOfSales,
|
|
114
|
+
officialReceiptNo: record.officialReceiptNo,
|
|
115
|
+
saleDate: record.saleDate,
|
|
116
|
+
amount: String(record.amount),
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
const rows = [
|
|
120
|
+
createRow([cell("WASTE MATERIALS REPORT", "title"), cell("", "blank"), cell("", "blank"), cell("", "blank"), cell("", "blank"), cell("", "blank"), cell("", "blank")]),
|
|
121
|
+
createRow([
|
|
122
|
+
cell("Entity Name : PCIC ASSET MANAGEMENT DIVISION", "meta"),
|
|
123
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
124
|
+
cell(`Fund Cluster : ${record.referenceDoc || "101-1"}`, "meta"),
|
|
125
|
+
cell("", "blank"), cell("", "blank"),
|
|
126
|
+
]),
|
|
127
|
+
createRow([
|
|
128
|
+
cell(`Place of Storage : ${record.schoolStorageName || "-"}`, "meta"),
|
|
129
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
130
|
+
cell(`Date : ${formatDate(record.reportDate)}`, "meta"),
|
|
131
|
+
cell("", "blank"), cell("", "blank"),
|
|
132
|
+
]),
|
|
133
|
+
createRow([
|
|
134
|
+
cell("ITEMS FOR DISPOSAL", "header"),
|
|
135
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
136
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
137
|
+
]),
|
|
138
|
+
createRow([
|
|
139
|
+
cell("Item", "header"),
|
|
140
|
+
cell("Quantity", "header"),
|
|
141
|
+
cell("Unit", "header"),
|
|
142
|
+
cell("Description", "header"),
|
|
143
|
+
cell("Record of Sales", "header"),
|
|
144
|
+
cell("", "blank"), cell("", "blank"),
|
|
145
|
+
]),
|
|
146
|
+
createRow([
|
|
147
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
148
|
+
cell("Official Receipt", "header"),
|
|
149
|
+
cell("", "blank"), cell("", "blank"),
|
|
150
|
+
]),
|
|
151
|
+
createRow([
|
|
152
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
153
|
+
cell("No.", "header"),
|
|
154
|
+
cell("Date", "header"),
|
|
155
|
+
cell("Amount", "header"),
|
|
156
|
+
]),
|
|
157
|
+
];
|
|
158
|
+
items.forEach((item, idx) => {
|
|
159
|
+
rows.push(createRow([
|
|
160
|
+
cell(item.item || `Item ${idx + 1}`, "item-text"),
|
|
161
|
+
cell(item.quantity || "-", "item-center"),
|
|
162
|
+
cell(item.unit || "-", "item-center"),
|
|
163
|
+
cell(item.description || "-", "item-text"),
|
|
164
|
+
cell(item.officialReceiptNo || "-", "item-text"),
|
|
165
|
+
cell(item.saleDate ? formatDate(item.saleDate) : "-", "item-center"),
|
|
166
|
+
cell(item.amount ? formatCurrency(Number(item.amount)) : "0.00", "item-number"),
|
|
167
|
+
]));
|
|
168
|
+
});
|
|
169
|
+
const totalAmount = items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0);
|
|
170
|
+
const fillCount = items.length < 10 ? 10 - items.length : 0;
|
|
171
|
+
for (let i = 0; i < fillCount; i++) {
|
|
172
|
+
rows.push(createRow([
|
|
173
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
174
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
175
|
+
cell("", "blank"),
|
|
176
|
+
]));
|
|
177
|
+
}
|
|
178
|
+
rows.push(createRow([
|
|
179
|
+
cell("", "blank"), cell("", "blank"), cell("", "blank"),
|
|
180
|
+
cell("TOTAL", "header"),
|
|
181
|
+
cell("", "blank"), cell("", "blank"),
|
|
182
|
+
cell(formatCurrency(totalAmount), "item-number"),
|
|
183
|
+
]));
|
|
184
|
+
const cols = [
|
|
185
|
+
{ wch: 14 },
|
|
186
|
+
{ wch: 12 },
|
|
187
|
+
{ wch: 10 },
|
|
188
|
+
{ wch: 30 },
|
|
189
|
+
{ wch: 18 },
|
|
190
|
+
{ wch: 16 },
|
|
191
|
+
{ wch: 16 },
|
|
192
|
+
];
|
|
193
|
+
const rowHeights = rows.map((_, index) => {
|
|
194
|
+
if (index === 0 || index === 1)
|
|
195
|
+
return { hpt: 24 };
|
|
196
|
+
if (index === 2)
|
|
197
|
+
return { hpt: 20 };
|
|
198
|
+
if (index === 3)
|
|
199
|
+
return { hpt: 22 };
|
|
200
|
+
if (index >= 4 && index <= 6)
|
|
201
|
+
return { hpt: 20 };
|
|
202
|
+
return { hpt: 18 };
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
rows,
|
|
206
|
+
merges: [
|
|
207
|
+
{ s: { r: 0, c: 0 }, e: { r: 0, c: 6 } },
|
|
208
|
+
{ s: { r: 1, c: 0 }, e: { r: 1, c: 3 } },
|
|
209
|
+
{ s: { r: 1, c: 4 }, e: { r: 1, c: 6 } },
|
|
210
|
+
{ s: { r: 2, c: 0 }, e: { r: 2, c: 3 } },
|
|
211
|
+
{ s: { r: 2, c: 4 }, e: { r: 2, c: 6 } },
|
|
212
|
+
{ s: { r: 3, c: 0 }, e: { r: 3, c: 6 } },
|
|
213
|
+
{ s: { r: 4, c: 0 }, e: { r: 6, c: 0 } },
|
|
214
|
+
{ s: { r: 4, c: 1 }, e: { r: 6, c: 1 } },
|
|
215
|
+
{ s: { r: 4, c: 2 }, e: { r: 6, c: 2 } },
|
|
216
|
+
{ s: { r: 4, c: 3 }, e: { r: 6, c: 3 } },
|
|
217
|
+
{ s: { r: 4, c: 4 }, e: { r: 4, c: 6 } },
|
|
218
|
+
{ s: { r: 5, c: 4 }, e: { r: 5, c: 6 } },
|
|
219
|
+
],
|
|
220
|
+
cols,
|
|
221
|
+
rowHeights,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function formatQty(value) {
|
|
225
|
+
const num = typeof value === "string" ? Number(value) : value;
|
|
226
|
+
if (Number.isNaN(num))
|
|
227
|
+
return "0.00";
|
|
228
|
+
return num.toFixed(2);
|
|
229
|
+
}
|
|
230
|
+
export function getExcelPreviewCellClassName(kind) {
|
|
231
|
+
switch (kind) {
|
|
232
|
+
case "title":
|
|
233
|
+
return "font-bold text-center text-sm";
|
|
234
|
+
case "meta":
|
|
235
|
+
return "text-xs";
|
|
236
|
+
case "header":
|
|
237
|
+
return "font-semibold text-center text-xs bg-slate-100";
|
|
238
|
+
case "item-text":
|
|
239
|
+
return "text-xs";
|
|
240
|
+
case "item-center":
|
|
241
|
+
return "text-xs text-center";
|
|
242
|
+
case "item-number":
|
|
243
|
+
return "text-xs text-right";
|
|
244
|
+
case "blank":
|
|
245
|
+
return "";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const blackBorder = {
|
|
249
|
+
top: { style: "thin", color: { rgb: "000000" } },
|
|
250
|
+
bottom: { style: "thin", color: { rgb: "000000" } },
|
|
251
|
+
left: { style: "thin", color: { rgb: "000000" } },
|
|
252
|
+
right: { style: "thin", color: { rgb: "000000" } },
|
|
253
|
+
};
|
|
254
|
+
function xlsxCellStyle(val, kind) {
|
|
255
|
+
const base = { t: typeof val === "number" ? "n" : "s", v: val, s: { border: blackBorder } };
|
|
256
|
+
switch (kind) {
|
|
257
|
+
case "title":
|
|
258
|
+
base.s = { ...base.s, font: { bold: true, sz: 14 }, alignment: { horizontal: "center" } };
|
|
259
|
+
break;
|
|
260
|
+
case "meta":
|
|
261
|
+
base.s = { ...base.s, font: { sz: 10 } };
|
|
262
|
+
break;
|
|
263
|
+
case "header":
|
|
264
|
+
base.s = {
|
|
265
|
+
...base.s,
|
|
266
|
+
font: { bold: true, sz: 10 },
|
|
267
|
+
fill: { fgColor: { rgb: "F1F5F9" } },
|
|
268
|
+
alignment: { horizontal: "center", wrapText: true },
|
|
269
|
+
};
|
|
270
|
+
break;
|
|
271
|
+
case "item-number":
|
|
272
|
+
base.t = "n";
|
|
273
|
+
base.v = typeof val === "string" ? Number(val) || 0 : val;
|
|
274
|
+
base.s = { ...base.s, alignment: { horizontal: "right" }, font: { sz: 10 } };
|
|
275
|
+
break;
|
|
276
|
+
case "item-center":
|
|
277
|
+
base.s = { ...base.s, alignment: { horizontal: "center" }, font: { sz: 10 } };
|
|
278
|
+
break;
|
|
279
|
+
case "item-text":
|
|
280
|
+
base.s = { ...base.s, font: { sz: 10 } };
|
|
281
|
+
break;
|
|
282
|
+
default:
|
|
283
|
+
base.s = { ...base.s, font: { sz: 10 } };
|
|
284
|
+
}
|
|
285
|
+
return base;
|
|
286
|
+
}
|
|
287
|
+
export function exportWmrXlsx(record) {
|
|
288
|
+
const model = buildWmrSheetModel(record);
|
|
289
|
+
const ws = XLSX.utils.aoa_to_sheet(model.rows.map(row => row.map(c => c.value)));
|
|
290
|
+
ws["!merges"] = model.merges;
|
|
291
|
+
ws["!cols"] = model.cols;
|
|
292
|
+
ws["!rows"] = model.rowHeights.map(r => ({ hpt: r.hpt }));
|
|
293
|
+
ws["!pageSetup"] = {
|
|
294
|
+
paperSize: 9,
|
|
295
|
+
orientation: "portrait",
|
|
296
|
+
fitToPage: true,
|
|
297
|
+
fitToWidth: 1,
|
|
298
|
+
fitToHeight: 0,
|
|
299
|
+
margins: { left: 0.7, right: 0.7, top: 0.75, bottom: 0.75, header: 0.3, footer: 0.3 },
|
|
300
|
+
};
|
|
301
|
+
for (let rowIndex = 0; rowIndex < model.rows.length; rowIndex += 1) {
|
|
302
|
+
for (let colIndex = 0; colIndex < model.rows[rowIndex].length; colIndex += 1) {
|
|
303
|
+
const addr = XLSX.utils.encode_cell({ r: rowIndex, c: colIndex });
|
|
304
|
+
const cellRef = ws[addr];
|
|
305
|
+
if (cellRef) {
|
|
306
|
+
cellRef.s = xlsxCellStyle(cellRef.v, model.rows[rowIndex][colIndex].kind).s ?? {};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const wb = XLSX.utils.book_new();
|
|
311
|
+
XLSX.utils.book_append_sheet(wb, ws, "WMR");
|
|
312
|
+
XLSX.writeFile(wb, `${record.wmrNo}.xlsx`);
|
|
313
|
+
}
|
|
314
|
+
export function exportWmrCsv(record) {
|
|
315
|
+
const items = record.items?.length
|
|
316
|
+
? record.items
|
|
317
|
+
: [
|
|
318
|
+
{
|
|
319
|
+
item: record.item,
|
|
320
|
+
quantity: String(record.quantity),
|
|
321
|
+
unit: record.unit || "",
|
|
322
|
+
description: record.description,
|
|
323
|
+
recordOfSales: record.recordOfSales,
|
|
324
|
+
officialReceiptNo: record.officialReceiptNo,
|
|
325
|
+
saleDate: record.saleDate,
|
|
326
|
+
amount: String(record.amount),
|
|
327
|
+
},
|
|
328
|
+
];
|
|
329
|
+
const header = "WMR No,School/Storage,Date,Source,Waste Type,Assessed Value,Disposition,Reference Doc";
|
|
330
|
+
const meta = `${record.wmrNo},${record.schoolStorageName},${record.reportDate},${record.sourceProcess},${record.wasteType},${record.assessedValue},${record.disposition},${record.referenceDoc}`;
|
|
331
|
+
const columnHeaders = "Item #,Item,Quantity,Unit,Description,Record of Sales,OR No.,Sale Date,Amount";
|
|
332
|
+
const itemRows = items.map((item, idx) => `${idx + 1},${item.item},${item.quantity},${item.unit || ""},${item.description},${item.recordOfSales},${item.officialReceiptNo},${item.saleDate},${item.amount}`);
|
|
333
|
+
const totalAmount = items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0);
|
|
334
|
+
const totalRow = `,,,,,,,TOTAL,${totalAmount}`;
|
|
335
|
+
const csv = [header, meta, "", columnHeaders, ...itemRows, totalRow].join("\n");
|
|
336
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
337
|
+
const url = URL.createObjectURL(blob);
|
|
338
|
+
const link = document.createElement("a");
|
|
339
|
+
link.href = url;
|
|
340
|
+
link.download = `${record.wmrNo}.csv`;
|
|
341
|
+
link.click();
|
|
342
|
+
URL.revokeObjectURL(url);
|
|
343
|
+
}
|