@litusarchieve18/agricore-utils 1.0.30 → 1.0.31

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 CHANGED
@@ -183,6 +183,8 @@ Run the publish command:
183
183
  Bash
184
184
  npm publish --access public
185
185
  📝 Version History
186
+ V1.0.31 — Added Receival menu path, moving some procurement enum to library, and added a functional calculatePaymentDueDate function
187
+
186
188
  V1.0.30 — altered authscoped Id to receive a list of string not a single string
187
189
 
188
190
  V1.0.29 — altered filtering logic from validFrom_lte: targetIso to validFrom: { $lte: targetIso }
@@ -381,6 +381,12 @@ var RESOURCE_PATHS = {
381
381
  farmManagement: "operations.farmManagement",
382
382
  packhouse: "operations.packhouse",
383
383
  accommodation: "operations.accommodation",
384
+ logistics: "operations.logistics",
385
+ logisticsReceival: "operations.logistics.receival",
386
+ logisticsReceivalReview: "operations.logistics.receival.review",
387
+ // being reviewed by manager/owner
388
+ logisticsDispatch: "operations.logistics.dispatch",
389
+ logisticsDispatchReview: "operations.logistics.dispatch.review",
384
390
  // ── Inventory ────────────────────────────────────────────────────────────
385
391
  // === Consumables ===
386
392
  inventory: "inventory",
@@ -416,6 +422,7 @@ var RESOURCE_PATHS = {
416
422
  equipFuelRegister: "equipment.fuelRegister",
417
423
  equipCalibration: "equipment.calibration",
418
424
  equipFleet: "equipment.fleetManagement",
425
+ // ── Finance ──────────────────────────────────────────────────────
419
426
  finance: "finance",
420
427
  financeProductRequisition: "finance.product.requistion",
421
428
  financeDashboard: "finance.dashboard",
@@ -479,12 +486,23 @@ var RESOURCE_MODULE_MAP = {
479
486
  [RESOURCE_PATHS.farmManagement]: [EnabledModule.FARM_MANAGEMENT],
480
487
  [RESOURCE_PATHS.packhouse]: [EnabledModule.PACKHOUSE],
481
488
  [RESOURCE_PATHS.accommodation]: [EnabledModule.ACCOMMODATION],
489
+ // ── Logistics ──────────────────────────────────────────────────────────────
490
+ [RESOURCE_PATHS.logistics]: ALL_OPERATIONS,
491
+ [RESOURCE_PATHS.logisticsReceival]: ALL_OPERATIONS,
492
+ [RESOURCE_PATHS.logisticsReceivalReview]: ALL_OPERATIONS,
493
+ [RESOURCE_PATHS.logisticsDispatch]: ALL_OPERATIONS,
494
+ [RESOURCE_PATHS.logisticsDispatchReview]: ALL_OPERATIONS,
482
495
  // ── Equipment & Fleet ──────────────────────────────────────────────────────
483
496
  [RESOURCE_PATHS.equipPreStart]: ALL_OPERATIONS,
484
497
  [RESOURCE_PATHS.equipMaintenance]: ALL_OPERATIONS,
485
498
  [RESOURCE_PATHS.equipFuelRegister]: ALL_OPERATIONS,
486
499
  [RESOURCE_PATHS.equipCalibration]: AGRI_ONLY,
487
500
  [RESOURCE_PATHS.equipFleet]: ALL_OPERATIONS,
501
+ // ── Finance ──────────────────────────────────────────────────────────────
502
+ [RESOURCE_PATHS.financeProductRequisition]: ALL_OPERATIONS,
503
+ [RESOURCE_PATHS.financeDashboard]: ALL_OPERATIONS,
504
+ [RESOURCE_PATHS.financeTransaction]: ALL_OPERATIONS,
505
+ [RESOURCE_PATHS.financeBudgetAllocation]: ALL_OPERATIONS,
488
506
  // ── Safety, Quality & Compliance ──────────────────────────────────────────
489
507
  [RESOURCE_PATHS.safetyAuditing]: ALL_OPERATIONS,
490
508
  [RESOURCE_PATHS.safetyFood]: AGRI_ONLY,
@@ -533,6 +551,15 @@ var RESOURCE_REQUIREMENTS = {
533
551
  allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR],
534
552
  requiredPrivileges: [UserPrivilege.ADMIN, UserPrivilege.AUDIT_COMPLIANCE, UserPrivilege.FINANCE, UserPrivilege.DOCUMENT]
535
553
  },
554
+ // ── Logistics ──────────────────────────────────────────────────────────────
555
+ [RESOURCE_PATHS.logisticsReceival]: {
556
+ allowedRoles: EVERYONE
557
+ },
558
+ [RESOURCE_PATHS.logisticsReceivalReview]: {
559
+ allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
560
+ },
561
+ [RESOURCE_PATHS.logisticsDispatch]: { allowedRoles: EVERYONE },
562
+ [RESOURCE_PATHS.logisticsDispatchReview]: { allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR] },
536
563
  // CONSUMABLES PERMISSIONS
537
564
  [RESOURCE_PATHS.inventoryConsumableProduct]: {
538
565
  allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
@@ -647,6 +674,7 @@ var DocumentType = /* @__PURE__ */ ((DocumentType2) => {
647
674
  DocumentType2["PACKHOUSE_INSPECTION"] = "PACKHOUSE_INSPECTION";
648
675
  DocumentType2["TRAINING_CERTIFICATE"] = "TRAINING_CERTIFICATE";
649
676
  DocumentType2["INVOICE"] = "INVOICE";
677
+ DocumentType2["PURCHASE"] = "PURCHASE";
650
678
  DocumentType2["LEGAL_CONTRACT"] = "LEGAL_CONTRACT";
651
679
  DocumentType2["AUDIT_REPORT"] = "AUDIT_REPORT";
652
680
  DocumentType2["SENSITIVE_IDENTITY"] = "SENSITIVE_IDENTITY";
@@ -660,6 +688,7 @@ var DocumentCategory = /* @__PURE__ */ ((DocumentCategory2) => {
660
688
  DocumentCategory2["ASSETS_MAINT"] = "Assets & Maintenance";
661
689
  DocumentCategory2["HR_LEGAL_SAFETY"] = "HR, Legal & Safety";
662
690
  DocumentCategory2["FINANCE_ADMIN"] = "Finance & Admin";
691
+ DocumentCategory2["LOGISTICS"] = "Logistics";
663
692
  return DocumentCategory2;
664
693
  })(DocumentCategory || {});
665
694
  var DOCUMENT_DISPLAY_INFO = {
@@ -834,6 +863,12 @@ var DOCUMENT_DISPLAY_INFO = {
834
863
  label: "Supplier Invoices",
835
864
  description: "Billing records for inputs, utilities, and services.",
836
865
  category: "Finance & Admin" /* FINANCE_ADMIN */
866
+ },
867
+ // --- LOGISTICS ---
868
+ ["PURCHASE" /* PURCHASE */]: {
869
+ label: "Purchase Orders",
870
+ description: "Purchase orders for goods and services.",
871
+ category: "Logistics" /* LOGISTICS */
837
872
  }
838
873
  };
839
874
  var CATEGORY_TABS = [
@@ -871,6 +906,7 @@ var DOCUMENT_MENU_MAP = {
871
906
  ["HARVEST_LOG" /* HARVEST_LOG */]: [RESOURCE_PATHS.farmManagement],
872
907
  ["PACKHOUSE_INSPECTION" /* PACKHOUSE_INSPECTION */]: [RESOURCE_PATHS.packhouse],
873
908
  ["INVOICE" /* INVOICE */]: [RESOURCE_PATHS.documentHub],
909
+ ["PURCHASE" /* PURCHASE */]: [RESOURCE_PATHS.logistics],
874
910
  ["LEGAL_CONTRACT" /* LEGAL_CONTRACT */]: [RESOURCE_PATHS.documentHub],
875
911
  ["AUDIT_REPORT" /* AUDIT_REPORT */]: [RESOURCE_PATHS.safetyAuditing, RESOURCE_PATHS.dashboard],
876
912
  ["SENSITIVE_IDENTITY" /* SENSITIVE_IDENTITY */]: [RESOURCE_PATHS.adminUserRoster]
@@ -887,10 +923,10 @@ var CORRECTIVE_ACTION_STATUSES = {
887
923
  CLOSED: "closed",
888
924
  FAILED: "failed"
889
925
  };
890
- var TEMPLATE_SCOPE_LEVELS = {
891
- FACILITY: "facility",
892
- LEGAL_ENTITY: "legalEntity",
893
- COMPANY: "company"
926
+ var SCOPE_LEVELS = {
927
+ COMPANY: "company",
928
+ LEGAL_ENTITY: "legal_entity",
929
+ FACILITY: "facility"
894
930
  };
895
931
  var CORRECTIVE_ACTION_GENERATION_SOURCES = {
896
932
  CREATE: "CREATE",
@@ -956,6 +992,42 @@ var StockPolicyTier = {
956
992
  BY_STORAGE_PHASE: 2,
957
993
  BY_LOCATION: 3
958
994
  };
995
+ var PRODUCT_TYPE_TO_BUDGET_CATEGORY = Object.freeze({
996
+ carton: "packaging",
997
+ tray: "packaging",
998
+ liner: "packaging",
999
+ label: "packaging",
1000
+ tape: "packaging",
1001
+ strapping: "packaging",
1002
+ pallet: "packaging",
1003
+ stretch_wrap: "packaging",
1004
+ other: "general"
1005
+ // fallback — reviewer must confirm at Step 3
1006
+ });
1007
+ var TERM_RESOLUTION_MODES = Object.freeze({
1008
+ SUPPLIER_LEVEL: "SUPPLIER_LEVEL",
1009
+ PRODUCT_LEVEL: "PRODUCT_LEVEL"
1010
+ });
1011
+ var REQUISITION_STATUSES = Object.freeze({
1012
+ DRAFT: "draft",
1013
+ PENDING_FINANCE: "pending_finance",
1014
+ APPROVED: "approved",
1015
+ REJECTED: "rejected",
1016
+ ORDERED: "ordered"
1017
+ });
1018
+ var PO_STATUSES = Object.freeze({
1019
+ NEW: "new",
1020
+ ACKNOWLEDGED: "acknowledged",
1021
+ IN_PROGRESS: "in_progress",
1022
+ SHIPPED: "shipped",
1023
+ RECEIVED: "received",
1024
+ CANCELLED: "cancelled"
1025
+ });
1026
+ var PREFLIGHT_CHECK_STATUSES = Object.freeze({
1027
+ OK: "ok",
1028
+ WARNING: "warning",
1029
+ BLOCKED: "blocked"
1030
+ });
959
1031
 
960
1032
  export {
961
1033
  MOD,
@@ -1010,7 +1082,7 @@ export {
1010
1082
  DOCUMENT_MENU_MAP,
1011
1083
  SIGNATURE_MODES,
1012
1084
  CORRECTIVE_ACTION_STATUSES,
1013
- TEMPLATE_SCOPE_LEVELS,
1085
+ SCOPE_LEVELS,
1014
1086
  CORRECTIVE_ACTION_GENERATION_SOURCES,
1015
1087
  CAR_SUPPORTED_EVIDENCE_MIME_TYPES,
1016
1088
  CAR_SUPPORTED_SIGNATURE_MIME_TYPES,
@@ -138,7 +138,7 @@ type CanonicalId = string;
138
138
  type SignatureMode = typeof SIGNATURE_MODES[keyof typeof SIGNATURE_MODES];
139
139
  type CorrectiveActionStatus = typeof CORRECTIVE_ACTION_STATUSES[keyof typeof CORRECTIVE_ACTION_STATUSES];
140
140
  type FileUploadTaskType = typeof TaskType[keyof typeof TaskType];
141
- type TemplateScopeLevel = typeof TEMPLATE_SCOPE_LEVELS[keyof typeof TEMPLATE_SCOPE_LEVELS];
141
+ type TemplateScopeLevel = typeof SCOPE_LEVELS[keyof typeof SCOPE_LEVELS];
142
142
  type CorrectiveActionGenerationSource = typeof CORRECTIVE_ACTION_GENERATION_SOURCES[keyof typeof CORRECTIVE_ACTION_GENERATION_SOURCES];
143
143
  type CarSupportedEvidenceMimeType = typeof CAR_SUPPORTED_EVIDENCE_MIME_TYPES[number];
144
144
  type CarSupportedSignatureMimeType = typeof CAR_SUPPORTED_SIGNATURE_MIME_TYPES[number];
@@ -266,6 +266,86 @@ interface ShadowedCleanMatch {
266
266
  contractReferenceNumber?: string;
267
267
  };
268
268
  }
269
+ type PaymentTerm = "cashOnDelivery" | "supplierTradeCredit" | "prePaymentProgram" | "forwardOrderingContract" | "thirdPartyInputFinance";
270
+ /**
271
+ * NET n -> transactionDate + n days
272
+ * EOM -> last day of the month AFTER the transaction month
273
+ * EOM n -> the n-th day of the month AFTER the transaction month
274
+ *
275
+ * Examples (transactionDate = 13 Jul):
276
+ * { type: "NET", days: 7 } -> 20 Jul
277
+ * { type: "EOM" } -> 31 Aug
278
+ * { type: "EOM", days: 14 } -> 14 Aug
279
+ */
280
+ type CreditDaysWindow = {
281
+ type: "NET";
282
+ days: number;
283
+ } | {
284
+ type: "EOM";
285
+ days?: number;
286
+ };
287
+ /**
288
+ * FIXED_DATE -> contract specifies one exact calendar due date.
289
+ * FIXED_DAY -> recurring monthly on a fixed day-of-month, relative to
290
+ * `triggerDate` (defaults to transactionDate if omitted).
291
+ * ASSUMPTION: if triggerDate's day-of-month <= dayOfMonth,
292
+ * the due date falls in the SAME month (same-day counts
293
+ * as due). Otherwise it rolls to next month. Flip this in
294
+ * calculateForwardOrderingContractDueDate() if the
295
+ * business rule is actually "always roll forward".
296
+ * END_OF_MONTH -> due date = last day of triggerDate's month, optionally
297
+ * shifted by offsetDays (e.g. "EOM + 5 days").
298
+ * DELIVERY_BASED -> due date = triggerDate (e.g. actual delivery date) +
299
+ * offsetDays.
300
+ */
301
+ type ForwardOrderingContractWindow = {
302
+ frequencyType: "FIXED_DATE";
303
+ dueDate: Date;
304
+ } | {
305
+ frequencyType: "FIXED_DAY";
306
+ dayOfMonth: number;
307
+ triggerDate?: Date;
308
+ } | {
309
+ frequencyType: "END_OF_MONTH";
310
+ triggerDate?: Date;
311
+ offsetDays?: number;
312
+ } | {
313
+ frequencyType: "DELIVERY_BASED";
314
+ triggerDate: Date;
315
+ offsetDays: number;
316
+ };
317
+ /**
318
+ * Generates `numberOfInstallments` due dates, spaced every `periodInterval`
319
+ * periods (days or months) starting from `startDate` (defaults to
320
+ * transactionDate).
321
+ *
322
+ * ASSUMPTION: installment #1 falls ONE period after the start date (not on
323
+ * the start date itself). e.g. periodType "MONTHS", periodInterval 1,
324
+ * dayOfMonth 15, numberOfInstallments 3, starting 13 Jul ->
325
+ * [15 Aug, 15 Sep, 15 Oct]
326
+ *
327
+ * `dayOfMonth` is required when periodType is "MONTHS" (pins each
328
+ * installment to a specific day, e.g. "every 1 month on the 15th").
329
+ */
330
+ type InstallmentWindow = {
331
+ numberOfInstallments: number;
332
+ periodType: "DAYS" | "MONTHS";
333
+ periodInterval: number;
334
+ dayOfMonth?: number;
335
+ startDate?: Date;
336
+ };
337
+ interface CalculatePaymentDueDateInput {
338
+ transactionDate: Date;
339
+ paymentTerm: PaymentTerm;
340
+ /** Required when paymentTerm === "supplierTradeCredit" */
341
+ creditDaysWindow?: CreditDaysWindow;
342
+ /** Required when paymentTerm === "cashOnDelivery" (due date = delivery date) */
343
+ deliveryDate?: Date;
344
+ /** Required when paymentTerm === "forwardOrderingContract" */
345
+ forwardOrderingContractWindow?: ForwardOrderingContractWindow;
346
+ /** Required when paymentTerm === "thirdPartyInputFinance" */
347
+ installmentWindow?: InstallmentWindow;
348
+ }
269
349
 
270
350
  declare const MOD: {
271
351
  readonly OPERATIONS: "OPR";
@@ -543,6 +623,11 @@ declare const RESOURCE_PATHS: {
543
623
  farmManagement: string;
544
624
  packhouse: string;
545
625
  accommodation: string;
626
+ logistics: string;
627
+ logisticsReceival: string;
628
+ logisticsReceivalReview: string;
629
+ logisticsDispatch: string;
630
+ logisticsDispatchReview: string;
546
631
  inventory: string;
547
632
  inventoryConsumable: string;
548
633
  inventoryConsumableProduct: string;
@@ -622,6 +707,7 @@ declare enum DocumentType {
622
707
  PACKHOUSE_INSPECTION = "PACKHOUSE_INSPECTION",
623
708
  TRAINING_CERTIFICATE = "TRAINING_CERTIFICATE",
624
709
  INVOICE = "INVOICE",
710
+ PURCHASE = "PURCHASE",
625
711
  LEGAL_CONTRACT = "LEGAL_CONTRACT",
626
712
  AUDIT_REPORT = "AUDIT_REPORT",
627
713
  SENSITIVE_IDENTITY = "SENSITIVE_IDENTITY"
@@ -633,7 +719,8 @@ declare enum DocumentCategory {
633
719
  INVENTORY_LOG = "Inventory & Logistics",
634
720
  ASSETS_MAINT = "Assets & Maintenance",
635
721
  HR_LEGAL_SAFETY = "HR, Legal & Safety",
636
- FINANCE_ADMIN = "Finance & Admin"
722
+ FINANCE_ADMIN = "Finance & Admin",
723
+ LOGISTICS = "Logistics"
637
724
  }
638
725
  declare const DOCUMENT_DISPLAY_INFO: Record<DocumentType, {
639
726
  label: string;
@@ -670,10 +757,10 @@ declare const CORRECTIVE_ACTION_STATUSES: {
670
757
  * Scope level used when resolving templates from OperationalSettings.
671
758
  * Resolution precedence is facility -> legalEntity -> company.
672
759
  */
673
- declare const TEMPLATE_SCOPE_LEVELS: {
674
- readonly FACILITY: "facility";
675
- readonly LEGAL_ENTITY: "legalEntity";
760
+ declare const SCOPE_LEVELS: {
676
761
  readonly COMPANY: "company";
762
+ readonly LEGAL_ENTITY: "legal_entity";
763
+ readonly FACILITY: "facility";
677
764
  };
678
765
  /**
679
766
  * Generation source for CAR creation.
@@ -746,4 +833,4 @@ declare const StockPolicyTier: {
746
833
  readonly BY_LOCATION: 3;
747
834
  };
748
835
 
749
- export { MimeType as $, ACCESS_RANK as A, BarcodeNamespace as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, type CompanyConfig as D, type CorrectiveActionCompileTaskMetadata as E, type CorrectiveActionGenerationSource as F, type CorrectiveActionStatus as G, CropCycleStatus as H, DOCUMENT_DISPLAY_INFO as I, DOCUMENT_MENU_MAP as J, DocumentCategory as K, DocumentType as L, ERROR_DICTIONARY as M, EVERYONE as N, EmitterType as O, EnabledModule as P, FORM_REGISTRY as Q, FacilityType as R, type FileUploadTaskType as S, type FormMeta as T, HarvestMethod as U, type InfrastructureFields as V, LinkedStatus as W, MOD as X, MODULE_LABELS as Y, type MatrixRow as Z, MicroclimateZone as _, ACT as a, type ModCode as a0, NettingType as a1, type NormalizedSignatureValue as a2, NotificationMode as a3, OrderStatus as a4, type PermissionLevel as a5, PhysicalState as a6, PlantingMethod as a7, type PriceConflictCandidate as a8, type PriceResolutionResult as a9, type StockPolicyTierType as aA, StoragePhases as aB, type StorageType as aC, TASK_TYPE_REGISTRY as aD, TEMPLATE_SCOPE_LEVELS as aE, type TabConfig as aF, TargetEntityType as aG, TaskStatus as aH, TaskType as aI, type TaskTypeConfig as aJ, type TemplateScopeLevel as aK, type Tier as aL, TransactionType as aM, TrellisType as aN, UserPrivilege as aO, type UserPrivilegeType as aP, UserRole as aQ, type UserRoleAssignment as aR, type UserRoleType as aS, VigorRating as aT, WaterSource as aU, type WireSession as aV, type PricingContext as aa, type PricingDataSource as ab, ProductType as ac, type ProductTypeType as ad, ProductUnit as ae, type ProductUnitType as af, RESOURCE_MODULE_MAP as ag, RESOURCE_PATHS as ah, RESOURCE_REQUIREMENTS as ai, ROLE_SECTIONS_BY_KEY as aj, RelationshipType as ak, type ResolvedError as al, type ResourceOverrides as am, type ResourceRequirement as an, type RoleAssignment as ao, RowOrientation as ap, SENTINEL_UUID as aq, SESSION_SCHEMA as ar, SIGNATURE_MODES as as, type SchemaField as at, type ScopeType as au, type ShadowedCleanMatch as av, type SignatureInput as aw, type SignatureMode as ax, SoilTexture as ay, StockPolicyTier as az, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type BarcodeNamespaceType as k, BarcodeType as l, type BarcodeTypeType as m, type Base44Id as n, type BaseProductRow as o, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as p, CAT as q, CATEGORY_TABS as r, CORRECTIVE_ACTION_GENERATION_SOURCES as s, CORRECTIVE_ACTION_STATUSES as t, type CanonicalId as u, type CarSupportedEvidenceMimeType as v, type CarSupportedSignatureMimeType as w, type CarTemplateFileMetadata as x, CatalogSyncStatus as y, type CatalogSyncStatusType as z };
836
+ export { MOD as $, ACCESS_RANK as A, BarcodeNamespace as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, type CatalogSyncStatusType as D, type CompanyConfig as E, type CorrectiveActionCompileTaskMetadata as F, type CorrectiveActionGenerationSource as G, type CorrectiveActionStatus as H, type CreditDaysWindow as I, CropCycleStatus as J, DOCUMENT_DISPLAY_INFO as K, DOCUMENT_MENU_MAP as L, DocumentCategory as M, DocumentType as N, ERROR_DICTIONARY as O, EVERYONE as P, EmitterType as Q, EnabledModule as R, FORM_REGISTRY as S, FacilityType as T, type FileUploadTaskType as U, type FormMeta as V, type ForwardOrderingContractWindow as W, HarvestMethod as X, type InfrastructureFields as Y, type InstallmentWindow as Z, LinkedStatus as _, ACT as a, MODULE_LABELS as a0, type MatrixRow as a1, MicroclimateZone as a2, MimeType as a3, type ModCode as a4, NettingType as a5, type NormalizedSignatureValue as a6, NotificationMode as a7, OrderStatus as a8, type PaymentTerm as a9, type ScopeType as aA, type ShadowedCleanMatch as aB, type SignatureInput as aC, type SignatureMode as aD, SoilTexture as aE, StockPolicyTier as aF, type StockPolicyTierType as aG, StoragePhases as aH, type StorageType as aI, TASK_TYPE_REGISTRY as aJ, type TabConfig as aK, TargetEntityType as aL, TaskStatus as aM, TaskType as aN, type TaskTypeConfig as aO, type TemplateScopeLevel as aP, type Tier as aQ, TransactionType as aR, TrellisType as aS, UserPrivilege as aT, type UserPrivilegeType as aU, UserRole as aV, type UserRoleAssignment as aW, type UserRoleType as aX, VigorRating as aY, WaterSource as aZ, type WireSession as a_, type PermissionLevel as aa, PhysicalState as ab, PlantingMethod as ac, type PriceConflictCandidate as ad, type PriceResolutionResult as ae, type PricingContext as af, type PricingDataSource as ag, ProductType as ah, type ProductTypeType as ai, ProductUnit as aj, type ProductUnitType as ak, RESOURCE_MODULE_MAP as al, RESOURCE_PATHS as am, RESOURCE_REQUIREMENTS as an, ROLE_SECTIONS_BY_KEY as ao, RelationshipType as ap, type ResolvedError as aq, type ResourceOverrides as ar, type ResourceRequirement as as, type RoleAssignment as at, RowOrientation as au, SCOPE_LEVELS as av, SENTINEL_UUID as aw, SESSION_SCHEMA as ax, SIGNATURE_MODES as ay, type SchemaField as az, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type BarcodeNamespaceType as k, BarcodeType as l, type BarcodeTypeType as m, type Base44Id as n, type BaseProductRow as o, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as p, CAT as q, CATEGORY_TABS as r, CORRECTIVE_ACTION_GENERATION_SOURCES as s, CORRECTIVE_ACTION_STATUSES as t, type CalculatePaymentDueDateInput as u, type CanonicalId as v, type CarSupportedEvidenceMimeType as w, type CarSupportedSignatureMimeType as x, type CarTemplateFileMetadata as y, CatalogSyncStatus as z };
@@ -138,7 +138,7 @@ type CanonicalId = string;
138
138
  type SignatureMode = typeof SIGNATURE_MODES[keyof typeof SIGNATURE_MODES];
139
139
  type CorrectiveActionStatus = typeof CORRECTIVE_ACTION_STATUSES[keyof typeof CORRECTIVE_ACTION_STATUSES];
140
140
  type FileUploadTaskType = typeof TaskType[keyof typeof TaskType];
141
- type TemplateScopeLevel = typeof TEMPLATE_SCOPE_LEVELS[keyof typeof TEMPLATE_SCOPE_LEVELS];
141
+ type TemplateScopeLevel = typeof SCOPE_LEVELS[keyof typeof SCOPE_LEVELS];
142
142
  type CorrectiveActionGenerationSource = typeof CORRECTIVE_ACTION_GENERATION_SOURCES[keyof typeof CORRECTIVE_ACTION_GENERATION_SOURCES];
143
143
  type CarSupportedEvidenceMimeType = typeof CAR_SUPPORTED_EVIDENCE_MIME_TYPES[number];
144
144
  type CarSupportedSignatureMimeType = typeof CAR_SUPPORTED_SIGNATURE_MIME_TYPES[number];
@@ -266,6 +266,86 @@ interface ShadowedCleanMatch {
266
266
  contractReferenceNumber?: string;
267
267
  };
268
268
  }
269
+ type PaymentTerm = "cashOnDelivery" | "supplierTradeCredit" | "prePaymentProgram" | "forwardOrderingContract" | "thirdPartyInputFinance";
270
+ /**
271
+ * NET n -> transactionDate + n days
272
+ * EOM -> last day of the month AFTER the transaction month
273
+ * EOM n -> the n-th day of the month AFTER the transaction month
274
+ *
275
+ * Examples (transactionDate = 13 Jul):
276
+ * { type: "NET", days: 7 } -> 20 Jul
277
+ * { type: "EOM" } -> 31 Aug
278
+ * { type: "EOM", days: 14 } -> 14 Aug
279
+ */
280
+ type CreditDaysWindow = {
281
+ type: "NET";
282
+ days: number;
283
+ } | {
284
+ type: "EOM";
285
+ days?: number;
286
+ };
287
+ /**
288
+ * FIXED_DATE -> contract specifies one exact calendar due date.
289
+ * FIXED_DAY -> recurring monthly on a fixed day-of-month, relative to
290
+ * `triggerDate` (defaults to transactionDate if omitted).
291
+ * ASSUMPTION: if triggerDate's day-of-month <= dayOfMonth,
292
+ * the due date falls in the SAME month (same-day counts
293
+ * as due). Otherwise it rolls to next month. Flip this in
294
+ * calculateForwardOrderingContractDueDate() if the
295
+ * business rule is actually "always roll forward".
296
+ * END_OF_MONTH -> due date = last day of triggerDate's month, optionally
297
+ * shifted by offsetDays (e.g. "EOM + 5 days").
298
+ * DELIVERY_BASED -> due date = triggerDate (e.g. actual delivery date) +
299
+ * offsetDays.
300
+ */
301
+ type ForwardOrderingContractWindow = {
302
+ frequencyType: "FIXED_DATE";
303
+ dueDate: Date;
304
+ } | {
305
+ frequencyType: "FIXED_DAY";
306
+ dayOfMonth: number;
307
+ triggerDate?: Date;
308
+ } | {
309
+ frequencyType: "END_OF_MONTH";
310
+ triggerDate?: Date;
311
+ offsetDays?: number;
312
+ } | {
313
+ frequencyType: "DELIVERY_BASED";
314
+ triggerDate: Date;
315
+ offsetDays: number;
316
+ };
317
+ /**
318
+ * Generates `numberOfInstallments` due dates, spaced every `periodInterval`
319
+ * periods (days or months) starting from `startDate` (defaults to
320
+ * transactionDate).
321
+ *
322
+ * ASSUMPTION: installment #1 falls ONE period after the start date (not on
323
+ * the start date itself). e.g. periodType "MONTHS", periodInterval 1,
324
+ * dayOfMonth 15, numberOfInstallments 3, starting 13 Jul ->
325
+ * [15 Aug, 15 Sep, 15 Oct]
326
+ *
327
+ * `dayOfMonth` is required when periodType is "MONTHS" (pins each
328
+ * installment to a specific day, e.g. "every 1 month on the 15th").
329
+ */
330
+ type InstallmentWindow = {
331
+ numberOfInstallments: number;
332
+ periodType: "DAYS" | "MONTHS";
333
+ periodInterval: number;
334
+ dayOfMonth?: number;
335
+ startDate?: Date;
336
+ };
337
+ interface CalculatePaymentDueDateInput {
338
+ transactionDate: Date;
339
+ paymentTerm: PaymentTerm;
340
+ /** Required when paymentTerm === "supplierTradeCredit" */
341
+ creditDaysWindow?: CreditDaysWindow;
342
+ /** Required when paymentTerm === "cashOnDelivery" (due date = delivery date) */
343
+ deliveryDate?: Date;
344
+ /** Required when paymentTerm === "forwardOrderingContract" */
345
+ forwardOrderingContractWindow?: ForwardOrderingContractWindow;
346
+ /** Required when paymentTerm === "thirdPartyInputFinance" */
347
+ installmentWindow?: InstallmentWindow;
348
+ }
269
349
 
270
350
  declare const MOD: {
271
351
  readonly OPERATIONS: "OPR";
@@ -543,6 +623,11 @@ declare const RESOURCE_PATHS: {
543
623
  farmManagement: string;
544
624
  packhouse: string;
545
625
  accommodation: string;
626
+ logistics: string;
627
+ logisticsReceival: string;
628
+ logisticsReceivalReview: string;
629
+ logisticsDispatch: string;
630
+ logisticsDispatchReview: string;
546
631
  inventory: string;
547
632
  inventoryConsumable: string;
548
633
  inventoryConsumableProduct: string;
@@ -622,6 +707,7 @@ declare enum DocumentType {
622
707
  PACKHOUSE_INSPECTION = "PACKHOUSE_INSPECTION",
623
708
  TRAINING_CERTIFICATE = "TRAINING_CERTIFICATE",
624
709
  INVOICE = "INVOICE",
710
+ PURCHASE = "PURCHASE",
625
711
  LEGAL_CONTRACT = "LEGAL_CONTRACT",
626
712
  AUDIT_REPORT = "AUDIT_REPORT",
627
713
  SENSITIVE_IDENTITY = "SENSITIVE_IDENTITY"
@@ -633,7 +719,8 @@ declare enum DocumentCategory {
633
719
  INVENTORY_LOG = "Inventory & Logistics",
634
720
  ASSETS_MAINT = "Assets & Maintenance",
635
721
  HR_LEGAL_SAFETY = "HR, Legal & Safety",
636
- FINANCE_ADMIN = "Finance & Admin"
722
+ FINANCE_ADMIN = "Finance & Admin",
723
+ LOGISTICS = "Logistics"
637
724
  }
638
725
  declare const DOCUMENT_DISPLAY_INFO: Record<DocumentType, {
639
726
  label: string;
@@ -670,10 +757,10 @@ declare const CORRECTIVE_ACTION_STATUSES: {
670
757
  * Scope level used when resolving templates from OperationalSettings.
671
758
  * Resolution precedence is facility -> legalEntity -> company.
672
759
  */
673
- declare const TEMPLATE_SCOPE_LEVELS: {
674
- readonly FACILITY: "facility";
675
- readonly LEGAL_ENTITY: "legalEntity";
760
+ declare const SCOPE_LEVELS: {
676
761
  readonly COMPANY: "company";
762
+ readonly LEGAL_ENTITY: "legal_entity";
763
+ readonly FACILITY: "facility";
677
764
  };
678
765
  /**
679
766
  * Generation source for CAR creation.
@@ -746,4 +833,4 @@ declare const StockPolicyTier: {
746
833
  readonly BY_LOCATION: 3;
747
834
  };
748
835
 
749
- export { MimeType as $, ACCESS_RANK as A, BarcodeNamespace as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, type CompanyConfig as D, type CorrectiveActionCompileTaskMetadata as E, type CorrectiveActionGenerationSource as F, type CorrectiveActionStatus as G, CropCycleStatus as H, DOCUMENT_DISPLAY_INFO as I, DOCUMENT_MENU_MAP as J, DocumentCategory as K, DocumentType as L, ERROR_DICTIONARY as M, EVERYONE as N, EmitterType as O, EnabledModule as P, FORM_REGISTRY as Q, FacilityType as R, type FileUploadTaskType as S, type FormMeta as T, HarvestMethod as U, type InfrastructureFields as V, LinkedStatus as W, MOD as X, MODULE_LABELS as Y, type MatrixRow as Z, MicroclimateZone as _, ACT as a, type ModCode as a0, NettingType as a1, type NormalizedSignatureValue as a2, NotificationMode as a3, OrderStatus as a4, type PermissionLevel as a5, PhysicalState as a6, PlantingMethod as a7, type PriceConflictCandidate as a8, type PriceResolutionResult as a9, type StockPolicyTierType as aA, StoragePhases as aB, type StorageType as aC, TASK_TYPE_REGISTRY as aD, TEMPLATE_SCOPE_LEVELS as aE, type TabConfig as aF, TargetEntityType as aG, TaskStatus as aH, TaskType as aI, type TaskTypeConfig as aJ, type TemplateScopeLevel as aK, type Tier as aL, TransactionType as aM, TrellisType as aN, UserPrivilege as aO, type UserPrivilegeType as aP, UserRole as aQ, type UserRoleAssignment as aR, type UserRoleType as aS, VigorRating as aT, WaterSource as aU, type WireSession as aV, type PricingContext as aa, type PricingDataSource as ab, ProductType as ac, type ProductTypeType as ad, ProductUnit as ae, type ProductUnitType as af, RESOURCE_MODULE_MAP as ag, RESOURCE_PATHS as ah, RESOURCE_REQUIREMENTS as ai, ROLE_SECTIONS_BY_KEY as aj, RelationshipType as ak, type ResolvedError as al, type ResourceOverrides as am, type ResourceRequirement as an, type RoleAssignment as ao, RowOrientation as ap, SENTINEL_UUID as aq, SESSION_SCHEMA as ar, SIGNATURE_MODES as as, type SchemaField as at, type ScopeType as au, type ShadowedCleanMatch as av, type SignatureInput as aw, type SignatureMode as ax, SoilTexture as ay, StockPolicyTier as az, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type BarcodeNamespaceType as k, BarcodeType as l, type BarcodeTypeType as m, type Base44Id as n, type BaseProductRow as o, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as p, CAT as q, CATEGORY_TABS as r, CORRECTIVE_ACTION_GENERATION_SOURCES as s, CORRECTIVE_ACTION_STATUSES as t, type CanonicalId as u, type CarSupportedEvidenceMimeType as v, type CarSupportedSignatureMimeType as w, type CarTemplateFileMetadata as x, CatalogSyncStatus as y, type CatalogSyncStatusType as z };
836
+ export { MOD as $, ACCESS_RANK as A, BarcodeNamespace as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, type CatalogSyncStatusType as D, type CompanyConfig as E, type CorrectiveActionCompileTaskMetadata as F, type CorrectiveActionGenerationSource as G, type CorrectiveActionStatus as H, type CreditDaysWindow as I, CropCycleStatus as J, DOCUMENT_DISPLAY_INFO as K, DOCUMENT_MENU_MAP as L, DocumentCategory as M, DocumentType as N, ERROR_DICTIONARY as O, EVERYONE as P, EmitterType as Q, EnabledModule as R, FORM_REGISTRY as S, FacilityType as T, type FileUploadTaskType as U, type FormMeta as V, type ForwardOrderingContractWindow as W, HarvestMethod as X, type InfrastructureFields as Y, type InstallmentWindow as Z, LinkedStatus as _, ACT as a, MODULE_LABELS as a0, type MatrixRow as a1, MicroclimateZone as a2, MimeType as a3, type ModCode as a4, NettingType as a5, type NormalizedSignatureValue as a6, NotificationMode as a7, OrderStatus as a8, type PaymentTerm as a9, type ScopeType as aA, type ShadowedCleanMatch as aB, type SignatureInput as aC, type SignatureMode as aD, SoilTexture as aE, StockPolicyTier as aF, type StockPolicyTierType as aG, StoragePhases as aH, type StorageType as aI, TASK_TYPE_REGISTRY as aJ, type TabConfig as aK, TargetEntityType as aL, TaskStatus as aM, TaskType as aN, type TaskTypeConfig as aO, type TemplateScopeLevel as aP, type Tier as aQ, TransactionType as aR, TrellisType as aS, UserPrivilege as aT, type UserPrivilegeType as aU, UserRole as aV, type UserRoleAssignment as aW, type UserRoleType as aX, VigorRating as aY, WaterSource as aZ, type WireSession as a_, type PermissionLevel as aa, PhysicalState as ab, PlantingMethod as ac, type PriceConflictCandidate as ad, type PriceResolutionResult as ae, type PricingContext as af, type PricingDataSource as ag, ProductType as ah, type ProductTypeType as ai, ProductUnit as aj, type ProductUnitType as ak, RESOURCE_MODULE_MAP as al, RESOURCE_PATHS as am, RESOURCE_REQUIREMENTS as an, ROLE_SECTIONS_BY_KEY as ao, RelationshipType as ap, type ResolvedError as aq, type ResourceOverrides as ar, type ResourceRequirement as as, type RoleAssignment as at, RowOrientation as au, SCOPE_LEVELS as av, SENTINEL_UUID as aw, SESSION_SCHEMA as ax, SIGNATURE_MODES as ay, type SchemaField as az, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type BarcodeNamespaceType as k, BarcodeType as l, type BarcodeTypeType as m, type Base44Id as n, type BaseProductRow as o, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as p, CAT as q, CATEGORY_TABS as r, CORRECTIVE_ACTION_GENERATION_SOURCES as s, CORRECTIVE_ACTION_STATUSES as t, type CalculatePaymentDueDateInput as u, type CanonicalId as v, type CarSupportedEvidenceMimeType as w, type CarSupportedSignatureMimeType as x, type CarTemplateFileMetadata as y, CatalogSyncStatus as z };
@@ -1 +1 @@
1
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, p as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, q as CAT, r as CATEGORY_TABS, s as CORRECTIVE_ACTION_GENERATION_SOURCES, t as CORRECTIVE_ACTION_STATUSES, y as CatalogSyncStatus, H as CropCycleStatus, I as DOCUMENT_DISPLAY_INFO, J as DOCUMENT_MENU_MAP, K as DocumentCategory, L as DocumentType, M as ERROR_DICTIONARY, N as EVERYONE, O as EmitterType, P as EnabledModule, Q as FORM_REGISTRY, R as FacilityType, U as HarvestMethod, W as LinkedStatus, X as MOD, Y as MODULE_LABELS, _ as MicroclimateZone, $ as MimeType, a0 as ModCode, a1 as NettingType, a3 as NotificationMode, a4 as OrderStatus, a6 as PhysicalState, a7 as PlantingMethod, ac as ProductType, ae as ProductUnit, ag as RESOURCE_MODULE_MAP, ah as RESOURCE_PATHS, ai as RESOURCE_REQUIREMENTS, aj as ROLE_SECTIONS_BY_KEY, ak as RelationshipType, an as ResourceRequirement, ap as RowOrientation, aq as SENTINEL_UUID, ar as SESSION_SCHEMA, as as SIGNATURE_MODES, ay as SoilTexture, az as StockPolicyTier, aB as StoragePhases, aD as TASK_TYPE_REGISTRY, aE as TEMPLATE_SCOPE_LEVELS, aG as TargetEntityType, aH as TaskStatus, aI as TaskType, aM as TransactionType, aN as TrellisType, aO as UserPrivilege, aQ as UserRole, aT as VigorRating, aU as WaterSource } from './constants-CrAPx_xU.mjs';
1
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, p as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, q as CAT, r as CATEGORY_TABS, s as CORRECTIVE_ACTION_GENERATION_SOURCES, t as CORRECTIVE_ACTION_STATUSES, z as CatalogSyncStatus, J as CropCycleStatus, K as DOCUMENT_DISPLAY_INFO, L as DOCUMENT_MENU_MAP, M as DocumentCategory, N as DocumentType, O as ERROR_DICTIONARY, P as EVERYONE, Q as EmitterType, R as EnabledModule, S as FORM_REGISTRY, T as FacilityType, X as HarvestMethod, _ as LinkedStatus, $ as MOD, a0 as MODULE_LABELS, a2 as MicroclimateZone, a3 as MimeType, a4 as ModCode, a5 as NettingType, a7 as NotificationMode, a8 as OrderStatus, ab as PhysicalState, ac as PlantingMethod, ah as ProductType, aj as ProductUnit, al as RESOURCE_MODULE_MAP, am as RESOURCE_PATHS, an as RESOURCE_REQUIREMENTS, ao as ROLE_SECTIONS_BY_KEY, ap as RelationshipType, as as ResourceRequirement, au as RowOrientation, av as SCOPE_LEVELS, aw as SENTINEL_UUID, ax as SESSION_SCHEMA, ay as SIGNATURE_MODES, aE as SoilTexture, aF as StockPolicyTier, aH as StoragePhases, aJ as TASK_TYPE_REGISTRY, aL as TargetEntityType, aM as TaskStatus, aN as TaskType, aR as TransactionType, aS as TrellisType, aT as UserPrivilege, aV as UserRole, aY as VigorRating, aZ as WaterSource } from './constants-KqcPqiCa.mjs';
@@ -1 +1 @@
1
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, p as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, q as CAT, r as CATEGORY_TABS, s as CORRECTIVE_ACTION_GENERATION_SOURCES, t as CORRECTIVE_ACTION_STATUSES, y as CatalogSyncStatus, H as CropCycleStatus, I as DOCUMENT_DISPLAY_INFO, J as DOCUMENT_MENU_MAP, K as DocumentCategory, L as DocumentType, M as ERROR_DICTIONARY, N as EVERYONE, O as EmitterType, P as EnabledModule, Q as FORM_REGISTRY, R as FacilityType, U as HarvestMethod, W as LinkedStatus, X as MOD, Y as MODULE_LABELS, _ as MicroclimateZone, $ as MimeType, a0 as ModCode, a1 as NettingType, a3 as NotificationMode, a4 as OrderStatus, a6 as PhysicalState, a7 as PlantingMethod, ac as ProductType, ae as ProductUnit, ag as RESOURCE_MODULE_MAP, ah as RESOURCE_PATHS, ai as RESOURCE_REQUIREMENTS, aj as ROLE_SECTIONS_BY_KEY, ak as RelationshipType, an as ResourceRequirement, ap as RowOrientation, aq as SENTINEL_UUID, ar as SESSION_SCHEMA, as as SIGNATURE_MODES, ay as SoilTexture, az as StockPolicyTier, aB as StoragePhases, aD as TASK_TYPE_REGISTRY, aE as TEMPLATE_SCOPE_LEVELS, aG as TargetEntityType, aH as TaskStatus, aI as TaskType, aM as TransactionType, aN as TrellisType, aO as UserPrivilege, aQ as UserRole, aT as VigorRating, aU as WaterSource } from './constants-CrAPx_xU.js';
1
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, p as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, q as CAT, r as CATEGORY_TABS, s as CORRECTIVE_ACTION_GENERATION_SOURCES, t as CORRECTIVE_ACTION_STATUSES, z as CatalogSyncStatus, J as CropCycleStatus, K as DOCUMENT_DISPLAY_INFO, L as DOCUMENT_MENU_MAP, M as DocumentCategory, N as DocumentType, O as ERROR_DICTIONARY, P as EVERYONE, Q as EmitterType, R as EnabledModule, S as FORM_REGISTRY, T as FacilityType, X as HarvestMethod, _ as LinkedStatus, $ as MOD, a0 as MODULE_LABELS, a2 as MicroclimateZone, a3 as MimeType, a4 as ModCode, a5 as NettingType, a7 as NotificationMode, a8 as OrderStatus, ab as PhysicalState, ac as PlantingMethod, ah as ProductType, aj as ProductUnit, al as RESOURCE_MODULE_MAP, am as RESOURCE_PATHS, an as RESOURCE_REQUIREMENTS, ao as ROLE_SECTIONS_BY_KEY, ap as RelationshipType, as as ResourceRequirement, au as RowOrientation, av as SCOPE_LEVELS, aw as SENTINEL_UUID, ax as SESSION_SCHEMA, ay as SIGNATURE_MODES, aE as SoilTexture, aF as StockPolicyTier, aH as StoragePhases, aJ as TASK_TYPE_REGISTRY, aL as TargetEntityType, aM as TaskStatus, aN as TaskType, aR as TransactionType, aS as TrellisType, aT as UserPrivilege, aV as UserRole, aY as VigorRating, aZ as WaterSource } from './constants-KqcPqiCa.js';