@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,248 @@
|
|
|
1
|
+
import * as XLSX from "xlsx-js-style";
|
|
2
|
+
export const EMPTY_ENTRY = {
|
|
3
|
+
transactionDate: "",
|
|
4
|
+
referenceDoc: "",
|
|
5
|
+
receiptQty: "0",
|
|
6
|
+
office: "",
|
|
7
|
+
issueQty: "0",
|
|
8
|
+
balanceQty: "0",
|
|
9
|
+
daysToConsume: "",
|
|
10
|
+
};
|
|
11
|
+
export const EMPTY_FORM = {
|
|
12
|
+
itemCode: "",
|
|
13
|
+
itemName: "",
|
|
14
|
+
reorderPoint: "",
|
|
15
|
+
unitOfMeasurement: "",
|
|
16
|
+
warehouse: "",
|
|
17
|
+
entries: [EMPTY_ENTRY],
|
|
18
|
+
};
|
|
19
|
+
export function generateScNo(index, itemCode) {
|
|
20
|
+
const sanitized = (itemCode || "ITEM").replace(/\s+/g, "-").toUpperCase();
|
|
21
|
+
const year = new Date().getFullYear();
|
|
22
|
+
return `SC-${sanitized}-${year}-${String(index).padStart(4, "0")}`;
|
|
23
|
+
}
|
|
24
|
+
export function formatQty(value) {
|
|
25
|
+
const num = typeof value === "string" ? Number(value) : value;
|
|
26
|
+
if (Number.isNaN(num))
|
|
27
|
+
return "0.00";
|
|
28
|
+
return num.toFixed(2);
|
|
29
|
+
}
|
|
30
|
+
export function formatScDate(value) {
|
|
31
|
+
if (!value)
|
|
32
|
+
return "";
|
|
33
|
+
const date = new Date(value);
|
|
34
|
+
if (Number.isNaN(date.getTime()))
|
|
35
|
+
return value;
|
|
36
|
+
return date.toLocaleDateString("en-PH", {
|
|
37
|
+
year: "numeric",
|
|
38
|
+
month: "long",
|
|
39
|
+
day: "2-digit",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function formatDateTime(value) {
|
|
43
|
+
if (!value)
|
|
44
|
+
return "";
|
|
45
|
+
const date = new Date(value);
|
|
46
|
+
if (Number.isNaN(date.getTime()))
|
|
47
|
+
return value;
|
|
48
|
+
return date.toLocaleString("en-PH", {
|
|
49
|
+
year: "numeric",
|
|
50
|
+
month: "short",
|
|
51
|
+
day: "2-digit",
|
|
52
|
+
hour: "2-digit",
|
|
53
|
+
minute: "2-digit",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function computeRunningBalance(entries) {
|
|
57
|
+
return entries.reduce((sum, entry) => {
|
|
58
|
+
const receipt = Number(entry.receiptQty) || 0;
|
|
59
|
+
const issue = Number(entry.issueQty) || 0;
|
|
60
|
+
return sum + receipt - issue;
|
|
61
|
+
}, 0).toFixed(2);
|
|
62
|
+
}
|
|
63
|
+
function cell(value, kind) {
|
|
64
|
+
return { value, kind };
|
|
65
|
+
}
|
|
66
|
+
function sheetCellClassName(kind) {
|
|
67
|
+
switch (kind) {
|
|
68
|
+
case "title":
|
|
69
|
+
return "font-bold text-center text-sm";
|
|
70
|
+
case "meta":
|
|
71
|
+
return "text-xs";
|
|
72
|
+
case "header":
|
|
73
|
+
return "font-semibold text-center text-xs bg-slate-100";
|
|
74
|
+
case "item-text":
|
|
75
|
+
return "text-xs";
|
|
76
|
+
case "item-center":
|
|
77
|
+
return "text-xs text-center";
|
|
78
|
+
case "item-number":
|
|
79
|
+
return "text-xs text-right";
|
|
80
|
+
case "blank":
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const STOCK_CARD_ROWS_PER_PAGE = 44;
|
|
85
|
+
export function formatStockCardEntryDate(value) {
|
|
86
|
+
if (!value)
|
|
87
|
+
return "";
|
|
88
|
+
const date = new Date(value);
|
|
89
|
+
return Number.isNaN(date.getTime()) ? value : date.toLocaleDateString("en-PH", {
|
|
90
|
+
year: "numeric", month: "short", day: "numeric",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function buildStockCardSheetModel(record) {
|
|
94
|
+
const sorted = [...record.entries].sort((a, b) => new Date(a.transactionDate).getTime() - new Date(b.transactionDate).getTime());
|
|
95
|
+
const rows = [];
|
|
96
|
+
const merges = [];
|
|
97
|
+
const rowHeights = [];
|
|
98
|
+
let balance = 0;
|
|
99
|
+
const pageCount = Math.max(1, Math.ceil(sorted.length / STOCK_CARD_ROWS_PER_PAGE));
|
|
100
|
+
for (let page = 0; page < pageCount; page++) {
|
|
101
|
+
const offset = rows.length;
|
|
102
|
+
const row = (values, kinds = [], height = 15) => {
|
|
103
|
+
rows.push(Array.from({ length: 7 }, (_, i) => cell(values[i] ?? "", kinds[i] ?? "blank")));
|
|
104
|
+
rowHeights.push({ hpt: height });
|
|
105
|
+
};
|
|
106
|
+
const merge = (r, c, er, ec) => {
|
|
107
|
+
merges.push({ s: { r: offset + r, c }, e: { r: offset + er, c: ec } });
|
|
108
|
+
};
|
|
109
|
+
row(["STOCK CARD"], ["title"], 28);
|
|
110
|
+
row(["BUREAU OF COMMUNICATIONS SERVICES"], ["title"], 24);
|
|
111
|
+
row(["Agency"], ["title"], 21);
|
|
112
|
+
row([
|
|
113
|
+
`Item: ${record.itemCode}`, "", `Description: ${record.itemName}`, "", "",
|
|
114
|
+
`Stock No: ${record.stockCardNo}`,
|
|
115
|
+
], ["meta", "blank", "meta", "blank", "blank", "meta"], 22);
|
|
116
|
+
row(["", "", "", "", "", `Re-order Point: ${record.reorderPoint}`], ["meta", "blank", "meta", "blank", "blank", "meta"], 22);
|
|
117
|
+
row(["Date", "Ref.", "Receipt", "Issuance", "", "Balance", "No. of Days to Consume"], Array(7).fill("header"), 18);
|
|
118
|
+
row(["", "", "Quantity", "Quantity", "Office/Officer", "Quantity"], Array(7).fill("header"), 18);
|
|
119
|
+
for (let r = 0; r < 3; r++)
|
|
120
|
+
merge(r, 0, r, 6);
|
|
121
|
+
for (let r = 3; r < 5; r++) {
|
|
122
|
+
merge(r, 0, r, 1);
|
|
123
|
+
merge(r, 2, r, 4);
|
|
124
|
+
merge(r, 5, r, 6);
|
|
125
|
+
}
|
|
126
|
+
merge(5, 0, 6, 0);
|
|
127
|
+
merge(5, 1, 6, 1);
|
|
128
|
+
merge(5, 3, 5, 4);
|
|
129
|
+
merge(5, 6, 6, 6);
|
|
130
|
+
const entries = sorted.slice(page * STOCK_CARD_ROWS_PER_PAGE, (page + 1) * STOCK_CARD_ROWS_PER_PAGE);
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
balance += (Number(entry.receiptQty) || 0) - (Number(entry.issueQty) || 0);
|
|
133
|
+
row([formatStockCardEntryDate(entry.transactionDate), entry.referenceDoc || "",
|
|
134
|
+
formatQty(entry.receiptQty), formatQty(entry.issueQty), entry.office || "",
|
|
135
|
+
formatQty(balance), entry.daysToConsume || ""], ["item-center", "item-text", "item-number", "item-number", "item-text", "item-number", "item-center"]);
|
|
136
|
+
}
|
|
137
|
+
for (let i = entries.length; i < STOCK_CARD_ROWS_PER_PAGE; i++)
|
|
138
|
+
row([]);
|
|
139
|
+
row([page > 0 ? "... continued from previous page" : ""], ["item-text"]);
|
|
140
|
+
merge(51, 0, 51, 6);
|
|
141
|
+
}
|
|
142
|
+
return { rows, merges, rowHeights, cols: [16, 22, 12, 12, 24, 12, 16].map(wch => ({ wch })) };
|
|
143
|
+
}
|
|
144
|
+
export function getExcelPreviewCellClassName(kind) {
|
|
145
|
+
return sheetCellClassName(kind);
|
|
146
|
+
}
|
|
147
|
+
export function makeEmptyForm() {
|
|
148
|
+
return { ...EMPTY_FORM, entries: [{ ...EMPTY_ENTRY }] };
|
|
149
|
+
}
|
|
150
|
+
const blackBorder = {
|
|
151
|
+
top: { style: "thin", color: { rgb: "000000" } },
|
|
152
|
+
bottom: { style: "thin", color: { rgb: "000000" } },
|
|
153
|
+
left: { style: "thin", color: { rgb: "000000" } },
|
|
154
|
+
right: { style: "thin", color: { rgb: "000000" } },
|
|
155
|
+
};
|
|
156
|
+
function xlsxCellStyle(val, kind) {
|
|
157
|
+
const base = { t: typeof val === "number" ? "n" : "s", v: val, s: { border: blackBorder, fill: { fgColor: { rgb: "FBF7E9" } }, alignment: { vertical: "center", wrapText: true } } };
|
|
158
|
+
switch (kind) {
|
|
159
|
+
case "title":
|
|
160
|
+
base.s = { ...base.s, font: { name: "Times New Roman", bold: true, sz: 14 }, alignment: { horizontal: "center" } };
|
|
161
|
+
break;
|
|
162
|
+
case "meta":
|
|
163
|
+
base.s = { ...base.s, font: { name: "Times New Roman", sz: 10 } };
|
|
164
|
+
break;
|
|
165
|
+
case "header":
|
|
166
|
+
base.s = { ...base.s, font: { name: "Times New Roman", bold: true, sz: 10 }, alignment: { horizontal: "center", wrapText: true } };
|
|
167
|
+
break;
|
|
168
|
+
case "item-number":
|
|
169
|
+
base.t = "n";
|
|
170
|
+
base.v = typeof val === "string" ? Number(val) || 0 : val;
|
|
171
|
+
base.s = { ...base.s, alignment: { horizontal: "right" }, font: { name: "Times New Roman", sz: 10 } };
|
|
172
|
+
break;
|
|
173
|
+
case "item-center":
|
|
174
|
+
base.s = { ...base.s, alignment: { horizontal: "center" }, font: { name: "Times New Roman", sz: 10 } };
|
|
175
|
+
break;
|
|
176
|
+
case "item-text":
|
|
177
|
+
base.s = { ...base.s, font: { name: "Times New Roman", sz: 10 } };
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
base.s = { ...base.s, font: { name: "Times New Roman", sz: 10 } };
|
|
181
|
+
}
|
|
182
|
+
return base;
|
|
183
|
+
}
|
|
184
|
+
export function exportStockCardXlsx(record) {
|
|
185
|
+
const model = buildStockCardSheetModel(record);
|
|
186
|
+
const ws = XLSX.utils.aoa_to_sheet(model.rows.map(row => row.map(c => c.value)));
|
|
187
|
+
ws["!merges"] = model.merges;
|
|
188
|
+
ws["!cols"] = model.cols;
|
|
189
|
+
ws["!rows"] = model.rowHeights.map(r => ({ hpt: r.hpt }));
|
|
190
|
+
ws["!margins"] = { left: 0.04, right: 0.04, top: 0.04, bottom: 0.04, header: 0, footer: 0 };
|
|
191
|
+
ws["!printArea"] = XLSX.utils.encode_range({ s: { r: 0, c: 0 }, e: { r: model.rows.length - 1, c: 6 } });
|
|
192
|
+
ws["!pageSetup"] = {
|
|
193
|
+
paperSize: 9,
|
|
194
|
+
orientation: "portrait",
|
|
195
|
+
fitToPage: true,
|
|
196
|
+
fitToWidth: 1,
|
|
197
|
+
fitToHeight: 0,
|
|
198
|
+
margins: { left: 0.7, right: 0.7, top: 0.75, bottom: 0.75, header: 0.3, footer: 0.3 },
|
|
199
|
+
};
|
|
200
|
+
for (let rowIndex = 0; rowIndex < model.rows.length; rowIndex += 1) {
|
|
201
|
+
for (let colIndex = 0; colIndex < model.rows[rowIndex].length; colIndex += 1) {
|
|
202
|
+
const addr = XLSX.utils.encode_cell({ r: rowIndex, c: colIndex });
|
|
203
|
+
const cellRef = ws[addr];
|
|
204
|
+
if (cellRef) {
|
|
205
|
+
const kind = model.rows[rowIndex][colIndex].kind;
|
|
206
|
+
cellRef.s = xlsxCellStyle(cellRef.v, kind).s ?? {};
|
|
207
|
+
const pageRow = rowIndex % (STOCK_CARD_ROWS_PER_PAGE + 8);
|
|
208
|
+
if (pageRow === 51) {
|
|
209
|
+
cellRef.s.border = {};
|
|
210
|
+
cellRef.s.alignment = { horizontal: "right" };
|
|
211
|
+
}
|
|
212
|
+
if (pageRow < 3) {
|
|
213
|
+
cellRef.s.border = {};
|
|
214
|
+
cellRef.s.font = { name: "Times New Roman", bold: true, sz: [22.5, 18, 12][pageRow] };
|
|
215
|
+
}
|
|
216
|
+
if (kind === "item-number") {
|
|
217
|
+
cellRef.t = "n";
|
|
218
|
+
cellRef.v = Number(cellRef.v);
|
|
219
|
+
cellRef.z = "0.00";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const wb = XLSX.utils.book_new();
|
|
225
|
+
XLSX.utils.book_append_sheet(wb, ws, "Stock Card");
|
|
226
|
+
XLSX.writeFile(wb, `${record.stockCardNo}.xlsx`);
|
|
227
|
+
}
|
|
228
|
+
export function exportStockCardCsv(record) {
|
|
229
|
+
const header = "Stock Card No,Item Code,Item Name,Warehouse";
|
|
230
|
+
const meta = `${record.stockCardNo},${record.itemCode},${record.itemName},${record.warehouse}`;
|
|
231
|
+
const columnHeaders = "Date,Reference,Receipt Qty,Issue Qty,Office/Officer,Balance Qty";
|
|
232
|
+
const sorted = [...record.entries].sort((a, b) => new Date(a.transactionDate).getTime() - new Date(b.transactionDate).getTime());
|
|
233
|
+
let runningBalance = 0;
|
|
234
|
+
const rows = sorted.map(entry => {
|
|
235
|
+
const receipt = Number(entry.receiptQty) || 0;
|
|
236
|
+
const issue = Number(entry.issueQty) || 0;
|
|
237
|
+
runningBalance += receipt - issue;
|
|
238
|
+
return `${entry.transactionDate},${entry.referenceDoc},${entry.receiptQty},${entry.issueQty},${entry.office},${runningBalance.toFixed(2)}`;
|
|
239
|
+
});
|
|
240
|
+
const csv = [header, meta, "", columnHeaders, ...rows].join("\n");
|
|
241
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
242
|
+
const url = URL.createObjectURL(blob);
|
|
243
|
+
const link = document.createElement("a");
|
|
244
|
+
link.href = url;
|
|
245
|
+
link.download = `${record.stockCardNo}.csv`;
|
|
246
|
+
link.click();
|
|
247
|
+
URL.revokeObjectURL(url);
|
|
248
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { WmrBasicForm, WmrBasicFormItem } from "../types.js";
|
|
2
|
+
type WmrCreateFormProps = {
|
|
3
|
+
wmrNo: string;
|
|
4
|
+
onRefreshWmrNo: () => void;
|
|
5
|
+
form: WmrBasicForm;
|
|
6
|
+
onFieldChange: <K extends keyof WmrBasicForm>(field: K, value: WmrBasicForm[K]) => void;
|
|
7
|
+
onItemFieldChange: (index: number, field: keyof WmrBasicFormItem, value: string) => void;
|
|
8
|
+
onAddItem: () => void;
|
|
9
|
+
onRemoveItem: (index: number) => void;
|
|
10
|
+
requestReferenceOptions?: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}>;
|
|
14
|
+
selectedRequestReferenceId?: string;
|
|
15
|
+
onSelectRequestReference?: (id: string) => void;
|
|
16
|
+
/** Hide the "Record of Sales" columns (OR No. / Sale Date / Amount). */
|
|
17
|
+
hideSalesFields?: boolean;
|
|
18
|
+
/** Hide the add-row / remove-row controls. */
|
|
19
|
+
lockItems?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function WastematerialReportWmrCreateForm({ wmrNo, onRefreshWmrNo, form, onFieldChange, onItemFieldChange, onAddItem, onRemoveItem, requestReferenceOptions, selectedRequestReferenceId, onSelectRequestReference, hideSalesFields, lockItems, }: WmrCreateFormProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export { WmrDocumentPreview as WastematerialReportWmrDocumentPreview } from "./document-preview.js";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Calendar03Icon } from "@hugeicons/core-free-icons";
|
|
5
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
6
|
+
import { format } from "date-fns";
|
|
7
|
+
import { ConfigurableFormLayout, } from "../../../internal/components/configurable-form-layout.js";
|
|
8
|
+
import { Button } from "../../../internal/components/ui/button.js";
|
|
9
|
+
import { Calendar } from "../../../internal/components/ui/calendar.js";
|
|
10
|
+
import { DateInput } from "../../../internal/components/ui/date-input.js";
|
|
11
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../internal/components/ui/popover.js";
|
|
12
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../../../internal/components/ui/select.js";
|
|
13
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../internal/components/ui/tabs.js";
|
|
14
|
+
import { cn } from "../../../internal/lib/utils.js";
|
|
15
|
+
// ─── Shared text input class ───────────────────────────────────────────────────
|
|
16
|
+
const fieldCls = "w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 " +
|
|
17
|
+
"placeholder:text-gray-400 " +
|
|
18
|
+
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 " +
|
|
19
|
+
"dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:placeholder:text-gray-500";
|
|
20
|
+
const labelCls = "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300";
|
|
21
|
+
// ─── Date Picker ───────────────────────────────────────────────────────────────
|
|
22
|
+
function DatePicker({ value, onChange, placeholder = "Pick a date", }) {
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
const selected = value ? new Date(value) : undefined;
|
|
25
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs(PopoverTrigger, { className: cn("w-full justify-start border border-gray-300 bg-white text-left text-sm font-normal text-gray-900", "inline-flex items-center gap-2 rounded-md px-3 py-2 shadow-xs", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:border-destructive aria-invalid:ring-destructive/20", "dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:hover:bg-gray-800", "dark:focus-visible:border-ring dark:focus-visible:ring-ring/50", !value && "text-gray-400 dark:text-gray-500"), children: [_jsx(HugeiconsIcon, { icon: Calendar03Icon, className: "mr-2 size-4 shrink-0 opacity-70" }), value ? format(new Date(value), "MMM dd, yyyy") : placeholder] }), _jsx(PopoverContent, { className: "w-auto p-0 dark:border-gray-700 dark:bg-gray-900", align: "start", children: _jsx(Calendar, { mode: "single", selected: selected, onSelect: date => {
|
|
26
|
+
onChange(date ? format(date, "yyyy-MM-dd") : "");
|
|
27
|
+
setOpen(false);
|
|
28
|
+
}, initialFocus: true }) })] }));
|
|
29
|
+
}
|
|
30
|
+
// ─── Shadcn Select wrapper ─────────────────────────────────────────────────────
|
|
31
|
+
function FieldSelect({ value, onValueChange, placeholder, options, }) {
|
|
32
|
+
const normalizedOptions = options.map(option => typeof option === "string" ? { value: option, label: option } : option);
|
|
33
|
+
return (_jsxs(Select, { value: value, onValueChange: val => val !== null && onValueChange(val), children: [_jsx(SelectTrigger, { className: cn("w-full border-gray-300 bg-white text-sm text-gray-900", "dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100", !value && "text-gray-400 dark:text-gray-500"), children: _jsx(SelectValue, { children: _jsx("span", { children: value || placeholder }) }) }), _jsx(SelectContent, { className: "dark:border-gray-700 dark:bg-gray-900", children: normalizedOptions.map(opt => (_jsx(SelectItem, { value: opt.value, className: "text-gray-900 dark:text-gray-100 dark:focus:bg-gray-800", children: opt.label }, opt.value))) })] }));
|
|
34
|
+
}
|
|
35
|
+
export function WastematerialReportWmrCreateForm({ wmrNo, onRefreshWmrNo, form, onFieldChange, onItemFieldChange, onAddItem, onRemoveItem, requestReferenceOptions = [], selectedRequestReferenceId = "", onSelectRequestReference, hideSalesFields = false, lockItems = false, }) {
|
|
36
|
+
const fields = [
|
|
37
|
+
{
|
|
38
|
+
id: "schoolStorageName",
|
|
39
|
+
label: "Place of Storage *",
|
|
40
|
+
render: () => (_jsx("input", { value: form.schoolStorageName, onChange: e => onFieldChange("schoolStorageName", e.target.value), placeholder: "Name of School Storage", className: fieldCls })),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "reportDate",
|
|
44
|
+
label: "Report Date *",
|
|
45
|
+
render: () => (_jsx(DatePicker, { value: form.reportDate, onChange: val => onFieldChange("reportDate", val), placeholder: "Select report date" })),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "referenceDoc",
|
|
49
|
+
label: "Fund Cluster",
|
|
50
|
+
fullWidth: true,
|
|
51
|
+
render: () => (_jsx("input", { value: form.referenceDoc, onChange: e => onFieldChange("referenceDoc", e.target.value), placeholder: "e.g. 101-1", className: fieldCls })),
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
return (_jsxs(Tabs, { defaultValue: "basic", children: [_jsxs(TabsList, { className: "grid w-full grid-cols-2", children: [_jsx(TabsTrigger, { value: "basic", children: "Basic Info" }), _jsx(TabsTrigger, { value: "items", children: "Items" })] }), _jsxs(TabsContent, { value: "basic", className: "mt-4 space-y-4", children: [_jsx("div", { className: "rounded-md border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-800/60 dark:bg-emerald-950/30", children: _jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsxs("div", { children: [_jsx("p", { className: "text-muted-foreground text-xs font-medium dark:text-gray-400", children: "Auto-Generated WMR Number" }), _jsx("p", { className: "mt-0.5 text-2xl font-semibold text-slate-700 dark:text-gray-100", children: wmrNo })] }), _jsx("button", { type: "button", onClick: onRefreshWmrNo, className: "border-input rounded-md border bg-white px-3 py-1.5 text-xs font-medium hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700", children: "Refresh" })] }) }), requestReferenceOptions.length > 0 && (_jsxs("fieldset", { className: "border-border/60 min-w-0 space-y-3 rounded-md border p-4 dark:border-gray-700/60", children: [_jsx("legend", { className: "text-muted-foreground px-1 text-xs font-semibold dark:text-gray-400", children: "Reference End User Request" }), _jsxs("div", { children: [_jsx("label", { className: labelCls, children: "Select Submitted End User Request" }), _jsx(FieldSelect, { value: selectedRequestReferenceId, onValueChange: val => onSelectRequestReference?.(val), placeholder: "Select request to auto-fill WMR form", options: requestReferenceOptions.map(option => ({
|
|
55
|
+
value: option.id,
|
|
56
|
+
label: option.label,
|
|
57
|
+
})) }), selectedRequestReferenceId ? (_jsx("p", { className: "text-muted-foreground mt-1 text-xs", children: requestReferenceOptions.find(option => option.id === selectedRequestReferenceId)
|
|
58
|
+
?.label })) : null] })] })), _jsxs("fieldset", { className: "border-border/60 rounded-md border p-4 dark:border-gray-700/60", children: [_jsx("legend", { className: "text-muted-foreground px-1 text-xs font-semibold dark:text-gray-400", children: "Report Information" }), _jsx(ConfigurableFormLayout, { formKey: "wmr-report-info", fields: fields })] })] }), _jsx(TabsContent, { value: "items", className: "mt-4 min-w-0 space-y-4", children: _jsxs("fieldset", { className: "border-border/60 space-y-3 rounded-md border p-4 dark:border-gray-700/60", children: [_jsx("legend", { className: "text-muted-foreground px-1 text-xs font-semibold dark:text-gray-400", children: "Items for Disposal" }), _jsx("div", { className: "min-w-0 space-y-4", children: form.items.map((item, index) => (_jsxs("section", { "aria-label": `Disposal item ${index + 1}`, className: "bg-card min-w-0 space-y-4 rounded-lg border p-4", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("h4", { className: "text-sm font-semibold", children: ["Item ", index + 1] }), !lockItems && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: form.items.length <= 1, onClick: () => onRemoveItem(index), "aria-label": `Remove item ${index + 1}`, className: "text-destructive", children: "Remove" }))] }), _jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Item name" }), _jsx("input", { type: "text", value: item.item, onChange: event => onItemFieldChange(index, "item", event.target.value), className: "bg-background text-foreground w-full min-w-0 rounded-md border px-3 py-2 text-sm" })] }), _jsxs("div", { className: "grid min-w-0 grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Quantity" }), _jsx("input", { type: "number", min: 0, step: "0.01", value: item.quantity, onChange: event => onItemFieldChange(index, "quantity", event.target.value), className: "bg-background text-foreground w-full min-w-0 rounded-md border px-3 py-2 text-sm" })] }), _jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Unit" }), _jsx("input", { type: "text", value: item.unit, onChange: event => onItemFieldChange(index, "unit", event.target.value), className: "bg-background text-foreground w-full min-w-0 rounded-md border px-3 py-2 text-sm" })] })] }), _jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Description" }), _jsx("textarea", { rows: 3, value: item.description, onChange: event => onItemFieldChange(index, "description", event.target.value), className: "bg-background text-foreground w-full min-w-0 resize-y rounded-md border px-3 py-2 text-sm" })] }), !hideSalesFields && (_jsxs("div", { className: "min-w-0 space-y-4 border-t pt-4", children: [_jsx("h5", { className: "text-muted-foreground text-xs font-semibold", children: "Record of Sales" }), _jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Official Receipt No." }), _jsx("input", { type: "text", value: item.officialReceiptNo, onChange: event => onItemFieldChange(index, "officialReceiptNo", event.target.value), className: "bg-background text-foreground w-full min-w-0 rounded-md border px-3 py-2 text-sm" })] }), _jsxs("div", { className: "grid min-w-0 grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "min-w-0 space-y-1", children: [_jsx("label", { htmlFor: `wmr-sale-date-${index}`, className: "text-sm font-medium", children: "Sale Date" }), _jsx(DateInput, { id: `wmr-sale-date-${index}`, value: item.saleDate, onValueChange: value => onItemFieldChange(index, "saleDate", value), className: "w-full min-w-0" })] }), _jsxs("label", { className: "block min-w-0 space-y-1", children: [_jsx("span", { className: "text-sm font-medium", children: "Amount" }), _jsx("input", { type: "number", min: 0, step: "0.01", value: item.amount, onChange: event => onItemFieldChange(index, "amount", event.target.value), className: "bg-background text-foreground w-full min-w-0 rounded-md border px-3 py-2 text-sm" })] })] })] }))] }, index))) }), !lockItems && (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onAddItem, children: "+ Add Item" }))] }) })] }));
|
|
59
|
+
}
|
|
60
|
+
// ─── Re-export document preview for backward compatibility ─────────────────────
|
|
61
|
+
export { WmrDocumentPreview as WastematerialReportWmrDocumentPreview } from "./document-preview.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WmrBasicForm, WmrRecord } from "../types.js";
|
|
2
|
+
type WmrDocumentPreviewProps = {
|
|
3
|
+
wmrNo: string;
|
|
4
|
+
form: WmrBasicForm;
|
|
5
|
+
};
|
|
6
|
+
export declare function WmrDocumentPreview({ wmrNo, form }: WmrDocumentPreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function WmrRecordPreview({ record }: {
|
|
8
|
+
record: WmrRecord;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { formatCurrency, formatDate } from "../utils.js";
|
|
4
|
+
const ITEMS_PER_PAGE = 17;
|
|
5
|
+
function mapLine(form, dataItem, i) {
|
|
6
|
+
const index = i + 1;
|
|
7
|
+
return {
|
|
8
|
+
index,
|
|
9
|
+
item: dataItem.item || "",
|
|
10
|
+
quantity: dataItem.quantity || "",
|
|
11
|
+
unit: dataItem.unit || "",
|
|
12
|
+
description: dataItem.description || "",
|
|
13
|
+
officialReceiptNo: dataItem.officialReceiptNo || "",
|
|
14
|
+
saleDate: dataItem.saleDate ? formatDate(dataItem.saleDate) : "",
|
|
15
|
+
amount: dataItem.amount ? formatCurrency(Number(dataItem.amount)) : "",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function WmrPage({ form, lines, totalAmount, wmrNo, isLastPage, }) {
|
|
19
|
+
return (_jsx("div", { className: "wmr-a4-page psms-print-preview mx-auto min-h-[1123px] w-[794px] border-[1.5px] border-slate-700 bg-white font-serif text-[11px] text-black shadow-[inset_0_0_0_1px_rgba(15,23,42,0.08)]", "data-pdf-page": "true", children: _jsxs("div", { className: "p-5", children: [_jsx("h4", { className: "mb-2 text-center text-2xl font-bold tracking-wide", children: "WASTE MATERIALS REPORT" }), _jsxs("div", { className: "mb-2 flex justify-between text-[12px]", children: [_jsx("span", { className: "font-bold", children: "Entity Name : PCIC ASSET MANAGEMENT DIVISION" }), _jsxs("span", { children: ["Fund Cluster : ", form.referenceDoc || "101-1"] })] }), _jsxs("table", { className: "w-full border-collapse border border-black text-[11px]", children: [_jsxs("thead", { children: [_jsxs("tr", { children: [_jsxs("th", { colSpan: 4, className: "border border-black px-2 py-1 text-left text-[11px] font-normal", children: ["Place of Storage : ", form.schoolStorageName || "-"] }), _jsxs("th", { colSpan: 3, className: "border border-black px-2 py-1 text-left text-[11px] font-normal", children: ["Date : ", formatDate(form.reportDate)] })] }), _jsx("tr", { children: _jsx("th", { colSpan: 7, className: "border border-black px-2 py-1 text-left text-[12px] font-bold", children: "ITEMS FOR DISPOSAL" }) }), _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: "Item" }), _jsx("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: "Quantity" }), _jsx("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: "Unit" }), _jsx("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: "Description" }), _jsxs("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: ["Record of Sales", _jsx("br", {}), "Official Receipt No."] }), _jsxs("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: ["Record of Sales", _jsx("br", {}), "Official Receipt Date"] }), _jsxs("th", { scope: "col", className: "border border-black px-2 py-2 text-center leading-4 font-bold", children: ["Record of Sales", _jsx("br", {}), "Amount"] })] })] }), _jsxs("tbody", { children: [Array.from({ length: ITEMS_PER_PAGE }).map((_, slotIndex) => {
|
|
20
|
+
const line = slotIndex < lines.length ? lines[slotIndex] : null;
|
|
21
|
+
return (_jsxs("tr", { children: [_jsx("td", { className: "border border-black px-1 py-1 text-center leading-4", children: line ? line.item : "\u00A0" }), _jsx("td", { className: "border border-black px-1 py-1 text-center leading-4", children: line ? line.quantity : "\u00A0" }), _jsx("td", { className: "border border-black px-1 py-1 text-center leading-4", children: line ? line.unit : "\u00A0" }), _jsx("td", { className: "border border-black px-2 py-1 leading-4", children: line ? line.description : "\u00A0" }), _jsx("td", { className: "border border-black px-1 py-1 text-center leading-4", children: line ? line.officialReceiptNo : "\u00A0" }), _jsx("td", { className: "border border-black px-1 py-1 text-center leading-4", children: line ? line.saleDate : "\u00A0" }), _jsx("td", { className: "border border-black px-1 py-1 text-right leading-4", children: line ? line.amount : "\u00A0" })] }, `wmr-row-${slotIndex}`));
|
|
22
|
+
}), isLastPage && (_jsxs("tr", { children: [_jsx("td", { colSpan: 4, className: "border border-black px-2 py-1 text-center font-bold", children: "TOTAL" }), _jsx("td", { className: "border border-black px-1 py-1" }), _jsx("td", { className: "border border-black px-1 py-1" }), _jsx("td", { className: "border border-black px-2 py-1 text-right font-bold", children: totalAmount > 0 ? formatCurrency(totalAmount) : "" })] }))] })] }), isLastPage ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "border border-black", children: [_jsx("div", { className: "border-b border-black px-2 py-1 text-[12px]", children: "Certified Correct :" }), _jsxs("div", { className: "grid grid-cols-2 border-b border-black", children: [_jsx("div", { className: "border-r border-black px-2 py-3 text-center", children: _jsx("div", { className: "mt-7 border-t border-black pt-1 text-[12px]", children: "Signature over Printed Name of Supply and/or Property Custodian" }) }), _jsx("div", { className: "px-2 py-3 text-center", children: _jsx("div", { className: "mt-7 border-t border-black pt-1 text-[12px]", children: "Signature over Printed Name of Head of Agency/Entity or his/her Authorized Representative" }) })] }), _jsx("div", { className: "border-b border-black px-2 py-1 text-center text-[12px] font-bold", children: "CERTIFICATE OF INSPECTION" }), _jsxs("div", { className: "border-b border-black px-2 py-2 text-[12px]", children: ["I hereby certify that the property enumerated above was disposed of as follows:", _jsxs("div", { className: "mt-2 space-y-1 pl-9", children: [_jsx("p", { children: "Item ________ Destroyed" }), _jsx("p", { children: "Item ________ Sold at private sale" }), _jsx("p", { children: "Item ________ Sold at public auction" }), _jsx("p", { children: "Item ________ Transferred without cost to ________________________" })] })] }), _jsxs("div", { className: "grid grid-cols-2", children: [_jsxs("div", { className: "border-r border-black px-2 py-2 text-[12px]", children: [_jsx("p", { children: "Certified Correct:" }), _jsx("div", { className: "mt-8 border-t border-black" })] }), _jsxs("div", { className: "px-2 py-2 text-[12px]", children: [_jsx("p", { children: "Witness to Disposal:" }), _jsx("div", { className: "mt-8 border-t border-black" })] })] })] }), _jsxs("p", { className: "mt-2 text-[10px] text-gray-600", children: ["WMR No: ", wmrNo] })] })) : (lines.length > 0 && (_jsx("p", { className: "mt-2 text-right text-[10px] text-gray-400", children: "... continued on next page" })))] }) }));
|
|
23
|
+
}
|
|
24
|
+
export function WmrDocumentPreview({ wmrNo, form }) {
|
|
25
|
+
const items = form.items;
|
|
26
|
+
const totalAmount = items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0);
|
|
27
|
+
const pages = [];
|
|
28
|
+
for (let i = 0; i < items.length; i += ITEMS_PER_PAGE) {
|
|
29
|
+
pages.push({ items: items.slice(i, i + ITEMS_PER_PAGE) });
|
|
30
|
+
}
|
|
31
|
+
if (pages.length === 0)
|
|
32
|
+
pages.push({ items: [] });
|
|
33
|
+
return (_jsx("div", { className: "mx-auto w-full max-w-full overflow-x-auto", children: _jsx("div", { className: "mx-auto w-fit space-y-6 rounded-[18px] border border-slate-300 bg-[linear-gradient(180deg,#ffffff_0%,#fcfcfc_100%)] p-4 shadow-[0_18px_40px_-24px_rgba(15,23,42,0.35)] dark:border-slate-600 dark:bg-[linear-gradient(180deg,#1e293b_0%,#0f172a_100%)]", children: pages.map((page, i) => (_jsx(WmrPage, { form: form, lines: page.items.map((item, idx) => mapLine(form, item, i * ITEMS_PER_PAGE + idx)), totalAmount: totalAmount, wmrNo: wmrNo, isLastPage: i === pages.length - 1 }, i))) }) }));
|
|
34
|
+
}
|
|
35
|
+
export function WmrRecordPreview({ record }) {
|
|
36
|
+
return (_jsx(WmrDocumentPreview, { wmrNo: record.wmrNo, form: {
|
|
37
|
+
schoolStorageName: record.schoolStorageName,
|
|
38
|
+
reportDate: record.reportDate,
|
|
39
|
+
sourceProcess: record.sourceProcess,
|
|
40
|
+
wasteType: record.wasteType,
|
|
41
|
+
assessedValue: String(record.assessedValue),
|
|
42
|
+
disposition: record.disposition,
|
|
43
|
+
referenceDoc: record.referenceDoc,
|
|
44
|
+
items: record.items?.length
|
|
45
|
+
? record.items.map(item => ({ ...item }))
|
|
46
|
+
: [
|
|
47
|
+
{
|
|
48
|
+
item: record.item,
|
|
49
|
+
quantity: String(record.quantity),
|
|
50
|
+
unit: record.unit || "",
|
|
51
|
+
description: record.description,
|
|
52
|
+
recordOfSales: record.recordOfSales,
|
|
53
|
+
officialReceiptNo: record.officialReceiptNo,
|
|
54
|
+
saleDate: record.saleDate,
|
|
55
|
+
amount: String(record.amount),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
} }));
|
|
59
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type WmrStatus = "Draft" | "Submitted" | "Approved" | "Closed" | "Returned" | "Cancelled";
|
|
2
|
+
export type WmrBasicFormItem = {
|
|
3
|
+
item: string;
|
|
4
|
+
quantity: string;
|
|
5
|
+
unit: string;
|
|
6
|
+
description: string;
|
|
7
|
+
recordOfSales: string;
|
|
8
|
+
officialReceiptNo: string;
|
|
9
|
+
saleDate: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
};
|
|
12
|
+
export type WmrRecord = {
|
|
13
|
+
id: string;
|
|
14
|
+
wmrNo: string;
|
|
15
|
+
schoolStorageName: string;
|
|
16
|
+
reportDate: string;
|
|
17
|
+
item: string;
|
|
18
|
+
quantity: number;
|
|
19
|
+
unit: string;
|
|
20
|
+
description: string;
|
|
21
|
+
recordOfSales: string;
|
|
22
|
+
officialReceiptNo: string;
|
|
23
|
+
saleDate: string;
|
|
24
|
+
amount: number;
|
|
25
|
+
sourceProcess: string;
|
|
26
|
+
wasteType: string;
|
|
27
|
+
assessedValue: number;
|
|
28
|
+
disposition: string;
|
|
29
|
+
referenceDoc: string;
|
|
30
|
+
status: WmrStatus;
|
|
31
|
+
note?: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
updatedBy: string;
|
|
34
|
+
items?: WmrBasicFormItem[];
|
|
35
|
+
};
|
|
36
|
+
export type WmrBasicForm = {
|
|
37
|
+
schoolStorageName: string;
|
|
38
|
+
reportDate: string;
|
|
39
|
+
sourceProcess: string;
|
|
40
|
+
wasteType: string;
|
|
41
|
+
assessedValue: string;
|
|
42
|
+
disposition: string;
|
|
43
|
+
referenceDoc: string;
|
|
44
|
+
items: WmrBasicFormItem[];
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as XLSX from "xlsx-js-style";
|
|
2
|
+
import type { WmrBasicForm, WmrBasicFormItem, WmrRecord } from "./types.js";
|
|
3
|
+
export declare function generateWmrNo(records: number | Pick<WmrRecord, "wmrNo">[]): string;
|
|
4
|
+
export declare function formatCurrency(value: number): string;
|
|
5
|
+
export declare function formatDateTime(value: string): string;
|
|
6
|
+
export declare function formatDate(value: string): string;
|
|
7
|
+
export declare const EMPTY_ITEM: WmrBasicFormItem;
|
|
8
|
+
export declare const EMPTY_BASIC_FORM: WmrBasicForm;
|
|
9
|
+
export declare const WASTE_TYPE_OPTIONS: readonly ["Condemned Equipment", "Scrap Materials", "Unserviceable Property", "Expired Supplies", "Damaged Goods", "Other Waste"];
|
|
10
|
+
export declare const DISPOSITION_OPTIONS: readonly ["Sale", "Disposal", "Transfer", "Destruction", "Auction", "Other"];
|
|
11
|
+
export declare const SOURCE_PROCESS_OPTIONS: readonly ["Annual Inventory", "Property Inspection", "Disposal Committee", "Condemnation", "Other"];
|
|
12
|
+
type WmrCellKind = "title" | "meta" | "header" | "item-text" | "item-center" | "item-number" | "blank";
|
|
13
|
+
export type WmrSheetCell = {
|
|
14
|
+
value: string | number;
|
|
15
|
+
kind: WmrCellKind;
|
|
16
|
+
};
|
|
17
|
+
export type WmrSheetModel = {
|
|
18
|
+
rows: WmrSheetCell[][];
|
|
19
|
+
merges: XLSX.Range[];
|
|
20
|
+
cols: {
|
|
21
|
+
wch: number;
|
|
22
|
+
}[];
|
|
23
|
+
rowHeights: {
|
|
24
|
+
hpt: number;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export declare function recordToForm(record: WmrRecord): WmrBasicForm;
|
|
28
|
+
export declare function buildWmrSheetModel(record: WmrRecord): WmrSheetModel;
|
|
29
|
+
export declare function getExcelPreviewCellClassName(kind: WmrCellKind): string;
|
|
30
|
+
export declare function exportWmrXlsx(record: WmrRecord): void;
|
|
31
|
+
export declare function exportWmrCsv(record: WmrRecord): void;
|
|
32
|
+
export {};
|