@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/dist/constants.js CHANGED
@@ -56,16 +56,21 @@ __export(constants_exports, {
56
56
  NettingType: () => NettingType,
57
57
  NotificationMode: () => NotificationMode,
58
58
  OrderStatus: () => OrderStatus,
59
+ PO_STATUSES: () => PO_STATUSES,
60
+ PREFLIGHT_CHECK_STATUSES: () => PREFLIGHT_CHECK_STATUSES,
61
+ PRODUCT_TYPE_TO_BUDGET_CATEGORY: () => PRODUCT_TYPE_TO_BUDGET_CATEGORY,
59
62
  PhysicalState: () => PhysicalState,
60
63
  PlantingMethod: () => PlantingMethod,
61
64
  ProductType: () => ProductType,
62
65
  ProductUnit: () => ProductUnit,
66
+ REQUISITION_STATUSES: () => REQUISITION_STATUSES,
63
67
  RESOURCE_MODULE_MAP: () => RESOURCE_MODULE_MAP,
64
68
  RESOURCE_PATHS: () => RESOURCE_PATHS,
65
69
  RESOURCE_REQUIREMENTS: () => RESOURCE_REQUIREMENTS,
66
70
  ROLE_SECTIONS_BY_KEY: () => ROLE_SECTIONS_BY_KEY,
67
71
  RelationshipType: () => RelationshipType,
68
72
  RowOrientation: () => RowOrientation,
73
+ SCOPE_LEVELS: () => SCOPE_LEVELS,
69
74
  SENTINEL_UUID: () => SENTINEL_UUID,
70
75
  SESSION_SCHEMA: () => SESSION_SCHEMA,
71
76
  SIGNATURE_MODES: () => SIGNATURE_MODES,
@@ -73,7 +78,7 @@ __export(constants_exports, {
73
78
  StockPolicyTier: () => StockPolicyTier,
74
79
  StoragePhases: () => StoragePhases,
75
80
  TASK_TYPE_REGISTRY: () => TASK_TYPE_REGISTRY,
76
- TEMPLATE_SCOPE_LEVELS: () => TEMPLATE_SCOPE_LEVELS,
81
+ TERM_RESOLUTION_MODES: () => TERM_RESOLUTION_MODES,
77
82
  TargetEntityType: () => TargetEntityType,
78
83
  TaskStatus: () => TaskStatus,
79
84
  TaskType: () => TaskType,
@@ -467,6 +472,12 @@ var RESOURCE_PATHS = {
467
472
  farmManagement: "operations.farmManagement",
468
473
  packhouse: "operations.packhouse",
469
474
  accommodation: "operations.accommodation",
475
+ logistics: "operations.logistics",
476
+ logisticsReceival: "operations.logistics.receival",
477
+ logisticsReceivalReview: "operations.logistics.receival.review",
478
+ // being reviewed by manager/owner
479
+ logisticsDispatch: "operations.logistics.dispatch",
480
+ logisticsDispatchReview: "operations.logistics.dispatch.review",
470
481
  // ── Inventory ────────────────────────────────────────────────────────────
471
482
  // === Consumables ===
472
483
  inventory: "inventory",
@@ -502,6 +513,7 @@ var RESOURCE_PATHS = {
502
513
  equipFuelRegister: "equipment.fuelRegister",
503
514
  equipCalibration: "equipment.calibration",
504
515
  equipFleet: "equipment.fleetManagement",
516
+ // ── Finance ──────────────────────────────────────────────────────
505
517
  finance: "finance",
506
518
  financeProductRequisition: "finance.product.requistion",
507
519
  financeDashboard: "finance.dashboard",
@@ -565,12 +577,23 @@ var RESOURCE_MODULE_MAP = {
565
577
  [RESOURCE_PATHS.farmManagement]: [EnabledModule.FARM_MANAGEMENT],
566
578
  [RESOURCE_PATHS.packhouse]: [EnabledModule.PACKHOUSE],
567
579
  [RESOURCE_PATHS.accommodation]: [EnabledModule.ACCOMMODATION],
580
+ // ── Logistics ──────────────────────────────────────────────────────────────
581
+ [RESOURCE_PATHS.logistics]: ALL_OPERATIONS,
582
+ [RESOURCE_PATHS.logisticsReceival]: ALL_OPERATIONS,
583
+ [RESOURCE_PATHS.logisticsReceivalReview]: ALL_OPERATIONS,
584
+ [RESOURCE_PATHS.logisticsDispatch]: ALL_OPERATIONS,
585
+ [RESOURCE_PATHS.logisticsDispatchReview]: ALL_OPERATIONS,
568
586
  // ── Equipment & Fleet ──────────────────────────────────────────────────────
569
587
  [RESOURCE_PATHS.equipPreStart]: ALL_OPERATIONS,
570
588
  [RESOURCE_PATHS.equipMaintenance]: ALL_OPERATIONS,
571
589
  [RESOURCE_PATHS.equipFuelRegister]: ALL_OPERATIONS,
572
590
  [RESOURCE_PATHS.equipCalibration]: AGRI_ONLY,
573
591
  [RESOURCE_PATHS.equipFleet]: ALL_OPERATIONS,
592
+ // ── Finance ──────────────────────────────────────────────────────────────
593
+ [RESOURCE_PATHS.financeProductRequisition]: ALL_OPERATIONS,
594
+ [RESOURCE_PATHS.financeDashboard]: ALL_OPERATIONS,
595
+ [RESOURCE_PATHS.financeTransaction]: ALL_OPERATIONS,
596
+ [RESOURCE_PATHS.financeBudgetAllocation]: ALL_OPERATIONS,
574
597
  // ── Safety, Quality & Compliance ──────────────────────────────────────────
575
598
  [RESOURCE_PATHS.safetyAuditing]: ALL_OPERATIONS,
576
599
  [RESOURCE_PATHS.safetyFood]: AGRI_ONLY,
@@ -619,6 +642,15 @@ var RESOURCE_REQUIREMENTS = {
619
642
  allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR],
620
643
  requiredPrivileges: [UserPrivilege.ADMIN, UserPrivilege.AUDIT_COMPLIANCE, UserPrivilege.FINANCE, UserPrivilege.DOCUMENT]
621
644
  },
645
+ // ── Logistics ──────────────────────────────────────────────────────────────
646
+ [RESOURCE_PATHS.logisticsReceival]: {
647
+ allowedRoles: EVERYONE
648
+ },
649
+ [RESOURCE_PATHS.logisticsReceivalReview]: {
650
+ allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
651
+ },
652
+ [RESOURCE_PATHS.logisticsDispatch]: { allowedRoles: EVERYONE },
653
+ [RESOURCE_PATHS.logisticsDispatchReview]: { allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR] },
622
654
  // CONSUMABLES PERMISSIONS
623
655
  [RESOURCE_PATHS.inventoryConsumableProduct]: {
624
656
  allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
@@ -733,6 +765,7 @@ var DocumentType = /* @__PURE__ */ ((DocumentType2) => {
733
765
  DocumentType2["PACKHOUSE_INSPECTION"] = "PACKHOUSE_INSPECTION";
734
766
  DocumentType2["TRAINING_CERTIFICATE"] = "TRAINING_CERTIFICATE";
735
767
  DocumentType2["INVOICE"] = "INVOICE";
768
+ DocumentType2["PURCHASE"] = "PURCHASE";
736
769
  DocumentType2["LEGAL_CONTRACT"] = "LEGAL_CONTRACT";
737
770
  DocumentType2["AUDIT_REPORT"] = "AUDIT_REPORT";
738
771
  DocumentType2["SENSITIVE_IDENTITY"] = "SENSITIVE_IDENTITY";
@@ -746,6 +779,7 @@ var DocumentCategory = /* @__PURE__ */ ((DocumentCategory2) => {
746
779
  DocumentCategory2["ASSETS_MAINT"] = "Assets & Maintenance";
747
780
  DocumentCategory2["HR_LEGAL_SAFETY"] = "HR, Legal & Safety";
748
781
  DocumentCategory2["FINANCE_ADMIN"] = "Finance & Admin";
782
+ DocumentCategory2["LOGISTICS"] = "Logistics";
749
783
  return DocumentCategory2;
750
784
  })(DocumentCategory || {});
751
785
  var DOCUMENT_DISPLAY_INFO = {
@@ -920,6 +954,12 @@ var DOCUMENT_DISPLAY_INFO = {
920
954
  label: "Supplier Invoices",
921
955
  description: "Billing records for inputs, utilities, and services.",
922
956
  category: "Finance & Admin" /* FINANCE_ADMIN */
957
+ },
958
+ // --- LOGISTICS ---
959
+ ["PURCHASE" /* PURCHASE */]: {
960
+ label: "Purchase Orders",
961
+ description: "Purchase orders for goods and services.",
962
+ category: "Logistics" /* LOGISTICS */
923
963
  }
924
964
  };
925
965
  var CATEGORY_TABS = [
@@ -957,6 +997,7 @@ var DOCUMENT_MENU_MAP = {
957
997
  ["HARVEST_LOG" /* HARVEST_LOG */]: [RESOURCE_PATHS.farmManagement],
958
998
  ["PACKHOUSE_INSPECTION" /* PACKHOUSE_INSPECTION */]: [RESOURCE_PATHS.packhouse],
959
999
  ["INVOICE" /* INVOICE */]: [RESOURCE_PATHS.documentHub],
1000
+ ["PURCHASE" /* PURCHASE */]: [RESOURCE_PATHS.logistics],
960
1001
  ["LEGAL_CONTRACT" /* LEGAL_CONTRACT */]: [RESOURCE_PATHS.documentHub],
961
1002
  ["AUDIT_REPORT" /* AUDIT_REPORT */]: [RESOURCE_PATHS.safetyAuditing, RESOURCE_PATHS.dashboard],
962
1003
  ["SENSITIVE_IDENTITY" /* SENSITIVE_IDENTITY */]: [RESOURCE_PATHS.adminUserRoster]
@@ -973,10 +1014,10 @@ var CORRECTIVE_ACTION_STATUSES = {
973
1014
  CLOSED: "closed",
974
1015
  FAILED: "failed"
975
1016
  };
976
- var TEMPLATE_SCOPE_LEVELS = {
977
- FACILITY: "facility",
978
- LEGAL_ENTITY: "legalEntity",
979
- COMPANY: "company"
1017
+ var SCOPE_LEVELS = {
1018
+ COMPANY: "company",
1019
+ LEGAL_ENTITY: "legal_entity",
1020
+ FACILITY: "facility"
980
1021
  };
981
1022
  var CORRECTIVE_ACTION_GENERATION_SOURCES = {
982
1023
  CREATE: "CREATE",
@@ -1042,6 +1083,42 @@ var StockPolicyTier = {
1042
1083
  BY_STORAGE_PHASE: 2,
1043
1084
  BY_LOCATION: 3
1044
1085
  };
1086
+ var PRODUCT_TYPE_TO_BUDGET_CATEGORY = Object.freeze({
1087
+ carton: "packaging",
1088
+ tray: "packaging",
1089
+ liner: "packaging",
1090
+ label: "packaging",
1091
+ tape: "packaging",
1092
+ strapping: "packaging",
1093
+ pallet: "packaging",
1094
+ stretch_wrap: "packaging",
1095
+ other: "general"
1096
+ // fallback — reviewer must confirm at Step 3
1097
+ });
1098
+ var TERM_RESOLUTION_MODES = Object.freeze({
1099
+ SUPPLIER_LEVEL: "SUPPLIER_LEVEL",
1100
+ PRODUCT_LEVEL: "PRODUCT_LEVEL"
1101
+ });
1102
+ var REQUISITION_STATUSES = Object.freeze({
1103
+ DRAFT: "draft",
1104
+ PENDING_FINANCE: "pending_finance",
1105
+ APPROVED: "approved",
1106
+ REJECTED: "rejected",
1107
+ ORDERED: "ordered"
1108
+ });
1109
+ var PO_STATUSES = Object.freeze({
1110
+ NEW: "new",
1111
+ ACKNOWLEDGED: "acknowledged",
1112
+ IN_PROGRESS: "in_progress",
1113
+ SHIPPED: "shipped",
1114
+ RECEIVED: "received",
1115
+ CANCELLED: "cancelled"
1116
+ });
1117
+ var PREFLIGHT_CHECK_STATUSES = Object.freeze({
1118
+ OK: "ok",
1119
+ WARNING: "warning",
1120
+ BLOCKED: "blocked"
1121
+ });
1045
1122
  // Annotate the CommonJS export names for ESM import in node:
1046
1123
  0 && (module.exports = {
1047
1124
  ACCESS_RANK,
@@ -1080,16 +1157,21 @@ var StockPolicyTier = {
1080
1157
  NettingType,
1081
1158
  NotificationMode,
1082
1159
  OrderStatus,
1160
+ PO_STATUSES,
1161
+ PREFLIGHT_CHECK_STATUSES,
1162
+ PRODUCT_TYPE_TO_BUDGET_CATEGORY,
1083
1163
  PhysicalState,
1084
1164
  PlantingMethod,
1085
1165
  ProductType,
1086
1166
  ProductUnit,
1167
+ REQUISITION_STATUSES,
1087
1168
  RESOURCE_MODULE_MAP,
1088
1169
  RESOURCE_PATHS,
1089
1170
  RESOURCE_REQUIREMENTS,
1090
1171
  ROLE_SECTIONS_BY_KEY,
1091
1172
  RelationshipType,
1092
1173
  RowOrientation,
1174
+ SCOPE_LEVELS,
1093
1175
  SENTINEL_UUID,
1094
1176
  SESSION_SCHEMA,
1095
1177
  SIGNATURE_MODES,
@@ -1097,7 +1179,7 @@ var StockPolicyTier = {
1097
1179
  StockPolicyTier,
1098
1180
  StoragePhases,
1099
1181
  TASK_TYPE_REGISTRY,
1100
- TEMPLATE_SCOPE_LEVELS,
1182
+ TERM_RESOLUTION_MODES,
1101
1183
  TargetEntityType,
1102
1184
  TaskStatus,
1103
1185
  TaskType,
@@ -35,16 +35,21 @@ import {
35
35
  NettingType,
36
36
  NotificationMode,
37
37
  OrderStatus,
38
+ PO_STATUSES,
39
+ PREFLIGHT_CHECK_STATUSES,
40
+ PRODUCT_TYPE_TO_BUDGET_CATEGORY,
38
41
  PhysicalState,
39
42
  PlantingMethod,
40
43
  ProductType,
41
44
  ProductUnit,
45
+ REQUISITION_STATUSES,
42
46
  RESOURCE_MODULE_MAP,
43
47
  RESOURCE_PATHS,
44
48
  RESOURCE_REQUIREMENTS,
45
49
  ROLE_SECTIONS_BY_KEY,
46
50
  RelationshipType,
47
51
  RowOrientation,
52
+ SCOPE_LEVELS,
48
53
  SENTINEL_UUID,
49
54
  SESSION_SCHEMA,
50
55
  SIGNATURE_MODES,
@@ -52,7 +57,7 @@ import {
52
57
  StockPolicyTier,
53
58
  StoragePhases,
54
59
  TASK_TYPE_REGISTRY,
55
- TEMPLATE_SCOPE_LEVELS,
60
+ TERM_RESOLUTION_MODES,
56
61
  TargetEntityType,
57
62
  TaskStatus,
58
63
  TaskType,
@@ -62,7 +67,7 @@ import {
62
67
  UserRole,
63
68
  VigorRating,
64
69
  WaterSource
65
- } from "./chunk-Y5KVDVNY.mjs";
70
+ } from "./chunk-U332M2N6.mjs";
66
71
  export {
67
72
  ACCESS_RANK,
68
73
  ACT,
@@ -100,16 +105,21 @@ export {
100
105
  NettingType,
101
106
  NotificationMode,
102
107
  OrderStatus,
108
+ PO_STATUSES,
109
+ PREFLIGHT_CHECK_STATUSES,
110
+ PRODUCT_TYPE_TO_BUDGET_CATEGORY,
103
111
  PhysicalState,
104
112
  PlantingMethod,
105
113
  ProductType,
106
114
  ProductUnit,
115
+ REQUISITION_STATUSES,
107
116
  RESOURCE_MODULE_MAP,
108
117
  RESOURCE_PATHS,
109
118
  RESOURCE_REQUIREMENTS,
110
119
  ROLE_SECTIONS_BY_KEY,
111
120
  RelationshipType,
112
121
  RowOrientation,
122
+ SCOPE_LEVELS,
113
123
  SENTINEL_UUID,
114
124
  SESSION_SCHEMA,
115
125
  SIGNATURE_MODES,
@@ -117,7 +127,7 @@ export {
117
127
  StockPolicyTier,
118
128
  StoragePhases,
119
129
  TASK_TYPE_REGISTRY,
120
- TEMPLATE_SCOPE_LEVELS,
130
+ TERM_RESOLUTION_MODES,
121
131
  TargetEntityType,
122
132
  TaskStatus,
123
133
  TaskType,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { d as AgriCoreSession, aR as UserRoleAssignment, aL as Tier, a8 as PriceConflictCandidate, av as ShadowedCleanMatch, ab as PricingDataSource, aa as PricingContext, a9 as PriceResolutionResult, au as ScopeType, aV as WireSession, an as ResourceRequirement, c as AccessLevelType, j as AvailableScope, V as InfrastructureFields, T as FormMeta, aF as TabConfig, al as ResolvedError } from './constants-CrAPx_xU.mjs';
2
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, o as BaseProductRow, 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, u as CanonicalId, v as CarSupportedEvidenceMimeType, w as CarSupportedSignatureMimeType, x as CarTemplateFileMetadata, y as CatalogSyncStatus, z as CatalogSyncStatusType, D as CompanyConfig, E as CorrectiveActionCompileTaskMetadata, F as CorrectiveActionGenerationSource, G as CorrectiveActionStatus, 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, S as FileUploadTaskType, U as HarvestMethod, W as LinkedStatus, X as MOD, Y as MODULE_LABELS, Z as MatrixRow, _ as MicroclimateZone, $ as MimeType, a0 as ModCode, a1 as NettingType, a2 as NormalizedSignatureValue, a3 as NotificationMode, a4 as OrderStatus, a5 as PermissionLevel, a6 as PhysicalState, a7 as PlantingMethod, ac as ProductType, ad as ProductTypeType, ae as ProductUnit, af as ProductUnitType, ag as RESOURCE_MODULE_MAP, ah as RESOURCE_PATHS, ai as RESOURCE_REQUIREMENTS, aj as ROLE_SECTIONS_BY_KEY, ak as RelationshipType, am as ResourceOverrides, ao as RoleAssignment, ap as RowOrientation, aq as SENTINEL_UUID, ar as SESSION_SCHEMA, as as SIGNATURE_MODES, at as SchemaField, aw as SignatureInput, ax as SignatureMode, ay as SoilTexture, az as StockPolicyTier, aA as StockPolicyTierType, aB as StoragePhases, aC as StorageType, aD as TASK_TYPE_REGISTRY, aE as TEMPLATE_SCOPE_LEVELS, aG as TargetEntityType, aH as TaskStatus, aI as TaskType, aJ as TaskTypeConfig, aK as TemplateScopeLevel, aM as TransactionType, aN as TrellisType, aO as UserPrivilege, aP as UserPrivilegeType, aQ as UserRole, aS as UserRoleType, aT as VigorRating, aU as WaterSource } from './constants-CrAPx_xU.mjs';
1
+ import { d as AgriCoreSession, a$ as UserRoleAssignment, aV as Tier, ag as PriceConflictCandidate, aF as ShadowedCleanMatch, aj as PricingDataSource, ai as PricingContext, ah as PriceResolutionResult, u as CalculatePaymentDueDateInput, aE as ScopeType, b3 as WireSession, aw as ResourceRequirement, c as AccessLevelType, j as AvailableScope, Y as InfrastructureFields, V as FormMeta, aP as TabConfig, au as ResolvedError } from './constants-x8gYRJIw.mjs';
2
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, o as BaseProductRow, 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, v as CanonicalId, w as CarSupportedEvidenceMimeType, x as CarSupportedSignatureMimeType, y as CarTemplateFileMetadata, z as CatalogSyncStatus, D as CatalogSyncStatusType, E as CompanyConfig, F as CorrectiveActionCompileTaskMetadata, G as CorrectiveActionGenerationSource, H as CorrectiveActionStatus, I as CreditDaysWindow, 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, U as FileUploadTaskType, W as ForwardOrderingContractWindow, X as HarvestMethod, Z as InstallmentWindow, _ as LinkedStatus, $ as MOD, a0 as MODULE_LABELS, a1 as MatrixRow, a2 as MicroclimateZone, a3 as MimeType, a4 as ModCode, a5 as NettingType, a6 as NormalizedSignatureValue, a7 as NotificationMode, a8 as OrderStatus, a9 as PO_STATUSES, aa as PREFLIGHT_CHECK_STATUSES, ab as PRODUCT_TYPE_TO_BUDGET_CATEGORY, ac as PaymentTerm, ad as PermissionLevel, ae as PhysicalState, af as PlantingMethod, ak as ProductType, al as ProductTypeType, am as ProductUnit, an as ProductUnitType, ao as REQUISITION_STATUSES, ap as RESOURCE_MODULE_MAP, aq as RESOURCE_PATHS, ar as RESOURCE_REQUIREMENTS, as as ROLE_SECTIONS_BY_KEY, at as RelationshipType, av as ResourceOverrides, ax as RoleAssignment, ay as RowOrientation, az as SCOPE_LEVELS, aA as SENTINEL_UUID, aB as SESSION_SCHEMA, aC as SIGNATURE_MODES, aD as SchemaField, aG as SignatureInput, aH as SignatureMode, aI as SoilTexture, aJ as StockPolicyTier, aK as StockPolicyTierType, aL as StoragePhases, aM as StorageType, aN as TASK_TYPE_REGISTRY, aO as TERM_RESOLUTION_MODES, aQ as TargetEntityType, aR as TaskStatus, aS as TaskType, aT as TaskTypeConfig, aU as TemplateScopeLevel, aW as TransactionType, aX as TrellisType, aY as UserPrivilege, aZ as UserPrivilegeType, a_ as UserRole, b0 as UserRoleType, b1 as VigorRating, b2 as WaterSource } from './constants-x8gYRJIw.mjs';
3
3
 
4
4
  declare const AgriLogger: {
5
5
  log(level: "INFO" | "WARN" | "ERROR", message: string, meta: any): void;
@@ -54,6 +54,50 @@ declare function findOverlappingPriceWindows(db: any, scope: OverlapCheckScope,
54
54
  validTo: string | null;
55
55
  }, excludeId?: string): Promise<PriceConflictCandidate[]>;
56
56
 
57
+ /**
58
+ * Payment Due Date Calculation Utility
59
+ * ------------------------------------
60
+ * Computes `paymentDueDate` (or, for installments, the full due-date
61
+ * schedule) from a `transactionDate`, a `paymentTerm`, and term-specific
62
+ * config.
63
+ *
64
+ * Dates are handled as UTC-normalized "calendar dates" (year/month/day only)
65
+ * to avoid timezone/DST bugs when adding days or jumping months. If you pass
66
+ * in a Date with a time component, it's normalized to midnight UTC first,
67
+ * and results are also midnight UTC.
68
+ */
69
+
70
+ /**
71
+ * Returns a single `Date` for most payment terms, a `Date[]` for
72
+ * "thirdPartyInputFinance" (the full installment schedule), or `null` when
73
+ * the due date can't be determined yet from the info available so far
74
+ * (currently only "cashOnDelivery" before a deliveryDate is known).
75
+ *
76
+ * Designed to be called from one central place regardless of paymentTerm —
77
+ * e.g. at order creation, then again once delivery is confirmed. Callers
78
+ * should handle the `null` case as "not yet known, try again later" rather
79
+ * than treating it as an error.
80
+ *
81
+ * Narrow with Array.isArray() / === null at the call site as needed.
82
+ */
83
+ declare function calculatePaymentDueDate(input: CalculatePaymentDueDateInput): Date | Date[] | null;
84
+ /**
85
+ * True when the due date isn't determinable yet (currently only
86
+ * "cashOnDelivery" before deliveryDate is known). Call
87
+ * calculatePaymentDueDate() again later once the missing info is available.
88
+ */
89
+ declare function isDueDatePending(result: Date | Date[] | null): result is null;
90
+ /**
91
+ * True when the result is a single due date (all terms except
92
+ * "thirdPartyInputFinance", and excluding the pending/null case).
93
+ */
94
+ declare function isSingleDueDate(result: Date | Date[] | null): result is Date;
95
+ /**
96
+ * True when the result is a full installment schedule
97
+ * (paymentTerm === "thirdPartyInputFinance").
98
+ */
99
+ declare function isInstallmentSchedule(result: Date | Date[] | null): result is Date[];
100
+
57
101
  declare const Validator: {
58
102
  /** * 1. Email: The classic. Uses a standard RFC 5322 regex.
59
103
  */
@@ -202,6 +246,7 @@ declare const getApproveAction: (taskType: string) => string | null;
202
246
  * Static: {SiteName}/_CORE/{DocumentType}
203
247
  * Dynamic: {SiteName}/_SEASONAL/{Year}/{DocumentType}/{Crop}
204
248
  */
249
+ declare function sanitizeSiteName(name: string): string;
205
250
  declare function generateDocumentPath(params: {
206
251
  siteName: string;
207
252
  docType: DocumentType;
@@ -209,10 +254,11 @@ declare function generateDocumentPath(params: {
209
254
  year?: number | string;
210
255
  crop?: string;
211
256
  }): string;
257
+ declare function generateSystemFolderPath(siteName: string, systemFolderKey: string): string;
212
258
  declare function calculateFileMetadataMatch(criteria: {
213
259
  mustMatch: Record<string, any>;
214
260
  mustMatchContext?: string[];
215
261
  contextMatch?: string[];
216
262
  }, fileMetadata: Record<string, any>, auditContext: Record<string, any>): number;
217
263
 
218
- export { AccessLevelType, AggregatePriceAmbiguityError, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, type OverlapCheckScope, PriceAmbiguityError, PriceConflictCandidate, PriceResolutionResult, type PricingAdapterScope, PricingContext, PricingDataSource, ResolvedError, ResourceRequirement, ScopeType, ShadowedCleanMatch, TabConfig, Tier, UserRoleAssignment, Validator, WireSession, assertTenantBoundary, calculateFileMetadataMatch, createBase44PricingAdapter, decodeSession, encodeSession, evaluateBaseAccess, extractAppCode, findOverlappingPriceWindows, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getPrivilegesAt, getRoleAt, getScopeAncestry, getTaskTypeOptions, handleAppErrorResponse, hasPrivilegeAt, hasRoleAt, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, resolvePrice, transformRoleAssignments, verifyAndExtractSession, withAgriLogging };
264
+ export { AccessLevelType, AggregatePriceAmbiguityError, AgriCoreSession, AgriLogger, AppError, AvailableScope, CalculatePaymentDueDateInput, Converter, ErrorFactory, FormMeta, InfrastructureFields, type OverlapCheckScope, PriceAmbiguityError, PriceConflictCandidate, PriceResolutionResult, type PricingAdapterScope, PricingContext, PricingDataSource, ResolvedError, ResourceRequirement, ScopeType, ShadowedCleanMatch, TabConfig, Tier, UserRoleAssignment, Validator, WireSession, assertTenantBoundary, calculateFileMetadataMatch, calculatePaymentDueDate, createBase44PricingAdapter, decodeSession, encodeSession, evaluateBaseAccess, extractAppCode, findOverlappingPriceWindows, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, generateSystemFolderPath, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getPrivilegesAt, getRoleAt, getScopeAncestry, getTaskTypeOptions, handleAppErrorResponse, hasPrivilegeAt, hasRoleAt, isDueDatePending, isInstallmentSchedule, isSingleDueDate, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, resolvePrice, sanitizeSiteName, transformRoleAssignments, verifyAndExtractSession, withAgriLogging };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { d as AgriCoreSession, aR as UserRoleAssignment, aL as Tier, a8 as PriceConflictCandidate, av as ShadowedCleanMatch, ab as PricingDataSource, aa as PricingContext, a9 as PriceResolutionResult, au as ScopeType, aV as WireSession, an as ResourceRequirement, c as AccessLevelType, j as AvailableScope, V as InfrastructureFields, T as FormMeta, aF as TabConfig, al as ResolvedError } from './constants-CrAPx_xU.js';
2
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, o as BaseProductRow, 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, u as CanonicalId, v as CarSupportedEvidenceMimeType, w as CarSupportedSignatureMimeType, x as CarTemplateFileMetadata, y as CatalogSyncStatus, z as CatalogSyncStatusType, D as CompanyConfig, E as CorrectiveActionCompileTaskMetadata, F as CorrectiveActionGenerationSource, G as CorrectiveActionStatus, 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, S as FileUploadTaskType, U as HarvestMethod, W as LinkedStatus, X as MOD, Y as MODULE_LABELS, Z as MatrixRow, _ as MicroclimateZone, $ as MimeType, a0 as ModCode, a1 as NettingType, a2 as NormalizedSignatureValue, a3 as NotificationMode, a4 as OrderStatus, a5 as PermissionLevel, a6 as PhysicalState, a7 as PlantingMethod, ac as ProductType, ad as ProductTypeType, ae as ProductUnit, af as ProductUnitType, ag as RESOURCE_MODULE_MAP, ah as RESOURCE_PATHS, ai as RESOURCE_REQUIREMENTS, aj as ROLE_SECTIONS_BY_KEY, ak as RelationshipType, am as ResourceOverrides, ao as RoleAssignment, ap as RowOrientation, aq as SENTINEL_UUID, ar as SESSION_SCHEMA, as as SIGNATURE_MODES, at as SchemaField, aw as SignatureInput, ax as SignatureMode, ay as SoilTexture, az as StockPolicyTier, aA as StockPolicyTierType, aB as StoragePhases, aC as StorageType, aD as TASK_TYPE_REGISTRY, aE as TEMPLATE_SCOPE_LEVELS, aG as TargetEntityType, aH as TaskStatus, aI as TaskType, aJ as TaskTypeConfig, aK as TemplateScopeLevel, aM as TransactionType, aN as TrellisType, aO as UserPrivilege, aP as UserPrivilegeType, aQ as UserRole, aS as UserRoleType, aT as VigorRating, aU as WaterSource } from './constants-CrAPx_xU.js';
1
+ import { d as AgriCoreSession, a$ as UserRoleAssignment, aV as Tier, ag as PriceConflictCandidate, aF as ShadowedCleanMatch, aj as PricingDataSource, ai as PricingContext, ah as PriceResolutionResult, u as CalculatePaymentDueDateInput, aE as ScopeType, b3 as WireSession, aw as ResourceRequirement, c as AccessLevelType, j as AvailableScope, Y as InfrastructureFields, V as FormMeta, aP as TabConfig, au as ResolvedError } from './constants-x8gYRJIw.js';
2
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, o as BaseProductRow, 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, v as CanonicalId, w as CarSupportedEvidenceMimeType, x as CarSupportedSignatureMimeType, y as CarTemplateFileMetadata, z as CatalogSyncStatus, D as CatalogSyncStatusType, E as CompanyConfig, F as CorrectiveActionCompileTaskMetadata, G as CorrectiveActionGenerationSource, H as CorrectiveActionStatus, I as CreditDaysWindow, 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, U as FileUploadTaskType, W as ForwardOrderingContractWindow, X as HarvestMethod, Z as InstallmentWindow, _ as LinkedStatus, $ as MOD, a0 as MODULE_LABELS, a1 as MatrixRow, a2 as MicroclimateZone, a3 as MimeType, a4 as ModCode, a5 as NettingType, a6 as NormalizedSignatureValue, a7 as NotificationMode, a8 as OrderStatus, a9 as PO_STATUSES, aa as PREFLIGHT_CHECK_STATUSES, ab as PRODUCT_TYPE_TO_BUDGET_CATEGORY, ac as PaymentTerm, ad as PermissionLevel, ae as PhysicalState, af as PlantingMethod, ak as ProductType, al as ProductTypeType, am as ProductUnit, an as ProductUnitType, ao as REQUISITION_STATUSES, ap as RESOURCE_MODULE_MAP, aq as RESOURCE_PATHS, ar as RESOURCE_REQUIREMENTS, as as ROLE_SECTIONS_BY_KEY, at as RelationshipType, av as ResourceOverrides, ax as RoleAssignment, ay as RowOrientation, az as SCOPE_LEVELS, aA as SENTINEL_UUID, aB as SESSION_SCHEMA, aC as SIGNATURE_MODES, aD as SchemaField, aG as SignatureInput, aH as SignatureMode, aI as SoilTexture, aJ as StockPolicyTier, aK as StockPolicyTierType, aL as StoragePhases, aM as StorageType, aN as TASK_TYPE_REGISTRY, aO as TERM_RESOLUTION_MODES, aQ as TargetEntityType, aR as TaskStatus, aS as TaskType, aT as TaskTypeConfig, aU as TemplateScopeLevel, aW as TransactionType, aX as TrellisType, aY as UserPrivilege, aZ as UserPrivilegeType, a_ as UserRole, b0 as UserRoleType, b1 as VigorRating, b2 as WaterSource } from './constants-x8gYRJIw.js';
3
3
 
4
4
  declare const AgriLogger: {
5
5
  log(level: "INFO" | "WARN" | "ERROR", message: string, meta: any): void;
@@ -54,6 +54,50 @@ declare function findOverlappingPriceWindows(db: any, scope: OverlapCheckScope,
54
54
  validTo: string | null;
55
55
  }, excludeId?: string): Promise<PriceConflictCandidate[]>;
56
56
 
57
+ /**
58
+ * Payment Due Date Calculation Utility
59
+ * ------------------------------------
60
+ * Computes `paymentDueDate` (or, for installments, the full due-date
61
+ * schedule) from a `transactionDate`, a `paymentTerm`, and term-specific
62
+ * config.
63
+ *
64
+ * Dates are handled as UTC-normalized "calendar dates" (year/month/day only)
65
+ * to avoid timezone/DST bugs when adding days or jumping months. If you pass
66
+ * in a Date with a time component, it's normalized to midnight UTC first,
67
+ * and results are also midnight UTC.
68
+ */
69
+
70
+ /**
71
+ * Returns a single `Date` for most payment terms, a `Date[]` for
72
+ * "thirdPartyInputFinance" (the full installment schedule), or `null` when
73
+ * the due date can't be determined yet from the info available so far
74
+ * (currently only "cashOnDelivery" before a deliveryDate is known).
75
+ *
76
+ * Designed to be called from one central place regardless of paymentTerm —
77
+ * e.g. at order creation, then again once delivery is confirmed. Callers
78
+ * should handle the `null` case as "not yet known, try again later" rather
79
+ * than treating it as an error.
80
+ *
81
+ * Narrow with Array.isArray() / === null at the call site as needed.
82
+ */
83
+ declare function calculatePaymentDueDate(input: CalculatePaymentDueDateInput): Date | Date[] | null;
84
+ /**
85
+ * True when the due date isn't determinable yet (currently only
86
+ * "cashOnDelivery" before deliveryDate is known). Call
87
+ * calculatePaymentDueDate() again later once the missing info is available.
88
+ */
89
+ declare function isDueDatePending(result: Date | Date[] | null): result is null;
90
+ /**
91
+ * True when the result is a single due date (all terms except
92
+ * "thirdPartyInputFinance", and excluding the pending/null case).
93
+ */
94
+ declare function isSingleDueDate(result: Date | Date[] | null): result is Date;
95
+ /**
96
+ * True when the result is a full installment schedule
97
+ * (paymentTerm === "thirdPartyInputFinance").
98
+ */
99
+ declare function isInstallmentSchedule(result: Date | Date[] | null): result is Date[];
100
+
57
101
  declare const Validator: {
58
102
  /** * 1. Email: The classic. Uses a standard RFC 5322 regex.
59
103
  */
@@ -202,6 +246,7 @@ declare const getApproveAction: (taskType: string) => string | null;
202
246
  * Static: {SiteName}/_CORE/{DocumentType}
203
247
  * Dynamic: {SiteName}/_SEASONAL/{Year}/{DocumentType}/{Crop}
204
248
  */
249
+ declare function sanitizeSiteName(name: string): string;
205
250
  declare function generateDocumentPath(params: {
206
251
  siteName: string;
207
252
  docType: DocumentType;
@@ -209,10 +254,11 @@ declare function generateDocumentPath(params: {
209
254
  year?: number | string;
210
255
  crop?: string;
211
256
  }): string;
257
+ declare function generateSystemFolderPath(siteName: string, systemFolderKey: string): string;
212
258
  declare function calculateFileMetadataMatch(criteria: {
213
259
  mustMatch: Record<string, any>;
214
260
  mustMatchContext?: string[];
215
261
  contextMatch?: string[];
216
262
  }, fileMetadata: Record<string, any>, auditContext: Record<string, any>): number;
217
263
 
218
- export { AccessLevelType, AggregatePriceAmbiguityError, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, type OverlapCheckScope, PriceAmbiguityError, PriceConflictCandidate, PriceResolutionResult, type PricingAdapterScope, PricingContext, PricingDataSource, ResolvedError, ResourceRequirement, ScopeType, ShadowedCleanMatch, TabConfig, Tier, UserRoleAssignment, Validator, WireSession, assertTenantBoundary, calculateFileMetadataMatch, createBase44PricingAdapter, decodeSession, encodeSession, evaluateBaseAccess, extractAppCode, findOverlappingPriceWindows, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getPrivilegesAt, getRoleAt, getScopeAncestry, getTaskTypeOptions, handleAppErrorResponse, hasPrivilegeAt, hasRoleAt, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, resolvePrice, transformRoleAssignments, verifyAndExtractSession, withAgriLogging };
264
+ export { AccessLevelType, AggregatePriceAmbiguityError, AgriCoreSession, AgriLogger, AppError, AvailableScope, CalculatePaymentDueDateInput, Converter, ErrorFactory, FormMeta, InfrastructureFields, type OverlapCheckScope, PriceAmbiguityError, PriceConflictCandidate, PriceResolutionResult, type PricingAdapterScope, PricingContext, PricingDataSource, ResolvedError, ResourceRequirement, ScopeType, ShadowedCleanMatch, TabConfig, Tier, UserRoleAssignment, Validator, WireSession, assertTenantBoundary, calculateFileMetadataMatch, calculatePaymentDueDate, createBase44PricingAdapter, decodeSession, encodeSession, evaluateBaseAccess, extractAppCode, findOverlappingPriceWindows, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, generateSystemFolderPath, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getPrivilegesAt, getRoleAt, getScopeAncestry, getTaskTypeOptions, handleAppErrorResponse, hasPrivilegeAt, hasRoleAt, isDueDatePending, isInstallmentSchedule, isSingleDueDate, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, resolvePrice, sanitizeSiteName, transformRoleAssignments, verifyAndExtractSession, withAgriLogging };