@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nilo Besingga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @ph-itdev/ph-warehouse-toolkit
2
+
3
+ Philippine warehousing utilities for Node.js — currency, BIR compliance,
4
+ inventory management, address lookup, validation, barcode support, and more.
5
+
6
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue.svg)](https://www.typescriptlang.org/)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @ph-itdev/ph-warehouse-toolkit
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```ts
18
+ import { formatPeso, calculateVAT, generateSKU, isWarehouseOpen } from '@ph-itdev/ph-warehouse-toolkit';
19
+
20
+ // Philippine Peso formatting
21
+ formatPeso(125000); // ₱125,000.00
22
+
23
+ // BIR VAT calculations (12%)
24
+ calculateVAT(1000); // 120
25
+
26
+ // SKU generation
27
+ generateSKU({ prefix: 'WH', category: 'EL', sequence: 1 }); // WH-EL-000001
28
+
29
+ // Warehouse scheduling
30
+ isWarehouseOpen(new Date()); // true/false
31
+ ```
32
+
33
+ ## Modules
34
+
35
+ ### 💰 Currency
36
+ ```ts
37
+ import { formatPeso, parsePeso, formatPesoShort, calculateVAT, addVAT, extractVAT } from '@ph-itdev/ph-warehouse-toolkit/currency';
38
+
39
+ formatPeso(1234567.89); // ₱1,234,567.89
40
+ formatPesoShort(2500000); // ₱2.5M
41
+ calculateVAT(1000); // 120
42
+ addVAT(1000); // 1120
43
+ extractVAT(1120); // { vatableAmount: 1000, vatAmount: 120, grossAmount: 1120 }
44
+ ```
45
+
46
+ ### 📍 Address
47
+ ```ts
48
+ import { getRegions, getProvinces, formatAddress } from '@ph-itdev/ph-warehouse-toolkit/address';
49
+
50
+ getRegions(); // All 17 PH regions
51
+ getProvinces('03'); // ['Aurora', 'Bataan', 'Bulacan', 'Pampanga', ...]
52
+ formatAddress({ street: '123 Rizal Ave', barangay: '123', city: 'Makati City', province: 'Metro Manila', zipCode: '1200' });
53
+ // '123 Rizal Ave, Brgy. 123, Makati City, Metro Manila, 1200'
54
+ ```
55
+
56
+ ### ✅ Validation
57
+ ```ts
58
+ import { isValidPHPhone, isValidPHMobile, isValidTIN, isValidPHZipCode } from '@ph-itdev/ph-warehouse-toolkit/validation';
59
+
60
+ isValidPHPhone('09171234567'); // true (Globe mobile)
61
+ isValidPHMobile('09171234567'); // true
62
+ isValidTIN('123-456-789-000'); // true
63
+ isValidPHZipCode('1200'); // true
64
+ ```
65
+
66
+ ### 📦 Inventory
67
+ ```ts
68
+ import { generateSKU, parseSKU, calculateReorderPoint, calculateEOQ, calculateStockValue } from '@ph-itdev/ph-warehouse-toolkit/inventory';
69
+
70
+ generateSKU({ prefix: 'WH', category: 'EL', sequence: 1 }); // 'WH-EL-000001'
71
+ parseSKU('WH-EL-000042'); // { prefix: 'WH', category: 'EL', sequence: 42 }
72
+ calculateReorderPoint(50, 7); // 350
73
+ calculateEOQ(1000, 50, 5); // ~141
74
+ calculateStockValue([{ quantity: 100, unitCost: 50 }, { quantity: 50, unitCost: 120 }]); // 11000
75
+ ```
76
+
77
+ ### 🏷️ Barcode
78
+ ```ts
79
+ import { calculateEAN13CheckDigit, validateEAN13, generateCode128Data } from '@ph-itdev/ph-warehouse-toolkit/barcode';
80
+
81
+ calculateEAN13CheckDigit('400638133393'); // 1
82
+ validateEAN13('4006381333931'); // true
83
+ ```
84
+
85
+ ### 📄 Documents
86
+ ```ts
87
+ import { generateGRNNumber, generateDRNumber, generateReferenceNumber } from '@ph-itdev/ph-warehouse-toolkit/documents';
88
+
89
+ generateGRNNumber({ warehouseCode: 'WH01', date: new Date('2026-06-15'), sequence: 1 });
90
+ // 'GRN-WH01-20260615-0001'
91
+ generateDRNumber({ warehouseCode: 'WH01', date: new Date('2026-06-15'), sequence: 1 });
92
+ // 'DR-WH01-20260615-0001'
93
+ ```
94
+
95
+ ### 🎌 Holidays
96
+ ```ts
97
+ import { getPhilippineHolidays, isHoliday, isWarehouseOpen } from '@ph-itdev/ph-warehouse-toolkit/holidays';
98
+
99
+ getPhilippineHolidays(2026); // Full list of PH holidays
100
+ isHoliday(new Date('2026-01-01')); // true (New Year's Day)
101
+ isWarehouseOpen(new Date()); // closed on Sundays + holidays
102
+ isWarehouseOpen(new Date(), { closedDays: [] }); // open every day except holidays
103
+ ```
104
+
105
+ ## Why This Package?
106
+
107
+ Warehouse management in the Philippines has unique requirements:
108
+ - **Philippine Peso (₱)** — proper currency formatting with peso sign
109
+ - **BIR Compliance** — 12% VAT calculations, TIN validation
110
+ - **PH Address System** — regions, provinces, cities, barangays
111
+ - **Local Holidays** — regular + special non-working holidays for scheduling
112
+ - **SKU & Inventory** — generate warehouse SKUs, calculate reorder points
113
+ - **Document Numbering** — GRN, DR, and PO reference numbers
114
+
115
+ ## License
116
+
117
+ MIT © Nilo Besingga
@@ -0,0 +1,83 @@
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/address/index.ts
21
+ var address_exports = {};
22
+ __export(address_exports, {
23
+ REGIONS: () => REGIONS,
24
+ formatAddress: () => formatAddress,
25
+ getProvinces: () => getProvinces,
26
+ getRegionByCode: () => getRegionByCode,
27
+ getRegions: () => getRegions
28
+ });
29
+ module.exports = __toCommonJS(address_exports);
30
+
31
+ // src/address/data.ts
32
+ var REGIONS = [
33
+ { code: "NCR", name: "National Capital Region", provinces: ["Metro Manila"] },
34
+ { code: "01", name: "Ilocos Region", provinces: ["Ilocos Norte", "Ilocos Sur", "La Union", "Pangasinan"] },
35
+ { code: "02", name: "Cagayan Valley", provinces: ["Batanes", "Cagayan", "Isabela", "Nueva Vizcaya", "Quirino"] },
36
+ { code: "03", name: "Central Luzon", provinces: ["Aurora", "Bataan", "Bulacan", "Nueva Ecija", "Pampanga", "Tarlac", "Zambales"] },
37
+ { code: "04A", name: "CALABARZON", provinces: ["Batangas", "Cavite", "Laguna", "Quezon", "Rizal"] },
38
+ { code: "04B", name: "MIMAROPA", provinces: ["Marinduque", "Occidental Mindoro", "Oriental Mindoro", "Palawan", "Romblon"] },
39
+ { code: "05", name: "Bicol Region", provinces: ["Albay", "Camarines Norte", "Camarines Sur", "Catanduanes", "Masbate", "Sorsogon"] },
40
+ { code: "06", name: "Western Visayas", provinces: ["Aklan", "Antique", "Capiz", "Guimaras", "Iloilo", "Negros Occidental"] },
41
+ { code: "07", name: "Central Visayas", provinces: ["Bohol", "Cebu", "Negros Oriental", "Siquijor"] },
42
+ { code: "08", name: "Eastern Visayas", provinces: ["Biliran", "Eastern Samar", "Leyte", "Northern Samar", "Samar", "Southern Leyte"] },
43
+ { code: "09", name: "Zamboanga Peninsula", provinces: ["Zamboanga del Norte", "Zamboanga del Sur", "Zamboanga Sibugay"] },
44
+ { code: "10", name: "Northern Mindanao", provinces: ["Bukidnon", "Camiguin", "Lanao del Norte", "Misamis Occidental", "Misamis Oriental"] },
45
+ { code: "11", name: "Davao Region", provinces: ["Davao de Oro", "Davao del Norte", "Davao del Sur", "Davao Occidental", "Davao Oriental"] },
46
+ { code: "12", name: "SOCCSKSARGEN", provinces: ["Cotabato", "Sarangani", "South Cotabato", "Sultan Kudarat"] },
47
+ { code: "13", name: "Caraga", provinces: ["Agusan del Norte", "Agusan del Sur", "Dinagat Islands", "Surigao del Norte", "Surigao del Sur"] },
48
+ { code: "BARMM", name: "Bangsamoro Autonomous Region in Muslim Mindanao", provinces: ["Basilan", "Lanao del Sur", "Maguindanao", "Sulu", "Tawi-Tawi"] },
49
+ { code: "CAR", name: "Cordillera Administrative Region", provinces: ["Abra", "Apayao", "Benguet", "Ifugao", "Kalinga", "Mountain Province"] }
50
+ ];
51
+
52
+ // src/address/lookup.ts
53
+ function getRegions() {
54
+ return [...REGIONS];
55
+ }
56
+ function getRegionByCode(code) {
57
+ return REGIONS.find((r) => r.code === code);
58
+ }
59
+ function getProvinces(regionCode) {
60
+ const region = getRegionByCode(regionCode);
61
+ return region ? [...region.provinces] : [];
62
+ }
63
+ function formatAddress(addr) {
64
+ const parts = [];
65
+ if (addr.unit) parts.push(addr.unit);
66
+ if (addr.floor) parts.push(`Floor ${addr.floor}`);
67
+ if (addr.building) parts.push(addr.building);
68
+ if (addr.street) parts.push(addr.street);
69
+ if (addr.barangay) parts.push(`Brgy. ${addr.barangay}`);
70
+ if (addr.city) parts.push(addr.city);
71
+ if (addr.province) parts.push(addr.province);
72
+ if (addr.zipCode) parts.push(addr.zipCode);
73
+ return parts.join(", ");
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ REGIONS,
78
+ formatAddress,
79
+ getProvinces,
80
+ getRegionByCode,
81
+ getRegions
82
+ });
83
+ //# sourceMappingURL=address.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address/index.ts","../src/address/data.ts","../src/address/lookup.ts"],"sourcesContent":["export { getRegions, getRegionByCode, getProvinces, formatAddress } from './lookup.js';\nexport { REGIONS } from './data.js';\nexport type { Region, PhilippineAddress } from './data.js';\n","export interface Region {\n code: string;\n name: string;\n provinces: string[];\n}\n\nexport interface PhilippineAddress {\n region?: string;\n province?: string;\n city?: string;\n barangay?: string;\n zipCode?: string;\n street?: string;\n building?: string;\n floor?: string;\n unit?: string;\n}\n\nexport const REGIONS: Region[] = [\n { code: 'NCR', name: 'National Capital Region', provinces: ['Metro Manila'] },\n { code: '01', name: 'Ilocos Region', provinces: ['Ilocos Norte', 'Ilocos Sur', 'La Union', 'Pangasinan'] },\n { code: '02', name: 'Cagayan Valley', provinces: ['Batanes', 'Cagayan', 'Isabela', 'Nueva Vizcaya', 'Quirino'] },\n { code: '03', name: 'Central Luzon', provinces: ['Aurora', 'Bataan', 'Bulacan', 'Nueva Ecija', 'Pampanga', 'Tarlac', 'Zambales'] },\n { code: '04A', name: 'CALABARZON', provinces: ['Batangas', 'Cavite', 'Laguna', 'Quezon', 'Rizal'] },\n { code: '04B', name: 'MIMAROPA', provinces: ['Marinduque', 'Occidental Mindoro', 'Oriental Mindoro', 'Palawan', 'Romblon'] },\n { code: '05', name: 'Bicol Region', provinces: ['Albay', 'Camarines Norte', 'Camarines Sur', 'Catanduanes', 'Masbate', 'Sorsogon'] },\n { code: '06', name: 'Western Visayas', provinces: ['Aklan', 'Antique', 'Capiz', 'Guimaras', 'Iloilo', 'Negros Occidental'] },\n { code: '07', name: 'Central Visayas', provinces: ['Bohol', 'Cebu', 'Negros Oriental', 'Siquijor'] },\n { code: '08', name: 'Eastern Visayas', provinces: ['Biliran', 'Eastern Samar', 'Leyte', 'Northern Samar', 'Samar', 'Southern Leyte'] },\n { code: '09', name: 'Zamboanga Peninsula', provinces: ['Zamboanga del Norte', 'Zamboanga del Sur', 'Zamboanga Sibugay'] },\n { code: '10', name: 'Northern Mindanao', provinces: ['Bukidnon', 'Camiguin', 'Lanao del Norte', 'Misamis Occidental', 'Misamis Oriental'] },\n { code: '11', name: 'Davao Region', provinces: ['Davao de Oro', 'Davao del Norte', 'Davao del Sur', 'Davao Occidental', 'Davao Oriental'] },\n { code: '12', name: 'SOCCSKSARGEN', provinces: ['Cotabato', 'Sarangani', 'South Cotabato', 'Sultan Kudarat'] },\n { code: '13', name: 'Caraga', provinces: ['Agusan del Norte', 'Agusan del Sur', 'Dinagat Islands', 'Surigao del Norte', 'Surigao del Sur'] },\n { code: 'BARMM', name: 'Bangsamoro Autonomous Region in Muslim Mindanao', provinces: ['Basilan', 'Lanao del Sur', 'Maguindanao', 'Sulu', 'Tawi-Tawi'] },\n { code: 'CAR', name: 'Cordillera Administrative Region', provinces: ['Abra', 'Apayao', 'Benguet', 'Ifugao', 'Kalinga', 'Mountain Province'] },\n];\n","import { REGIONS, type Region, type PhilippineAddress } from './data.js';\n\nexport function getRegions(): Region[] {\n return [...REGIONS];\n}\n\nexport function getRegionByCode(code: string): Region | undefined {\n return REGIONS.find(r => r.code === code);\n}\n\nexport function getProvinces(regionCode: string): string[] {\n const region = getRegionByCode(regionCode);\n return region ? [...region.provinces] : [];\n}\n\nexport function formatAddress(addr: PhilippineAddress): string {\n const parts: string[] = [];\n if (addr.unit) parts.push(addr.unit);\n if (addr.floor) parts.push(`Floor ${addr.floor}`);\n if (addr.building) parts.push(addr.building);\n if (addr.street) parts.push(addr.street);\n if (addr.barangay) parts.push(`Brgy. ${addr.barangay}`);\n if (addr.city) parts.push(addr.city);\n if (addr.province) parts.push(addr.province);\n if (addr.zipCode) parts.push(addr.zipCode);\n return parts.join(', ');\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,24 @@
1
+ interface Region {
2
+ code: string;
3
+ name: string;
4
+ provinces: string[];
5
+ }
6
+ interface PhilippineAddress {
7
+ region?: string;
8
+ province?: string;
9
+ city?: string;
10
+ barangay?: string;
11
+ zipCode?: string;
12
+ street?: string;
13
+ building?: string;
14
+ floor?: string;
15
+ unit?: string;
16
+ }
17
+ declare const REGIONS: Region[];
18
+
19
+ declare function getRegions(): Region[];
20
+ declare function getRegionByCode(code: string): Region | undefined;
21
+ declare function getProvinces(regionCode: string): string[];
22
+ declare function formatAddress(addr: PhilippineAddress): string;
23
+
24
+ export { type PhilippineAddress, REGIONS, type Region, formatAddress, getProvinces, getRegionByCode, getRegions };
@@ -0,0 +1,24 @@
1
+ interface Region {
2
+ code: string;
3
+ name: string;
4
+ provinces: string[];
5
+ }
6
+ interface PhilippineAddress {
7
+ region?: string;
8
+ province?: string;
9
+ city?: string;
10
+ barangay?: string;
11
+ zipCode?: string;
12
+ street?: string;
13
+ building?: string;
14
+ floor?: string;
15
+ unit?: string;
16
+ }
17
+ declare const REGIONS: Region[];
18
+
19
+ declare function getRegions(): Region[];
20
+ declare function getRegionByCode(code: string): Region | undefined;
21
+ declare function getProvinces(regionCode: string): string[];
22
+ declare function formatAddress(addr: PhilippineAddress): string;
23
+
24
+ export { type PhilippineAddress, REGIONS, type Region, formatAddress, getProvinces, getRegionByCode, getRegions };
@@ -0,0 +1,52 @@
1
+ // src/address/data.ts
2
+ var REGIONS = [
3
+ { code: "NCR", name: "National Capital Region", provinces: ["Metro Manila"] },
4
+ { code: "01", name: "Ilocos Region", provinces: ["Ilocos Norte", "Ilocos Sur", "La Union", "Pangasinan"] },
5
+ { code: "02", name: "Cagayan Valley", provinces: ["Batanes", "Cagayan", "Isabela", "Nueva Vizcaya", "Quirino"] },
6
+ { code: "03", name: "Central Luzon", provinces: ["Aurora", "Bataan", "Bulacan", "Nueva Ecija", "Pampanga", "Tarlac", "Zambales"] },
7
+ { code: "04A", name: "CALABARZON", provinces: ["Batangas", "Cavite", "Laguna", "Quezon", "Rizal"] },
8
+ { code: "04B", name: "MIMAROPA", provinces: ["Marinduque", "Occidental Mindoro", "Oriental Mindoro", "Palawan", "Romblon"] },
9
+ { code: "05", name: "Bicol Region", provinces: ["Albay", "Camarines Norte", "Camarines Sur", "Catanduanes", "Masbate", "Sorsogon"] },
10
+ { code: "06", name: "Western Visayas", provinces: ["Aklan", "Antique", "Capiz", "Guimaras", "Iloilo", "Negros Occidental"] },
11
+ { code: "07", name: "Central Visayas", provinces: ["Bohol", "Cebu", "Negros Oriental", "Siquijor"] },
12
+ { code: "08", name: "Eastern Visayas", provinces: ["Biliran", "Eastern Samar", "Leyte", "Northern Samar", "Samar", "Southern Leyte"] },
13
+ { code: "09", name: "Zamboanga Peninsula", provinces: ["Zamboanga del Norte", "Zamboanga del Sur", "Zamboanga Sibugay"] },
14
+ { code: "10", name: "Northern Mindanao", provinces: ["Bukidnon", "Camiguin", "Lanao del Norte", "Misamis Occidental", "Misamis Oriental"] },
15
+ { code: "11", name: "Davao Region", provinces: ["Davao de Oro", "Davao del Norte", "Davao del Sur", "Davao Occidental", "Davao Oriental"] },
16
+ { code: "12", name: "SOCCSKSARGEN", provinces: ["Cotabato", "Sarangani", "South Cotabato", "Sultan Kudarat"] },
17
+ { code: "13", name: "Caraga", provinces: ["Agusan del Norte", "Agusan del Sur", "Dinagat Islands", "Surigao del Norte", "Surigao del Sur"] },
18
+ { code: "BARMM", name: "Bangsamoro Autonomous Region in Muslim Mindanao", provinces: ["Basilan", "Lanao del Sur", "Maguindanao", "Sulu", "Tawi-Tawi"] },
19
+ { code: "CAR", name: "Cordillera Administrative Region", provinces: ["Abra", "Apayao", "Benguet", "Ifugao", "Kalinga", "Mountain Province"] }
20
+ ];
21
+
22
+ // src/address/lookup.ts
23
+ function getRegions() {
24
+ return [...REGIONS];
25
+ }
26
+ function getRegionByCode(code) {
27
+ return REGIONS.find((r) => r.code === code);
28
+ }
29
+ function getProvinces(regionCode) {
30
+ const region = getRegionByCode(regionCode);
31
+ return region ? [...region.provinces] : [];
32
+ }
33
+ function formatAddress(addr) {
34
+ const parts = [];
35
+ if (addr.unit) parts.push(addr.unit);
36
+ if (addr.floor) parts.push(`Floor ${addr.floor}`);
37
+ if (addr.building) parts.push(addr.building);
38
+ if (addr.street) parts.push(addr.street);
39
+ if (addr.barangay) parts.push(`Brgy. ${addr.barangay}`);
40
+ if (addr.city) parts.push(addr.city);
41
+ if (addr.province) parts.push(addr.province);
42
+ if (addr.zipCode) parts.push(addr.zipCode);
43
+ return parts.join(", ");
44
+ }
45
+ export {
46
+ REGIONS,
47
+ formatAddress,
48
+ getProvinces,
49
+ getRegionByCode,
50
+ getRegions
51
+ };
52
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address/data.ts","../src/address/lookup.ts"],"sourcesContent":["export interface Region {\n code: string;\n name: string;\n provinces: string[];\n}\n\nexport interface PhilippineAddress {\n region?: string;\n province?: string;\n city?: string;\n barangay?: string;\n zipCode?: string;\n street?: string;\n building?: string;\n floor?: string;\n unit?: string;\n}\n\nexport const REGIONS: Region[] = [\n { code: 'NCR', name: 'National Capital Region', provinces: ['Metro Manila'] },\n { code: '01', name: 'Ilocos Region', provinces: ['Ilocos Norte', 'Ilocos Sur', 'La Union', 'Pangasinan'] },\n { code: '02', name: 'Cagayan Valley', provinces: ['Batanes', 'Cagayan', 'Isabela', 'Nueva Vizcaya', 'Quirino'] },\n { code: '03', name: 'Central Luzon', provinces: ['Aurora', 'Bataan', 'Bulacan', 'Nueva Ecija', 'Pampanga', 'Tarlac', 'Zambales'] },\n { code: '04A', name: 'CALABARZON', provinces: ['Batangas', 'Cavite', 'Laguna', 'Quezon', 'Rizal'] },\n { code: '04B', name: 'MIMAROPA', provinces: ['Marinduque', 'Occidental Mindoro', 'Oriental Mindoro', 'Palawan', 'Romblon'] },\n { code: '05', name: 'Bicol Region', provinces: ['Albay', 'Camarines Norte', 'Camarines Sur', 'Catanduanes', 'Masbate', 'Sorsogon'] },\n { code: '06', name: 'Western Visayas', provinces: ['Aklan', 'Antique', 'Capiz', 'Guimaras', 'Iloilo', 'Negros Occidental'] },\n { code: '07', name: 'Central Visayas', provinces: ['Bohol', 'Cebu', 'Negros Oriental', 'Siquijor'] },\n { code: '08', name: 'Eastern Visayas', provinces: ['Biliran', 'Eastern Samar', 'Leyte', 'Northern Samar', 'Samar', 'Southern Leyte'] },\n { code: '09', name: 'Zamboanga Peninsula', provinces: ['Zamboanga del Norte', 'Zamboanga del Sur', 'Zamboanga Sibugay'] },\n { code: '10', name: 'Northern Mindanao', provinces: ['Bukidnon', 'Camiguin', 'Lanao del Norte', 'Misamis Occidental', 'Misamis Oriental'] },\n { code: '11', name: 'Davao Region', provinces: ['Davao de Oro', 'Davao del Norte', 'Davao del Sur', 'Davao Occidental', 'Davao Oriental'] },\n { code: '12', name: 'SOCCSKSARGEN', provinces: ['Cotabato', 'Sarangani', 'South Cotabato', 'Sultan Kudarat'] },\n { code: '13', name: 'Caraga', provinces: ['Agusan del Norte', 'Agusan del Sur', 'Dinagat Islands', 'Surigao del Norte', 'Surigao del Sur'] },\n { code: 'BARMM', name: 'Bangsamoro Autonomous Region in Muslim Mindanao', provinces: ['Basilan', 'Lanao del Sur', 'Maguindanao', 'Sulu', 'Tawi-Tawi'] },\n { code: 'CAR', name: 'Cordillera Administrative Region', provinces: ['Abra', 'Apayao', 'Benguet', 'Ifugao', 'Kalinga', 'Mountain Province'] },\n];\n","import { REGIONS, type Region, type PhilippineAddress } from './data.js';\n\nexport function getRegions(): Region[] {\n return [...REGIONS];\n}\n\nexport function getRegionByCode(code: string): Region | undefined {\n return REGIONS.find(r => r.code === code);\n}\n\nexport function getProvinces(regionCode: string): string[] {\n const region = getRegionByCode(regionCode);\n return region ? [...region.provinces] : [];\n}\n\nexport function formatAddress(addr: PhilippineAddress): string {\n const parts: string[] = [];\n if (addr.unit) parts.push(addr.unit);\n if (addr.floor) parts.push(`Floor ${addr.floor}`);\n if (addr.building) parts.push(addr.building);\n if (addr.street) parts.push(addr.street);\n if (addr.barangay) parts.push(`Brgy. ${addr.barangay}`);\n if (addr.city) parts.push(addr.city);\n if (addr.province) parts.push(addr.province);\n if (addr.zipCode) parts.push(addr.zipCode);\n return parts.join(', ');\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,57 @@
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/barcode/index.ts
21
+ var barcode_exports = {};
22
+ __export(barcode_exports, {
23
+ calculateEAN13CheckDigit: () => calculateEAN13CheckDigit,
24
+ generateCode128Data: () => generateCode128Data,
25
+ validateEAN13: () => validateEAN13
26
+ });
27
+ module.exports = __toCommonJS(barcode_exports);
28
+
29
+ // src/barcode/checksum.ts
30
+ function calculateEAN13CheckDigit(digits12) {
31
+ const cleaned = digits12.replace(/\D/g, "");
32
+ if (cleaned.length !== 12) {
33
+ throw new Error("EAN-13 requires exactly 12 digits (without check digit)");
34
+ }
35
+ let sum = 0;
36
+ for (let i = 0; i < 12; i++) {
37
+ const d = parseInt(cleaned[i], 10);
38
+ sum += i % 2 === 0 ? d : d * 3;
39
+ }
40
+ return (10 - sum % 10) % 10;
41
+ }
42
+ function validateEAN13(ean) {
43
+ const cleaned = ean.replace(/\D/g, "");
44
+ if (cleaned.length !== 13) return false;
45
+ const expectedCheck = calculateEAN13CheckDigit(cleaned.slice(0, 12));
46
+ return parseInt(cleaned[12], 10) === expectedCheck;
47
+ }
48
+ function generateCode128Data(data) {
49
+ return data.trim();
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ calculateEAN13CheckDigit,
54
+ generateCode128Data,
55
+ validateEAN13
56
+ });
57
+ //# sourceMappingURL=barcode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/barcode/index.ts","../src/barcode/checksum.ts"],"sourcesContent":["export { calculateEAN13CheckDigit, validateEAN13, generateCode128Data } from './checksum.js';\n","export function calculateEAN13CheckDigit(digits12: string): number {\n const cleaned = digits12.replace(/\\D/g, '');\n if (cleaned.length !== 12) {\n throw new Error('EAN-13 requires exactly 12 digits (without check digit)');\n }\n let sum = 0;\n for (let i = 0; i < 12; i++) {\n const d = parseInt(cleaned[i], 10);\n sum += i % 2 === 0 ? d : d * 3;\n }\n return (10 - (sum % 10)) % 10;\n}\n\nexport function validateEAN13(ean: string): boolean {\n const cleaned = ean.replace(/\\D/g, '');\n if (cleaned.length !== 13) return false;\n const expectedCheck = calculateEAN13CheckDigit(cleaned.slice(0, 12));\n return parseInt(cleaned[12], 10) === expectedCheck;\n}\n\nexport function generateCode128Data(data: string): string {\n return data.trim();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,yBAAyB,UAA0B;AACjE,QAAM,UAAU,SAAS,QAAQ,OAAO,EAAE;AAC1C,MAAI,QAAQ,WAAW,IAAI;AACzB,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,UAAM,IAAI,SAAS,QAAQ,CAAC,GAAG,EAAE;AACjC,WAAO,IAAI,MAAM,IAAI,IAAI,IAAI;AAAA,EAC/B;AACA,UAAQ,KAAM,MAAM,MAAO;AAC7B;AAEO,SAAS,cAAc,KAAsB;AAClD,QAAM,UAAU,IAAI,QAAQ,OAAO,EAAE;AACrC,MAAI,QAAQ,WAAW,GAAI,QAAO;AAClC,QAAM,gBAAgB,yBAAyB,QAAQ,MAAM,GAAG,EAAE,CAAC;AACnE,SAAO,SAAS,QAAQ,EAAE,GAAG,EAAE,MAAM;AACvC;AAEO,SAAS,oBAAoB,MAAsB;AACxD,SAAO,KAAK,KAAK;AACnB;","names":[]}
@@ -0,0 +1,5 @@
1
+ declare function calculateEAN13CheckDigit(digits12: string): number;
2
+ declare function validateEAN13(ean: string): boolean;
3
+ declare function generateCode128Data(data: string): string;
4
+
5
+ export { calculateEAN13CheckDigit, generateCode128Data, validateEAN13 };
@@ -0,0 +1,5 @@
1
+ declare function calculateEAN13CheckDigit(digits12: string): number;
2
+ declare function validateEAN13(ean: string): boolean;
3
+ declare function generateCode128Data(data: string): string;
4
+
5
+ export { calculateEAN13CheckDigit, generateCode128Data, validateEAN13 };
@@ -0,0 +1,28 @@
1
+ // src/barcode/checksum.ts
2
+ function calculateEAN13CheckDigit(digits12) {
3
+ const cleaned = digits12.replace(/\D/g, "");
4
+ if (cleaned.length !== 12) {
5
+ throw new Error("EAN-13 requires exactly 12 digits (without check digit)");
6
+ }
7
+ let sum = 0;
8
+ for (let i = 0; i < 12; i++) {
9
+ const d = parseInt(cleaned[i], 10);
10
+ sum += i % 2 === 0 ? d : d * 3;
11
+ }
12
+ return (10 - sum % 10) % 10;
13
+ }
14
+ function validateEAN13(ean) {
15
+ const cleaned = ean.replace(/\D/g, "");
16
+ if (cleaned.length !== 13) return false;
17
+ const expectedCheck = calculateEAN13CheckDigit(cleaned.slice(0, 12));
18
+ return parseInt(cleaned[12], 10) === expectedCheck;
19
+ }
20
+ function generateCode128Data(data) {
21
+ return data.trim();
22
+ }
23
+ export {
24
+ calculateEAN13CheckDigit,
25
+ generateCode128Data,
26
+ validateEAN13
27
+ };
28
+ //# sourceMappingURL=barcode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/barcode/checksum.ts"],"sourcesContent":["export function calculateEAN13CheckDigit(digits12: string): number {\n const cleaned = digits12.replace(/\\D/g, '');\n if (cleaned.length !== 12) {\n throw new Error('EAN-13 requires exactly 12 digits (without check digit)');\n }\n let sum = 0;\n for (let i = 0; i < 12; i++) {\n const d = parseInt(cleaned[i], 10);\n sum += i % 2 === 0 ? d : d * 3;\n }\n return (10 - (sum % 10)) % 10;\n}\n\nexport function validateEAN13(ean: string): boolean {\n const cleaned = ean.replace(/\\D/g, '');\n if (cleaned.length !== 13) return false;\n const expectedCheck = calculateEAN13CheckDigit(cleaned.slice(0, 12));\n return parseInt(cleaned[12], 10) === expectedCheck;\n}\n\nexport function generateCode128Data(data: string): string {\n return data.trim();\n}\n"],"mappings":";AAAO,SAAS,yBAAyB,UAA0B;AACjE,QAAM,UAAU,SAAS,QAAQ,OAAO,EAAE;AAC1C,MAAI,QAAQ,WAAW,IAAI;AACzB,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,UAAM,IAAI,SAAS,QAAQ,CAAC,GAAG,EAAE;AACjC,WAAO,IAAI,MAAM,IAAI,IAAI,IAAI;AAAA,EAC/B;AACA,UAAQ,KAAM,MAAM,MAAO;AAC7B;AAEO,SAAS,cAAc,KAAsB;AAClD,QAAM,UAAU,IAAI,QAAQ,OAAO,EAAE;AACrC,MAAI,QAAQ,WAAW,GAAI,QAAO;AAClC,QAAM,gBAAgB,yBAAyB,QAAQ,MAAM,GAAG,EAAE,CAAC;AACnE,SAAO,SAAS,QAAQ,EAAE,GAAG,EAAE,MAAM;AACvC;AAEO,SAAS,oBAAoB,MAAsB;AACxD,SAAO,KAAK,KAAK;AACnB;","names":[]}
@@ -0,0 +1,61 @@
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/compliance/index.ts
21
+ var compliance_exports = {};
22
+ __export(compliance_exports, {
23
+ calculateInvoiceTotals: () => calculateInvoiceTotals,
24
+ formatTIN: () => formatTIN,
25
+ generateBIRSerial: () => generateBIRSerial,
26
+ isValidBIRInvoiceNumber: () => isValidBIRInvoiceNumber
27
+ });
28
+ module.exports = __toCommonJS(compliance_exports);
29
+ function formatTIN(tin) {
30
+ const cleaned = tin.replace(/[^0-9]/g, "");
31
+ if (cleaned.length === 12) {
32
+ return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;
33
+ }
34
+ if (cleaned.length === 15) {
35
+ return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9, 12)}-${cleaned.slice(12)}`;
36
+ }
37
+ return tin;
38
+ }
39
+ function isValidBIRInvoiceNumber(invoiceNo) {
40
+ return /^[A-Z0-9]{2,12}$/.test(invoiceNo.toUpperCase().replace(/[\s-]/g, ""));
41
+ }
42
+ function generateBIRSerial(branchCode, sequence) {
43
+ const prefix = branchCode.slice(0, 2).toUpperCase();
44
+ const seq = String(sequence).padStart(7, "0");
45
+ return `${prefix}${seq}`;
46
+ }
47
+ function calculateInvoiceTotals(amounts, isVATExclusive) {
48
+ const subtotal = amounts.reduce((sum, a) => sum + a, 0);
49
+ const vatRate = 0.12;
50
+ const vatAmount = isVATExclusive ? Math.round(subtotal * vatRate * 100) / 100 : Math.round((subtotal - subtotal / (1 + vatRate)) * 100) / 100;
51
+ const totalAmount = isVATExclusive ? Math.round(subtotal * (1 + vatRate) * 100) / 100 : subtotal;
52
+ return { subtotal, vatAmount, totalAmount };
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ calculateInvoiceTotals,
57
+ formatTIN,
58
+ generateBIRSerial,
59
+ isValidBIRInvoiceNumber
60
+ });
61
+ //# sourceMappingURL=compliance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compliance/index.ts"],"sourcesContent":["/**\n * Philippine BIR Compliance utilities\n * - TIN formatting\n * - VAT registration checks\n * - Invoice numbering per BIR guidelines\n */\n\nexport function formatTIN(tin: string): string {\n const cleaned = tin.replace(/[^0-9]/g, '');\n if (cleaned.length === 12) {\n return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;\n }\n if (cleaned.length === 15) {\n return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9, 12)}-${cleaned.slice(12)}`;\n }\n return tin; // return as-is if unexpected format\n}\n\nexport function isValidBIRInvoiceNumber(invoiceNo: string): boolean {\n // BIR serial numbers: 2 letters + 7 digits (e.g., AB1234567) or\n // machine-registered: up to 12 alphanumeric characters\n return /^[A-Z0-9]{2,12}$/.test(invoiceNo.toUpperCase().replace(/[\\s-]/g, ''));\n}\n\nexport function generateBIRSerial(\n branchCode: string,\n sequence: number\n): string {\n const prefix = branchCode.slice(0, 2).toUpperCase();\n const seq = String(sequence).padStart(7, '0');\n return `${prefix}${seq}`;\n}\n\nexport interface InvoiceMetadata {\n invoiceNumber: string;\n date: Date;\n sellerTIN: string;\n sellerName: string;\n buyerName?: string;\n totalAmount: number;\n vatAmount: number;\n isVATExclusive: boolean;\n}\n\nexport function calculateInvoiceTotals(\n amounts: number[],\n isVATExclusive: boolean\n): { subtotal: number; vatAmount: number; totalAmount: number } {\n const subtotal = amounts.reduce((sum, a) => sum + a, 0);\n const vatRate = 0.12;\n const vatAmount = isVATExclusive\n ? Math.round(subtotal * vatRate * 100) / 100\n : Math.round((subtotal - subtotal / (1 + vatRate)) * 100) / 100;\n const totalAmount = isVATExclusive\n ? Math.round(subtotal * (1 + vatRate) * 100) / 100\n : subtotal;\n return { subtotal, vatAmount, totalAmount };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,UAAU,KAAqB;AAC7C,QAAM,UAAU,IAAI,QAAQ,WAAW,EAAE;AACzC,MAAI,QAAQ,WAAW,IAAI;AACzB,WAAO,GAAG,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,CAAC,CAAC;AAAA,EACjG;AACA,MAAI,QAAQ,WAAW,IAAI;AACzB,WAAO,GAAG,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,EAAE,CAAC,IAAI,QAAQ,MAAM,EAAE,CAAC;AAAA,EAC1H;AACA,SAAO;AACT;AAEO,SAAS,wBAAwB,WAA4B;AAGlE,SAAO,mBAAmB,KAAK,UAAU,YAAY,EAAE,QAAQ,UAAU,EAAE,CAAC;AAC9E;AAEO,SAAS,kBACd,YACA,UACQ;AACR,QAAM,SAAS,WAAW,MAAM,GAAG,CAAC,EAAE,YAAY;AAClD,QAAM,MAAM,OAAO,QAAQ,EAAE,SAAS,GAAG,GAAG;AAC5C,SAAO,GAAG,MAAM,GAAG,GAAG;AACxB;AAaO,SAAS,uBACd,SACA,gBAC8D;AAC9D,QAAM,WAAW,QAAQ,OAAO,CAAC,KAAK,MAAM,MAAM,GAAG,CAAC;AACtD,QAAM,UAAU;AAChB,QAAM,YAAY,iBACd,KAAK,MAAM,WAAW,UAAU,GAAG,IAAI,MACvC,KAAK,OAAO,WAAW,YAAY,IAAI,YAAY,GAAG,IAAI;AAC9D,QAAM,cAAc,iBAChB,KAAK,MAAM,YAAY,IAAI,WAAW,GAAG,IAAI,MAC7C;AACJ,SAAO,EAAE,UAAU,WAAW,YAAY;AAC5C;","names":[]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Philippine BIR Compliance utilities
3
+ * - TIN formatting
4
+ * - VAT registration checks
5
+ * - Invoice numbering per BIR guidelines
6
+ */
7
+ declare function formatTIN(tin: string): string;
8
+ declare function isValidBIRInvoiceNumber(invoiceNo: string): boolean;
9
+ declare function generateBIRSerial(branchCode: string, sequence: number): string;
10
+ interface InvoiceMetadata {
11
+ invoiceNumber: string;
12
+ date: Date;
13
+ sellerTIN: string;
14
+ sellerName: string;
15
+ buyerName?: string;
16
+ totalAmount: number;
17
+ vatAmount: number;
18
+ isVATExclusive: boolean;
19
+ }
20
+ declare function calculateInvoiceTotals(amounts: number[], isVATExclusive: boolean): {
21
+ subtotal: number;
22
+ vatAmount: number;
23
+ totalAmount: number;
24
+ };
25
+
26
+ export { type InvoiceMetadata, calculateInvoiceTotals, formatTIN, generateBIRSerial, isValidBIRInvoiceNumber };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Philippine BIR Compliance utilities
3
+ * - TIN formatting
4
+ * - VAT registration checks
5
+ * - Invoice numbering per BIR guidelines
6
+ */
7
+ declare function formatTIN(tin: string): string;
8
+ declare function isValidBIRInvoiceNumber(invoiceNo: string): boolean;
9
+ declare function generateBIRSerial(branchCode: string, sequence: number): string;
10
+ interface InvoiceMetadata {
11
+ invoiceNumber: string;
12
+ date: Date;
13
+ sellerTIN: string;
14
+ sellerName: string;
15
+ buyerName?: string;
16
+ totalAmount: number;
17
+ vatAmount: number;
18
+ isVATExclusive: boolean;
19
+ }
20
+ declare function calculateInvoiceTotals(amounts: number[], isVATExclusive: boolean): {
21
+ subtotal: number;
22
+ vatAmount: number;
23
+ totalAmount: number;
24
+ };
25
+
26
+ export { type InvoiceMetadata, calculateInvoiceTotals, formatTIN, generateBIRSerial, isValidBIRInvoiceNumber };
@@ -0,0 +1,33 @@
1
+ // src/compliance/index.ts
2
+ function formatTIN(tin) {
3
+ const cleaned = tin.replace(/[^0-9]/g, "");
4
+ if (cleaned.length === 12) {
5
+ return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;
6
+ }
7
+ if (cleaned.length === 15) {
8
+ return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9, 12)}-${cleaned.slice(12)}`;
9
+ }
10
+ return tin;
11
+ }
12
+ function isValidBIRInvoiceNumber(invoiceNo) {
13
+ return /^[A-Z0-9]{2,12}$/.test(invoiceNo.toUpperCase().replace(/[\s-]/g, ""));
14
+ }
15
+ function generateBIRSerial(branchCode, sequence) {
16
+ const prefix = branchCode.slice(0, 2).toUpperCase();
17
+ const seq = String(sequence).padStart(7, "0");
18
+ return `${prefix}${seq}`;
19
+ }
20
+ function calculateInvoiceTotals(amounts, isVATExclusive) {
21
+ const subtotal = amounts.reduce((sum, a) => sum + a, 0);
22
+ const vatRate = 0.12;
23
+ const vatAmount = isVATExclusive ? Math.round(subtotal * vatRate * 100) / 100 : Math.round((subtotal - subtotal / (1 + vatRate)) * 100) / 100;
24
+ const totalAmount = isVATExclusive ? Math.round(subtotal * (1 + vatRate) * 100) / 100 : subtotal;
25
+ return { subtotal, vatAmount, totalAmount };
26
+ }
27
+ export {
28
+ calculateInvoiceTotals,
29
+ formatTIN,
30
+ generateBIRSerial,
31
+ isValidBIRInvoiceNumber
32
+ };
33
+ //# sourceMappingURL=compliance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compliance/index.ts"],"sourcesContent":["/**\n * Philippine BIR Compliance utilities\n * - TIN formatting\n * - VAT registration checks\n * - Invoice numbering per BIR guidelines\n */\n\nexport function formatTIN(tin: string): string {\n const cleaned = tin.replace(/[^0-9]/g, '');\n if (cleaned.length === 12) {\n return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;\n }\n if (cleaned.length === 15) {\n return `${cleaned.slice(0, 3)}-${cleaned.slice(3, 6)}-${cleaned.slice(6, 9)}-${cleaned.slice(9, 12)}-${cleaned.slice(12)}`;\n }\n return tin; // return as-is if unexpected format\n}\n\nexport function isValidBIRInvoiceNumber(invoiceNo: string): boolean {\n // BIR serial numbers: 2 letters + 7 digits (e.g., AB1234567) or\n // machine-registered: up to 12 alphanumeric characters\n return /^[A-Z0-9]{2,12}$/.test(invoiceNo.toUpperCase().replace(/[\\s-]/g, ''));\n}\n\nexport function generateBIRSerial(\n branchCode: string,\n sequence: number\n): string {\n const prefix = branchCode.slice(0, 2).toUpperCase();\n const seq = String(sequence).padStart(7, '0');\n return `${prefix}${seq}`;\n}\n\nexport interface InvoiceMetadata {\n invoiceNumber: string;\n date: Date;\n sellerTIN: string;\n sellerName: string;\n buyerName?: string;\n totalAmount: number;\n vatAmount: number;\n isVATExclusive: boolean;\n}\n\nexport function calculateInvoiceTotals(\n amounts: number[],\n isVATExclusive: boolean\n): { subtotal: number; vatAmount: number; totalAmount: number } {\n const subtotal = amounts.reduce((sum, a) => sum + a, 0);\n const vatRate = 0.12;\n const vatAmount = isVATExclusive\n ? Math.round(subtotal * vatRate * 100) / 100\n : Math.round((subtotal - subtotal / (1 + vatRate)) * 100) / 100;\n const totalAmount = isVATExclusive\n ? Math.round(subtotal * (1 + vatRate) * 100) / 100\n : subtotal;\n return { subtotal, vatAmount, totalAmount };\n}\n"],"mappings":";AAOO,SAAS,UAAU,KAAqB;AAC7C,QAAM,UAAU,IAAI,QAAQ,WAAW,EAAE;AACzC,MAAI,QAAQ,WAAW,IAAI;AACzB,WAAO,GAAG,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,CAAC,CAAC;AAAA,EACjG;AACA,MAAI,QAAQ,WAAW,IAAI;AACzB,WAAO,GAAG,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,MAAM,GAAG,EAAE,CAAC,IAAI,QAAQ,MAAM,EAAE,CAAC;AAAA,EAC1H;AACA,SAAO;AACT;AAEO,SAAS,wBAAwB,WAA4B;AAGlE,SAAO,mBAAmB,KAAK,UAAU,YAAY,EAAE,QAAQ,UAAU,EAAE,CAAC;AAC9E;AAEO,SAAS,kBACd,YACA,UACQ;AACR,QAAM,SAAS,WAAW,MAAM,GAAG,CAAC,EAAE,YAAY;AAClD,QAAM,MAAM,OAAO,QAAQ,EAAE,SAAS,GAAG,GAAG;AAC5C,SAAO,GAAG,MAAM,GAAG,GAAG;AACxB;AAaO,SAAS,uBACd,SACA,gBAC8D;AAC9D,QAAM,WAAW,QAAQ,OAAO,CAAC,KAAK,MAAM,MAAM,GAAG,CAAC;AACtD,QAAM,UAAU;AAChB,QAAM,YAAY,iBACd,KAAK,MAAM,WAAW,UAAU,GAAG,IAAI,MACvC,KAAK,OAAO,WAAW,YAAY,IAAI,YAAY,GAAG,IAAI;AAC9D,QAAM,cAAc,iBAChB,KAAK,MAAM,YAAY,IAAI,WAAW,GAAG,IAAI,MAC7C;AACJ,SAAO,EAAE,UAAU,WAAW,YAAY;AAC5C;","names":[]}