@ph-itdev/ph-warehouse-toolkit 0.1.1

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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/address.cjs +83 -0
  4. package/dist/address.cjs.map +1 -0
  5. package/dist/address.d.cts +24 -0
  6. package/dist/address.d.ts +24 -0
  7. package/dist/address.js +52 -0
  8. package/dist/address.js.map +1 -0
  9. package/dist/barcode.cjs +57 -0
  10. package/dist/barcode.cjs.map +1 -0
  11. package/dist/barcode.d.cts +5 -0
  12. package/dist/barcode.d.ts +5 -0
  13. package/dist/barcode.js +28 -0
  14. package/dist/barcode.js.map +1 -0
  15. package/dist/compliance.cjs +61 -0
  16. package/dist/compliance.cjs.map +1 -0
  17. package/dist/compliance.d.cts +26 -0
  18. package/dist/compliance.d.ts +26 -0
  19. package/dist/compliance.js +33 -0
  20. package/dist/compliance.js.map +1 -0
  21. package/dist/currency.cjs +91 -0
  22. package/dist/currency.cjs.map +1 -0
  23. package/dist/currency.d.cts +20 -0
  24. package/dist/currency.d.ts +20 -0
  25. package/dist/currency.js +57 -0
  26. package/dist/currency.js.map +1 -0
  27. package/dist/documents.cjs +59 -0
  28. package/dist/documents.cjs.map +1 -0
  29. package/dist/documents.d.cts +10 -0
  30. package/dist/documents.d.ts +10 -0
  31. package/dist/documents.js +30 -0
  32. package/dist/documents.js.map +1 -0
  33. package/dist/holidays.cjs +125 -0
  34. package/dist/holidays.cjs.map +1 -0
  35. package/dist/holidays.d.cts +14 -0
  36. package/dist/holidays.d.ts +14 -0
  37. package/dist/holidays.js +95 -0
  38. package/dist/holidays.js.map +1 -0
  39. package/dist/index.cjs +409 -0
  40. package/dist/index.cjs.map +1 -0
  41. package/dist/index.d.cts +8 -0
  42. package/dist/index.d.ts +8 -0
  43. package/dist/index.js +345 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/inventory.cjs +73 -0
  46. package/dist/inventory.cjs.map +1 -0
  47. package/dist/inventory.d.cts +28 -0
  48. package/dist/inventory.d.ts +28 -0
  49. package/dist/inventory.js +40 -0
  50. package/dist/inventory.js.map +1 -0
  51. package/dist/validation.cjs +54 -0
  52. package/dist/validation.cjs.map +1 -0
  53. package/dist/validation.d.cts +6 -0
  54. package/dist/validation.d.ts +6 -0
  55. package/dist/validation.js +24 -0
  56. package/dist/validation.js.map +1 -0
  57. package/package.json +74 -0
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/currency/index.ts
21
+ var currency_exports = {};
22
+ __export(currency_exports, {
23
+ VAT_RATE: () => VAT_RATE,
24
+ addVAT: () => addVAT,
25
+ calculateVAT: () => calculateVAT,
26
+ extractVAT: () => extractVAT,
27
+ formatPeso: () => formatPeso,
28
+ formatPesoShort: () => formatPesoShort,
29
+ isVATRegistered: () => isVATRegistered,
30
+ parsePeso: () => parsePeso
31
+ });
32
+ module.exports = __toCommonJS(currency_exports);
33
+
34
+ // src/currency/format.ts
35
+ function formatPeso(amount, options = {}) {
36
+ const { decimals = 2 } = options;
37
+ const sign = amount < 0 ? "-" : "";
38
+ const abs = Math.abs(amount);
39
+ const formatted = abs.toLocaleString("en-PH", {
40
+ minimumFractionDigits: decimals,
41
+ maximumFractionDigits: decimals
42
+ });
43
+ return `${sign}\u20B1${formatted}`;
44
+ }
45
+ function parsePeso(value) {
46
+ const cleaned = value.replace(/[\u20B1,\s]/g, "");
47
+ return Number(cleaned);
48
+ }
49
+ function formatPesoShort(amount) {
50
+ const abs = Math.abs(amount);
51
+ const sign = amount < 0 ? "-" : "";
52
+ if (abs >= 1e6) {
53
+ const millions = abs / 1e6;
54
+ return `${sign}\u20B1${millions % 1 === 0 ? millions.toFixed(0) : millions.toFixed(1)}M`;
55
+ }
56
+ if (abs >= 1e3) {
57
+ const thousands = abs / 1e3;
58
+ return `${sign}\u20B1${thousands % 1 === 0 ? thousands.toFixed(0) : thousands.toFixed(1)}K`;
59
+ }
60
+ return `${sign}\u20B1${abs}`;
61
+ }
62
+
63
+ // src/currency/tax.ts
64
+ var VAT_RATE = 0.12;
65
+ var VAT_FACTOR = 1 + VAT_RATE;
66
+ function calculateVAT(netAmount) {
67
+ return Math.round(netAmount * VAT_RATE * 100) / 100;
68
+ }
69
+ function addVAT(netAmount) {
70
+ return Math.round(netAmount * VAT_FACTOR * 100) / 100;
71
+ }
72
+ function extractVAT(grossAmount) {
73
+ const vatableAmount = Math.round(grossAmount / VAT_FACTOR * 100) / 100;
74
+ const vatAmount = Math.round((grossAmount - vatableAmount) * 100) / 100;
75
+ return { vatableAmount, vatAmount, grossAmount };
76
+ }
77
+ function isVATRegistered(tin) {
78
+ return /^\d{3}-\d{3}-\d{3}-\d{3}$/.test(tin);
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ VAT_RATE,
83
+ addVAT,
84
+ calculateVAT,
85
+ extractVAT,
86
+ formatPeso,
87
+ formatPesoShort,
88
+ isVATRegistered,
89
+ parsePeso
90
+ });
91
+ //# sourceMappingURL=currency.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/currency/index.ts","../src/currency/format.ts","../src/currency/tax.ts"],"sourcesContent":["export { formatPeso, parsePeso, formatPesoShort } from './format.js';\nexport type { FormatPesoOptions } from './format.js';\nexport { calculateVAT, addVAT, extractVAT, isVATRegistered, VAT_RATE } from './tax.js';\nexport type { VATBreakdown } from './tax.js';\n","export interface FormatPesoOptions {\n decimals?: number;\n showSign?: boolean;\n}\n\nexport function formatPeso(amount: number, options: FormatPesoOptions = {}): string {\n const { decimals = 2 } = options;\n const sign = amount < 0 ? '-' : '';\n const abs = Math.abs(amount);\n const formatted = abs.toLocaleString('en-PH', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n return `${sign}\\u20B1${formatted}`;\n}\n\nexport function parsePeso(value: string): number {\n const cleaned = value.replace(/[\\u20B1,\\s]/g, '');\n return Number(cleaned);\n}\n\nexport function formatPesoShort(amount: number): string {\n const abs = Math.abs(amount);\n const sign = amount < 0 ? '-' : '';\n if (abs >= 1_000_000) {\n const millions = abs / 1_000_000;\n return `${sign}\\u20B1${millions % 1 === 0 ? millions.toFixed(0) : millions.toFixed(1)}M`;\n }\n if (abs >= 1_000) {\n const thousands = abs / 1_000;\n return `${sign}\\u20B1${thousands % 1 === 0 ? thousands.toFixed(0) : thousands.toFixed(1)}K`;\n }\n return `${sign}\\u20B1${abs}`;\n}\n","export const VAT_RATE = 0.12;\nconst VAT_FACTOR = 1 + VAT_RATE;\n\nexport function calculateVAT(netAmount: number): number {\n return Math.round(netAmount * VAT_RATE * 100) / 100;\n}\n\nexport function addVAT(netAmount: number): number {\n return Math.round(netAmount * VAT_FACTOR * 100) / 100;\n}\n\nexport interface VATBreakdown {\n vatableAmount: number;\n vatAmount: number;\n grossAmount: number;\n}\n\nexport function extractVAT(grossAmount: number): VATBreakdown {\n const vatableAmount = Math.round((grossAmount / VAT_FACTOR) * 100) / 100;\n const vatAmount = Math.round((grossAmount - vatableAmount) * 100) / 100;\n return { vatableAmount, vatAmount, grossAmount };\n}\n\nexport function isVATRegistered(tin: string): boolean {\n return /^\\d{3}-\\d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5D,QAAM,gBAAgB,KAAK,MAAO,cAAc,aAAc,GAAG,IAAI;AACrE,QAAM,YAAY,KAAK,OAAO,cAAc,iBAAiB,GAAG,IAAI;AACpE,SAAO,EAAE,eAAe,WAAW,YAAY;AACjD;AAEO,SAAS,gBAAgB,KAAsB;AACpD,SAAO,4BAA4B,KAAK,GAAG;AAC7C;","names":[]}
@@ -0,0 +1,20 @@
1
+ interface FormatPesoOptions {
2
+ decimals?: number;
3
+ showSign?: boolean;
4
+ }
5
+ declare function formatPeso(amount: number, options?: FormatPesoOptions): string;
6
+ declare function parsePeso(value: string): number;
7
+ declare function formatPesoShort(amount: number): string;
8
+
9
+ declare const VAT_RATE = 0.12;
10
+ declare function calculateVAT(netAmount: number): number;
11
+ declare function addVAT(netAmount: number): number;
12
+ interface VATBreakdown {
13
+ vatableAmount: number;
14
+ vatAmount: number;
15
+ grossAmount: number;
16
+ }
17
+ declare function extractVAT(grossAmount: number): VATBreakdown;
18
+ declare function isVATRegistered(tin: string): boolean;
19
+
20
+ export { type FormatPesoOptions, type VATBreakdown, VAT_RATE, addVAT, calculateVAT, extractVAT, formatPeso, formatPesoShort, isVATRegistered, parsePeso };
@@ -0,0 +1,20 @@
1
+ interface FormatPesoOptions {
2
+ decimals?: number;
3
+ showSign?: boolean;
4
+ }
5
+ declare function formatPeso(amount: number, options?: FormatPesoOptions): string;
6
+ declare function parsePeso(value: string): number;
7
+ declare function formatPesoShort(amount: number): string;
8
+
9
+ declare const VAT_RATE = 0.12;
10
+ declare function calculateVAT(netAmount: number): number;
11
+ declare function addVAT(netAmount: number): number;
12
+ interface VATBreakdown {
13
+ vatableAmount: number;
14
+ vatAmount: number;
15
+ grossAmount: number;
16
+ }
17
+ declare function extractVAT(grossAmount: number): VATBreakdown;
18
+ declare function isVATRegistered(tin: string): boolean;
19
+
20
+ export { type FormatPesoOptions, type VATBreakdown, VAT_RATE, addVAT, calculateVAT, extractVAT, formatPeso, formatPesoShort, isVATRegistered, parsePeso };
@@ -0,0 +1,57 @@
1
+ // src/currency/format.ts
2
+ function formatPeso(amount, options = {}) {
3
+ const { decimals = 2 } = options;
4
+ const sign = amount < 0 ? "-" : "";
5
+ const abs = Math.abs(amount);
6
+ const formatted = abs.toLocaleString("en-PH", {
7
+ minimumFractionDigits: decimals,
8
+ maximumFractionDigits: decimals
9
+ });
10
+ return `${sign}\u20B1${formatted}`;
11
+ }
12
+ function parsePeso(value) {
13
+ const cleaned = value.replace(/[\u20B1,\s]/g, "");
14
+ return Number(cleaned);
15
+ }
16
+ function formatPesoShort(amount) {
17
+ const abs = Math.abs(amount);
18
+ const sign = amount < 0 ? "-" : "";
19
+ if (abs >= 1e6) {
20
+ const millions = abs / 1e6;
21
+ return `${sign}\u20B1${millions % 1 === 0 ? millions.toFixed(0) : millions.toFixed(1)}M`;
22
+ }
23
+ if (abs >= 1e3) {
24
+ const thousands = abs / 1e3;
25
+ return `${sign}\u20B1${thousands % 1 === 0 ? thousands.toFixed(0) : thousands.toFixed(1)}K`;
26
+ }
27
+ return `${sign}\u20B1${abs}`;
28
+ }
29
+
30
+ // src/currency/tax.ts
31
+ var VAT_RATE = 0.12;
32
+ var VAT_FACTOR = 1 + VAT_RATE;
33
+ function calculateVAT(netAmount) {
34
+ return Math.round(netAmount * VAT_RATE * 100) / 100;
35
+ }
36
+ function addVAT(netAmount) {
37
+ return Math.round(netAmount * VAT_FACTOR * 100) / 100;
38
+ }
39
+ function extractVAT(grossAmount) {
40
+ const vatableAmount = Math.round(grossAmount / VAT_FACTOR * 100) / 100;
41
+ const vatAmount = Math.round((grossAmount - vatableAmount) * 100) / 100;
42
+ return { vatableAmount, vatAmount, grossAmount };
43
+ }
44
+ function isVATRegistered(tin) {
45
+ return /^\d{3}-\d{3}-\d{3}-\d{3}$/.test(tin);
46
+ }
47
+ export {
48
+ VAT_RATE,
49
+ addVAT,
50
+ calculateVAT,
51
+ extractVAT,
52
+ formatPeso,
53
+ formatPesoShort,
54
+ isVATRegistered,
55
+ parsePeso
56
+ };
57
+ //# sourceMappingURL=currency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/currency/format.ts","../src/currency/tax.ts"],"sourcesContent":["export interface FormatPesoOptions {\n decimals?: number;\n showSign?: boolean;\n}\n\nexport function formatPeso(amount: number, options: FormatPesoOptions = {}): string {\n const { decimals = 2 } = options;\n const sign = amount < 0 ? '-' : '';\n const abs = Math.abs(amount);\n const formatted = abs.toLocaleString('en-PH', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n return `${sign}\\u20B1${formatted}`;\n}\n\nexport function parsePeso(value: string): number {\n const cleaned = value.replace(/[\\u20B1,\\s]/g, '');\n return Number(cleaned);\n}\n\nexport function formatPesoShort(amount: number): string {\n const abs = Math.abs(amount);\n const sign = amount < 0 ? '-' : '';\n if (abs >= 1_000_000) {\n const millions = abs / 1_000_000;\n return `${sign}\\u20B1${millions % 1 === 0 ? millions.toFixed(0) : millions.toFixed(1)}M`;\n }\n if (abs >= 1_000) {\n const thousands = abs / 1_000;\n return `${sign}\\u20B1${thousands % 1 === 0 ? thousands.toFixed(0) : thousands.toFixed(1)}K`;\n }\n return `${sign}\\u20B1${abs}`;\n}\n","export const VAT_RATE = 0.12;\nconst VAT_FACTOR = 1 + VAT_RATE;\n\nexport function calculateVAT(netAmount: number): number {\n return Math.round(netAmount * VAT_RATE * 100) / 100;\n}\n\nexport function addVAT(netAmount: number): number {\n return Math.round(netAmount * VAT_FACTOR * 100) / 100;\n}\n\nexport interface VATBreakdown {\n vatableAmount: number;\n vatAmount: number;\n grossAmount: number;\n}\n\nexport function extractVAT(grossAmount: number): VATBreakdown {\n const vatableAmount = Math.round((grossAmount / VAT_FACTOR) * 100) / 100;\n const vatAmount = Math.round((grossAmount - vatableAmount) * 100) / 100;\n return { vatableAmount, vatAmount, grossAmount };\n}\n\nexport function isVATRegistered(tin: string): boolean {\n return /^\\d{3}-\\d{3}-\\d{3}-\\d{3}$/.test(tin);\n}\n"],"mappings":";AAKO,SAA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AAEO,SAAS,gBAAgB,KAAsB;AACpD,SAAO,4BAA4B,KAAK,GAAG;AAC7C;","names":[]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/documents/index.ts
21
+ var documents_exports = {};
22
+ __export(documents_exports, {
23
+ generateDRNumber: () => generateDRNumber,
24
+ generateGRNNumber: () => generateGRNNumber,
25
+ generateReferenceNumber: () => generateReferenceNumber
26
+ });
27
+ module.exports = __toCommonJS(documents_exports);
28
+
29
+ // src/documents/numbering.ts
30
+ function formatDate(d) {
31
+ const y = d.getFullYear();
32
+ const m = String(d.getMonth() + 1).padStart(2, "0");
33
+ const day = String(d.getDate()).padStart(2, "0");
34
+ return `${y}${m}${day}`;
35
+ }
36
+ function generateGRNNumber(opts) {
37
+ const dateStr = formatDate(opts.date ?? /* @__PURE__ */ new Date());
38
+ const seq = String(opts.sequence).padStart(4, "0");
39
+ return `GRN-${opts.warehouseCode}-${dateStr}-${seq}`;
40
+ }
41
+ function generateDRNumber(opts) {
42
+ const dateStr = formatDate(opts.date ?? /* @__PURE__ */ new Date());
43
+ const seq = String(opts.sequence).padStart(4, "0");
44
+ return `DR-${opts.warehouseCode}-${dateStr}-${seq}`;
45
+ }
46
+ function generateReferenceNumber(prefix, sequence, date) {
47
+ const seq = String(sequence).padStart(6, "0");
48
+ if (date) {
49
+ return `${prefix}-${formatDate(date)}-${seq}`;
50
+ }
51
+ return `${prefix}-${seq}`;
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ generateDRNumber,
56
+ generateGRNNumber,
57
+ generateReferenceNumber
58
+ });
59
+ //# sourceMappingURL=documents.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/documents/index.ts","../src/documents/numbering.ts"],"sourcesContent":["export { generateGRNNumber, generateDRNumber, generateReferenceNumber } from './numbering.js';\nexport type { NumberingOptions } from './numbering.js';\n","export interface NumberingOptions {\n warehouseCode: string;\n date?: Date;\n sequence: number;\n}\n\nfunction formatDate(d: Date): string {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${y}${m}${day}`;\n}\n\nexport function generateGRNNumber(opts: NumberingOptions): string {\n const dateStr = formatDate(opts.date ?? new Date());\n const seq = String(opts.sequence).padStart(4, '0');\n return `GRN-${opts.warehouseCode}-${dateStr}-${seq}`;\n}\n\nexport function generateDRNumber(opts: NumberingOptions): string {\n const dateStr = formatDate(opts.date ?? new Date());\n const seq = String(opts.sequence).padStart(4, '0');\n return `DR-${opts.warehouseCode}-${dateStr}-${seq}`;\n}\n\nexport function generateReferenceNumber(\n prefix: string,\n sequence: number,\n date?: Date\n): string {\n const seq = String(sequence).padStart(6, '0');\n if (date) {\n return `${prefix}-${formatDate(date)}-${seq}`;\n }\n return `${prefix}-${seq}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,SAAS,WAAW,GAAiB;AACnC,QAAM,IAAI,EAAE,YAAY;AACxB,QAAM,IAAI,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAClD,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,SAAO,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG;AACvB;AAEO,SAAS,kBAAkB,MAAgC;AAChE,QAAM,UAAU,WAAW,KAAK,QAAQ,oBAAI,KAAK,CAAC;AAClD,QAAM,MAAM,OAAO,KAAK,QAAQ,EAAE,SAAS,GAAG,GAAG;AACjD,SAAO,OAAO,KAAK,aAAa,IAAI,OAAO,IAAI,GAAG;AACpD;AAEO,SAAS,iBAAiB,MAAgC;AAC/D,QAAM,UAAU,WAAW,KAAK,QAAQ,oBAAI,KAAK,CAAC;AAClD,QAAM,MAAM,OAAO,KAAK,QAAQ,EAAE,SAAS,GAAG,GAAG;AACjD,SAAO,MAAM,KAAK,aAAa,IAAI,OAAO,IAAI,GAAG;AACnD;AAEO,SAAS,wBACd,QACA,UACA,MACQ;AACR,QAAM,MAAM,OAAO,QAAQ,EAAE,SAAS,GAAG,GAAG;AAC5C,MAAI,MAAM;AACR,WAAO,GAAG,MAAM,IAAI,WAAW,IAAI,CAAC,IAAI,GAAG;AAAA,EAC7C;AACA,SAAO,GAAG,MAAM,IAAI,GAAG;AACzB;","names":[]}
@@ -0,0 +1,10 @@
1
+ interface NumberingOptions {
2
+ warehouseCode: string;
3
+ date?: Date;
4
+ sequence: number;
5
+ }
6
+ declare function generateGRNNumber(opts: NumberingOptions): string;
7
+ declare function generateDRNumber(opts: NumberingOptions): string;
8
+ declare function generateReferenceNumber(prefix: string, sequence: number, date?: Date): string;
9
+
10
+ export { type NumberingOptions, generateDRNumber, generateGRNNumber, generateReferenceNumber };
@@ -0,0 +1,10 @@
1
+ interface NumberingOptions {
2
+ warehouseCode: string;
3
+ date?: Date;
4
+ sequence: number;
5
+ }
6
+ declare function generateGRNNumber(opts: NumberingOptions): string;
7
+ declare function generateDRNumber(opts: NumberingOptions): string;
8
+ declare function generateReferenceNumber(prefix: string, sequence: number, date?: Date): string;
9
+
10
+ export { type NumberingOptions, generateDRNumber, generateGRNNumber, generateReferenceNumber };
@@ -0,0 +1,30 @@
1
+ // src/documents/numbering.ts
2
+ function formatDate(d) {
3
+ const y = d.getFullYear();
4
+ const m = String(d.getMonth() + 1).padStart(2, "0");
5
+ const day = String(d.getDate()).padStart(2, "0");
6
+ return `${y}${m}${day}`;
7
+ }
8
+ function generateGRNNumber(opts) {
9
+ const dateStr = formatDate(opts.date ?? /* @__PURE__ */ new Date());
10
+ const seq = String(opts.sequence).padStart(4, "0");
11
+ return `GRN-${opts.warehouseCode}-${dateStr}-${seq}`;
12
+ }
13
+ function generateDRNumber(opts) {
14
+ const dateStr = formatDate(opts.date ?? /* @__PURE__ */ new Date());
15
+ const seq = String(opts.sequence).padStart(4, "0");
16
+ return `DR-${opts.warehouseCode}-${dateStr}-${seq}`;
17
+ }
18
+ function generateReferenceNumber(prefix, sequence, date) {
19
+ const seq = String(sequence).padStart(6, "0");
20
+ if (date) {
21
+ return `${prefix}-${formatDate(date)}-${seq}`;
22
+ }
23
+ return `${prefix}-${seq}`;
24
+ }
25
+ export {
26
+ generateDRNumber,
27
+ generateGRNNumber,
28
+ generateReferenceNumber
29
+ };
30
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/documents/numbering.ts"],"sourcesContent":["export interface NumberingOptions {\n warehouseCode: string;\n date?: Date;\n sequence: number;\n}\n\nfunction formatDate(d: Date): string {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${y}${m}${day}`;\n}\n\nexport function generateGRNNumber(opts: NumberingOptions): string {\n const dateStr = formatDate(opts.date ?? new Date());\n const seq = String(opts.sequence).padStart(4, '0');\n return `GRN-${opts.warehouseCode}-${dateStr}-${seq}`;\n}\n\nexport function generateDRNumber(opts: NumberingOptions): string {\n const dateStr = formatDate(opts.date ?? new Date());\n const seq = String(opts.sequence).padStart(4, '0');\n return `DR-${opts.warehouseCode}-${dateStr}-${seq}`;\n}\n\nexport function generateReferenceNumber(\n prefix: string,\n sequence: number,\n date?: Date\n): string {\n const seq = String(sequence).padStart(6, '0');\n if (date) {\n return `${prefix}-${formatDate(date)}-${seq}`;\n }\n return `${prefix}-${seq}`;\n}\n"],"mappings":";AAMA,SAAS,WAAW,GAAiB;AACnC,QAAM,IAAI,EAAE,YAAY;AACxB,QAAM,IAAI,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAClD,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,SAAO,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG;AACvB;AAEO,SAAS,kBAAkB,MAAgC;AAChE,QAAM,UAAU,WAAW,KAAK,QAAQ,oBAAI,KAAK,CAAC;AAClD,QAAM,MAAM,OAAO,KAAK,QAAQ,EAAE,SAAS,GAAG,GAAG;AACjD,SAAO,OAAO,KAAK,aAAa,IAAI,OAAO,IAAI,GAAG;AACpD;AAEO,SAAS,iBAAiB,MAAgC;AAC/D,QAAM,UAAU,WAAW,KAAK,QAAQ,oBAAI,KAAK,CAAC;AAClD,QAAM,MAAM,OAAO,KAAK,QAAQ,EAAE,SAAS,GAAG,GAAG;AACjD,SAAO,MAAM,KAAK,aAAa,IAAI,OAAO,IAAI,GAAG;AACnD;AAEO,SAAS,wBACd,QACA,UACA,MACQ;AACR,QAAM,MAAM,OAAO,QAAQ,EAAE,SAAS,GAAG,GAAG;AAC5C,MAAI,MAAM;AACR,WAAO,GAAG,MAAM,IAAI,WAAW,IAAI,CAAC,IAAI,GAAG;AAAA,EAC7C;AACA,SAAO,GAAG,MAAM,IAAI,GAAG;AACzB;","names":[]}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/holidays/index.ts
21
+ var holidays_exports = {};
22
+ __export(holidays_exports, {
23
+ getPhilippineHolidays: () => getPhilippineHolidays,
24
+ isHoliday: () => isHoliday,
25
+ isRegularHoliday: () => isRegularHoliday,
26
+ isWarehouseOpen: () => isWarehouseOpen
27
+ });
28
+ module.exports = __toCommonJS(holidays_exports);
29
+
30
+ // src/holidays/data.ts
31
+ var FIXED_HOLIDAYS = [
32
+ { month: 1, day: 1, name: "New Year's Day", type: "regular" },
33
+ { month: 2, day: 25, name: "EDSA People Power Revolution", type: "regular" },
34
+ { month: 4, day: 9, name: "Araw ng Kagitingan (Day of Valor)", type: "regular" },
35
+ { month: 5, day: 1, name: "Labor Day", type: "regular" },
36
+ { month: 6, day: 12, name: "Independence Day", type: "regular" },
37
+ { month: 8, day: 21, name: "Ninoy Aquino Day", type: "special_non_working" },
38
+ { month: 8, day: 26, name: "National Heroes Day", type: "regular" },
39
+ { month: 11, day: 1, name: "All Saints' Day", type: "special_non_working" },
40
+ { month: 11, day: 2, name: "All Souls' Day", type: "special_non_working" },
41
+ { month: 11, day: 30, name: "Bonifacio Day", type: "regular" },
42
+ { month: 12, day: 8, name: "Feast of the Immaculate Conception", type: "special_non_working" },
43
+ { month: 12, day: 24, name: "Christmas Eve", type: "special_non_working" },
44
+ { month: 12, day: 25, name: "Christmas Day", type: "regular" },
45
+ { month: 12, day: 30, name: "Rizal Day", type: "regular" },
46
+ { month: 12, day: 31, name: "Last Day of the Year", type: "special_non_working" }
47
+ ];
48
+ function getPhilippineHolidays(year) {
49
+ const holidays = [];
50
+ for (const h of FIXED_HOLIDAYS) {
51
+ holidays.push({
52
+ name: h.name,
53
+ date: `${year}-${String(h.month).padStart(2, "0")}-${String(h.day).padStart(2, "0")}`,
54
+ type: h.type
55
+ });
56
+ }
57
+ const easterDate = getEasterDate(year);
58
+ const goodFriday = new Date(easterDate);
59
+ goodFriday.setDate(easterDate.getDate() - 2);
60
+ const blackSaturday = new Date(easterDate);
61
+ blackSaturday.setDate(easterDate.getDate() - 1);
62
+ holidays.push({
63
+ name: "Maundy Thursday",
64
+ date: formatDateISO(new Date(easterDate.getTime() - 3 * 864e5)),
65
+ type: "regular"
66
+ });
67
+ holidays.push({
68
+ name: "Good Friday",
69
+ date: formatDateISO(goodFriday),
70
+ type: "regular"
71
+ });
72
+ holidays.push({
73
+ name: "Black Saturday",
74
+ date: formatDateISO(blackSaturday),
75
+ type: "special_non_working"
76
+ });
77
+ holidays.push({
78
+ name: "Easter Sunday",
79
+ date: formatDateISO(easterDate),
80
+ type: "regular"
81
+ });
82
+ return holidays;
83
+ }
84
+ function getEasterDate(year) {
85
+ const a = year % 19;
86
+ const b = Math.floor(year / 100);
87
+ const c = year % 100;
88
+ const d = Math.floor(b / 4);
89
+ const e = b % 4;
90
+ const f = Math.floor((b + 8) / 25);
91
+ const g = Math.floor((b - f + 1) / 3);
92
+ const h = (19 * a + b - d - g + 15) % 30;
93
+ const i = Math.floor(c / 4);
94
+ const k = c % 4;
95
+ const l = (32 + 2 * e + 2 * i - h - k) % 7;
96
+ const m = Math.floor((a + 11 * h + 22 * l) / 451);
97
+ const month = Math.floor((h + l - 7 * m + 114) / 31);
98
+ const day = (h + l - 7 * m + 114) % 31 + 1;
99
+ return new Date(year, month - 1, day);
100
+ }
101
+ function formatDateISO(d) {
102
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
103
+ }
104
+ function isHoliday(date) {
105
+ const iso = formatDateISO(date);
106
+ return getPhilippineHolidays(date.getFullYear()).some((h) => h.date === iso);
107
+ }
108
+ function isRegularHoliday(date) {
109
+ const iso = formatDateISO(date);
110
+ return getPhilippineHolidays(date.getFullYear()).some((h) => h.date === iso && h.type === "regular");
111
+ }
112
+ function isWarehouseOpen(date, options = {}) {
113
+ const { closedDays = [0] } = options;
114
+ if (closedDays.includes(date.getDay())) return false;
115
+ if (isHoliday(date)) return false;
116
+ return true;
117
+ }
118
+ // Annotate the CommonJS export names for ESM import in node:
119
+ 0 && (module.exports = {
120
+ getPhilippineHolidays,
121
+ isHoliday,
122
+ isRegularHoliday,
123
+ isWarehouseOpen
124
+ });
125
+ //# sourceMappingURL=holidays.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/holidays/index.ts","../src/holidays/data.ts"],"sourcesContent":["export {\n getPhilippineHolidays,\n isHoliday,\n isRegularHoliday,\n isWarehouseOpen,\n} from './data.js';\nexport type { PhilippineHoliday, WarehouseOpenOptions } from './data.js';\n","export interface PhilippineHoliday {\n name: string;\n date: string;\n type: 'regular' | 'special_non_working';\n}\n\nconst FIXED_HOLIDAYS: { month: number; day: number; name: string; type: PhilippineHoliday['type'] }[] = [\n { month: 1, day: 1, name: \"New Year's Day\", type: 'regular' },\n { month: 2, day: 25, name: 'EDSA People Power Revolution', type: 'regular' },\n { month: 4, day: 9, name: 'Araw ng Kagitingan (Day of Valor)', type: 'regular' },\n { month: 5, day: 1, name: 'Labor Day', type: 'regular' },\n { month: 6, day: 12, name: 'Independence Day', type: 'regular' },\n { month: 8, day: 21, name: 'Ninoy Aquino Day', type: 'special_non_working' },\n { month: 8, day: 26, name: 'National Heroes Day', type: 'regular' },\n { month: 11, day: 1, name: \"All Saints' Day\", type: 'special_non_working' },\n { month: 11, day: 2, name: \"All Souls' Day\", type: 'special_non_working' },\n { month: 11, day: 30, name: 'Bonifacio Day', type: 'regular' },\n { month: 12, day: 8, name: 'Feast of the Immaculate Conception', type: 'special_non_working' },\n { month: 12, day: 24, name: 'Christmas Eve', type: 'special_non_working' },\n { month: 12, day: 25, name: 'Christmas Day', type: 'regular' },\n { month: 12, day: 30, name: 'Rizal Day', type: 'regular' },\n { month: 12, day: 31, name: 'Last Day of the Year', type: 'special_non_working' },\n];\n\nexport function getPhilippineHolidays(year: number): PhilippineHoliday[] {\n const holidays: PhilippineHoliday[] = [];\n\n for (const h of FIXED_HOLIDAYS) {\n holidays.push({\n name: h.name,\n date: `${year}-${String(h.month).padStart(2, '0')}-${String(h.day).padStart(2, '0')}`,\n type: h.type,\n });\n }\n\n const easterDate = getEasterDate(year);\n const goodFriday = new Date(easterDate);\n goodFriday.setDate(easterDate.getDate() - 2);\n const blackSaturday = new Date(easterDate);\n blackSaturday.setDate(easterDate.getDate() - 1);\n\n holidays.push({\n name: 'Maundy Thursday',\n date: formatDateISO(new Date(easterDate.getTime() - 3 * 86400000)),\n type: 'regular',\n });\n holidays.push({\n name: 'Good Friday',\n date: formatDateISO(goodFriday),\n type: 'regular',\n });\n holidays.push({\n name: 'Black Saturday',\n date: formatDateISO(blackSaturday),\n type: 'special_non_working',\n });\n holidays.push({\n name: 'Easter Sunday',\n date: formatDateISO(easterDate),\n type: 'regular',\n });\n\n return holidays;\n}\n\nfunction getEasterDate(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\nfunction formatDateISO(d: Date): string {\n return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;\n}\n\nexport function isHoliday(date: Date): boolean {\n const iso = formatDateISO(date);\n return getPhilippineHolidays(date.getFullYear()).some(h => h.date === iso);\n}\n\nexport function isRegularHoliday(date: Date): boolean {\n const iso = formatDateISO(date);\n return getPhilippineHolidays(date.getFullYear()).some(h => h.date === iso && h.type === 'regular');\n}\n\nexport interface WarehouseOpenOptions {\n closedDays?: number[];\n}\n\nexport function isWarehouseOpen(date: Date, options: WarehouseOpenOptions = {}): boolean {\n const { closedDays = [0] } = options;\n if (closedDays.includes(date.getDay())) return false;\n if (isHoliday(date)) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAM,iBAAkG;AAAA,EACtG,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,kBAAkB,MAAM,UAAU;AAAA,EAC5D,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,gCAAgC,MAAM,UAAU;AAAA,EAC3E,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,qCAAqC,MAAM,UAAU;AAAA,EAC/E,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,aAAa,MAAM,UAAU;AAAA,EACvD,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,oBAAoB,MAAM,UAAU;AAAA,EAC/D,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,oBAAoB,MAAM,sBAAsB;AAAA,EAC3E,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,uBAAuB,MAAM,UAAU;AAAA,EAClE,EAAE,OAAO,IAAI,KAAK,GAAG,MAAM,mBAAmB,MAAM,sBAAsB;AAAA,EAC1E,EAAE,OAAO,IAAI,KAAK,GAAG,MAAM,kBAAkB,MAAM,sBAAsB;AAAA,EACzE,EAAE,OAAO,IAAI,KAAK,IAAI,MAAM,iBAAiB,MAAM,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AAY,CAAC,EAAE,KAAK,OAAK,EAAE,SAAS,OAAO,EAAE,SAAS,SAAS;AACnG;AAMO,SAAS,gBAAgB,MAAY,UAAgC,CAAC,GAAY;AACvF,QAAM,EAAE,aAAa,CAAC,CAAC,EAAE,IAAI;AAC7B,MAAI,WAAW,SAAS,KAAK,OAAO,CAAC,EAAG,QAAO;AAC/C,MAAI,UAAU,IAAI,EAAG,QAAO;AAC5B,SAAO;AACT;","names":[]}
@@ -0,0 +1,14 @@
1
+ interface PhilippineHoliday {
2
+ name: string;
3
+ date: string;
4
+ type: 'regular' | 'special_non_working';
5
+ }
6
+ declare function getPhilippineHolidays(year: number): PhilippineHoliday[];
7
+ declare function isHoliday(date: Date): boolean;
8
+ declare function isRegularHoliday(date: Date): boolean;
9
+ interface WarehouseOpenOptions {
10
+ closedDays?: number[];
11
+ }
12
+ declare function isWarehouseOpen(date: Date, options?: WarehouseOpenOptions): boolean;
13
+
14
+ export { type PhilippineHoliday, type WarehouseOpenOptions, getPhilippineHolidays, isHoliday, isRegularHoliday, isWarehouseOpen };
@@ -0,0 +1,14 @@
1
+ interface PhilippineHoliday {
2
+ name: string;
3
+ date: string;
4
+ type: 'regular' | 'special_non_working';
5
+ }
6
+ declare function getPhilippineHolidays(year: number): PhilippineHoliday[];
7
+ declare function isHoliday(date: Date): boolean;
8
+ declare function isRegularHoliday(date: Date): boolean;
9
+ interface WarehouseOpenOptions {
10
+ closedDays?: number[];
11
+ }
12
+ declare function isWarehouseOpen(date: Date, options?: WarehouseOpenOptions): boolean;
13
+
14
+ export { type PhilippineHoliday, type WarehouseOpenOptions, getPhilippineHolidays, isHoliday, isRegularHoliday, isWarehouseOpen };
@@ -0,0 +1,95 @@
1
+ // src/holidays/data.ts
2
+ var FIXED_HOLIDAYS = [
3
+ { month: 1, day: 1, name: "New Year's Day", type: "regular" },
4
+ { month: 2, day: 25, name: "EDSA People Power Revolution", type: "regular" },
5
+ { month: 4, day: 9, name: "Araw ng Kagitingan (Day of Valor)", type: "regular" },
6
+ { month: 5, day: 1, name: "Labor Day", type: "regular" },
7
+ { month: 6, day: 12, name: "Independence Day", type: "regular" },
8
+ { month: 8, day: 21, name: "Ninoy Aquino Day", type: "special_non_working" },
9
+ { month: 8, day: 26, name: "National Heroes Day", type: "regular" },
10
+ { month: 11, day: 1, name: "All Saints' Day", type: "special_non_working" },
11
+ { month: 11, day: 2, name: "All Souls' Day", type: "special_non_working" },
12
+ { month: 11, day: 30, name: "Bonifacio Day", type: "regular" },
13
+ { month: 12, day: 8, name: "Feast of the Immaculate Conception", type: "special_non_working" },
14
+ { month: 12, day: 24, name: "Christmas Eve", type: "special_non_working" },
15
+ { month: 12, day: 25, name: "Christmas Day", type: "regular" },
16
+ { month: 12, day: 30, name: "Rizal Day", type: "regular" },
17
+ { month: 12, day: 31, name: "Last Day of the Year", type: "special_non_working" }
18
+ ];
19
+ function getPhilippineHolidays(year) {
20
+ const holidays = [];
21
+ for (const h of FIXED_HOLIDAYS) {
22
+ holidays.push({
23
+ name: h.name,
24
+ date: `${year}-${String(h.month).padStart(2, "0")}-${String(h.day).padStart(2, "0")}`,
25
+ type: h.type
26
+ });
27
+ }
28
+ const easterDate = getEasterDate(year);
29
+ const goodFriday = new Date(easterDate);
30
+ goodFriday.setDate(easterDate.getDate() - 2);
31
+ const blackSaturday = new Date(easterDate);
32
+ blackSaturday.setDate(easterDate.getDate() - 1);
33
+ holidays.push({
34
+ name: "Maundy Thursday",
35
+ date: formatDateISO(new Date(easterDate.getTime() - 3 * 864e5)),
36
+ type: "regular"
37
+ });
38
+ holidays.push({
39
+ name: "Good Friday",
40
+ date: formatDateISO(goodFriday),
41
+ type: "regular"
42
+ });
43
+ holidays.push({
44
+ name: "Black Saturday",
45
+ date: formatDateISO(blackSaturday),
46
+ type: "special_non_working"
47
+ });
48
+ holidays.push({
49
+ name: "Easter Sunday",
50
+ date: formatDateISO(easterDate),
51
+ type: "regular"
52
+ });
53
+ return holidays;
54
+ }
55
+ function getEasterDate(year) {
56
+ const a = year % 19;
57
+ const b = Math.floor(year / 100);
58
+ const c = year % 100;
59
+ const d = Math.floor(b / 4);
60
+ const e = b % 4;
61
+ const f = Math.floor((b + 8) / 25);
62
+ const g = Math.floor((b - f + 1) / 3);
63
+ const h = (19 * a + b - d - g + 15) % 30;
64
+ const i = Math.floor(c / 4);
65
+ const k = c % 4;
66
+ const l = (32 + 2 * e + 2 * i - h - k) % 7;
67
+ const m = Math.floor((a + 11 * h + 22 * l) / 451);
68
+ const month = Math.floor((h + l - 7 * m + 114) / 31);
69
+ const day = (h + l - 7 * m + 114) % 31 + 1;
70
+ return new Date(year, month - 1, day);
71
+ }
72
+ function formatDateISO(d) {
73
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
74
+ }
75
+ function isHoliday(date) {
76
+ const iso = formatDateISO(date);
77
+ return getPhilippineHolidays(date.getFullYear()).some((h) => h.date === iso);
78
+ }
79
+ function isRegularHoliday(date) {
80
+ const iso = formatDateISO(date);
81
+ return getPhilippineHolidays(date.getFullYear()).some((h) => h.date === iso && h.type === "regular");
82
+ }
83
+ function isWarehouseOpen(date, options = {}) {
84
+ const { closedDays = [0] } = options;
85
+ if (closedDays.includes(date.getDay())) return false;
86
+ if (isHoliday(date)) return false;
87
+ return true;
88
+ }
89
+ export {
90
+ getPhilippineHolidays,
91
+ isHoliday,
92
+ isRegularHoliday,
93
+ isWarehouseOpen
94
+ };
95
+ //# sourceMappingURL=holidays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/holidays/data.ts"],"sourcesContent":["export interface PhilippineHoliday {\n name: string;\n date: string;\n type: 'regular' | 'special_non_working';\n}\n\nconst FIXED_HOLIDAYS: { month: number; day: number; name: string; type: PhilippineHoliday['type'] }[] = [\n { month: 1, day: 1, name: \"New Year's Day\", type: 'regular' },\n { month: 2, day: 25, name: 'EDSA People Power Revolution', type: 'regular' },\n { month: 4, day: 9, name: 'Araw ng Kagitingan (Day of Valor)', type: 'regular' },\n { month: 5, day: 1, name: 'Labor Day', type: 'regular' },\n { month: 6, day: 12, name: 'Independence Day', type: 'regular' },\n { month: 8, day: 21, name: 'Ninoy Aquino Day', type: 'special_non_working' },\n { month: 8, day: 26, name: 'National Heroes Day', type: 'regular' },\n { month: 11, day: 1, name: \"All Saints' Day\", type: 'special_non_working' },\n { month: 11, day: 2, name: \"All Souls' Day\", type: 'special_non_working' },\n { month: 11, day: 30, name: 'Bonifacio Day', type: 'regular' },\n { month: 12, day: 8, name: 'Feast of the Immaculate Conception', type: 'special_non_working' },\n { month: 12, day: 24, name: 'Christmas Eve', type: 'special_non_working' },\n { month: 12, day: 25, name: 'Christmas Day', type: 'regular' },\n { month: 12, day: 30, name: 'Rizal Day', type: 'regular' },\n { month: 12, day: 31, name: 'Last Day of the Year', type: 'special_non_working' },\n];\n\nexport function getPhilippineHolidays(year: number): PhilippineHoliday[] {\n const holidays: PhilippineHoliday[] = [];\n\n for (const h of FIXED_HOLIDAYS) {\n holidays.push({\n name: h.name,\n date: `${year}-${String(h.month).padStart(2, '0')}-${String(h.day).padStart(2, '0')}`,\n type: h.type,\n });\n }\n\n const easterDate = getEasterDate(year);\n const goodFriday = new Date(easterDate);\n goodFriday.setDate(easterDate.getDate() - 2);\n const blackSaturday = new Date(easterDate);\n blackSaturday.setDate(easterDate.getDate() - 1);\n\n holidays.push({\n name: 'Maundy Thursday',\n date: formatDateISO(new Date(easterDate.getTime() - 3 * 86400000)),\n type: 'regular',\n });\n holidays.push({\n name: 'Good Friday',\n date: formatDateISO(goodFriday),\n type: 'regular',\n });\n holidays.push({\n name: 'Black Saturday',\n date: formatDateISO(blackSaturday),\n type: 'special_non_working',\n });\n holidays.push({\n name: 'Easter Sunday',\n date: formatDateISO(easterDate),\n type: 'regular',\n });\n\n return holidays;\n}\n\nfunction getEasterDate(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\nfunction formatDateISO(d: Date): string {\n return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;\n}\n\nexport function isHoliday(date: Date): boolean {\n const iso = formatDateISO(date);\n return getPhilippineHolidays(date.getFullYear()).some(h => h.date === iso);\n}\n\nexport function isRegularHoliday(date: Date): boolean {\n const iso = formatDateISO(date);\n return getPhilippineHolidays(date.getFullYear()).some(h => h.date === iso && h.type === 'regular');\n}\n\nexport interface WarehouseOpenOptions {\n closedDays?: number[];\n}\n\nexport function isWarehouseOpen(date: Date, options: WarehouseOpenOptions = {}): boolean {\n const { closedDays = [0] } = options;\n if (closedDays.includes(date.getDay())) return false;\n if (isHoliday(date)) return false;\n return true;\n}\n"],"mappings":";AAMA,IAAM,iBAAkG;AAAA,EACtG,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,kBAAkB,MAAM,UAAU;AAAA,EAC5D,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,gCAAgC,MAAM,UAAU;AAAA,EAC3E,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,qCAAqC,MAAM,UAAU;AAAA,EAC/E,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,aAAa,MAAM,UAAU;AAAA,EACvD,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,oBAAoB,MAAM,UAAU;AAAA,EAC/D,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,oBAAoB,MAAM,sBAAsB;AAAA,EAC3E,EAAE,OAAO,GAAG,KAAK,IAAI,MAA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