@litusarchieve18/agricore-utils 1.0.30 → 1.0.32
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/README.md +4 -0
- package/dist/{chunk-Y5KVDVNY.mjs → chunk-U332M2N6.mjs} +83 -6
- package/dist/{constants-CrAPx_xU.d.mts → constants-x8gYRJIw.d.mts} +154 -6
- package/dist/{constants-CrAPx_xU.d.ts → constants-x8gYRJIw.d.ts} +154 -6
- package/dist/constants.d.mts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +88 -6
- package/dist/constants.mjs +13 -3
- package/dist/index.d.mts +49 -3
- package/dist/index.d.ts +49 -3
- package/dist/index.js +267 -14
- package/dist/index.mjs +186 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61,17 +61,22 @@ __export(index_exports, {
|
|
|
61
61
|
NettingType: () => NettingType,
|
|
62
62
|
NotificationMode: () => NotificationMode,
|
|
63
63
|
OrderStatus: () => OrderStatus,
|
|
64
|
+
PO_STATUSES: () => PO_STATUSES,
|
|
65
|
+
PREFLIGHT_CHECK_STATUSES: () => PREFLIGHT_CHECK_STATUSES,
|
|
66
|
+
PRODUCT_TYPE_TO_BUDGET_CATEGORY: () => PRODUCT_TYPE_TO_BUDGET_CATEGORY,
|
|
64
67
|
PhysicalState: () => PhysicalState,
|
|
65
68
|
PlantingMethod: () => PlantingMethod,
|
|
66
69
|
PriceAmbiguityError: () => PriceAmbiguityError,
|
|
67
70
|
ProductType: () => ProductType,
|
|
68
71
|
ProductUnit: () => ProductUnit,
|
|
72
|
+
REQUISITION_STATUSES: () => REQUISITION_STATUSES,
|
|
69
73
|
RESOURCE_MODULE_MAP: () => RESOURCE_MODULE_MAP,
|
|
70
74
|
RESOURCE_PATHS: () => RESOURCE_PATHS,
|
|
71
75
|
RESOURCE_REQUIREMENTS: () => RESOURCE_REQUIREMENTS,
|
|
72
76
|
ROLE_SECTIONS_BY_KEY: () => ROLE_SECTIONS_BY_KEY,
|
|
73
77
|
RelationshipType: () => RelationshipType,
|
|
74
78
|
RowOrientation: () => RowOrientation,
|
|
79
|
+
SCOPE_LEVELS: () => SCOPE_LEVELS,
|
|
75
80
|
SENTINEL_UUID: () => SENTINEL_UUID,
|
|
76
81
|
SESSION_SCHEMA: () => SESSION_SCHEMA,
|
|
77
82
|
SIGNATURE_MODES: () => SIGNATURE_MODES,
|
|
@@ -79,7 +84,7 @@ __export(index_exports, {
|
|
|
79
84
|
StockPolicyTier: () => StockPolicyTier,
|
|
80
85
|
StoragePhases: () => StoragePhases,
|
|
81
86
|
TASK_TYPE_REGISTRY: () => TASK_TYPE_REGISTRY,
|
|
82
|
-
|
|
87
|
+
TERM_RESOLUTION_MODES: () => TERM_RESOLUTION_MODES,
|
|
83
88
|
TargetEntityType: () => TargetEntityType,
|
|
84
89
|
TaskStatus: () => TaskStatus,
|
|
85
90
|
TaskType: () => TaskType,
|
|
@@ -92,6 +97,7 @@ __export(index_exports, {
|
|
|
92
97
|
WaterSource: () => WaterSource,
|
|
93
98
|
assertTenantBoundary: () => assertTenantBoundary,
|
|
94
99
|
calculateFileMetadataMatch: () => calculateFileMetadataMatch,
|
|
100
|
+
calculatePaymentDueDate: () => calculatePaymentDueDate,
|
|
95
101
|
createBase44PricingAdapter: () => createBase44PricingAdapter,
|
|
96
102
|
decodeSession: () => decodeSession,
|
|
97
103
|
encodeSession: () => encodeSession,
|
|
@@ -102,6 +108,7 @@ __export(index_exports, {
|
|
|
102
108
|
generateCanonicalId: () => generateCanonicalId,
|
|
103
109
|
generateDocumentPath: () => generateDocumentPath,
|
|
104
110
|
generateInfrastructureFields: () => generateInfrastructureFields,
|
|
111
|
+
generateSystemFolderPath: () => generateSystemFolderPath,
|
|
105
112
|
getAcceptedMimeTypes: () => getAcceptedMimeTypes,
|
|
106
113
|
getApproveAction: () => getApproveAction,
|
|
107
114
|
getFormMeta: () => getFormMeta,
|
|
@@ -113,6 +120,9 @@ __export(index_exports, {
|
|
|
113
120
|
handleAppErrorResponse: () => handleAppErrorResponse,
|
|
114
121
|
hasPrivilegeAt: () => hasPrivilegeAt,
|
|
115
122
|
hasRoleAt: () => hasRoleAt,
|
|
123
|
+
isDueDatePending: () => isDueDatePending,
|
|
124
|
+
isInstallmentSchedule: () => isInstallmentSchedule,
|
|
125
|
+
isSingleDueDate: () => isSingleDueDate,
|
|
116
126
|
isTabVisible: () => isTabVisible,
|
|
117
127
|
isTabWritable: () => isTabWritable,
|
|
118
128
|
resolveAccess: () => resolveAccess,
|
|
@@ -120,6 +130,7 @@ __export(index_exports, {
|
|
|
120
130
|
resolveEffectiveAccess: () => resolveEffectiveAccess,
|
|
121
131
|
resolveError: () => resolveError,
|
|
122
132
|
resolvePrice: () => resolvePrice,
|
|
133
|
+
sanitizeSiteName: () => sanitizeSiteName,
|
|
123
134
|
transformRoleAssignments: () => transformRoleAssignments,
|
|
124
135
|
verifyAndExtractSession: () => verifyAndExtractSession,
|
|
125
136
|
withAgriLogging: () => withAgriLogging
|
|
@@ -470,6 +481,165 @@ async function findOverlappingPriceWindows(db, scope, newRow, excludeId) {
|
|
|
470
481
|
}));
|
|
471
482
|
}
|
|
472
483
|
|
|
484
|
+
// src/paymentDueDateHelpers.ts
|
|
485
|
+
function toUtcMidnight(date) {
|
|
486
|
+
return new Date(
|
|
487
|
+
Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
function addDaysUtc(date, days) {
|
|
491
|
+
const result = new Date(date);
|
|
492
|
+
result.setUTCDate(result.getUTCDate() + days);
|
|
493
|
+
return result;
|
|
494
|
+
}
|
|
495
|
+
function lastDayOfNextMonthUtc(date) {
|
|
496
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 2, 0));
|
|
497
|
+
}
|
|
498
|
+
function nthDayOfNextMonthUtc(date, day) {
|
|
499
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, day));
|
|
500
|
+
}
|
|
501
|
+
function lastDayOfMonthUtc(date) {
|
|
502
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0));
|
|
503
|
+
}
|
|
504
|
+
function calculateSupplierTradeCreditDueDate(transactionDate, window) {
|
|
505
|
+
if (!window) {
|
|
506
|
+
throw new Error(
|
|
507
|
+
"creditDaysWindow is required when paymentTerm is 'supplierTradeCredit'"
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
switch (window.type) {
|
|
511
|
+
case "NET":
|
|
512
|
+
if (!Number.isInteger(window.days) || window.days < 0) {
|
|
513
|
+
throw new Error(`Invalid NET days: ${window.days}`);
|
|
514
|
+
}
|
|
515
|
+
return addDaysUtc(transactionDate, window.days);
|
|
516
|
+
case "EOM":
|
|
517
|
+
if (window.days === void 0) {
|
|
518
|
+
return lastDayOfNextMonthUtc(transactionDate);
|
|
519
|
+
}
|
|
520
|
+
if (!Number.isInteger(window.days) || window.days < 1 || window.days > 31) {
|
|
521
|
+
throw new Error(`Invalid EOM day-of-month: ${window.days}`);
|
|
522
|
+
}
|
|
523
|
+
return nthDayOfNextMonthUtc(transactionDate, window.days);
|
|
524
|
+
default: {
|
|
525
|
+
const exhaustiveCheck = window;
|
|
526
|
+
throw new Error(`Unknown creditDaysWindow type: ${JSON.stringify(exhaustiveCheck)}`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function calculateForwardOrderingContractDueDate(transactionDate, window) {
|
|
531
|
+
if (!window) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
"forwardOrderingContractWindow is required when paymentTerm is 'forwardOrderingContract'"
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
switch (window.frequencyType) {
|
|
537
|
+
case "FIXED_DATE":
|
|
538
|
+
return toUtcMidnight(window.dueDate);
|
|
539
|
+
case "FIXED_DAY": {
|
|
540
|
+
if (!Number.isInteger(window.dayOfMonth) || window.dayOfMonth < 1 || window.dayOfMonth > 31) {
|
|
541
|
+
throw new Error(`Invalid dayOfMonth: ${window.dayOfMonth}`);
|
|
542
|
+
}
|
|
543
|
+
const trigger = window.triggerDate ? toUtcMidnight(window.triggerDate) : transactionDate;
|
|
544
|
+
const candidateThisMonth = new Date(
|
|
545
|
+
Date.UTC(trigger.getUTCFullYear(), trigger.getUTCMonth(), window.dayOfMonth)
|
|
546
|
+
);
|
|
547
|
+
if (trigger.getUTCDate() <= window.dayOfMonth) {
|
|
548
|
+
return candidateThisMonth;
|
|
549
|
+
}
|
|
550
|
+
return new Date(
|
|
551
|
+
Date.UTC(trigger.getUTCFullYear(), trigger.getUTCMonth() + 1, window.dayOfMonth)
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
case "END_OF_MONTH": {
|
|
555
|
+
const trigger = window.triggerDate ? toUtcMidnight(window.triggerDate) : transactionDate;
|
|
556
|
+
const eom = lastDayOfMonthUtc(trigger);
|
|
557
|
+
return window.offsetDays ? addDaysUtc(eom, window.offsetDays) : eom;
|
|
558
|
+
}
|
|
559
|
+
case "DELIVERY_BASED": {
|
|
560
|
+
if (!window.triggerDate) {
|
|
561
|
+
throw new Error("triggerDate is required for DELIVERY_BASED forward ordering contracts");
|
|
562
|
+
}
|
|
563
|
+
const trigger = toUtcMidnight(window.triggerDate);
|
|
564
|
+
return addDaysUtc(trigger, window.offsetDays);
|
|
565
|
+
}
|
|
566
|
+
default: {
|
|
567
|
+
const exhaustiveCheck = window;
|
|
568
|
+
throw new Error(`Unknown frequencyType: ${JSON.stringify(exhaustiveCheck)}`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function calculateInstallmentSchedule(transactionDate, window) {
|
|
573
|
+
if (!window) {
|
|
574
|
+
throw new Error(
|
|
575
|
+
"installmentWindow is required when paymentTerm is 'thirdPartyInputFinance'"
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
if (!Number.isInteger(window.numberOfInstallments) || window.numberOfInstallments < 1) {
|
|
579
|
+
throw new Error(`Invalid numberOfInstallments: ${window.numberOfInstallments}`);
|
|
580
|
+
}
|
|
581
|
+
if (!Number.isInteger(window.periodInterval) || window.periodInterval < 1) {
|
|
582
|
+
throw new Error(`Invalid periodInterval: ${window.periodInterval}`);
|
|
583
|
+
}
|
|
584
|
+
const start = window.startDate ? toUtcMidnight(window.startDate) : transactionDate;
|
|
585
|
+
const dueDates = [];
|
|
586
|
+
for (let installmentNumber = 1; installmentNumber <= window.numberOfInstallments; installmentNumber++) {
|
|
587
|
+
if (window.periodType === "DAYS") {
|
|
588
|
+
dueDates.push(addDaysUtc(start, window.periodInterval * installmentNumber));
|
|
589
|
+
} else {
|
|
590
|
+
if (window.dayOfMonth == null) {
|
|
591
|
+
throw new Error("dayOfMonth is required when periodType is 'MONTHS'");
|
|
592
|
+
}
|
|
593
|
+
const monthOffset = window.periodInterval * installmentNumber;
|
|
594
|
+
dueDates.push(
|
|
595
|
+
new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth() + monthOffset, window.dayOfMonth))
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return dueDates;
|
|
600
|
+
}
|
|
601
|
+
function calculatePaymentDueDate(input) {
|
|
602
|
+
const { transactionDate, paymentTerm } = input;
|
|
603
|
+
const normalizedTransactionDate = toUtcMidnight(transactionDate);
|
|
604
|
+
switch (paymentTerm) {
|
|
605
|
+
case "cashOnDelivery":
|
|
606
|
+
if (!input.deliveryDate) {
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
return toUtcMidnight(input.deliveryDate);
|
|
610
|
+
case "prePaymentProgram":
|
|
611
|
+
return normalizedTransactionDate;
|
|
612
|
+
case "supplierTradeCredit":
|
|
613
|
+
return calculateSupplierTradeCreditDueDate(
|
|
614
|
+
normalizedTransactionDate,
|
|
615
|
+
input.creditDaysWindow
|
|
616
|
+
);
|
|
617
|
+
case "forwardOrderingContract":
|
|
618
|
+
return calculateForwardOrderingContractDueDate(
|
|
619
|
+
normalizedTransactionDate,
|
|
620
|
+
input.forwardOrderingContractWindow
|
|
621
|
+
);
|
|
622
|
+
case "thirdPartyInputFinance":
|
|
623
|
+
return calculateInstallmentSchedule(
|
|
624
|
+
normalizedTransactionDate,
|
|
625
|
+
input.installmentWindow
|
|
626
|
+
);
|
|
627
|
+
default: {
|
|
628
|
+
const exhaustiveCheck = paymentTerm;
|
|
629
|
+
throw new Error(`Unknown paymentTerm: ${JSON.stringify(exhaustiveCheck)}`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function isDueDatePending(result) {
|
|
634
|
+
return result === null;
|
|
635
|
+
}
|
|
636
|
+
function isSingleDueDate(result) {
|
|
637
|
+
return result instanceof Date;
|
|
638
|
+
}
|
|
639
|
+
function isInstallmentSchedule(result) {
|
|
640
|
+
return Array.isArray(result);
|
|
641
|
+
}
|
|
642
|
+
|
|
473
643
|
// src/validators.ts
|
|
474
644
|
var Validator = {
|
|
475
645
|
/** * 1. Email: The classic. Uses a standard RFC 5322 regex.
|
|
@@ -976,6 +1146,12 @@ var RESOURCE_PATHS = {
|
|
|
976
1146
|
farmManagement: "operations.farmManagement",
|
|
977
1147
|
packhouse: "operations.packhouse",
|
|
978
1148
|
accommodation: "operations.accommodation",
|
|
1149
|
+
logistics: "operations.logistics",
|
|
1150
|
+
logisticsReceival: "operations.logistics.receival",
|
|
1151
|
+
logisticsReceivalReview: "operations.logistics.receival.review",
|
|
1152
|
+
// being reviewed by manager/owner
|
|
1153
|
+
logisticsDispatch: "operations.logistics.dispatch",
|
|
1154
|
+
logisticsDispatchReview: "operations.logistics.dispatch.review",
|
|
979
1155
|
// ── Inventory ────────────────────────────────────────────────────────────
|
|
980
1156
|
// === Consumables ===
|
|
981
1157
|
inventory: "inventory",
|
|
@@ -1011,6 +1187,7 @@ var RESOURCE_PATHS = {
|
|
|
1011
1187
|
equipFuelRegister: "equipment.fuelRegister",
|
|
1012
1188
|
equipCalibration: "equipment.calibration",
|
|
1013
1189
|
equipFleet: "equipment.fleetManagement",
|
|
1190
|
+
// ── Finance ──────────────────────────────────────────────────────
|
|
1014
1191
|
finance: "finance",
|
|
1015
1192
|
financeProductRequisition: "finance.product.requistion",
|
|
1016
1193
|
financeDashboard: "finance.dashboard",
|
|
@@ -1074,12 +1251,23 @@ var RESOURCE_MODULE_MAP = {
|
|
|
1074
1251
|
[RESOURCE_PATHS.farmManagement]: [EnabledModule.FARM_MANAGEMENT],
|
|
1075
1252
|
[RESOURCE_PATHS.packhouse]: [EnabledModule.PACKHOUSE],
|
|
1076
1253
|
[RESOURCE_PATHS.accommodation]: [EnabledModule.ACCOMMODATION],
|
|
1254
|
+
// ── Logistics ──────────────────────────────────────────────────────────────
|
|
1255
|
+
[RESOURCE_PATHS.logistics]: ALL_OPERATIONS,
|
|
1256
|
+
[RESOURCE_PATHS.logisticsReceival]: ALL_OPERATIONS,
|
|
1257
|
+
[RESOURCE_PATHS.logisticsReceivalReview]: ALL_OPERATIONS,
|
|
1258
|
+
[RESOURCE_PATHS.logisticsDispatch]: ALL_OPERATIONS,
|
|
1259
|
+
[RESOURCE_PATHS.logisticsDispatchReview]: ALL_OPERATIONS,
|
|
1077
1260
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
1078
1261
|
[RESOURCE_PATHS.equipPreStart]: ALL_OPERATIONS,
|
|
1079
1262
|
[RESOURCE_PATHS.equipMaintenance]: ALL_OPERATIONS,
|
|
1080
1263
|
[RESOURCE_PATHS.equipFuelRegister]: ALL_OPERATIONS,
|
|
1081
1264
|
[RESOURCE_PATHS.equipCalibration]: AGRI_ONLY,
|
|
1082
1265
|
[RESOURCE_PATHS.equipFleet]: ALL_OPERATIONS,
|
|
1266
|
+
// ── Finance ──────────────────────────────────────────────────────────────
|
|
1267
|
+
[RESOURCE_PATHS.financeProductRequisition]: ALL_OPERATIONS,
|
|
1268
|
+
[RESOURCE_PATHS.financeDashboard]: ALL_OPERATIONS,
|
|
1269
|
+
[RESOURCE_PATHS.financeTransaction]: ALL_OPERATIONS,
|
|
1270
|
+
[RESOURCE_PATHS.financeBudgetAllocation]: ALL_OPERATIONS,
|
|
1083
1271
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
1084
1272
|
[RESOURCE_PATHS.safetyAuditing]: ALL_OPERATIONS,
|
|
1085
1273
|
[RESOURCE_PATHS.safetyFood]: AGRI_ONLY,
|
|
@@ -1128,6 +1316,15 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
1128
1316
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR],
|
|
1129
1317
|
requiredPrivileges: [UserPrivilege.ADMIN, UserPrivilege.AUDIT_COMPLIANCE, UserPrivilege.FINANCE, UserPrivilege.DOCUMENT]
|
|
1130
1318
|
},
|
|
1319
|
+
// ── Logistics ──────────────────────────────────────────────────────────────
|
|
1320
|
+
[RESOURCE_PATHS.logisticsReceival]: {
|
|
1321
|
+
allowedRoles: EVERYONE
|
|
1322
|
+
},
|
|
1323
|
+
[RESOURCE_PATHS.logisticsReceivalReview]: {
|
|
1324
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
1325
|
+
},
|
|
1326
|
+
[RESOURCE_PATHS.logisticsDispatch]: { allowedRoles: EVERYONE },
|
|
1327
|
+
[RESOURCE_PATHS.logisticsDispatchReview]: { allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR] },
|
|
1131
1328
|
// CONSUMABLES PERMISSIONS
|
|
1132
1329
|
[RESOURCE_PATHS.inventoryConsumableProduct]: {
|
|
1133
1330
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -1242,6 +1439,7 @@ var DocumentType = /* @__PURE__ */ ((DocumentType2) => {
|
|
|
1242
1439
|
DocumentType2["PACKHOUSE_INSPECTION"] = "PACKHOUSE_INSPECTION";
|
|
1243
1440
|
DocumentType2["TRAINING_CERTIFICATE"] = "TRAINING_CERTIFICATE";
|
|
1244
1441
|
DocumentType2["INVOICE"] = "INVOICE";
|
|
1442
|
+
DocumentType2["PURCHASE"] = "PURCHASE";
|
|
1245
1443
|
DocumentType2["LEGAL_CONTRACT"] = "LEGAL_CONTRACT";
|
|
1246
1444
|
DocumentType2["AUDIT_REPORT"] = "AUDIT_REPORT";
|
|
1247
1445
|
DocumentType2["SENSITIVE_IDENTITY"] = "SENSITIVE_IDENTITY";
|
|
@@ -1255,6 +1453,7 @@ var DocumentCategory = /* @__PURE__ */ ((DocumentCategory2) => {
|
|
|
1255
1453
|
DocumentCategory2["ASSETS_MAINT"] = "Assets & Maintenance";
|
|
1256
1454
|
DocumentCategory2["HR_LEGAL_SAFETY"] = "HR, Legal & Safety";
|
|
1257
1455
|
DocumentCategory2["FINANCE_ADMIN"] = "Finance & Admin";
|
|
1456
|
+
DocumentCategory2["LOGISTICS"] = "Logistics";
|
|
1258
1457
|
return DocumentCategory2;
|
|
1259
1458
|
})(DocumentCategory || {});
|
|
1260
1459
|
var DOCUMENT_DISPLAY_INFO = {
|
|
@@ -1429,6 +1628,12 @@ var DOCUMENT_DISPLAY_INFO = {
|
|
|
1429
1628
|
label: "Supplier Invoices",
|
|
1430
1629
|
description: "Billing records for inputs, utilities, and services.",
|
|
1431
1630
|
category: "Finance & Admin" /* FINANCE_ADMIN */
|
|
1631
|
+
},
|
|
1632
|
+
// --- LOGISTICS ---
|
|
1633
|
+
["PURCHASE" /* PURCHASE */]: {
|
|
1634
|
+
label: "Purchase Orders",
|
|
1635
|
+
description: "Purchase orders for goods and services.",
|
|
1636
|
+
category: "Logistics" /* LOGISTICS */
|
|
1432
1637
|
}
|
|
1433
1638
|
};
|
|
1434
1639
|
var CATEGORY_TABS = [
|
|
@@ -1466,6 +1671,7 @@ var DOCUMENT_MENU_MAP = {
|
|
|
1466
1671
|
["HARVEST_LOG" /* HARVEST_LOG */]: [RESOURCE_PATHS.farmManagement],
|
|
1467
1672
|
["PACKHOUSE_INSPECTION" /* PACKHOUSE_INSPECTION */]: [RESOURCE_PATHS.packhouse],
|
|
1468
1673
|
["INVOICE" /* INVOICE */]: [RESOURCE_PATHS.documentHub],
|
|
1674
|
+
["PURCHASE" /* PURCHASE */]: [RESOURCE_PATHS.logistics],
|
|
1469
1675
|
["LEGAL_CONTRACT" /* LEGAL_CONTRACT */]: [RESOURCE_PATHS.documentHub],
|
|
1470
1676
|
["AUDIT_REPORT" /* AUDIT_REPORT */]: [RESOURCE_PATHS.safetyAuditing, RESOURCE_PATHS.dashboard],
|
|
1471
1677
|
["SENSITIVE_IDENTITY" /* SENSITIVE_IDENTITY */]: [RESOURCE_PATHS.adminUserRoster]
|
|
@@ -1482,10 +1688,10 @@ var CORRECTIVE_ACTION_STATUSES = {
|
|
|
1482
1688
|
CLOSED: "closed",
|
|
1483
1689
|
FAILED: "failed"
|
|
1484
1690
|
};
|
|
1485
|
-
var
|
|
1486
|
-
|
|
1487
|
-
LEGAL_ENTITY: "
|
|
1488
|
-
|
|
1691
|
+
var SCOPE_LEVELS = {
|
|
1692
|
+
COMPANY: "company",
|
|
1693
|
+
LEGAL_ENTITY: "legal_entity",
|
|
1694
|
+
FACILITY: "facility"
|
|
1489
1695
|
};
|
|
1490
1696
|
var CORRECTIVE_ACTION_GENERATION_SOURCES = {
|
|
1491
1697
|
CREATE: "CREATE",
|
|
@@ -1551,6 +1757,42 @@ var StockPolicyTier = {
|
|
|
1551
1757
|
BY_STORAGE_PHASE: 2,
|
|
1552
1758
|
BY_LOCATION: 3
|
|
1553
1759
|
};
|
|
1760
|
+
var PRODUCT_TYPE_TO_BUDGET_CATEGORY = Object.freeze({
|
|
1761
|
+
carton: "packaging",
|
|
1762
|
+
tray: "packaging",
|
|
1763
|
+
liner: "packaging",
|
|
1764
|
+
label: "packaging",
|
|
1765
|
+
tape: "packaging",
|
|
1766
|
+
strapping: "packaging",
|
|
1767
|
+
pallet: "packaging",
|
|
1768
|
+
stretch_wrap: "packaging",
|
|
1769
|
+
other: "general"
|
|
1770
|
+
// fallback — reviewer must confirm at Step 3
|
|
1771
|
+
});
|
|
1772
|
+
var TERM_RESOLUTION_MODES = Object.freeze({
|
|
1773
|
+
SUPPLIER_LEVEL: "SUPPLIER_LEVEL",
|
|
1774
|
+
PRODUCT_LEVEL: "PRODUCT_LEVEL"
|
|
1775
|
+
});
|
|
1776
|
+
var REQUISITION_STATUSES = Object.freeze({
|
|
1777
|
+
DRAFT: "draft",
|
|
1778
|
+
PENDING_FINANCE: "pending_finance",
|
|
1779
|
+
APPROVED: "approved",
|
|
1780
|
+
REJECTED: "rejected",
|
|
1781
|
+
ORDERED: "ordered"
|
|
1782
|
+
});
|
|
1783
|
+
var PO_STATUSES = Object.freeze({
|
|
1784
|
+
NEW: "new",
|
|
1785
|
+
ACKNOWLEDGED: "acknowledged",
|
|
1786
|
+
IN_PROGRESS: "in_progress",
|
|
1787
|
+
SHIPPED: "shipped",
|
|
1788
|
+
RECEIVED: "received",
|
|
1789
|
+
CANCELLED: "cancelled"
|
|
1790
|
+
});
|
|
1791
|
+
var PREFLIGHT_CHECK_STATUSES = Object.freeze({
|
|
1792
|
+
OK: "ok",
|
|
1793
|
+
WARNING: "warning",
|
|
1794
|
+
BLOCKED: "blocked"
|
|
1795
|
+
});
|
|
1554
1796
|
|
|
1555
1797
|
// src/index.ts
|
|
1556
1798
|
var AppError = class extends Error {
|
|
@@ -1922,15 +2164,15 @@ var getAcceptedMimeTypes = (taskType) => {
|
|
|
1922
2164
|
var getApproveAction = (taskType) => {
|
|
1923
2165
|
return TASK_TYPE_REGISTRY[taskType]?.approveAction ?? null;
|
|
1924
2166
|
};
|
|
2167
|
+
function sanitizeSiteName(name) {
|
|
2168
|
+
return name.replace(/[^a-z0-9]/gi, "_");
|
|
2169
|
+
}
|
|
1925
2170
|
function generateDocumentPath(params) {
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
const folderCrop = params.crop ? `/${params.crop.toUpperCase()}` : "";
|
|
1932
|
-
return `${sanitizedName}/_SEASONAL/${folderYear}/${params.docType}${folderCrop}`;
|
|
1933
|
-
}
|
|
2171
|
+
const sanitized = sanitizeSiteName(params.siteName);
|
|
2172
|
+
return params.isStatic ? `${sanitized}/_CORE/${params.docType}` : `${sanitized}/_SEASONAL/${params.year || (/* @__PURE__ */ new Date()).getUTCFullYear()}/${params.docType}${params.crop ? `/${params.crop.toUpperCase()}` : ""}`;
|
|
2173
|
+
}
|
|
2174
|
+
function generateSystemFolderPath(siteName, systemFolderKey) {
|
|
2175
|
+
return `${sanitizeSiteName(siteName)}/.system/${systemFolderKey}`;
|
|
1934
2176
|
}
|
|
1935
2177
|
function isValueMatch(fileValue, expectedValue) {
|
|
1936
2178
|
if (Array.isArray(expectedValue)) return expectedValue.includes(fileValue);
|
|
@@ -2002,17 +2244,22 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2002
2244
|
NettingType,
|
|
2003
2245
|
NotificationMode,
|
|
2004
2246
|
OrderStatus,
|
|
2247
|
+
PO_STATUSES,
|
|
2248
|
+
PREFLIGHT_CHECK_STATUSES,
|
|
2249
|
+
PRODUCT_TYPE_TO_BUDGET_CATEGORY,
|
|
2005
2250
|
PhysicalState,
|
|
2006
2251
|
PlantingMethod,
|
|
2007
2252
|
PriceAmbiguityError,
|
|
2008
2253
|
ProductType,
|
|
2009
2254
|
ProductUnit,
|
|
2255
|
+
REQUISITION_STATUSES,
|
|
2010
2256
|
RESOURCE_MODULE_MAP,
|
|
2011
2257
|
RESOURCE_PATHS,
|
|
2012
2258
|
RESOURCE_REQUIREMENTS,
|
|
2013
2259
|
ROLE_SECTIONS_BY_KEY,
|
|
2014
2260
|
RelationshipType,
|
|
2015
2261
|
RowOrientation,
|
|
2262
|
+
SCOPE_LEVELS,
|
|
2016
2263
|
SENTINEL_UUID,
|
|
2017
2264
|
SESSION_SCHEMA,
|
|
2018
2265
|
SIGNATURE_MODES,
|
|
@@ -2020,7 +2267,7 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2020
2267
|
StockPolicyTier,
|
|
2021
2268
|
StoragePhases,
|
|
2022
2269
|
TASK_TYPE_REGISTRY,
|
|
2023
|
-
|
|
2270
|
+
TERM_RESOLUTION_MODES,
|
|
2024
2271
|
TargetEntityType,
|
|
2025
2272
|
TaskStatus,
|
|
2026
2273
|
TaskType,
|
|
@@ -2033,6 +2280,7 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2033
2280
|
WaterSource,
|
|
2034
2281
|
assertTenantBoundary,
|
|
2035
2282
|
calculateFileMetadataMatch,
|
|
2283
|
+
calculatePaymentDueDate,
|
|
2036
2284
|
createBase44PricingAdapter,
|
|
2037
2285
|
decodeSession,
|
|
2038
2286
|
encodeSession,
|
|
@@ -2043,6 +2291,7 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2043
2291
|
generateCanonicalId,
|
|
2044
2292
|
generateDocumentPath,
|
|
2045
2293
|
generateInfrastructureFields,
|
|
2294
|
+
generateSystemFolderPath,
|
|
2046
2295
|
getAcceptedMimeTypes,
|
|
2047
2296
|
getApproveAction,
|
|
2048
2297
|
getFormMeta,
|
|
@@ -2054,6 +2303,9 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2054
2303
|
handleAppErrorResponse,
|
|
2055
2304
|
hasPrivilegeAt,
|
|
2056
2305
|
hasRoleAt,
|
|
2306
|
+
isDueDatePending,
|
|
2307
|
+
isInstallmentSchedule,
|
|
2308
|
+
isSingleDueDate,
|
|
2057
2309
|
isTabVisible,
|
|
2058
2310
|
isTabWritable,
|
|
2059
2311
|
resolveAccess,
|
|
@@ -2061,6 +2313,7 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
2061
2313
|
resolveEffectiveAccess,
|
|
2062
2314
|
resolveError,
|
|
2063
2315
|
resolvePrice,
|
|
2316
|
+
sanitizeSiteName,
|
|
2064
2317
|
transformRoleAssignments,
|
|
2065
2318
|
verifyAndExtractSession,
|
|
2066
2319
|
withAgriLogging
|