@feedmepos/mf-inventory-portal 1.3.7-dev.2 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/{App-Bt9_9LW3.js → App-D1-fT3jF.js} +3 -3
  2. package/dist/ApprovalView-0FbsslVD.js +226 -0
  3. package/dist/{BindingsDialog-lLNdP2RG.js → BindingsDialog-DeavyPY-.js} +5 -5
  4. package/dist/{BindingsPicker-BwxdoHu-.js → BindingsPicker-BGzhKq8G.js} +3 -3
  5. package/dist/{BindingsTable-C8cf9nV_.js → BindingsTable-Dr9hWkE1.js} +5 -5
  6. package/dist/{ClosingDraftView-CHB815at.js → ClosingDraftView-6gwWEWWB.js} +57 -57
  7. package/dist/{ClosingHistoryView-BQS52wLi.js → ClosingHistoryView-D4rNnlsq.js} +4 -4
  8. package/dist/{ClosingTemplateView-7o5xDvYi.js → ClosingTemplateView-DxCLH1GH.js} +16 -16
  9. package/dist/{DeliveryOrderPrintPreview-DBWYDmhP.js → DeliveryOrderPrintPreview-D-XeZX-z.js} +17 -17
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-hX9rZGHP.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DeoaPLQm.js} +14 -14
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DLo83JRe.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js} +2 -2
  12. package/dist/{FmMultiselectDialog-CX6Q05kY.js → FmMultiselectDialog-BQZmTWDb.js} +2 -2
  13. package/dist/{FmMultiselectDialog-eZLmEoMJ.js → FmMultiselectDialog-DJFi54mG.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CNP7o7p-.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js} +4 -4
  15. package/dist/{ImportView-5F1k_NOx.js → ImportView-DPQY0ELT.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-COyKYsPf.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeVYXEzb.js} +1 -1
  17. package/dist/{IngredientGroupView-1kwOZDub.js → IngredientGroupView-5AuPbMDz.js} +7 -7
  18. package/dist/{IngredientsView-L50oDR5B.js → IngredientsView-qMotWYnL.js} +17 -17
  19. package/dist/{IntegrationView-CwBluyeW.js → IntegrationView-CVdwhNTA.js} +13 -13
  20. package/dist/{InventoryBindingForm-28KU0Y69.js → InventoryBindingForm-B5KUYKIu.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DAxmcGtJ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-pbyMU879.js} +5 -5
  22. package/dist/{InventoryBindingSummary-hjZLd6je.js → InventoryBindingSummary-Bm3A2kmC.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-GqT3S9zo.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NnoVkA8W.js} +1 -1
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-6jv1aHW-.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Dp4gFbs5.js} +1 -1
  25. package/dist/PublishView-DOIiAeDK.js +208 -0
  26. package/dist/{PurchaseOrderPrintPreview-C_AaZuFs.js → PurchaseOrderPrintPreview-BE-8EJFv.js} +12 -12
  27. package/dist/ReceiveRequestView-ur3OeHuv.js +2802 -0
  28. package/dist/{RecipeView-B39YtOhH.js → RecipeView-CM-BrVSe.js} +21 -22
  29. package/dist/{StockView-DGO3Xf6j.js → StockView-DDqlms0m.js} +20 -21
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-b6jr57r-.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CcQ6bBWG.js} +1 -1
  31. package/dist/{SupplierView-Bfo4AYFs.js → SupplierView-CM2PrtHi.js} +14 -14
  32. package/dist/{SurchargeView-CPuDx3I8.js → SurchargeView-q2NfASMH.js} +8 -8
  33. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-EmbaZT8X.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js} +2 -2
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CMWRgrTV.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bp3joqMK.js} +67 -60
  35. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-GhRFdMoW.js +3521 -0
  36. package/dist/{TransferTemplateView-DH1BkbUP.js → TransferTemplateView-B26H_T9Q.js} +19 -20
  37. package/dist/{UnitCostHistoryView-DonGH8na.js → UnitCostHistoryView-BzumRVdx.js} +4 -4
  38. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CW3kofME.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CfWpv2Mv.js} +4 -4
  39. package/dist/{UnitView-CFBdZjSP.js → UnitView-Cxfg--TU.js} +9 -9
  40. package/dist/{WarehouseView-gdd1ou_Y.js → WarehouseView-CvoafTrd.js} +7 -7
  41. package/dist/{WastageTemplateView-BoMqb-zR.js → WastageTemplateView-Bqd4Wp3d.js} +16 -16
  42. package/dist/{app-QEDlYnlN.js → app-CrrDFeMj.js} +4557 -4711
  43. package/dist/app.d.ts +0 -32
  44. package/dist/app.js +2 -2
  45. package/dist/{closing-template-CbHN15AQ.js → closing-template-Ew74NLQj.js} +1 -1
  46. package/dist/{component-kqxARxvM.js → component-DpCUABT3.js} +21 -30
  47. package/dist/components/row-action.enum.d.ts +0 -3
  48. package/dist/{date2-Z-I7Kd_W.js → date2-Bklbk2g-.js} +4 -4
  49. package/dist/{dayjs.min-D4CmdyEZ.js → dayjs.min-B463GIlc.js} +1 -1
  50. package/dist/{decimal-C-T875Hm.js → decimal-Dm2vbfDq.js} +2 -2
  51. package/dist/defineDeepModel-SD5OUepJ.js +19 -0
  52. package/dist/{duplicate-template-CmTg7BGs.js → duplicate-template-CR79OmLy.js} +1 -1
  53. package/dist/{export-B1VAPZRx.js → export-CQJcxfPC.js} +1 -1
  54. package/dist/{inventory-core-dart.default-ugZJdof5.js → feature-CZHvliez.js} +1395 -322
  55. package/dist/{format-time-from-id-DZ_PAFci.js → format-time-from-id-61ydd8RS.js} +1 -1
  56. package/dist/{format-unit-display-DlODRa7k.js → format-unit-display-BLtW28yU.js} +13 -13
  57. package/dist/{import-export.helper-DVCiPtHv.js → import-export.helper-uhFwjH6X.js} +6 -6
  58. package/dist/{index-rghVMuZK.js → index-CouegIcG.js} +1 -1
  59. package/dist/{index-BHqcJDf6.js → index-Dx5HvWR_.js} +1 -1
  60. package/dist/{index-BZxwdVW1.js → index-uA6bkf1x.js} +3 -3
  61. package/dist/{lodash-CgDY9U7s.js → lodash-CjyamSgJ.js} +1 -1
  62. package/dist/{lz-string-DNoTxtCy.js → lz-string-BbZdMrTL.js} +1 -1
  63. package/dist/{netsuite-B64xGIt5.js → netsuite-2v3F8ILe.js} +9 -60
  64. package/dist/{number-Bqy4-9rV.js → number-BYbxsJHr.js} +3 -3
  65. package/dist/{purchase-order-template-BxowjjVQ.js → purchase-order-template-s1AiueV_.js} +1 -1
  66. package/dist/router/name.d.ts +0 -2
  67. package/dist/{row-action.enum-Co_O4qD9.js → row-action.enum-BcW_L_nE.js} +3 -11
  68. package/dist/{rules-BkK6oJzC.js → rules-C7L-LFOd.js} +2 -2
  69. package/dist/{stock-lXNLY2TO.js → stock-CvYOcgWb.js} +3 -3
  70. package/dist/{stock-CedueOcQ.js → stock-D2s88pz1.js} +1 -1
  71. package/dist/stores/feature.d.ts +0 -2
  72. package/dist/stores/integration/netsuite.d.ts +1 -1
  73. package/dist/style.css +1 -1
  74. package/dist/{supplier-BxEW6DYL.js → supplier-DmobM7mD.js} +2 -2
  75. package/dist/{surcharge-_zxlHhpJ.js → surcharge-BdZOVfi0.js} +1 -1
  76. package/dist/tsconfig.app.tsbuildinfo +1 -1
  77. package/dist/{use-ingredient-select-dialog-BQFTqO6q.js → use-ingredient-select-dialog-BUCJBHjV.js} +2 -2
  78. package/dist/{use-inventory-binding-dialog-BnJKIhqC.js → use-inventory-binding-dialog-DiN1hBIm.js} +2 -2
  79. package/dist/{use-template-enabled-locations-2-Ch5vC3Ux.js → use-template-enabled-locations-CmH6I2cy.js} +33 -21
  80. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +21 -21
  81. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +21 -21
  82. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +129 -129
  83. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +150 -154
  84. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +7 -93
  85. package/dist/vue-i18n-D0Q6LFcu.js +2365 -0
  86. package/dist/{xlsx-BlvEsbYy.js → xlsx-D4PML26z.js} +398 -398
  87. package/dist/{xlsx.util-B4ae3AUU.js → xlsx.util-BWLcCmO_.js} +1 -1
  88. package/package.json +3 -8
  89. package/dist/ApprovalView-BAFatrEE.js +0 -241
  90. package/dist/IntegrationExplorerView-BVJ3qSYS.js +0 -22254
  91. package/dist/PublishView-kBqlO98G.js +0 -234
  92. package/dist/ReceiveRequestView-sebwwuaH.js +0 -2817
  93. package/dist/SettingsView-CFoKuaMo.js +0 -695
  94. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-_5fogvJl.js +0 -3790
  95. package/dist/api/integration-sync-log.d.ts +0 -47
  96. package/dist/api/netsuite-explorer.d.ts +0 -51
  97. package/dist/defineDeepModel-Ds_lq_kg.js +0 -19
  98. package/dist/feature-_WJViVjR.js +0 -1081
  99. package/dist/modules/print-template/api/print-template.d.ts +0 -29
  100. package/dist/modules/print-template/components/BlockConfigPanel.vue.d.ts +0 -19
  101. package/dist/modules/print-template/components/CustomPrintTemplatePreview.vue.d.ts +0 -25
  102. package/dist/modules/print-template/components/PrintTemplateEditorDialog.vue.d.ts +0 -45
  103. package/dist/modules/print-template/components/TemplatePreview.vue.d.ts +0 -22
  104. package/dist/modules/print-template/composables/print-po-with-template.d.ts +0 -25
  105. package/dist/modules/print-template/definitions/block-definitions.d.ts +0 -88
  106. package/dist/modules/print-template/definitions/predefined-templates.d.ts +0 -22
  107. package/dist/modules/print-template/definitions/template-renderer.d.ts +0 -17
  108. package/dist/modules/print-template/index.d.ts +0 -11
  109. package/dist/modules/print-template/store/print-template.d.ts +0 -170
  110. package/dist/modules/print-template/types/print-data.d.ts +0 -52
  111. package/dist/modules/print-template/utils/sanitize-html.d.ts +0 -32
  112. package/dist/predefined-templates-B5qmOdnZ.js +0 -4542
  113. package/dist/views/integration/components/IntegrationSyncLogTab.vue.d.ts +0 -15
  114. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
  115. package/dist/views/integration-explorer/IntegrationExplorerView.vue.d.ts +0 -2
  116. package/dist/views/integration-explorer/composables/use-explorer-tab.d.ts +0 -126
  117. package/dist/views/integration-explorer/netsuite/ExplorerRecordSyncLog.vue.d.ts +0 -17
  118. package/dist/views/integration-explorer/netsuite/ExplorerRecordToolbar.vue.d.ts +0 -201
  119. package/dist/views/integration-explorer/netsuite/ExplorerSystemNote.vue.d.ts +0 -15
  120. package/dist/views/integration-explorer/netsuite/JsonViewer.vue.d.ts +0 -15
  121. package/dist/views/integration-explorer/netsuite/NetSuiteExplorerView.vue.d.ts +0 -2
  122. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferSideSheet.vue.d.ts +0 -7
  123. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferView.vue.d.ts +0 -39
  124. package/dist/views/integration-explorer/netsuite/items/AssemblyItemSideSheet.vue.d.ts +0 -7
  125. package/dist/views/integration-explorer/netsuite/items/InventoryItemSideSheet.vue.d.ts +0 -7
  126. package/dist/views/integration-explorer/netsuite/items/ItemsView.vue.d.ts +0 -2
  127. package/dist/views/integration-explorer/netsuite/items/ServiceItemSideSheet.vue.d.ts +0 -7
  128. package/dist/views/integration-explorer/netsuite/orders/ExplorerOrderDetailSideSheet.vue.d.ts +0 -7
  129. package/dist/views/integration-explorer/netsuite/orders/OrdersView.vue.d.ts +0 -39
  130. package/dist/views/integration-explorer/netsuite/orders/PurchaseOrderSideSheet.vue.d.ts +0 -7
  131. package/dist/views/integration-explorer/netsuite/orders/SyncNetsuiteButton.vue.d.ts +0 -29
  132. package/dist/views/integration-explorer/netsuite/orders/TransferOrderSideSheet.vue.d.ts +0 -7
  133. package/dist/views/settings/SettingsView.vue.d.ts +0 -2
  134. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +0 -13
  135. package/dist/vue-i18n-taYcBeKI.js +0 -2365
@@ -0,0 +1,3521 @@
1
+ import { p as Et, f as et } from "./format-time-from-id-61ydd8RS.js";
2
+ import { defineComponent as De, ref as Q, watch as Xe, openBlock as i, createElementBlock as g, toDisplayString as p, createCommentVNode as L, createElementVNode as e, unref as m, withDirectives as Lt, vModelText as Ut, toRaw as Mt, shallowRef as bt, onUnmounted as jt, triggerRef as Bt, computed as Y, readonly as zt, h as M, reactive as Kt, onMounted as Rt, resolveComponent as G, createBlock as ie, withCtx as te, createVNode as T, Fragment as fe, renderList as Ce, createTextVNode as Ne, normalizeClass as ze, isRef as Gt, resolveDynamicComponent as Ht } from "vue";
3
+ import { c as _t } from "./component-DpCUABT3.js";
4
+ import { R as pe, D as be } from "./row-action.enum-BcW_L_nE.js";
5
+ import { o as Wt, u as Fe, U as N, V as nt, O as se, a as Yt, W as St, X as Qt, Y as Jt, H as Xt, c as $t, v as ht, s as Oe, Z as kt, t as Qe, D as tt, y as Ue, E as Le } from "./app-CrrDFeMj.js";
6
+ import { j as Zt, c as er, a as _e, t as rt, d as Ye } from "./number-BYbxsJHr.js";
7
+ import { F as tr } from "./decimal-Dm2vbfDq.js";
8
+ import { t as rr, c as sr, h as At, a as Je } from "./date2-Bklbk2g-.js";
9
+ import { u as je, c as or, F as nr, b as ut } from "./feature-CZHvliez.js";
10
+ import { L as ar } from "./lz-string-BbZdMrTL.js";
11
+ import { useI18n as at, useCoreStore as lt, validatePermission as lr, Permission as xt } from "@feedmepos/mf-common";
12
+ import { u as it, a as gt, S as $e } from "./netsuite-2v3F8ILe.js";
13
+ import { useDialog as ct, useSnackbar as Ke, components as st, FmButtonVariant as xe, useProxiedModel as ir } from "@feedmepos/ui-library";
14
+ import { F as Me } from "./FmAdminBadge-BOEV93D3.js";
15
+ import { E as cr } from "./empty-placeholder-wf6-BWE8.js";
16
+ import { u as ur, a as dr, f as mr } from "./format-unit-display-BLtW28yU.js";
17
+ import { u as Ge, _ as pr } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js";
18
+ import { _ as fr, a as yr, b as vr } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js";
19
+ import { u as hr, R as Ot } from "./usePromise-CbVUCxhj.js";
20
+ import { c as gr } from "./index-uA6bkf1x.js";
21
+ import { i as br } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js";
22
+ import { F as wt } from "./form-mode.enum-BKiNVH6A.js";
23
+ import { u as _r } from "./supplier-DmobM7mD.js";
24
+ import { u as Sr } from "./surcharge-BdZOVfi0.js";
25
+ import { d as Nt } from "./defineDeepModel-SD5OUepJ.js";
26
+ import { u as xr } from "./vue-i18n-D0Q6LFcu.js";
27
+ const Or = Wt((v, r) => {
28
+ const s = Fe();
29
+ return {
30
+ async getShipments({
31
+ start: l,
32
+ end: f
33
+ }) {
34
+ const a = s.currentLocationDBName, h = `${v.inventoryBackendUrl}/${a}/shipments`;
35
+ return await r.get(`${h}?start=${l}&end=${f}`);
36
+ },
37
+ async getShipmentsByIds(l) {
38
+ if (l.length === 0)
39
+ return [];
40
+ const f = s.currentLocationDBName, a = `${v.inventoryBackendUrl}/${f}/shipments/get`;
41
+ return await r.post(a, { shipmentIds: l });
42
+ }
43
+ };
44
+ }), Ft = {
45
+ [N.enum.confirmDraft]: {
46
+ primaryActions: {
47
+ text: "Confirm draft",
48
+ close: !0
49
+ },
50
+ title: "Confirm draft?",
51
+ message: "Purchase order cannot be changed after confirm draft.",
52
+ successMessage: "Purchase order draft has been confirmed"
53
+ },
54
+ [N.enum.cancelDraft]: {
55
+ primaryActions: {
56
+ text: "Cancel draft",
57
+ close: !0,
58
+ variant: "destructive"
59
+ },
60
+ title: "Cancel draft?",
61
+ message: "Purchase order cannot be changed after cancelled draft.",
62
+ successMessage: "Purchase order draft has been cancelled"
63
+ },
64
+ [N.enum.approveDraft]: {
65
+ primaryActions: {
66
+ text: "Approve draft",
67
+ close: !0
68
+ },
69
+ title: "Approve draft?",
70
+ message: "Purchase order request will be accepted.",
71
+ successMessage: "Purchase order has been approved"
72
+ },
73
+ [N.enum.rejectDraft]: {
74
+ primaryActions: {
75
+ text: "Reject draft",
76
+ close: !0
77
+ },
78
+ title: "Reject draft?",
79
+ message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
80
+ successMessage: "Purchase order has been rejected"
81
+ },
82
+ [N.enum.submitRequest]: {
83
+ primaryActions: {
84
+ text: "Submit request",
85
+ close: !0
86
+ },
87
+ title: "Confirm draft?",
88
+ message: "Purchase order cannot be changed after confirm draft.",
89
+ successMessage: "Purchase order draft has been submitted"
90
+ },
91
+ [N.enum.completeReceive]: {
92
+ primaryActions: {
93
+ text: "Mark received",
94
+ close: !0
95
+ },
96
+ title: "Mark as received",
97
+ message: "Purchase order cannot be changed after it has complete receiving.",
98
+ successMessage: "Purchase order has been marked as received"
99
+ },
100
+ [N.enum.approveRequest]: {
101
+ primaryActions: {
102
+ text: "Accept request",
103
+ close: !0
104
+ },
105
+ title: "Accept request?",
106
+ message: "Transfer out request will be accepted.",
107
+ successMessage: "Transfer out request has been approved"
108
+ },
109
+ [N.enum.rejectRequest]: {
110
+ primaryActions: {
111
+ text: "Reject request",
112
+ close: !0,
113
+ variant: "destructive"
114
+ },
115
+ title: "Reject request?",
116
+ message: "Purchase order will be rejected.",
117
+ successMessage: "Purchase order has been rejected"
118
+ },
119
+ [N.enum.processRequest]: {
120
+ primaryActions: {
121
+ text: "Process request",
122
+ close: !0,
123
+ variant: "destructive"
124
+ },
125
+ title: "Process request?",
126
+ message: "Purchase order will be processed.",
127
+ successMessage: "Purchase order has been processed"
128
+ }
129
+ }, wr = { class: "p-4" }, Cr = {
130
+ key: 0,
131
+ class: "fm-typo-en-body-md-400 mb-3"
132
+ }, Dr = { class: "fm-typo-en-body-md-400" }, Pt = /* @__PURE__ */ De({
133
+ __name: "RejectDraftForm",
134
+ props: {
135
+ message: {},
136
+ confirm: { type: Function },
137
+ onChange: { type: Function }
138
+ },
139
+ setup(v) {
140
+ const r = v, { t: s } = at(), l = Q("");
141
+ Xe(l, (a) => {
142
+ var h;
143
+ (h = r.onChange) == null || h.call(r, a ?? "");
144
+ });
145
+ function f() {
146
+ l.value = "";
147
+ }
148
+ return (a, h) => (i(), g("div", wr, [
149
+ r.message ? (i(), g("div", Cr, p(r.message), 1)) : L("", !0),
150
+ e("label", Dr, p(m(s)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + p(m(s)("inventory.common.optional")) + ")", 1),
151
+ Lt(e("textarea", {
152
+ "onUpdate:modelValue": h[0] || (h[0] = (t) => l.value = t),
153
+ rows: "4",
154
+ class: "w-full mt-2 p-2 border rounded"
155
+ }, null, 512), [
156
+ [Ut, l.value]
157
+ ]),
158
+ e("div", { class: "mt-3 flex gap-2" }, [
159
+ e("button", {
160
+ type: "button",
161
+ class: "fm-btn fm-btn-tertiary",
162
+ onClick: f
163
+ }, "Clear")
164
+ ])
165
+ ]));
166
+ }
167
+ });
168
+ function ot(v) {
169
+ return nt.generatedPOReceivedMap({
170
+ purchaseOrder: v
171
+ });
172
+ }
173
+ function Rr(v) {
174
+ return nt.validatePOItemReceivedStatus({
175
+ dto: v
176
+ });
177
+ }
178
+ function ft(v) {
179
+ return nt.validatePOReceivedStatus({
180
+ receivedMap: v
181
+ });
182
+ }
183
+ function yt(v, r, s) {
184
+ if (!se.safeParse(v).success)
185
+ throw new Error(`Invalid purchase order status: ${v}`);
186
+ const l = se.parse(v);
187
+ return nt.orderStatusCombination({
188
+ status: l,
189
+ isPOPartialReceive: r,
190
+ isPOOverReceive: s
191
+ });
192
+ }
193
+ function Tt() {
194
+ const v = Fe(), r = Ge(), s = je();
195
+ async function l(a, h) {
196
+ const t = v.currentLocationDBName;
197
+ return a.doc.supplier.internal && a.operation === N.enum.confirmDraft && (a.operation = N.enum.submitRequest), await r.processPurchaseOrder(a, h || t);
198
+ }
199
+ async function f(a, h) {
200
+ const t = v.currentLocationDBName;
201
+ return await r.processPurchaseOrderV2(a, h || t);
202
+ }
203
+ return (a) => s.useOperatePurchaseOrderV2 ? f(a.operateV2, a.transferTo) : l(a.operate, a.transferTo);
204
+ }
205
+ function Ie(v) {
206
+ const r = Mt(v);
207
+ if (Array.isArray(r))
208
+ return r.map(Ie);
209
+ if (r !== null && typeof r == "object") {
210
+ const s = {};
211
+ for (const l in r)
212
+ Object.prototype.hasOwnProperty.call(r, l) && (s[l] = Ie(r[l]));
213
+ return s;
214
+ }
215
+ return r;
216
+ }
217
+ const dt = {
218
+ set: "set",
219
+ add: "add",
220
+ delete: "delete"
221
+ };
222
+ function Ct(v) {
223
+ return {
224
+ dbName: v.dbName,
225
+ type: v.type,
226
+ name: v.name,
227
+ acceptRequest: v.acceptRequest ?? !1,
228
+ doc: v.doc
229
+ };
230
+ }
231
+ function Dt(v, r, s, l, f) {
232
+ const a = Ie(v.suppliers ?? []), h = Ie(r.allLocations ?? []).map(Ct), t = r._currentLocation ? Ct(Ie(r._currentLocation)) : null, c = s.inventory ? [Ie(s.inventory)] : [], x = l.state.setting ? Ie(l.state.setting) : null, O = Ie(f.surcharges ?? []);
233
+ return {
234
+ suppliers: a,
235
+ locations: h,
236
+ currentLocation: t,
237
+ inventoryDoc: c,
238
+ netSuiteSetting: x,
239
+ surcharges: O
240
+ };
241
+ }
242
+ function It() {
243
+ const v = _r(), r = Fe(), s = Yt(), l = it(), f = Sr(), a = Dt(
244
+ v,
245
+ r,
246
+ s,
247
+ l,
248
+ f
249
+ ), h = bt(or({ env: a }));
250
+ h.value.setUsePartialUpdates(!0);
251
+ const t = bt(h.value.state()), c = (_) => {
252
+ t.value = _;
253
+ };
254
+ h.value.addListener(c);
255
+ const x = (_, $, R) => {
256
+ switch (_) {
257
+ case dt.set:
258
+ St(t.value, $, R);
259
+ break;
260
+ case dt.add:
261
+ Jt(t.value, $, R);
262
+ break;
263
+ case dt.delete:
264
+ Qt(t.value, $);
265
+ break;
266
+ default:
267
+ console.warn(`Unknown partial update operation: ${_}, falling back to 'set'`), St(t.value, $, R);
268
+ }
269
+ $ !== "remark" && $ !== "ref" && Bt(t);
270
+ };
271
+ h.value.addPartialListener(x);
272
+ function O() {
273
+ const _ = Dt(
274
+ v,
275
+ r,
276
+ s,
277
+ l,
278
+ f
279
+ );
280
+ h.value.updateFullEnv(_), t.value = h.value.state();
281
+ }
282
+ Xe(
283
+ [
284
+ () => v.suppliers,
285
+ () => r.allLocations,
286
+ () => r._currentLocation,
287
+ () => s.inventory,
288
+ () => l.state.setting,
289
+ () => f.surcharges
290
+ ],
291
+ () => {
292
+ O();
293
+ },
294
+ { deep: !0 }
295
+ ), jt(() => {
296
+ h.value.removeListener(c), h.value.removePartialListener(x);
297
+ });
298
+ function C(_) {
299
+ var $;
300
+ if (_ != null && _._id) {
301
+ h.value.loadPurchaseOrder(_);
302
+ return;
303
+ }
304
+ if (!je().mustUsePoTemplate) {
305
+ h.value.init();
306
+ return;
307
+ }
308
+ _ != null && _.template && (($ = _.templateDoc) != null && $.purchaseOrder) ? (_.items = _.templateDoc.purchaseOrder.items, h.value.initFromTemplate(_)) : h.value.initOutletToOutlet();
309
+ }
310
+ return {
311
+ controller: h,
312
+ state: t,
313
+ init: C
314
+ };
315
+ }
316
+ var vt = /* @__PURE__ */ ((v) => (v.RECEIVE_REQUEST = "receive/request", v.APPROVAL = "approval", v))(vt || {});
317
+ const We = Q(), mt = Q();
318
+ function Pa(v, r) {
319
+ const s = ct(), l = Fe(), f = je(), a = ur(), h = dr(), t = Q(!1), c = Ke(), x = Ge(), O = Or(), C = Q(new Array()), _ = Q(new Array()), $ = Q(
320
+ r != null && r.startDate && (r != null && r.endDate) ? r : br()
321
+ ), R = Y(() => {
322
+ const E = new Date($.value.startDate), B = new Date($.value.endDate);
323
+ return {
324
+ start: rr(E).toISOString(),
325
+ end: sr(B).toISOString()
326
+ };
327
+ }), D = Q(new Array()), S = Xt(), u = Q(null);
328
+ async function o(E) {
329
+ function B(F) {
330
+ const b = {
331
+ mode: wt.CREATE,
332
+ modelValue: E || void 0,
333
+ show: !0,
334
+ "onUpdate:show"(q) {
335
+ We.value.show = q;
336
+ },
337
+ templateId: F,
338
+ lastClosingDate: u.value
339
+ };
340
+ We.value = b;
341
+ }
342
+ let le;
343
+ f.mustUsePoTemplate && !(E != null && E.template) ? s.open({
344
+ title: "Create transfer",
345
+ message: "",
346
+ primaryActions: {
347
+ text: "Select a template",
348
+ close: !0
349
+ },
350
+ secondaryActions: {
351
+ text: "Outlet to Outlet",
352
+ variant: "secondary",
353
+ close: !0
354
+ }
355
+ }).onPrimary(async () => {
356
+ le = await a.getTemplateId(), le && B(le);
357
+ }).onSecondary(() => {
358
+ B(void 0);
359
+ }) : B(le);
360
+ }
361
+ function y(E) {
362
+ const B = {
363
+ mode: wt.UPDATE,
364
+ modelValue: $t(E),
365
+ show: !0,
366
+ "onUpdate:show"(le) {
367
+ We.value.show = le;
368
+ },
369
+ lastClosingDate: u.value
370
+ };
371
+ We.value = B;
372
+ }
373
+ async function I() {
374
+ C.value = [], _.value = [], t.value = !0;
375
+ try {
376
+ const E = await x.getPurchaseOrders(R.value);
377
+ C.value = E.sort((z, ce) => ce._id.localeCompare(z._id));
378
+ const B = E.flatMap((z) => z.shipmentIds || []).filter(Boolean), le = B.length > 0 ? await O.getShipmentsByIds(B) : [];
379
+ _.value = le;
380
+ const F = await S.readCurrentLocationLastClosing(!0), b = F == null ? void 0 : F._id;
381
+ b && (u.value = Et(b)), await f.awaitFeatureLoaded(() => f.mustUsePoTemplate) && await h.fetchTemplates();
382
+ const q = C.value.map((z) => {
383
+ var ce;
384
+ return ((ce = z.request) == null ? void 0 : ce.id) ?? "";
385
+ }).filter((z) => z);
386
+ D.value = await x.readRequestByIds(q);
387
+ } catch {
388
+ c.open({
389
+ title: "Something went wrong",
390
+ message: "Error at fetching purchase orders",
391
+ type: "error"
392
+ });
393
+ } finally {
394
+ t.value = !1;
395
+ }
396
+ }
397
+ async function V() {
398
+ D.value = [], t.value = !0;
399
+ try {
400
+ D.value = await x.readRequests(
401
+ void 0,
402
+ R.value.start,
403
+ R.value.end
404
+ ).then((E) => E.reverse());
405
+ } catch {
406
+ c.open({
407
+ title: "Something went wrong",
408
+ message: "Error at fetching purchase requests",
409
+ type: "error"
410
+ });
411
+ } finally {
412
+ t.value = !1;
413
+ }
414
+ }
415
+ function A() {
416
+ switch (v) {
417
+ case "receive/request":
418
+ return I();
419
+ case "approval":
420
+ return V();
421
+ }
422
+ }
423
+ function J(E, B) {
424
+ $.value = {
425
+ startDate: E,
426
+ endDate: B
427
+ }, A();
428
+ }
429
+ l.watchLocation(async (E) => {
430
+ if (!E) {
431
+ C.value = [];
432
+ return;
433
+ }
434
+ await A();
435
+ });
436
+ const H = Q(), W = Q(Math.random().toString());
437
+ async function ne(E, B) {
438
+ const le = Math.random().toString();
439
+ W.value = le, B ?? (B = D.value.computeFirst(
440
+ (z) => z.purchaseOrderId === E._id ? z : null
441
+ ) ?? void 0);
442
+ const F = v === "receive/request" ? l.currentLocation : B == null ? void 0 : B.to, b = v === "approval", q = {
443
+ poRequest: B,
444
+ purchaseOrder: {
445
+ ...E,
446
+ status: b && (B != null && B.rejectedAt) ? se.Enum.REJECT : E.status
447
+ },
448
+ transferTo: F == null ? void 0 : F.name,
449
+ transferToDbName: F == null ? void 0 : F.dbName,
450
+ show: !0,
451
+ canResubmit: !1,
452
+ canApprove: b,
453
+ "onUpdate:show"(z) {
454
+ H.value.show = z;
455
+ },
456
+ scope: v,
457
+ receivedMap: ot(E) ?? {},
458
+ shipments: _.value
459
+ };
460
+ H.value = q;
461
+ }
462
+ async function ae(E, B, le, F, b) {
463
+ const q = Tt();
464
+ t.value = !0;
465
+ try {
466
+ await q({
467
+ operate: {
468
+ operation: B,
469
+ doc: E,
470
+ options: (
471
+ // auto receive for supplier to warehouse
472
+ (B === N.enum.confirmDraft || // auto receive for warehouse to warehouse
473
+ B === N.enum.completeReceive) && f.autoReceiveWarehouse ? {
474
+ autoReceive: !0
475
+ } : void 0
476
+ )
477
+ },
478
+ operateV2: {
479
+ _id: E._id,
480
+ _rev: E._rev ?? "",
481
+ action: B,
482
+ payloads: b ?? []
483
+ },
484
+ transferTo: F
485
+ }), await new Promise((Re) => setTimeout(Re, 1e3));
486
+ const ce = Fe().currentLocationDBName.startsWith("restaurant_");
487
+ B === N.enum.confirmDraft && E.effectiveAt && ce ? c.open({
488
+ title: "Success",
489
+ message: `${le}. The backdate will be reflected once your POS has received this change.`,
490
+ type: "success"
491
+ }) : c.open({
492
+ title: "Success",
493
+ message: le,
494
+ type: "success"
495
+ });
496
+ } catch (z) {
497
+ c.open({
498
+ title: "Something went wrong",
499
+ message: "Please try again.",
500
+ type: "error"
501
+ }), console.error("Error when submitting PO operation", B, E, z);
502
+ } finally {
503
+ t.value = !1, A();
504
+ }
505
+ }
506
+ async function ke(E, B, le) {
507
+ const F = Ft[B];
508
+ if (!F) {
509
+ c.open({
510
+ title: "Something went wrong",
511
+ message: `Cannot process order: ${ht(B)}`,
512
+ type: "error"
513
+ });
514
+ return;
515
+ }
516
+ const { successMessage: b, ...q } = F;
517
+ if (B === N.enum.rejectDraft) {
518
+ let Re = "";
519
+ s.open({
520
+ title: q.title,
521
+ message: q.message,
522
+ primaryActions: q.primaryActions,
523
+ contentComponent: Pt,
524
+ contentComponentProps: {
525
+ message: q.message,
526
+ onChange: (Se) => Re = Se
527
+ }
528
+ }).onPrimary(() => {
529
+ const Se = [];
530
+ Se.push({
531
+ action: "rejectDraft",
532
+ payload: {
533
+ rejectReason: Re
534
+ }
535
+ }), ae(E, B, b, le, Se);
536
+ });
537
+ return;
538
+ }
539
+ const z = [], ce = It();
540
+ ce.init(E), B === N.enum.confirmDraft && z.push({
541
+ action: "confirmDraft",
542
+ payload: ce.controller.value.toConfirmDraftData(Oe())
543
+ }), s.open({
544
+ title: q.title,
545
+ message: q.message,
546
+ primaryActions: q.primaryActions
547
+ }).onPrimary(() => {
548
+ ae(E, B, b, le, z);
549
+ });
550
+ }
551
+ async function qe() {
552
+ s.open({
553
+ title: "Upload Transfer",
554
+ primaryActions: {
555
+ text: "Xilnex transfer note",
556
+ close: !0
557
+ },
558
+ secondaryActions: {
559
+ text: "Cancel",
560
+ close: !0
561
+ }
562
+ }).onPrimary(() => {
563
+ const E = {
564
+ show: !0,
565
+ "onUpdate:show"(B) {
566
+ mt.value.show = B;
567
+ }
568
+ };
569
+ mt.value = E;
570
+ });
571
+ }
572
+ return {
573
+ purchaseOrders: C,
574
+ shipments: _,
575
+ purchaseRequests: D,
576
+ updateDateRange: J,
577
+ fetchData: A,
578
+ loading: t,
579
+ transferDialogProps: We,
580
+ promptCreateTransferDialog: o,
581
+ promptUpdateTransferDialog: y,
582
+ transferDetailsProps: H,
583
+ promptShowTransferDetails: ne,
584
+ submitAction: ke,
585
+ xilnexImportDialogProps: mt,
586
+ promptUploadTransferDialog: qe
587
+ };
588
+ }
589
+ function $r(v, r) {
590
+ return r.reduce(
591
+ (l, f) => {
592
+ const a = f.received.find((h) => h.sku._id === v._id);
593
+ return a && (l = Zt(l, a.amount)), l;
594
+ },
595
+ tr.toPrecision(er(0), v.unit.precision)
596
+ );
597
+ }
598
+ function kr(v) {
599
+ const { po: r, currentLocation: s, business: l, fulfilling: f, por: a } = v, { name: h, address: t, regNo: c, legalName: x } = s.doc.profile, O = {
600
+ name: h,
601
+ legalName: x,
602
+ registrationNumber: c,
603
+ line1: t == null ? void 0 : t.line1,
604
+ line2: t == null ? void 0 : t.line2,
605
+ postcode: t == null ? void 0 : t.postcode,
606
+ city: t == null ? void 0 : t.city,
607
+ state: t == null ? void 0 : t.state,
608
+ country: t == null ? void 0 : t.country
609
+ }, C = {
610
+ name: r.supplier.name,
611
+ phoneNumber: r.supplier.phoneNumber,
612
+ registrationNumber: r.supplier.registrationNumber,
613
+ line1: r.supplier.address.line1,
614
+ line2: r.supplier.address.line2,
615
+ postcode: r.supplier.address.postcode,
616
+ city: r.supplier.address.city,
617
+ state: r.supplier.address.state,
618
+ country: r.supplier.address.country
619
+ }, _ = r.items.map((V) => {
620
+ const { sku: A, measurement: J } = V, H = _e(
621
+ $r(V.sku, r.deliveryOrder || []),
622
+ !1
623
+ );
624
+ return {
625
+ code: A.code,
626
+ description: A.name,
627
+ quantity: _e(V.quantity, !1),
628
+ unit: (J == null ? void 0 : J.abbrev) || A.unit.abbrev,
629
+ received: H,
630
+ cost: V.totalCost ? `${V.totalCost.currency} ${nr.toFormatString({
631
+ value: V.totalCost
632
+ })}` : void 0
633
+ };
634
+ }), $ = r.deliveryOrder.map((V) => ({
635
+ createdAt: At(new Date(V.createdAt)),
636
+ ref: V.deliveryOrderNumber,
637
+ remark: V.remark || "",
638
+ items: V.received.map((A) => {
639
+ var J;
640
+ return {
641
+ code: A.sku.code,
642
+ description: A.sku.name,
643
+ quantity: _e(A.amount),
644
+ unit: ((J = A.measurement) == null ? void 0 : J.abbrev) || A.sku.unit.abbrev
645
+ };
646
+ })
647
+ })), R = [
648
+ // Production
649
+ "67ca5d2c80bd0e001c5bf5bc",
650
+ // Dev
651
+ "6880b36a3054c5001db19218"
652
+ ];
653
+ let D = "Inventory Receive Note";
654
+ if (r.supplier.internal ? (D = "Inventory Transfer Note", R.includes((l == null ? void 0 : l._id) || "") && (D = "Stock Request")) : D = "Purchase Order", a) {
655
+ const V = a.from.dbName;
656
+ s.dbName === V || (D = "Inventory Receive Note");
657
+ }
658
+ const u = {
659
+ title: D,
660
+ businessName: l == null ? void 0 : l.name,
661
+ logo: l == null ? void 0 : l.thumbnail,
662
+ orderNumber: r.seqNumber.toString(),
663
+ createdAt: et(r._id),
664
+ ref: r.ref || "",
665
+ remark: r.remark || "",
666
+ buyer: O,
667
+ supplier: C,
668
+ items: _,
669
+ status: r.status,
670
+ deliveryOrders: $
671
+ }, o = new URL(window.location.href), y = f && (r.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
672
+ o.pathname = o.hostname.includes("portal.feedme") ? `/inventory/${y}` : `/${y}`;
673
+ const I = ar.compressToEncodedURIComponent(JSON.stringify(u));
674
+ o.searchParams.append("data", I), window.open(o.href, "_blank", "noreferrer");
675
+ }
676
+ const Te = {
677
+ submitRequest: {
678
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
679
+ color: "text-fm-color-typo-primary",
680
+ value: N.enum.submitRequest
681
+ },
682
+ confirmDraft: {
683
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
684
+ color: "text-fm-color-typo-primary",
685
+ value: N.enum.confirmDraft
686
+ },
687
+ cancelDraft: {
688
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
689
+ color: "text-fm-color-typo-error",
690
+ value: N.enum.cancelDraft
691
+ },
692
+ approveRequest: {
693
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
694
+ color: "text-fm-color-typo-primary",
695
+ value: N.enum.approveRequest
696
+ },
697
+ rejectRequest: {
698
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
699
+ color: "text-fm-color-typo-error",
700
+ value: N.enum.rejectRequest
701
+ },
702
+ processRequest: {
703
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
704
+ color: "text-fm-color-typo-primary",
705
+ value: N.enum.processRequest
706
+ },
707
+ receiveStock: {
708
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
709
+ color: "text-fm-color-typo-primary",
710
+ value: N.enum.receiveStock
711
+ },
712
+ completeReceive: {
713
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
714
+ color: "text-fm-color-typo-primary",
715
+ value: N.enum.completeReceive
716
+ },
717
+ closeRequest: {
718
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
719
+ color: "system-error-300",
720
+ value: N.enum.closeRequest
721
+ },
722
+ approveDraft: {
723
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
724
+ color: "text-fm-color-typo-primary",
725
+ value: N.enum.approveDraft
726
+ },
727
+ rejectDraft: {
728
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
729
+ color: "text-fm-color-typo-error",
730
+ value: N.enum.rejectDraft
731
+ },
732
+ returnStock: {
733
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
734
+ color: "text-fm-color-typo-primary",
735
+ value: N.enum.returnStock
736
+ }
737
+ };
738
+ function qt() {
739
+ const v = je();
740
+ return {
741
+ ableToMarkReceived(r) {
742
+ if (!r || r.status !== se.enum.RECEIVING || v.useOperatePurchaseOrderV2) return !1;
743
+ const l = Fe().currentLocationDBName;
744
+ return `${r.supplier.internal}_${r.supplier._id}` !== l;
745
+ },
746
+ ableToMarkApproved(r) {
747
+ return !(!r || (r == null ? void 0 : r.status) !== se.enum.REQUESTING);
748
+ },
749
+ ableToCreateFulfillment(r, s) {
750
+ var a, h;
751
+ if (!v.acceptRequireFulfillment || !r || !s || r.status !== se.enum.PROCESSING || !s.processedAt)
752
+ return !1;
753
+ const l = (a = s == null ? void 0 : s.from) == null ? void 0 : a.dbName, f = (h = s == null ? void 0 : s.to) == null ? void 0 : h.dbName;
754
+ return !(l.startsWith("restaurant_") && f.startsWith("restaurant_"));
755
+ }
756
+ };
757
+ }
758
+ function Vt() {
759
+ const v = lt(), r = Q(!1);
760
+ return Xe(() => v.sessionUser.value, async () => {
761
+ try {
762
+ const l = await lr({
763
+ sessionUser: v.sessionUser.value,
764
+ validationManifest: {
765
+ requiredCaslPermissions: [
766
+ {
767
+ action: xt.Action.manage,
768
+ subject: xt.Subject.Business.orderDraft
769
+ }
770
+ ]
771
+ }
772
+ });
773
+ r.value = (l == null ? void 0 : l.canAccess) ?? !1;
774
+ } catch (l) {
775
+ console.error("Permission validation failed:", l), r.value = !1;
776
+ }
777
+ }, { immediate: !0 }), {
778
+ hasOrderDraftPermission: zt(r)
779
+ };
780
+ }
781
+ function Ta(v, r, s) {
782
+ const l = Fe(), f = it(), a = lt(), h = qt(), { t } = at(), { hasOrderDraftPermission: c } = Vt();
783
+ function x(D) {
784
+ switch (D.status) {
785
+ case "DRAFT":
786
+ return [
787
+ be[pe.Update],
788
+ be[pe.Details],
789
+ D.supplier.internal === "restaurant" || D.supplier.internal === "warehouse" ? Te[N.enum.submitRequest] : Te[N.enum.confirmDraft],
790
+ Te[N.enum.cancelDraft]
791
+ ];
792
+ case "RECEIVING":
793
+ return [
794
+ ...h.ableToMarkReceived(D) ? [Te[N.enum.completeReceive]] : [],
795
+ be[pe.Details],
796
+ be[pe.Print]
797
+ ];
798
+ case "PENDING_APPROVAL": {
799
+ const u = [
800
+ be[pe.Details]
801
+ ];
802
+ return c.value && u.push(
803
+ be[pe.Update],
804
+ Te[N.enum.approveDraft],
805
+ Te[N.enum.rejectDraft]
806
+ ), u;
807
+ }
808
+ case "REQUESTING":
809
+ return v === "receive/request" ? [be[pe.Details], be[pe.Print]] : [
810
+ Te[N.enum.approveRequest],
811
+ Te[N.enum.rejectRequest],
812
+ be[pe.Details]
813
+ // DefaultRowActions[RowActionEnum.Print]
814
+ ];
815
+ case "PROCESSING":
816
+ return [be[pe.Details], be[pe.Print]];
817
+ case "COMPLETE":
818
+ case "CANCEL":
819
+ default:
820
+ return [be[pe.Details], be[pe.Print]];
821
+ }
822
+ }
823
+ function O(D) {
824
+ return Object.values(N.enum).includes(D);
825
+ }
826
+ async function C(D, S, u) {
827
+ var y, I, V, A, J, H;
828
+ const o = $t(S);
829
+ if (D === pe.Print) {
830
+ const W = (u == null ? void 0 : u.toInventoryLocation) ?? l.currentLocation;
831
+ if (W.type === "restaurant") {
832
+ const ne = l.locationRestaurantFromCore(W.doc._id);
833
+ ne !== null && (W.doc = ne);
834
+ }
835
+ ((y = u == null ? void 0 : u.netSuite) != null && y.refNo || (I = o.netSuite) != null && I.refNo) && (o.ref = [((V = u == null ? void 0 : u.netSuite) == null ? void 0 : V.refNo) || ((A = o.netSuite) == null ? void 0 : A.refNo)].filter((ne) => ne).join(" ")), kr({
836
+ po: o,
837
+ currentLocation: W,
838
+ business: a.currentBusiness.value,
839
+ fulfilling: v === "approval",
840
+ por: u
841
+ });
842
+ return;
843
+ }
844
+ if (D === pe.Details) {
845
+ r.promptShowTransferDetails(o, u);
846
+ return;
847
+ }
848
+ if (D === pe.Update) {
849
+ (J = r.promptUpdateTransferDialog) == null || J.call(r, o);
850
+ return;
851
+ }
852
+ if (O(D)) {
853
+ r.submitAction(S, D, (H = u == null ? void 0 : u.to) == null ? void 0 : H.dbName);
854
+ return;
855
+ }
856
+ }
857
+ function _() {
858
+ var S;
859
+ const D = [
860
+ {
861
+ accessorKey: "seqNumber",
862
+ header: () => t("inventory.transfer.table.seqNo"),
863
+ enableSorting: !0,
864
+ size: 80,
865
+ sortUndefined: "last"
866
+ },
867
+ {
868
+ accessorKey: "_id",
869
+ header: () => t("inventory.transfer.table.createdAt"),
870
+ cell(u) {
871
+ return et(`${u.getValue()}`);
872
+ },
873
+ enableSorting: !0
874
+ },
875
+ {
876
+ accessorKey: "supplier.name",
877
+ header: () => t("inventory.transfer.table.transferFrom"),
878
+ enableSorting: !0,
879
+ size: 200
880
+ },
881
+ {
882
+ accessorKey: "items.length",
883
+ header: () => t("inventory.transfer.table.noOfItems"),
884
+ cell: (u) => {
885
+ const o = u.row.original.version || "1", y = u.getValue();
886
+ return M("div", { class: "flex items-center gap-2" }, [
887
+ y,
888
+ o !== "1" ? M(
889
+ "div",
890
+ { class: "py-3" },
891
+ M(
892
+ Me,
893
+ M(
894
+ "div",
895
+ {
896
+ class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
897
+ },
898
+ `v${o}`
899
+ )
900
+ )
901
+ ) : null
902
+ ]);
903
+ },
904
+ enableSorting: !1,
905
+ meta: {
906
+ width: "10rem"
907
+ }
908
+ },
909
+ {
910
+ accessorKey: "ref",
911
+ header: () => t("inventory.transfer.table.reference"),
912
+ enableSorting: !1,
913
+ size: "auto"
914
+ },
915
+ ...(S = a.sessionUser.value) != null && S.role.isAdmin ? [
916
+ {
917
+ id: "statusForAdmin",
918
+ header: () => M(Me, {}, () => `${t("inventory.transfer.table.status")}`),
919
+ cell(u) {
920
+ return u.row.original.status;
921
+ },
922
+ enableSorting: !0,
923
+ size: 200
924
+ }
925
+ ] : [],
926
+ {
927
+ accessorKey: "status",
928
+ header: () => t("inventory.transfer.table.status"),
929
+ cell(u) {
930
+ const o = u.getValue(), y = ot(u.row.original), { partial: I, over: V } = ft(y), A = yt(o ?? "", I, V);
931
+ let J = t(`inventory.transfer.status.${A}`), H = `${o ?? ""}`.toLocaleLowerCase("en-us");
932
+ A === se.enum.CLOSE && (J = `${t(`inventory.transfer.status.${se.enum.COMPLETE}`)}`), A === "PARTIAL_RECEIVED" && H === se.enum.PROCESSING.toLocaleLowerCase("en-us") && (H = se.enum.RECEIVING.toLocaleLowerCase("en-us"));
933
+ let W = null;
934
+ const ne = s.value.find((ae) => ae.ref === u.row.original._id);
935
+ if (ne != null && ne.milestones && ne.milestones.length > 0) {
936
+ const ae = ne.milestones[ne.milestones.length - 1];
937
+ if (ae.estimatedTime) {
938
+ const ke = new Date(ae.estimatedTime), qe = ke.getDate().toString().padStart(2, "0");
939
+ W = `${ke.toLocaleString("en-US", { month: "short" })} ${qe}`;
940
+ }
941
+ }
942
+ return M(
943
+ "div",
944
+ {
945
+ class: "flex"
946
+ },
947
+ [
948
+ M(
949
+ "div",
950
+ { class: "flex items-center" },
951
+ M(
952
+ "div",
953
+ {
954
+ class: [
955
+ "fm-status-badge",
956
+ `fm-status-badge-${H}`,
957
+ V && "fm-status-badge-error"
958
+ ].filter(Boolean).join(" ")
959
+ },
960
+ `${J}`
961
+ )
962
+ ),
963
+ ...W ? [
964
+ M(
965
+ "div",
966
+ {
967
+ class: "flex items-center gap-1 ml-2"
968
+ },
969
+ [
970
+ M(st.FmIcon, {
971
+ name: "local_shipping",
972
+ size: "md",
973
+ color: "neutral-gray-400"
974
+ }),
975
+ M(
976
+ "span",
977
+ { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
978
+ W
979
+ )
980
+ ]
981
+ )
982
+ ] : []
983
+ ]
984
+ );
985
+ },
986
+ enableSorting: !0,
987
+ size: 150
988
+ },
989
+ {
990
+ id: "action",
991
+ cell(u) {
992
+ const o = u.row.original, y = x(o);
993
+ return _t(y, (I) => C(I, o));
994
+ },
995
+ enableSorting: !1,
996
+ size: 40,
997
+ meta: {
998
+ cellClass: "",
999
+ headerClass: ""
1000
+ }
1001
+ }
1002
+ ];
1003
+ if (f.isEnabled) {
1004
+ const u = [
1005
+ {
1006
+ id: "netsuiteTransferOrder",
1007
+ accessorFn: (o) => {
1008
+ var y;
1009
+ return (y = o.netSuite) != null && y.id ? `${o.netSuite.refNo} (${o.netSuite.id})` : "N/A";
1010
+ },
1011
+ header: () => "NetSuite Order (ID)",
1012
+ cell(o) {
1013
+ var I;
1014
+ const y = o.row.original;
1015
+ return (I = y.netSuite) != null && I.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
1016
+ },
1017
+ enableSorting: !1,
1018
+ size: 200,
1019
+ meta: {
1020
+ cellClass: "",
1021
+ headerClass: ""
1022
+ }
1023
+ },
1024
+ {
1025
+ id: "netsuiteTransactionNumber",
1026
+ accessorFn: (o) => {
1027
+ var y, I;
1028
+ return ((I = (y = o.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : I.transactionnumber) ?? "N/A";
1029
+ },
1030
+ header: () => "NetSuite Transaction No.",
1031
+ cell(o) {
1032
+ var I, V;
1033
+ return ((V = (I = o.row.original.netSuite) == null ? void 0 : I.additionalInfo) == null ? void 0 : V.transactionnumber) ?? "N/A";
1034
+ },
1035
+ enableSorting: !1,
1036
+ size: 200,
1037
+ meta: {
1038
+ cellClass: "",
1039
+ headerClass: ""
1040
+ }
1041
+ }
1042
+ ];
1043
+ D.splice(D.length - 1, 0, ...u);
1044
+ }
1045
+ return D;
1046
+ }
1047
+ function $() {
1048
+ var S;
1049
+ const D = [
1050
+ {
1051
+ accessorKey: "purchaseOrder.seqNumber",
1052
+ header: () => t("inventory.transfer.table.seqNo"),
1053
+ enableSorting: !0,
1054
+ size: 80,
1055
+ sortUndefined: "last"
1056
+ },
1057
+ {
1058
+ accessorKey: "purchaseOrder._id",
1059
+ header: () => t("inventory.transfer.table.createdAt"),
1060
+ cell(u) {
1061
+ return et(`${u.getValue()}`);
1062
+ },
1063
+ enableSorting: !0
1064
+ },
1065
+ {
1066
+ accessorKey: "to.name",
1067
+ header: () => t("inventory.transfer.table.transferTo"),
1068
+ enableSorting: !1,
1069
+ size: 200
1070
+ },
1071
+ {
1072
+ accessorKey: "purchaseOrder.items.length",
1073
+ header: () => t("inventory.transfer.table.noOfItems"),
1074
+ enableSorting: !1
1075
+ },
1076
+ {
1077
+ accessorKey: "purchaseOrder.ref",
1078
+ header: () => t("inventory.transfer.table.reference"),
1079
+ enableSorting: !1,
1080
+ size: "auto"
1081
+ },
1082
+ ...(S = a.sessionUser.value) != null && S.role.isAdmin ? [
1083
+ {
1084
+ id: "statusForAdmin",
1085
+ header: () => M(Me, {}, () => `${t("inventory.transfer.table.status")}`),
1086
+ cell(u) {
1087
+ return u.row.original.status;
1088
+ },
1089
+ enableSorting: !0,
1090
+ size: 200
1091
+ }
1092
+ ] : [],
1093
+ {
1094
+ accessorKey: "purchaseOrder.status",
1095
+ header: () => t("inventory.transfer.table.status"),
1096
+ cell(u) {
1097
+ const o = u.row.original, y = u.getValue();
1098
+ if (!o.purchaseOrder)
1099
+ return M(st.FmChip, {
1100
+ label: "N/A",
1101
+ compact: !0
1102
+ });
1103
+ const I = ot(o.purchaseOrder), { partial: V, over: A } = ft(I), J = yt(y ?? "", V, A);
1104
+ let H = t(`inventory.transfer.status.${J}`), W = `${y ?? ""}`.toLocaleLowerCase("en-us");
1105
+ return J === se.enum.CLOSE && (H = `${t(`inventory.transfer.status.${se.enum.COMPLETE}`)}`), J === "PARTIAL_RECEIVED" && W === se.enum.PROCESSING.toLocaleLowerCase("en-us") && (W = se.enum.RECEIVING.toLocaleLowerCase("en-us")), o.rejectedAt && (H = t("inventory.transfer.status.REJECT"), W = se.enum.REJECT.toLocaleLowerCase("en-us")), M(
1106
+ "div",
1107
+ {
1108
+ class: "flex"
1109
+ },
1110
+ M(
1111
+ "div",
1112
+ {
1113
+ class: [
1114
+ "fm-status-badge",
1115
+ `fm-status-badge-${W}`,
1116
+ A && "fm-status-badge-error"
1117
+ ].filter(Boolean).join(" ")
1118
+ },
1119
+ `${H}`
1120
+ )
1121
+ );
1122
+ },
1123
+ enableSorting: !0
1124
+ },
1125
+ {
1126
+ id: "action",
1127
+ cell(u) {
1128
+ const o = u.row.original, I = (o.purchaseOrder ? x(o.purchaseOrder) : []).map((V) => V.value === pe.Print ? {
1129
+ ...V,
1130
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1131
+ } : V);
1132
+ return _t(
1133
+ I,
1134
+ (V) => o.purchaseOrder ? C(V, o.purchaseOrder, o) : void 0
1135
+ );
1136
+ },
1137
+ enableSorting: !1,
1138
+ size: 40,
1139
+ meta: {
1140
+ cellClass: "",
1141
+ headerClass: ""
1142
+ }
1143
+ }
1144
+ ];
1145
+ if (f.isEnabled) {
1146
+ const u = [
1147
+ {
1148
+ id: "netsuiteTransferOrder",
1149
+ accessorFn: (o) => {
1150
+ var y;
1151
+ return (y = o.netSuite) != null && y.id ? `${o.netSuite.refNo} (${o.netSuite.id})` : "N/A";
1152
+ },
1153
+ header: () => "NetSuite Order (ID)",
1154
+ cell(o) {
1155
+ var I;
1156
+ const y = o.row.original;
1157
+ return (I = y.netSuite) != null && I.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
1158
+ },
1159
+ enableSorting: !1,
1160
+ size: 200,
1161
+ meta: {
1162
+ cellClass: "",
1163
+ headerClass: ""
1164
+ }
1165
+ },
1166
+ {
1167
+ id: "netsuiteTransactionNumber",
1168
+ accessorFn: (o) => {
1169
+ var y, I;
1170
+ return ((I = (y = o.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : I.transactionnumber) ?? "N/A";
1171
+ },
1172
+ header: () => "NetSuite Transaction No.",
1173
+ cell(o) {
1174
+ var I, V;
1175
+ return ((V = (I = o.row.original.netSuite) == null ? void 0 : I.additionalInfo) == null ? void 0 : V.transactionnumber) ?? "N/A";
1176
+ },
1177
+ enableSorting: !1,
1178
+ size: 200,
1179
+ meta: {
1180
+ cellClass: "",
1181
+ headerClass: ""
1182
+ }
1183
+ }
1184
+ ];
1185
+ D.splice(D.length - 2, 0, ...u);
1186
+ }
1187
+ return D;
1188
+ }
1189
+ return {
1190
+ columnDefs: Y(() => v === "receive/request" ? _() : $())
1191
+ };
1192
+ }
1193
+ const Ar = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Nr = { class: "flex flex-col gap-8" }, Fr = { class: "flex w-full justify-end gap-16" }, Pr = /* @__PURE__ */ De({
1194
+ __name: "FulfillmentForm",
1195
+ props: {
1196
+ purchaseOrder: {},
1197
+ confirm: { type: Function }
1198
+ },
1199
+ emits: ["update:show"],
1200
+ setup(v, { emit: r }) {
1201
+ const s = v, l = Kt({
1202
+ id: "",
1203
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1204
+ items: []
1205
+ }), f = Q(), a = r;
1206
+ Rt(() => {
1207
+ s.purchaseOrder && (l.items = s.purchaseOrder.items.map((t) => ({
1208
+ id: t.id,
1209
+ sku: t.sku,
1210
+ measurement: t.measurement,
1211
+ amount: t.quantity ?? { amount: 1, precision: 0 }
1212
+ })));
1213
+ });
1214
+ const h = Y(() => l.items.length <= 10);
1215
+ return (t, c) => {
1216
+ const x = G("FmTable"), O = G("FmButton"), C = G("FmForm");
1217
+ return i(), ie(C, {
1218
+ ref_key: "formRef",
1219
+ ref: f,
1220
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1221
+ onValidationFailed: console.log,
1222
+ onValidationSuccess: c[1] || (c[1] = () => s.confirm(l))
1223
+ }, {
1224
+ default: te(() => [
1225
+ c[2] || (c[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1226
+ e("div", Ar, [
1227
+ e("div", Nr, [
1228
+ T(x, {
1229
+ "column-defs": [
1230
+ {
1231
+ header: "Code",
1232
+ cell: (_) => {
1233
+ const $ = s.purchaseOrder.items.find((R) => R.id === _.row.original.id || R.sku._id === _.row.original.sku._id);
1234
+ return M(
1235
+ m(st).FmTooltip,
1236
+ {
1237
+ content: $.code,
1238
+ placement: "top",
1239
+ variant: "plain",
1240
+ zIndex: 50
1241
+ },
1242
+ M(
1243
+ "span",
1244
+ {
1245
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1246
+ },
1247
+ $.code
1248
+ )
1249
+ );
1250
+ }
1251
+ },
1252
+ {
1253
+ header: "Name",
1254
+ cell: (_) => {
1255
+ const $ = s.purchaseOrder.items.find((R) => R.id === _.row.original.id || R.sku._id === _.row.original.sku._id);
1256
+ return M(
1257
+ m(st).FmTooltip,
1258
+ {
1259
+ content: $.name,
1260
+ placement: "top",
1261
+ variant: "plain",
1262
+ zIndex: 50
1263
+ },
1264
+ M(
1265
+ "span",
1266
+ {
1267
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
1268
+ },
1269
+ $.name
1270
+ )
1271
+ );
1272
+ }
1273
+ },
1274
+ {
1275
+ header: "Amount",
1276
+ cell: (_) => {
1277
+ const $ = _.row.original, R = s.purchaseOrder.items.find((S) => S.id === $.id || S.sku._id === $.sku._id), D = $.amount ?? {
1278
+ amount: 1,
1279
+ precision: 0
1280
+ };
1281
+ return M(fr, {
1282
+ style: {
1283
+ flex: "1 1 0%"
1284
+ },
1285
+ modelValue: {
1286
+ amount: D,
1287
+ measurement: $.measurement ?? null
1288
+ },
1289
+ key: $.id ?? $.sku._id,
1290
+ unit: $.sku.unit,
1291
+ "onUpdate:modelValue": (S) => {
1292
+ if (!S) return;
1293
+ const u = l.items.find((o) => o.id === $.id || o.sku._id === $.sku._id);
1294
+ u && (u.amount = S.amount);
1295
+ },
1296
+ disableUnit: !0,
1297
+ rules: [
1298
+ m(yr)(
1299
+ +m(_e)({ amount: 0, precision: 0 })
1300
+ ),
1301
+ m(vr)(+m(_e)(R.quantity))
1302
+ ],
1303
+ applyDefaultRules: !0
1304
+ });
1305
+ }
1306
+ }
1307
+ ],
1308
+ "row-data": l.items,
1309
+ "hide-footer": h.value
1310
+ }, null, 8, ["column-defs", "row-data", "hide-footer"])
1311
+ ])
1312
+ ]),
1313
+ e("div", Fr, [
1314
+ T(O, {
1315
+ class: "px-16",
1316
+ label: "Confirm",
1317
+ size: "md",
1318
+ variant: "primary",
1319
+ type: "submit"
1320
+ }),
1321
+ T(O, {
1322
+ class: "px-16",
1323
+ label: "Cancel",
1324
+ size: "md",
1325
+ variant: "secondary",
1326
+ onClick: c[0] || (c[0] = () => a("update:show", !1))
1327
+ })
1328
+ ])
1329
+ ]),
1330
+ _: 1
1331
+ }, 8, ["onValidationFailed"]);
1332
+ };
1333
+ }
1334
+ }), pt = {
1335
+ submitRequest: {
1336
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1337
+ color: "primary",
1338
+ buttonVariant: xe.Primary
1339
+ },
1340
+ confirmDraft: {
1341
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1342
+ color: "primary",
1343
+ buttonVariant: xe.Primary
1344
+ },
1345
+ cancelDraft: {
1346
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1347
+ color: "system-error-300",
1348
+ buttonVariant: xe.Destructive
1349
+ },
1350
+ approveDraft: {
1351
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1352
+ color: "primary",
1353
+ buttonVariant: xe.Primary
1354
+ },
1355
+ rejectDraft: {
1356
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1357
+ color: "system-error-300",
1358
+ buttonVariant: xe.Destructive
1359
+ },
1360
+ approveRequest: {
1361
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1362
+ color: "primary",
1363
+ buttonVariant: xe.Primary
1364
+ },
1365
+ processRequest: {
1366
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1367
+ color: "primary",
1368
+ buttonVariant: xe.Primary
1369
+ },
1370
+ receiveStock: {
1371
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1372
+ color: "primary",
1373
+ buttonVariant: xe.Primary,
1374
+ available: !1
1375
+ },
1376
+ completeReceive: {
1377
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1378
+ color: "primary",
1379
+ buttonVariant: xe.Plain
1380
+ },
1381
+ rejectRequest: {
1382
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1383
+ color: "system-error-300",
1384
+ buttonVariant: xe.Destructive
1385
+ },
1386
+ closeRequest: {
1387
+ translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1388
+ color: "system-error-300",
1389
+ buttonVariant: xe.Destructive,
1390
+ available: !1
1391
+ },
1392
+ returnStock: {
1393
+ translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1394
+ color: "primary",
1395
+ buttonVariant: xe.Primary,
1396
+ available: !1
1397
+ }
1398
+ }, Tr = { class: "flex flex-row-reverse" }, Ir = /* @__PURE__ */ De({
1399
+ __name: "NetSuiteSync",
1400
+ props: {
1401
+ poRequest: {},
1402
+ purchaseOrder: {},
1403
+ isTransferBetweenOutlets: { type: Boolean },
1404
+ scope: {}
1405
+ },
1406
+ setup(v) {
1407
+ const r = v, s = it(), l = Ke(), f = ct(), a = Q(!1);
1408
+ Y(() => {
1409
+ var O, C, _, $;
1410
+ let t = !0;
1411
+ s.isEnabled || (t = !1);
1412
+ const c = r.purchaseOrder, x = r.poRequest;
1413
+ return c && ((O = c == null ? void 0 : c.supplier) != null && O.internal ? (!x && c.status == se.enum.DRAFT && (t = !1), x && !((C = x == null ? void 0 : x.netSuite) != null && C.id) && (t = !1), r.isTransferBetweenOutlets && (t = !1)) : ((c == null ? void 0 : c.status) !== se.enum.REQUESTING && c.supplier.internal && (t = !1), !x && !((_ = c == null ? void 0 : c.netSuite) != null && _.id) && (t = !1), !x && (($ = c == null ? void 0 : c.netSuite) != null && $.id) && (c == null ? void 0 : c.status) == se.enum.REQUESTING && (t = !1))), t;
1414
+ });
1415
+ async function h() {
1416
+ a.value || f.open({
1417
+ title: "Sync with NetSuite",
1418
+ contentComponent: M("div", [
1419
+ M("p", "Are you sure you want to sync now?"),
1420
+ M("br"),
1421
+ M(
1422
+ "p",
1423
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1424
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
1425
+ )
1426
+ ]),
1427
+ primaryActions: {
1428
+ text: "Sync",
1429
+ close: !0,
1430
+ variant: "destructive"
1431
+ },
1432
+ secondaryActions: { text: "Not now", close: !0 }
1433
+ }).onPrimary(async () => {
1434
+ var t, c, x;
1435
+ try {
1436
+ a.value = !0;
1437
+ const O = ((t = r.purchaseOrder) == null ? void 0 : t._id) || ((c = r.poRequest) == null ? void 0 : c.purchaseOrderId) || "", C = (x = r.poRequest) == null ? void 0 : x.to.dbName;
1438
+ await s.syncPurchaseOrder(
1439
+ O,
1440
+ r.scope === "approval" ? C : void 0
1441
+ ), l.open({
1442
+ title: "Sync with NetSuite",
1443
+ message: "Requested to sync with NetSuite. Please wait a moment.",
1444
+ type: "success"
1445
+ }), await new Promise((_) => setTimeout(_, 5e3)), a.value = !1;
1446
+ } catch {
1447
+ l.open({
1448
+ title: "Error",
1449
+ message: "Failed to sync with NetSuite",
1450
+ type: "error"
1451
+ }), a.value = !1;
1452
+ }
1453
+ });
1454
+ }
1455
+ return (t, c) => {
1456
+ const x = G("FmButton");
1457
+ return i(), g("div", Tr, [
1458
+ T(x, {
1459
+ "prepend-icon": "sync",
1460
+ variant: "secondary",
1461
+ label: "Sync",
1462
+ loading: a.value,
1463
+ onClick: h,
1464
+ "text-color": "primary",
1465
+ "bg-color": "transparent",
1466
+ "border-color": "primary"
1467
+ }, null, 8, ["loading"])
1468
+ ]);
1469
+ };
1470
+ }
1471
+ }), qr = {
1472
+ key: 0,
1473
+ class: "flex flex-col gap-8"
1474
+ }, Vr = { class: "flex flex-col gap-4" }, Er = { class: "fm-typo-en-body-lg-600" }, Lr = {
1475
+ key: 0,
1476
+ class: "flex flex-col gap-4"
1477
+ }, Ur = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Mr = { class: "fm-typo-en-body-lg-600" }, jr = { key: 0 }, Br = { key: 1 }, zr = {
1478
+ key: 1,
1479
+ class: "flex flex-col gap-4"
1480
+ }, Kr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Gr = { class: "fm-typo-en-body-lg-600" }, Hr = { key: 0 }, Wr = { key: 1 }, Yr = {
1481
+ key: 2,
1482
+ class: "flex flex-col gap-4"
1483
+ }, Qr = { class: "fm-typo-en-body-lg-600" }, Jr = {
1484
+ key: 3,
1485
+ class: "flex flex-col gap-4"
1486
+ }, Xr = { class: "fm-typo-en-body-lg-600" }, Zr = /* @__PURE__ */ De({
1487
+ __name: "NetSuiteInfo",
1488
+ props: {
1489
+ transferType: {},
1490
+ transferToDbName: {},
1491
+ poRequest: {},
1492
+ purchaseOrder: {},
1493
+ isTransferBetweenOutlets: { type: Boolean },
1494
+ scope: {}
1495
+ },
1496
+ setup(v) {
1497
+ const r = v, s = it(), l = Ge(), f = Q(r.poRequest);
1498
+ Rt(async () => {
1499
+ var c;
1500
+ if (!r.poRequest && ((c = r.purchaseOrder) != null && c._id)) {
1501
+ const x = await l.getLatestPurchaseOrderRequest(r.purchaseOrder._id);
1502
+ f.value = x;
1503
+ }
1504
+ });
1505
+ const a = Y(
1506
+ () => {
1507
+ var c, x, O, C, _, $;
1508
+ return s.getSubsidiaryFullName(
1509
+ ((O = (x = (c = r.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : x.subsidiary) == null ? void 0 : O.id) || (($ = (_ = (C = r.poRequest) == null ? void 0 : C.netSuite) == null ? void 0 : _.subsidiary) == null ? void 0 : $.id)
1510
+ ).fullName;
1511
+ }
1512
+ ), h = Y(() => {
1513
+ var c, x, O, C, _, $, R, D, S, u, o, y;
1514
+ return (O = (x = (c = r.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : x.additionalInfo) != null && O.transactionnumber ? ($ = (_ = (C = r.purchaseOrder) == null ? void 0 : C.netSuite) == null ? void 0 : _.additionalInfo) == null ? void 0 : $.transactionnumber : (S = (D = (R = f.value) == null ? void 0 : R.netSuite) == null ? void 0 : D.additionalInfo) != null && S.transactionnumber ? (y = (o = (u = f.value) == null ? void 0 : u.netSuite) == null ? void 0 : o.additionalInfo) == null ? void 0 : y.transactionnumber : null;
1515
+ }), t = Y(() => {
1516
+ var c, x, O, C, _, $;
1517
+ return (x = (c = r.purchaseOrder) == null ? void 0 : c.deliveryFullfillment) != null && x.length && ((C = (O = r.purchaseOrder) == null ? void 0 : O.deliveryFullfillment) == null ? void 0 : C.length) > 0 ? ($ = (_ = r.purchaseOrder) == null ? void 0 : _.deliveryFullfillment) == null ? void 0 : $.map((R) => {
1518
+ var D;
1519
+ return (D = R.netSuite) == null ? void 0 : D.refNo;
1520
+ }).join(", ") : "N/A";
1521
+ });
1522
+ return (c, x) => {
1523
+ var O, C, _, $, R, D, S, u, o, y, I, V, A, J, H, W;
1524
+ return m(s).isEnabled ? (i(), g("div", qr, [
1525
+ e("div", Vr, [
1526
+ x[0] || (x[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1527
+ e("div", Er, p(a.value || "N/A"), 1)
1528
+ ]),
1529
+ !c.isTransferBetweenOutlets && c.scope === m(vt).RECEIVE_REQUEST ? (i(), g("div", Lr, [
1530
+ e("div", Ur, " NetSuite " + p((C = (O = c.purchaseOrder) == null ? void 0 : O.netSuite) != null && C.recordType ? m(kt)(($ = (_ = c.purchaseOrder) == null ? void 0 : _.netSuite) == null ? void 0 : $.recordType) : c.transferType === m(Qe).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1531
+ e("div", Mr, [
1532
+ (D = (R = c.purchaseOrder) == null ? void 0 : R.netSuite) != null && D.id ? (i(), g("span", jr, p((u = (S = c.purchaseOrder) == null ? void 0 : S.netSuite) == null ? void 0 : u.refNo) + " (" + p((y = (o = c.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : y.id) + ") ", 1)) : (i(), g("span", Br, "N/A"))
1533
+ ])
1534
+ ])) : L("", !0),
1535
+ !c.isTransferBetweenOutlets && f.value || c.scope === m(vt).APPROVAL ? (i(), g("div", zr, [
1536
+ e("div", Kr, " (Request) NetSuite " + p(c.transferType === m(Qe).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1537
+ e("div", Gr, [
1538
+ (V = (I = f.value) == null ? void 0 : I.netSuite) != null && V.id ? (i(), g("span", Hr, p((J = (A = f.value) == null ? void 0 : A.netSuite) == null ? void 0 : J.refNo) + " (" + p((W = (H = f.value) == null ? void 0 : H.netSuite) == null ? void 0 : W.id) + ") ", 1)) : (i(), g("span", Wr, "N/A"))
1539
+ ])
1540
+ ])) : L("", !0),
1541
+ h.value ? (i(), g("div", Yr, [
1542
+ x[1] || (x[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1543
+ e("div", Qr, p(h.value), 1)
1544
+ ])) : L("", !0),
1545
+ m(s).isEnabled && c.transferType === m(Qe).enum.transfer && !c.isTransferBetweenOutlets ? (i(), g("div", Jr, [
1546
+ x[2] || (x[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1547
+ e("div", Xr, p(t.value), 1)
1548
+ ])) : L("", !0)
1549
+ ])) : L("", !0);
1550
+ };
1551
+ }
1552
+ }), es = { class: "flex flex-row-reverse" }, ts = /* @__PURE__ */ De({
1553
+ __name: "NetSuiteLog",
1554
+ props: {
1555
+ netsuiteId: {},
1556
+ purchaseOrderId: {}
1557
+ },
1558
+ setup(v) {
1559
+ const r = Ke(), s = gt();
1560
+ async function l(f, a) {
1561
+ const h = [];
1562
+ if (f && h.push(`body.message:*${f}*`), a) {
1563
+ const O = a.replace(/:/g, "\\:");
1564
+ h.push(`${O}`);
1565
+ }
1566
+ if (h.length === 0) {
1567
+ r.open({
1568
+ message: "Cannot open logs without valid filters.",
1569
+ type: "error"
1570
+ });
1571
+ return;
1572
+ }
1573
+ const c = `attributes.pod:netsuite* AND (${h.join(" OR ")})`, { url: x } = await s.getSyncLogs(c);
1574
+ r.open(
1575
+ {
1576
+ message: "Opening NetSuite logs...",
1577
+ type: "info"
1578
+ },
1579
+ 800
1580
+ ), await new Promise((O) => setTimeout(O, 800)), window.open(x, "_blank");
1581
+ }
1582
+ return (f, a) => {
1583
+ const h = G("FmButton");
1584
+ return i(), g("div", es, [
1585
+ T(h, {
1586
+ "prepend-icon": "history",
1587
+ variant: "secondary",
1588
+ label: "Logs",
1589
+ onClick: a[0] || (a[0] = (t) => l(f.netsuiteId, f.purchaseOrderId)),
1590
+ "text-color": "primary",
1591
+ "bg-color": "transparent",
1592
+ "border-color": "primary"
1593
+ })
1594
+ ]);
1595
+ };
1596
+ }
1597
+ }), rs = { class: "flex flex-row-reverse" }, ss = { key: 0 }, os = { key: 1 }, ns = { class: "mb-6" }, as = { class: "fm-typo-en-body-md-400" }, ls = { key: 0 }, is = { key: 1 }, cs = {
1598
+ key: 0,
1599
+ class: "flex"
1600
+ }, us = {
1601
+ key: 1,
1602
+ class: "border-t pt-6"
1603
+ }, ds = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, ms = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, ps = { class: "w-full" }, fs = {
1604
+ class: "p-3 fm-typo-en-body-sm-600",
1605
+ style: { "min-width": "130px" }
1606
+ }, ys = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, vs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, hs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, gs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, bs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _s = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ss = { class: "p-3 fm-typo-en-body-sm-600" }, xs = { key: 2 }, Os = { key: 1 }, ws = /* @__PURE__ */ De({
1607
+ __name: "NetSuiteLatestInfo",
1608
+ props: {
1609
+ netsuiteId: {},
1610
+ purchaseOrderId: {}
1611
+ },
1612
+ setup(v) {
1613
+ const r = v, s = gt(), l = Q(!1), f = Fe(), a = Q(!0), h = Q(!1), t = Q(!1), c = Q(!1), x = Q(null), O = Q([]);
1614
+ async function C() {
1615
+ if (!x.value) {
1616
+ l.value = !0;
1617
+ try {
1618
+ a.value = !0;
1619
+ const D = await s.getMoreInfo(
1620
+ f.currentLocation.dbName,
1621
+ r.purchaseOrderId
1622
+ );
1623
+ x.value = D, h.value = !1;
1624
+ } catch {
1625
+ h.value = !0;
1626
+ } finally {
1627
+ a.value = !1;
1628
+ }
1629
+ await _();
1630
+ }
1631
+ }
1632
+ async function _() {
1633
+ if (!(O.value.length > 0))
1634
+ try {
1635
+ t.value = !0;
1636
+ const D = await s.getChangeLogs(r.netsuiteId);
1637
+ O.value = D, c.value = !1;
1638
+ } catch {
1639
+ c.value = !0;
1640
+ } finally {
1641
+ t.value = !1;
1642
+ }
1643
+ }
1644
+ function $(D) {
1645
+ switch (D) {
1646
+ case $e.Create:
1647
+ return "text-green-600 bg-green-100";
1648
+ case $e.Set:
1649
+ return "text-blue-600 bg-blue-100";
1650
+ case $e.Change:
1651
+ return "text-yellow-600 bg-yellow-100";
1652
+ case $e.Unset:
1653
+ return "text-red-600 bg-red-100";
1654
+ default:
1655
+ return "text-gray-600 bg-gray-100";
1656
+ }
1657
+ }
1658
+ function R(D) {
1659
+ return new Date(D).toLocaleDateString("en-US", {
1660
+ year: "numeric",
1661
+ month: "short",
1662
+ day: "numeric",
1663
+ hour: "2-digit",
1664
+ minute: "2-digit"
1665
+ });
1666
+ }
1667
+ return (D, S) => {
1668
+ const u = G("FmButton"), o = G("FmLabel"), y = G("FmCircularProgress"), I = G("FmIcon"), V = G("FmDialog");
1669
+ return i(), g("div", rs, [
1670
+ T(V, {
1671
+ modelValue: l.value,
1672
+ "onUpdate:modelValue": S[2] || (S[2] = (A) => l.value = A),
1673
+ overlay: !0,
1674
+ "max-width": 800
1675
+ }, {
1676
+ "dialog-button": te(() => [
1677
+ T(u, {
1678
+ "prepend-icon": "info",
1679
+ variant: "secondary",
1680
+ label: "Latest Info",
1681
+ onClick: S[0] || (S[0] = (A) => C()),
1682
+ "text-color": "primary",
1683
+ "bg-color": "transparent",
1684
+ "border-color": "primary"
1685
+ })
1686
+ ]),
1687
+ "dialog-header": te(() => S[3] || (S[3] = [
1688
+ e("div", null, "NetSuite latest info", -1)
1689
+ ])),
1690
+ default: te(() => [
1691
+ a.value ? (i(), g("div", ss, "Loading...")) : (i(), g("div", os, [
1692
+ h.value ? (i(), g("p", Os, "Something went wrong.")) : (i(), g(fe, { key: 0 }, [
1693
+ e("div", ns, [
1694
+ S[4] || (S[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1695
+ (i(!0), g(fe, null, Ce(x.value, (A, J) => (i(), g("div", {
1696
+ key: J,
1697
+ class: "mb-2"
1698
+ }, [
1699
+ e("div", null, [
1700
+ T(o, {
1701
+ label: m(ht)(J)
1702
+ }, null, 8, ["label"]),
1703
+ e("div", as, [
1704
+ Array.isArray(A) ? (i(), g("span", ls, p(A.length > 0 ? A.join(", ") : "N/A"), 1)) : (i(), g("span", is, p(A), 1))
1705
+ ])
1706
+ ])
1707
+ ]))), 128))
1708
+ ]),
1709
+ t.value ? (i(), g("div", cs, [
1710
+ S[5] || (S[5] = e("span", null, "Change Log Loading...", -1)),
1711
+ T(y, { size: "md" })
1712
+ ])) : L("", !0),
1713
+ !t.value && O.value.length > 0 ? (i(), g("div", us, [
1714
+ e("h3", ds, [
1715
+ T(I, {
1716
+ name: "error",
1717
+ color: "#ff9500",
1718
+ size: "sm"
1719
+ }),
1720
+ S[6] || (S[6] = Ne(" Change Logs "))
1721
+ ]),
1722
+ e("div", ms, [
1723
+ e("table", ps, [
1724
+ S[7] || (S[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1725
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1726
+ e("th", {
1727
+ class: "text-left p-3 fm-typo-en-body-md-600",
1728
+ style: { "min-width": "130px" }
1729
+ }, " Date "),
1730
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1731
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1732
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1733
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1734
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1735
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1736
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1737
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1738
+ ])
1739
+ ], -1)),
1740
+ e("tbody", null, [
1741
+ (i(!0), g(fe, null, Ce(O.value, (A, J) => (i(), g("tr", {
1742
+ key: J,
1743
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1744
+ }, [
1745
+ e("td", fs, p(R(A._dateiso8601)), 1),
1746
+ e("td", ys, p(A._rolename), 1),
1747
+ e("td", vs, p(A._employeename), 1),
1748
+ e("td", hs, p(A._contextname), 1),
1749
+ e("td", {
1750
+ class: ze(`p-3 fm-typo-en-body-sm-600 ${$(Number(A.type) - 1)}`)
1751
+ }, p(m($e)[Number(A.type) - 1]), 3),
1752
+ e("td", gs, p(A.lineid || ""), 1),
1753
+ e("td", bs, p(A._fieldname), 1),
1754
+ e("td", _s, p(A.oldvalue || ""), 1),
1755
+ e("td", Ss, p(A.newvalue || ""), 1)
1756
+ ]))), 128))
1757
+ ])
1758
+ ])
1759
+ ])
1760
+ ])) : (i(), g("div", xs, S[8] || (S[8] = [
1761
+ e("p", null, "No change logs available.", -1)
1762
+ ])))
1763
+ ], 64))
1764
+ ]))
1765
+ ]),
1766
+ "dialog-footer": te(() => [
1767
+ T(u, {
1768
+ class: "ml-auto sm:w-full xs:w-full",
1769
+ label: "Close",
1770
+ size: "md",
1771
+ variant: "primary",
1772
+ onClick: S[1] || (S[1] = (A) => l.value = !1)
1773
+ })
1774
+ ]),
1775
+ _: 1
1776
+ }, 8, ["modelValue"])
1777
+ ]);
1778
+ };
1779
+ }
1780
+ }), Cs = {
1781
+ key: 0,
1782
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1783
+ }, Ds = { class: "flex gap-8 items-center" }, Rs = { class: "ml-auto" }, $s = { class: "flex gap-3" }, ks = /* @__PURE__ */ De({
1784
+ __name: "NetSuitePanel",
1785
+ props: {
1786
+ poRequest: {},
1787
+ purchaseOrder: {},
1788
+ transferType: {},
1789
+ transferToDbName: {},
1790
+ scope: {}
1791
+ },
1792
+ setup(v) {
1793
+ const r = v, s = gr(), l = Y(() => s.isNetSuiteEnabled);
1794
+ return (f, a) => {
1795
+ var t, c;
1796
+ const h = G("FmMenuDivider");
1797
+ return l.value ? (i(), g("div", Cs, [
1798
+ e("div", Ds, [
1799
+ a[0] || (a[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1800
+ e("div", Rs, [
1801
+ e("div", $s, [
1802
+ (c = (t = r.purchaseOrder) == null ? void 0 : t.netSuite) != null && c.id ? (i(), ie(Me, { key: 0 }, {
1803
+ default: te(() => {
1804
+ var x, O, C;
1805
+ return [
1806
+ T(ws, {
1807
+ "netsuite-id": (O = (x = f.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : O.id,
1808
+ "purchase-order-id": (C = f.purchaseOrder) == null ? void 0 : C._id
1809
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
1810
+ ];
1811
+ }),
1812
+ _: 1
1813
+ })) : L("", !0),
1814
+ T(Me, null, {
1815
+ default: te(() => {
1816
+ var x, O, C;
1817
+ return [
1818
+ T(ts, {
1819
+ "netsuite-id": (O = (x = f.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : O.id,
1820
+ "purchase-order-id": (C = f.purchaseOrder) == null ? void 0 : C._id
1821
+ }, null, 8, ["netsuite-id", "purchase-order-id"])
1822
+ ];
1823
+ }),
1824
+ _: 1
1825
+ }),
1826
+ T(Ir, {
1827
+ "po-request": f.poRequest,
1828
+ "purchase-order": f.purchaseOrder,
1829
+ "is-transfer-between-outlets": !l.value,
1830
+ scope: f.scope
1831
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1832
+ ])
1833
+ ])
1834
+ ]),
1835
+ T(h),
1836
+ T(Zr, {
1837
+ "po-request": f.poRequest,
1838
+ "purchase-order": f.purchaseOrder,
1839
+ "transfer-type": f.transferType,
1840
+ "transfer-to-db-name": f.transferToDbName,
1841
+ "is-transfer-between-outlets": !l.value,
1842
+ scope: f.scope
1843
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1844
+ ])) : L("", !0);
1845
+ };
1846
+ }
1847
+ }), As = { class: "flex flex-col gap-3" }, Ns = { class: "flex flex-col gap-4" }, Fs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Ps = { class: "flex flex-col gap-4" }, Ts = { class: "flex justify-between items-center py-1 gap-4" }, Is = { class: "flex flex-col" }, qs = { class: "fm-typo-en-body-lg-600" }, Vs = { class: "fm-typo-en-body-md-400" }, Es = { class: "flex flex-col gap-2 items-end" }, Ls = { class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Us = {
1848
+ key: 0,
1849
+ class: "flex items-center gap-2"
1850
+ }, Ms = {
1851
+ key: 0,
1852
+ class: "border-b border-fm-color-stroke-secondary"
1853
+ }, js = { class: "flex flex-col gap-4" }, Bs = { class: "flex flex-col gap-4" }, zs = { class: "flex flex-col gap-4" }, Ks = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Gs = {
1854
+ key: 0,
1855
+ class: "flex flex-col gap-4"
1856
+ }, Hs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Ws = /* @__PURE__ */ De({
1857
+ __name: "EditForm",
1858
+ props: {
1859
+ purchaseOrder: {},
1860
+ deliveryOrder: {}
1861
+ },
1862
+ emits: ["submitted"],
1863
+ setup(v, { emit: r }) {
1864
+ xr();
1865
+ const s = je(), l = Ke(), f = Q(!1), a = v, h = r, t = Nt("deliveryOrder"), c = Ge(), x = Y(
1866
+ () => {
1867
+ var u;
1868
+ return ((u = a.purchaseOrder.deliveryFullfillment) == null ? void 0 : u.findIndex(
1869
+ (o) => a.deliveryOrder.fullfillmentId && o.id === a.deliveryOrder.fullfillmentId
1870
+ )) ?? -1;
1871
+ }
1872
+ ), O = s.enablePurchaseOrderReceiveWithCustomCost, C = s.enablePortalDeliveryOrderWrite, _ = Q({}), $ = Y(() => a.purchaseOrder.items.map((u, o) => Y({
1873
+ get: () => {
1874
+ var I;
1875
+ const y = (I = t.received[o]) == null ? void 0 : I.cost;
1876
+ return y ? +_e(y) : 0;
1877
+ },
1878
+ set: (y) => {
1879
+ t.received[o].cost = {
1880
+ currency: Oe(),
1881
+ ...rt(y, 4)
1882
+ };
1883
+ }
1884
+ }))), R = Y(() => a.deliveryOrder.received.map((u, o) => Y({
1885
+ get: () => {
1886
+ var I;
1887
+ const y = (I = t.received[o]) == null ? void 0 : I.amount;
1888
+ return y ? +_e(y) : 0;
1889
+ },
1890
+ set: (y) => {
1891
+ t.received[o].amount = rt(y, 2);
1892
+ }
1893
+ })));
1894
+ function D(u) {
1895
+ const o = !_.value[u];
1896
+ if (_.value[u] = o, o) {
1897
+ const y = a.deliveryOrder.received[u];
1898
+ y.cost ? t.received[u].cost = {
1899
+ currency: y.cost.currency,
1900
+ amount: y.cost.amount,
1901
+ precision: y.cost.precision
1902
+ } : t.received[u].cost = {
1903
+ currency: Oe(),
1904
+ amount: 0,
1905
+ precision: 4
1906
+ };
1907
+ } else
1908
+ delete t.received[u].cost;
1909
+ }
1910
+ function S() {
1911
+ c.updateDeliveryOrder({
1912
+ deliveryOrder: {
1913
+ ...a.deliveryOrder,
1914
+ ...t
1915
+ },
1916
+ purchaseOrderId: a.purchaseOrder._id,
1917
+ purchaseOrderRev: a.purchaseOrder._rev
1918
+ }).then(() => {
1919
+ l.open(
1920
+ {
1921
+ title: "Success",
1922
+ message: `PO# ${a.purchaseOrder.seqNumber} Changes have been saved`,
1923
+ type: "success"
1924
+ },
1925
+ 1e4
1926
+ ), f.value = !1, h("submitted");
1927
+ });
1928
+ }
1929
+ return (u, o) => {
1930
+ const y = G("FmButton"), I = G("FmStepperField"), V = G("FmSwitch"), A = G("FmTextField"), J = G("FmDialog");
1931
+ return i(), ie(J, {
1932
+ modelValue: f.value,
1933
+ "onUpdate:modelValue": o[1] || (o[1] = (H) => f.value = H),
1934
+ overlay: !0
1935
+ }, {
1936
+ "dialog-button": te(() => [
1937
+ m(C) ? (i(), ie(y, {
1938
+ key: 0,
1939
+ variant: "plain",
1940
+ label: "Edit",
1941
+ size: "md",
1942
+ "prepend-icon": "edit"
1943
+ })) : L("", !0)
1944
+ ]),
1945
+ "dialog-header": te(() => [
1946
+ e("div", null, "Received on " + p(m(Je)(a.deliveryOrder.createdAt)), 1)
1947
+ ]),
1948
+ "dialog-footer": te(() => [
1949
+ T(y, {
1950
+ class: "ml-auto",
1951
+ label: "Apply changes",
1952
+ size: "md",
1953
+ variant: "destructive",
1954
+ onClick: S
1955
+ })
1956
+ ]),
1957
+ default: te(() => [
1958
+ e("div", null, [
1959
+ e("div", As, [
1960
+ e("div", Ns, [
1961
+ o[2] || (o[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
1962
+ e("div", Fs, p(a.deliveryOrder.adjustment ? m(Je)(new Date(m(tt)(a.deliveryOrder.adjustment))) : "-"), 1)
1963
+ ]),
1964
+ e("div", Ps, [
1965
+ o[4] || (o[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received items", -1)),
1966
+ (i(!0), g(fe, null, Ce(a.deliveryOrder.received, (H, W) => {
1967
+ var ne;
1968
+ return i(), g("div", { key: W }, [
1969
+ e("div", Ts, [
1970
+ e("div", Is, [
1971
+ e("span", qs, p(H.sku.name), 1),
1972
+ e("span", Vs, p(H.sku.code), 1)
1973
+ ]),
1974
+ e("div", Es, [
1975
+ T(I, {
1976
+ label: "Receive Quantity",
1977
+ modelValue: R.value[W].value,
1978
+ "onUpdate:modelValue": (ae) => R.value[W].value = ae,
1979
+ min: 0,
1980
+ "append-text": ((ne = H.measurement) == null ? void 0 : ne.abbrev) ?? H.sku.unit.abbrev
1981
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"]),
1982
+ e("div", Ls, p(`${H.cost ? `${m(Ye)(H.cost)}` : ""}`), 1),
1983
+ m(O) ? (i(), g("div", Us, [
1984
+ T(V, {
1985
+ "model-value": _.value[W],
1986
+ "onUpdate:modelValue": (ae) => D(W),
1987
+ size: "sm"
1988
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1989
+ o[3] || (o[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
1990
+ ])) : L("", !0),
1991
+ m(O) && _.value[W] ? (i(), ie(I, {
1992
+ key: 1,
1993
+ modelValue: $.value[W].value,
1994
+ "onUpdate:modelValue": (ae) => $.value[W].value = ae,
1995
+ label: "Total Cost",
1996
+ step: 1e-4,
1997
+ min: 0,
1998
+ placeholder: "0.0000",
1999
+ size: "sm",
2000
+ "append-text": m(Oe)()
2001
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : L("", !0)
2002
+ ])
2003
+ ]),
2004
+ W < a.purchaseOrder.items.length - 1 ? (i(), g("div", Ms)) : L("", !0)
2005
+ ]);
2006
+ }), 128))
2007
+ ]),
2008
+ e("div", js, [
2009
+ o[5] || (o[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2010
+ e("div", Bs, [
2011
+ T(A, {
2012
+ modelValue: m(t).deliveryOrderNumber,
2013
+ "onUpdate:modelValue": o[0] || (o[0] = (H) => m(t).deliveryOrderNumber = H),
2014
+ size: "md",
2015
+ placeholder: a.deliveryOrder.deliveryOrderNumber
2016
+ }, null, 8, ["modelValue", "placeholder"])
2017
+ ])
2018
+ ]),
2019
+ e("div", zs, [
2020
+ o[6] || (o[6] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2021
+ e("div", Ks, p(a.deliveryOrder.remark || "N/A"), 1)
2022
+ ]),
2023
+ x.value >= 0 ? (i(), g("div", Gs, [
2024
+ o[7] || (o[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fulfilment's sequence ", -1)),
2025
+ e("div", Hs, p(x.value + 1), 1)
2026
+ ])) : L("", !0)
2027
+ ])
2028
+ ])
2029
+ ]),
2030
+ _: 1
2031
+ }, 8, ["modelValue"]);
2032
+ };
2033
+ }
2034
+ }), Ys = { class: "flex flex-col gap-3" }, Qs = { class: "flex flex-col gap-4" }, Js = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Xs = {
2035
+ key: 0,
2036
+ class: "flex flex-col gap-4"
2037
+ }, Zs = { class: "flex items-center justify-between" }, eo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, to = {
2038
+ key: 0,
2039
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2040
+ }, ro = { class: "flex gap-4" }, so = { class: "flex-1" }, oo = { class: "flex-1" }, no = {
2041
+ key: 0,
2042
+ class: "flex items-center text-fm-color-system-error-300"
2043
+ }, ao = { class: "fm-typo-en-body-md-400" }, lo = { class: "flex flex-col gap-4" }, io = { class: "flex justify-between items-center py-1 gap-4" }, co = { class: "flex flex-col" }, uo = { class: "fm-typo-en-body-lg-600" }, mo = { class: "fm-typo-en-body-md-400" }, po = { class: "flex flex-col gap-2 items-end" }, fo = {
2044
+ key: 0,
2045
+ class: "flex items-center gap-2"
2046
+ }, yo = {
2047
+ key: 0,
2048
+ class: "border-b border-fm-color-stroke-secondary"
2049
+ }, vo = { class: "flex flex-col gap-4" }, ho = { class: "flex flex-col gap-4" }, go = { class: "flex flex-col gap-4" }, bo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, _o = /* @__PURE__ */ De({
2050
+ __name: "CreateForm",
2051
+ props: {
2052
+ purchaseOrder: {},
2053
+ receivedInfoMap: {}
2054
+ },
2055
+ emits: ["submitted"],
2056
+ setup(v, { emit: r }) {
2057
+ var E, B, le;
2058
+ const { t: s } = at(), l = Q(!1), f = lt(), a = v, h = r, t = Nt("", {
2059
+ default: {
2060
+ deliveryOrderNumber: "",
2061
+ remark: "",
2062
+ received: a.purchaseOrder.items.map((F) => ({
2063
+ sku: F.sku,
2064
+ amount: Ue.fromNumber(0),
2065
+ measurement: F.measurement
2066
+ })),
2067
+ createdBy: {
2068
+ id: ((E = f.sessionUser.value) == null ? void 0 : E.id) || "",
2069
+ name: ((B = f.sessionUser.value) == null ? void 0 : B.displayName) || ""
2070
+ },
2071
+ createdAt: ""
2072
+ }
2073
+ }), c = Ge(), x = ct(), O = je(), C = ((le = a.purchaseOrder) == null ? void 0 : le.supplier.internal) != null, _ = C && O.enablePOSTransferRequireFulfillment, $ = O.enablePortalDeliveryOrderWrite && (a.purchaseOrder.status === se.Enum.RECEIVING || a.purchaseOrder.status === se.Enum.COMPLETE) && (C ? !_ : !0), R = O.enablePurchaseOrderReceiveWithCustomCost, D = O.enableBackdateReceive, S = Q({}), u = Ke(), o = Y({
2074
+ get() {
2075
+ if (!t.createdAt) return "";
2076
+ const F = new Date(t.createdAt), b = F.getFullYear(), q = String(F.getMonth() + 1).padStart(2, "0"), z = String(F.getDate()).padStart(2, "0");
2077
+ return `${b}-${q}-${z}`;
2078
+ },
2079
+ set(F) {
2080
+ if (F) {
2081
+ const b = t.createdAt ? new Date(t.createdAt) : /* @__PURE__ */ new Date(), [q, z, ce] = F.split("-");
2082
+ b.setFullYear(parseInt(q)), b.setMonth(parseInt(z) - 1), b.setDate(parseInt(ce)), t.createdAt = b.toISOString();
2083
+ }
2084
+ }
2085
+ }), y = Y({
2086
+ get() {
2087
+ if (!t.createdAt) return "";
2088
+ const F = new Date(t.createdAt), b = String(F.getHours()).padStart(2, "0"), q = String(F.getMinutes()).padStart(2, "0");
2089
+ return `${b}:${q}`;
2090
+ },
2091
+ set(F) {
2092
+ if (F) {
2093
+ const b = t.createdAt ? new Date(t.createdAt) : /* @__PURE__ */ new Date(), [q, z] = F.split(":");
2094
+ b.setHours(parseInt(q)), b.setMinutes(parseInt(z)), t.createdAt = b.toISOString();
2095
+ }
2096
+ }
2097
+ }), I = Y(() => {
2098
+ const F = tt(a.purchaseOrder._id);
2099
+ if (!F) return "";
2100
+ const b = new Date(F), q = b.getFullYear(), z = String(b.getMonth() + 1).padStart(2, "0"), ce = String(b.getDate()).padStart(2, "0");
2101
+ return `${q}-${z}-${ce}`;
2102
+ }), V = Y(() => {
2103
+ const F = tt(a.purchaseOrder._id);
2104
+ return F ? new Date(F) : null;
2105
+ }), A = Y(() => {
2106
+ if (!o.value || !y.value || !V.value) return null;
2107
+ if (/* @__PURE__ */ new Date(`${o.value}T${y.value}:00`) < V.value) {
2108
+ const b = I.value, q = V.value.getHours(), z = V.value.getMinutes(), ce = q >= 12 ? "PM" : "AM", Re = q % 12 || 12, Se = `${String(Re).padStart(2, "0")}:${String(z).padStart(2, "0")} ${ce}`;
2109
+ return `Delivery date & time cannot be earlier than order creation (${b} ${Se})`;
2110
+ }
2111
+ return null;
2112
+ }), J = Y(() => A.value ? !1 : t.received.some((b) => {
2113
+ const q = b.amount;
2114
+ return q ? +_e(q) > 0 : !1;
2115
+ }));
2116
+ function H() {
2117
+ t.createdAt = "";
2118
+ }
2119
+ const W = Y(() => a.purchaseOrder.items.map((F, b) => Y({
2120
+ get: () => {
2121
+ var z;
2122
+ const q = (z = t.received[b]) == null ? void 0 : z.amount;
2123
+ return q ? +_e(q) : 0;
2124
+ },
2125
+ set: (q) => {
2126
+ t.received[b].amount = rt(q, 2);
2127
+ }
2128
+ })));
2129
+ function ne(F) {
2130
+ const b = !S.value[F];
2131
+ if (S.value[F] = b, b) {
2132
+ const q = a.purchaseOrder.items[F];
2133
+ q.totalCost ? t.received[F].cost = {
2134
+ currency: q.totalCost.currency,
2135
+ amount: q.totalCost.amount,
2136
+ precision: 4
2137
+ // Standardize to 4 decimals
2138
+ } : t.received[F].cost = {
2139
+ currency: Oe(),
2140
+ amount: 0,
2141
+ precision: 4
2142
+ };
2143
+ } else
2144
+ delete t.received[F].cost;
2145
+ }
2146
+ const ae = Y(() => a.purchaseOrder.items.map((F, b) => Y({
2147
+ get: () => {
2148
+ var z;
2149
+ const q = (z = t.received[b]) == null ? void 0 : z.cost;
2150
+ return q ? +_e(q) : 0;
2151
+ },
2152
+ set: (q) => {
2153
+ t.received[b].cost = {
2154
+ currency: Oe(),
2155
+ ...rt(q, 4)
2156
+ };
2157
+ }
2158
+ })));
2159
+ function ke() {
2160
+ x.open({
2161
+ title: "Confirm Create Delivery Order",
2162
+ message: `Are you sure you want to create delivery order for PO# ${a.purchaseOrder.seqNumber}?`,
2163
+ primaryActions: {
2164
+ text: "Create",
2165
+ close: !0,
2166
+ variant: "primary"
2167
+ },
2168
+ secondaryActions: {
2169
+ text: "Cancel",
2170
+ close: !0
2171
+ }
2172
+ }).onPrimary(() => qe());
2173
+ }
2174
+ function qe() {
2175
+ c.createDeliveryOrder({
2176
+ deliveryOrder: t,
2177
+ purchaseOrderId: a.purchaseOrder._id,
2178
+ purchaseOrderRev: a.purchaseOrder._rev,
2179
+ currency: Oe()
2180
+ }).then(() => {
2181
+ u.open(
2182
+ {
2183
+ title: "Success",
2184
+ message: `New delivery order created for PO# ${a.purchaseOrder.seqNumber}`,
2185
+ type: "success"
2186
+ },
2187
+ 1e4
2188
+ ), l.value = !1, h("submitted");
2189
+ });
2190
+ }
2191
+ return (F, b) => {
2192
+ const q = G("FmButton"), z = G("FmDatePicker"), ce = G("FmTimePicker"), Re = G("FmIcon"), Se = G("FmStepperField"), He = G("FmSwitch"), n = G("FmTextField"), d = G("FmDialog");
2193
+ return i(), ie(d, {
2194
+ modelValue: l.value,
2195
+ "onUpdate:modelValue": b[4] || (b[4] = (P) => l.value = P),
2196
+ overlay: !0,
2197
+ "min-width": 800
2198
+ }, {
2199
+ "dialog-button": te(() => [
2200
+ m($) ? (i(), ie(q, {
2201
+ key: 0,
2202
+ variant: "primary",
2203
+ label: "Create",
2204
+ size: "md",
2205
+ "prepend-icon": "add",
2206
+ class: "w-full"
2207
+ })) : L("", !0)
2208
+ ]),
2209
+ "dialog-header": te(() => [
2210
+ e("div", null, "Order #" + p(a.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
2211
+ ]),
2212
+ "dialog-footer": te(() => [
2213
+ T(q, {
2214
+ class: "ml-auto",
2215
+ label: "Create",
2216
+ size: "md",
2217
+ variant: "destructive",
2218
+ disabled: !J.value,
2219
+ onClick: ke
2220
+ }, null, 8, ["disabled"])
2221
+ ]),
2222
+ default: te(() => {
2223
+ var P;
2224
+ return [
2225
+ e("div", Ys, [
2226
+ e("div", Qs, [
2227
+ b[5] || (b[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
2228
+ e("div", Js, p((P = m(f).sessionUser.value) == null ? void 0 : P.displayName), 1)
2229
+ ]),
2230
+ m(D) ? (i(), g("div", Xs, [
2231
+ e("div", Zs, [
2232
+ e("div", eo, [
2233
+ b[6] || (b[6] = Ne(" Delivery Date & Time ")),
2234
+ !o.value && !y.value ? (i(), g("div", to, " Leave blank to use current date & time ")) : L("", !0)
2235
+ ]),
2236
+ o.value || y.value ? (i(), ie(q, {
2237
+ key: 0,
2238
+ variant: "tertiary",
2239
+ label: "Clear",
2240
+ "prepend-icon": "close",
2241
+ onClick: H
2242
+ })) : L("", !0)
2243
+ ]),
2244
+ e("div", ro, [
2245
+ e("div", so, [
2246
+ T(z, {
2247
+ modelValue: o.value,
2248
+ "onUpdate:modelValue": b[0] || (b[0] = (k) => o.value = k)
2249
+ }, null, 8, ["modelValue"])
2250
+ ]),
2251
+ e("div", oo, [
2252
+ T(ce, {
2253
+ modelValue: y.value,
2254
+ "onUpdate:modelValue": b[1] || (b[1] = (k) => y.value = k)
2255
+ }, null, 8, ["modelValue"])
2256
+ ])
2257
+ ]),
2258
+ A.value ? (i(), g("div", no, [
2259
+ T(Re, {
2260
+ name: "error",
2261
+ class: "inline-block mr-1",
2262
+ size: "sm"
2263
+ }),
2264
+ e("div", ao, p(A.value), 1)
2265
+ ])) : L("", !0)
2266
+ ])) : L("", !0),
2267
+ e("div", lo, [
2268
+ b[8] || (b[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2269
+ (i(!0), g(fe, null, Ce(a.purchaseOrder.items, (k, j) => {
2270
+ var U, K, w;
2271
+ return i(), g("div", { key: j }, [
2272
+ e("div", io, [
2273
+ e("div", co, [
2274
+ e("span", uo, p(k.sku.name), 1),
2275
+ e("span", mo, p(k.sku.code), 1)
2276
+ ]),
2277
+ e("div", po, [
2278
+ T(Se, {
2279
+ label: "Receive Quantity",
2280
+ modelValue: W.value[j].value,
2281
+ "onUpdate:modelValue": (X) => W.value[j].value = X,
2282
+ "helper-text": `${m(s)("inventory.transfer.receiveRequest.details.received")} ${m(Ue).toFormatString(
2283
+ {
2284
+ value: (U = F.receivedInfoMap[k.sku._id]) == null ? void 0 : U.received
2285
+ }
2286
+ )} ${((K = k.measurement) == null ? void 0 : K.abbrev) ?? k.sku.unit.abbrev}`,
2287
+ min: 0,
2288
+ "append-text": ((w = k.measurement) == null ? void 0 : w.abbrev) ?? k.sku.unit.abbrev
2289
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
2290
+ m(R) ? (i(), g("div", fo, [
2291
+ T(He, {
2292
+ "model-value": S.value[j],
2293
+ "onUpdate:modelValue": (X) => ne(j),
2294
+ size: "sm"
2295
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2296
+ b[7] || (b[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2297
+ ])) : L("", !0),
2298
+ m(R) && S.value[j] ? (i(), ie(Se, {
2299
+ key: 1,
2300
+ modelValue: ae.value[j].value,
2301
+ "onUpdate:modelValue": (X) => ae.value[j].value = X,
2302
+ label: "Total Cost",
2303
+ step: 1e-4,
2304
+ min: 0,
2305
+ placeholder: "0.0000",
2306
+ size: "sm",
2307
+ "append-text": m(Oe)()
2308
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : L("", !0)
2309
+ ])
2310
+ ]),
2311
+ j < a.purchaseOrder.items.length - 1 ? (i(), g("div", yo)) : L("", !0)
2312
+ ]);
2313
+ }), 128))
2314
+ ]),
2315
+ e("div", vo, [
2316
+ b[9] || (b[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2317
+ e("div", ho, [
2318
+ T(n, {
2319
+ modelValue: m(t).deliveryOrderNumber,
2320
+ "onUpdate:modelValue": b[2] || (b[2] = (k) => m(t).deliveryOrderNumber = k),
2321
+ size: "md"
2322
+ }, null, 8, ["modelValue"])
2323
+ ])
2324
+ ]),
2325
+ e("div", go, [
2326
+ b[10] || (b[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2327
+ e("div", bo, [
2328
+ T(n, {
2329
+ modelValue: m(t).remark,
2330
+ "onUpdate:modelValue": b[3] || (b[3] = (k) => m(t).remark = k),
2331
+ size: "md"
2332
+ }, null, 8, ["modelValue"])
2333
+ ])
2334
+ ])
2335
+ ])
2336
+ ];
2337
+ }),
2338
+ _: 1
2339
+ }, 8, ["modelValue"]);
2340
+ };
2341
+ }
2342
+ }), So = { class: "flex flex-row-reverse" }, xo = {
2343
+ key: 0,
2344
+ class: "flex"
2345
+ }, Oo = {
2346
+ key: 1,
2347
+ class: "border-t pt-6"
2348
+ }, wo = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Co = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Do = { class: "w-full" }, Ro = {
2349
+ class: "p-3 fm-typo-en-body-sm-600",
2350
+ style: { "min-width": "130px" }
2351
+ }, $o = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ko = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ao = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, No = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Po = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, To = { class: "p-3 fm-typo-en-body-sm-600" }, Io = { key: 2 }, qo = /* @__PURE__ */ De({
2352
+ __name: "NetSuiteTransactionChangeLog",
2353
+ props: {
2354
+ netsuiteId: {}
2355
+ },
2356
+ setup(v) {
2357
+ const r = v, s = gt(), l = Q(!1), f = Q(!1), a = Q(!1), h = Q([]);
2358
+ async function t() {
2359
+ if (!(h.value.length > 0))
2360
+ try {
2361
+ f.value = !0;
2362
+ const O = await s.getChangeLogs(r.netsuiteId);
2363
+ h.value = O, a.value = !1;
2364
+ } catch {
2365
+ a.value = !0;
2366
+ } finally {
2367
+ f.value = !1;
2368
+ }
2369
+ }
2370
+ function c(O) {
2371
+ switch (O) {
2372
+ case $e.Create:
2373
+ return "text-green-600 bg-green-100";
2374
+ case $e.Set:
2375
+ return "text-blue-600 bg-blue-100";
2376
+ case $e.Change:
2377
+ return "text-yellow-600 bg-yellow-100";
2378
+ case $e.Unset:
2379
+ return "text-red-600 bg-red-100";
2380
+ default:
2381
+ return "text-gray-600 bg-gray-100";
2382
+ }
2383
+ }
2384
+ function x(O) {
2385
+ return new Date(O).toLocaleDateString("en-US", {
2386
+ year: "numeric",
2387
+ month: "short",
2388
+ day: "numeric",
2389
+ hour: "2-digit",
2390
+ minute: "2-digit"
2391
+ });
2392
+ }
2393
+ return (O, C) => {
2394
+ const _ = G("FmButton"), $ = G("FmCircularProgress"), R = G("FmIcon"), D = G("FmDialog");
2395
+ return i(), g("div", So, [
2396
+ T(D, {
2397
+ modelValue: l.value,
2398
+ "onUpdate:modelValue": C[2] || (C[2] = (S) => l.value = S),
2399
+ overlay: !0,
2400
+ "max-width": 800
2401
+ }, {
2402
+ "dialog-button": te(() => [
2403
+ T(_, {
2404
+ "prepend-icon": "info",
2405
+ variant: "secondary",
2406
+ label: "NetSuite",
2407
+ onClick: C[0] || (C[0] = (S) => t()),
2408
+ "text-color": "primary",
2409
+ "bg-color": "transparent",
2410
+ "border-color": "primary"
2411
+ })
2412
+ ]),
2413
+ "dialog-header": te(() => C[3] || (C[3] = [
2414
+ e("div", null, "NetSuite info", -1)
2415
+ ])),
2416
+ default: te(() => [
2417
+ f.value ? (i(), g("div", xo, [
2418
+ C[4] || (C[4] = e("span", null, "Change Log Loading...", -1)),
2419
+ T($, { size: "md" })
2420
+ ])) : L("", !0),
2421
+ !f.value && h.value.length > 0 ? (i(), g("div", Oo, [
2422
+ e("h3", wo, [
2423
+ T(R, {
2424
+ name: "error",
2425
+ color: "#ff9500",
2426
+ size: "sm"
2427
+ }),
2428
+ C[5] || (C[5] = Ne(" Change Logs "))
2429
+ ]),
2430
+ e("div", Co, [
2431
+ e("table", Do, [
2432
+ C[6] || (C[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2433
+ e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2434
+ e("th", {
2435
+ class: "text-left p-3 fm-typo-en-body-md-600",
2436
+ style: { "min-width": "130px" }
2437
+ }, " Date "),
2438
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2439
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2440
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2441
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2442
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2443
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2444
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2445
+ e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2446
+ ])
2447
+ ], -1)),
2448
+ e("tbody", null, [
2449
+ (i(!0), g(fe, null, Ce(h.value, (S, u) => (i(), g("tr", {
2450
+ key: u,
2451
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2452
+ }, [
2453
+ e("td", Ro, p(x(S._dateiso8601)), 1),
2454
+ e("td", $o, p(S._rolename), 1),
2455
+ e("td", ko, p(S._employeename), 1),
2456
+ e("td", Ao, p(S._contextname), 1),
2457
+ e("td", {
2458
+ class: ze(`p-3 fm-typo-en-body-sm-600 ${c(Number(S.type) - 1)}`)
2459
+ }, p(m($e)[Number(S.type) - 1]), 3),
2460
+ e("td", No, p(S.lineid || ""), 1),
2461
+ e("td", Fo, p(S._fieldname), 1),
2462
+ e("td", Po, p(S.oldvalue || ""), 1),
2463
+ e("td", To, p(S.newvalue || ""), 1)
2464
+ ]))), 128))
2465
+ ])
2466
+ ])
2467
+ ])
2468
+ ])) : (i(), g("div", Io, C[7] || (C[7] = [
2469
+ e("p", null, "No change logs available.", -1)
2470
+ ])))
2471
+ ]),
2472
+ "dialog-footer": te(() => [
2473
+ T(_, {
2474
+ class: "ml-auto sm:w-full xs:w-full",
2475
+ label: "Close",
2476
+ size: "md",
2477
+ variant: "primary",
2478
+ onClick: C[1] || (C[1] = (S) => l.value = !1)
2479
+ })
2480
+ ]),
2481
+ _: 1
2482
+ }, 8, ["modelValue"])
2483
+ ]);
2484
+ };
2485
+ }
2486
+ }), Vo = { class: "flex flex-col w-full gap-3" }, Eo = { class: "flex" }, Lo = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, Uo = { class: "flex flex-col gap-16 w-full h-full" }, Mo = { class: "flex justify-between" }, jo = { class: "fm-typo-en-body-lg-600" }, Bo = { class: "flex gap-2" }, zo = {
2487
+ key: 0,
2488
+ class: "flex items-center gap-1"
2489
+ }, Ko = { class: "fm-typo-en-body-md-400" }, Go = { class: "flex flex-col gap-8" }, Ho = { class: "flex flex-col gap-4" }, Wo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yo = { class: "flex gap-1" }, Qo = { class: "fm-typo-en-body-lg-600" }, Jo = {
2490
+ key: 0,
2491
+ class: "flex flex-col gap-4"
2492
+ }, Xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Zo = { class: "fm-typo-en-body-lg-600" }, en = { class: "flex flex-col gap-4" }, tn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rn = { class: "fm-typo-en-body-lg-600" }, sn = {
2493
+ key: 1,
2494
+ class: "flex flex-col gap-4"
2495
+ }, on = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, nn = { class: "fm-typo-en-body-lg-600" }, an = {
2496
+ key: 2,
2497
+ class: "flex flex-col gap-4"
2498
+ }, ln = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, cn = { class: "fm-typo-en-body-lg-600" }, un = {
2499
+ key: 3,
2500
+ class: "flex flex-col gap-4"
2501
+ }, dn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, mn = { class: "fm-typo-en-body-lg-600" }, pn = {
2502
+ key: 4,
2503
+ class: "flex flex-col gap-4"
2504
+ }, fn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, yn = { class: "fm-typo-en-body-lg-600" }, vn = {
2505
+ key: 5,
2506
+ class: "flex flex-col gap-4"
2507
+ }, hn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gn = { class: "fm-typo-en-body-lg-600" }, bn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, _n = { class: "flex flex-col gap-8" }, Sn = { class: "flex gap-8 items-center" }, xn = { class: "flex-1 fm-typo-en-body-lg-600" }, On = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, wn = { class: "flex w-full gap-4" }, Cn = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Dn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Rn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, $n = ["innerHTML"], kn = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, An = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Nn = {
2508
+ key: 0,
2509
+ class: "flex items-center gap-4"
2510
+ }, Fn = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Pn = {
2511
+ key: 0,
2512
+ class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
2513
+ }, Tn = { class: "py-8" }, In = { class: "flex justify-end gap-4 items-center" }, qn = { class: "fm-typo-en-body-lg-600" }, Vn = {
2514
+ key: 1,
2515
+ class: "flex-1 xs:w-screen xs:max-w-full"
2516
+ }, En = {
2517
+ key: 0,
2518
+ class: "flex flex-col items-center gap-8 h-full"
2519
+ }, Ln = ["src"], Un = { class: "fm-typo-en-body-lg-600" }, Mn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, jn = {
2520
+ key: 1,
2521
+ class: "px-4 flex flex-col"
2522
+ }, Bn = { class: "flex gap-12 content-stretch" }, zn = {
2523
+ class: "flex flex-col w-40",
2524
+ name: "circles"
2525
+ }, Kn = { class: "flex-1 flex flex-col items-center" }, Gn = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, Hn = { class: "flex-1 flex flex-col items-center" }, Wn = { class: "flex w-full items-center gap-4" }, Yn = {
2526
+ class: "py-12 flex flex-col gap-4",
2527
+ name: "received-at header"
2528
+ }, Qn = { class: "fm-typo-en-body-lg-400" }, Jn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Xn = { class: "ml-auto flex gap-1" }, Zn = { class: "flex gap-12 content-stretch" }, ea = {
2529
+ class: "flex flex-col w-40",
2530
+ name: "circles"
2531
+ }, ta = { class: "flex-1 flex flex-col items-center" }, ra = {
2532
+ class: "py-12 flex flex-col gap-4 flex-1",
2533
+ name: "delivery details"
2534
+ }, sa = { class: "flex flex-col gap-8" }, oa = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, na = { class: "flex flex-col gap-4" }, aa = { class: "flex gap-8 xs:flex-col" }, Ia = /* @__PURE__ */ De({
2535
+ __name: "TransferDetails",
2536
+ props: {
2537
+ poRequest: {},
2538
+ purchaseOrder: {},
2539
+ transferTo: {},
2540
+ transferToDbName: {},
2541
+ show: { type: Boolean },
2542
+ canResubmit: { type: Boolean },
2543
+ canApprove: { type: Boolean },
2544
+ scope: {},
2545
+ receivedMap: {},
2546
+ shipments: {}
2547
+ },
2548
+ emits: ["update:show", "submitted"],
2549
+ setup(v, { emit: r }) {
2550
+ const s = v, l = r, f = ct(), a = Ke(), h = je(), t = Fe(), c = lt(), { hasOrderDraftPermission: x } = Vt(), O = It();
2551
+ function C(n) {
2552
+ const d = n.isCustomCost, P = n.totalCost;
2553
+ return d != null ? d === !0 : P != null;
2554
+ }
2555
+ Xe(
2556
+ () => s.purchaseOrder,
2557
+ (n) => {
2558
+ O.init(n);
2559
+ },
2560
+ { immediate: !0 }
2561
+ );
2562
+ const _ = Y(
2563
+ () => {
2564
+ var n, d;
2565
+ return {
2566
+ id: ((n = c.sessionUser.value) == null ? void 0 : n.id) ?? "",
2567
+ name: ((d = c.sessionUser.value) == null ? void 0 : d.displayName) ?? ""
2568
+ };
2569
+ }
2570
+ ), $ = qt(), { t: R } = at(), D = Y(
2571
+ () => {
2572
+ var n, d, P, k;
2573
+ return ((d = (n = s.purchaseOrder) == null ? void 0 : n.supplier) == null ? void 0 : d.internal) === "restaurant" || ((k = (P = s.purchaseOrder) == null ? void 0 : P.supplier) == null ? void 0 : k.internal) === "warehouse" ? Qe.enum.transfer : Qe.enum.purchase;
2574
+ }
2575
+ ), S = Y(() => {
2576
+ var P;
2577
+ const n = (P = s.shipments) == null ? void 0 : P.find((k) => {
2578
+ var j;
2579
+ return k.ref === ((j = s.purchaseOrder) == null ? void 0 : j._id);
2580
+ });
2581
+ let d = null;
2582
+ if (n != null && n.milestones && n.milestones.length > 0) {
2583
+ const k = n.milestones[n.milestones.length - 1];
2584
+ if (k.estimatedTime) {
2585
+ const j = new Date(k.estimatedTime), U = j.getDate().toString().padStart(2, "0");
2586
+ d = `${j.toLocaleString("en-US", { month: "short" })} ${U}`;
2587
+ }
2588
+ }
2589
+ return d;
2590
+ }), u = Q(!1), o = Q(""), y = Q(!0), I = Ge(), V = hr(I.getWorkflowConfig), A = Tt(), J = [
2591
+ N.enum.receiveStock,
2592
+ N.enum.processRequest,
2593
+ N.enum.closeRequest
2594
+ ], H = Y(() => {
2595
+ if (!s.purchaseOrder)
2596
+ return [];
2597
+ const n = V.result.value;
2598
+ if (n.state === Ot.loading)
2599
+ return [];
2600
+ const d = {
2601
+ user: _.value,
2602
+ executedAt: t.locations.computeFirst(
2603
+ (K) => {
2604
+ var w;
2605
+ return K.dbName === ((w = t._currentLocation) == null ? void 0 : w.dbName) ? K : null;
2606
+ }
2607
+ ),
2608
+ purchaseOrderRequest: s.poRequest,
2609
+ purchaseOrder: s.purchaseOrder
2610
+ }, P = h.useOperatePurchaseOrderV2, k = h.poWorkflowAllowToMarkCompleted, j = [...J];
2611
+ P && !k && j.push(N.enum.completeReceive);
2612
+ let U = [];
2613
+ try {
2614
+ n.state === Ot.error ? (console.error("Error fetching workflow config:", n.error), U = ut.getAvailableActions({
2615
+ ...d,
2616
+ orderConfig: ut.getDefaultConfig()
2617
+ }).actions.filter((K) => !j.includes(K))) : U = ut.getAvailableActions({
2618
+ ...d,
2619
+ orderConfig: n.data
2620
+ }).actions.filter((K) => !j.includes(K));
2621
+ } catch (K) {
2622
+ console.error("Error getting available actions:", K);
2623
+ }
2624
+ return s.scope === "approval" && (U = U.filter((K) => K !== N.enum.completeReceive)), x.value || (U = U.filter(
2625
+ (K) => K !== N.enum.approveDraft && K !== N.enum.rejectDraft
2626
+ )), U;
2627
+ }), W = ir(s, "show"), ne = Y(() => [
2628
+ {
2629
+ label: R("inventory.transfer.receiveRequest.details.overview"),
2630
+ value: "overview"
2631
+ },
2632
+ {
2633
+ label: R("inventory.transfer.receiveRequest.details.deliveryHistory"),
2634
+ value: "deliveryHistory"
2635
+ }
2636
+ ]), ae = Q(ne.value[0]);
2637
+ Xe(
2638
+ () => s.show,
2639
+ (n) => {
2640
+ n && (ae.value = ne.value[0]);
2641
+ }
2642
+ );
2643
+ function ke(n) {
2644
+ return n.map((d) => ({
2645
+ ...d,
2646
+ amount: {
2647
+ ...d.amount,
2648
+ amount: -Math.abs(d.amount.amount)
2649
+ }
2650
+ }));
2651
+ }
2652
+ async function qe(n, d, P, k, j) {
2653
+ return new Promise((U, K) => {
2654
+ const w = {
2655
+ closeButton: !1,
2656
+ title: k.title,
2657
+ message: k.message,
2658
+ primaryActions: k.primaryActions,
2659
+ secondaryActions: { text: "No", close: !1 }
2660
+ };
2661
+ let X = d.rejectReason ?? "";
2662
+ P === N.enum.rejectDraft && (w.contentComponent = Pt, w.contentComponentProps = {
2663
+ message: k.message,
2664
+ onChange: (re) => {
2665
+ X = re ?? "";
2666
+ }
2667
+ }), f.open(w).onPrimary(async () => {
2668
+ var ue, Z, oe, ye;
2669
+ const re = [];
2670
+ P === N.enum.confirmDraft ? re.push({
2671
+ action: "confirmDraft",
2672
+ payload: O.controller.value.toConfirmDraftData(Oe())
2673
+ }) : P === N.enum.approveRequest ? (re.push({
2674
+ action: "approveRequest",
2675
+ payload: null
2676
+ }), d.fulfillment && re.push({
2677
+ action: "processRequest",
2678
+ payload: {
2679
+ fulfillmentId: "",
2680
+ deliveryOrderNumber: "",
2681
+ deliveryRemark: null,
2682
+ items: ke(d.fulfillment.items),
2683
+ createdBy: _.value
2684
+ }
2685
+ })) : P === N.enum.processRequest ? d.fulfillment && re.push({
2686
+ action: "processRequest",
2687
+ payload: {
2688
+ fulfillmentId: "",
2689
+ deliveryOrderNumber: "",
2690
+ deliveryRemark: null,
2691
+ items: ke(d.fulfillment.items),
2692
+ createdBy: _.value
2693
+ }
2694
+ }) : P === N.enum.rejectRequest ? re.push({
2695
+ action: "rejectRequest",
2696
+ payload: null
2697
+ }) : P === N.enum.closeRequest ? re.push({
2698
+ action: "closeRequest",
2699
+ payload: null
2700
+ }) : P === N.enum.rejectDraft && re.push({
2701
+ action: "rejectDraft",
2702
+ payload: {
2703
+ rejectReason: X ?? ""
2704
+ }
2705
+ });
2706
+ try {
2707
+ await A({
2708
+ operate: {
2709
+ operation: P,
2710
+ doc: n,
2711
+ options: d
2712
+ },
2713
+ operateV2: {
2714
+ _id: ((ue = s.purchaseOrder) == null ? void 0 : ue._id) ?? "",
2715
+ _rev: ((Z = s.purchaseOrder) == null ? void 0 : Z._rev) ?? "",
2716
+ action: P,
2717
+ payloads: re
2718
+ // add payload if action is receiveStock or processRequest
2719
+ },
2720
+ transferTo: (ye = (oe = s.poRequest) == null ? void 0 : oe.to) == null ? void 0 : ye.dbName
2721
+ }).delayed(1e3), U("submitted");
2722
+ } catch (Ae) {
2723
+ K(Ae);
2724
+ }
2725
+ }).onSecondary(() => {
2726
+ U("cancelled");
2727
+ for (let re = 0; re < j + 2; re++)
2728
+ f.close();
2729
+ }).onClose(() => {
2730
+ });
2731
+ });
2732
+ }
2733
+ async function E(n) {
2734
+ var j, U, K, w;
2735
+ if (n === N.enum.receiveStock)
2736
+ return;
2737
+ const d = Ft[n];
2738
+ if (!d) {
2739
+ a.open({
2740
+ title: "Something went wrong",
2741
+ message: `Cannot process order: ${ht(n)}`,
2742
+ type: "error"
2743
+ });
2744
+ return;
2745
+ }
2746
+ const { successMessage: P, ...k } = d;
2747
+ if (s.purchaseOrder) {
2748
+ o.value = `${n}`, u.value = !0, y.value = !1;
2749
+ const X = {};
2750
+ let re = 0;
2751
+ if ((n === N.enum.confirmDraft || // auto receive for warehouse to warehouse
2752
+ n === N.enum.completeReceive) && h.autoReceiveWarehouse)
2753
+ X.autoReceive = !0;
2754
+ else if ((n === N.enum.approveRequest || n === N.enum.processRequest) && h.acceptRequireFulfillment) {
2755
+ const ue = (U = (j = s.poRequest) == null ? void 0 : j.from) == null ? void 0 : U.dbName, Z = (w = (K = s.poRequest) == null ? void 0 : K.to) == null ? void 0 : w.dbName;
2756
+ if (ue && Z && (ue.startsWith("warehouse_") || Z.startsWith("warehouse_"))) {
2757
+ const oe = await new Promise((ye, Ae) => {
2758
+ f.open({
2759
+ closeButton: !1,
2760
+ title: "Confirm transfer amount",
2761
+ dialogComponent: Pr,
2762
+ dialogComponentProps: {
2763
+ purchaseOrder: s.purchaseOrder,
2764
+ confirm: ye,
2765
+ "onUpdate:show": (Ve) => {
2766
+ Ve || (o.value = "", u.value = !1, y.value = !0, re++, f.close()), Ae("cancelled");
2767
+ }
2768
+ }
2769
+ });
2770
+ });
2771
+ X.fulfillment = oe;
2772
+ }
2773
+ }
2774
+ try {
2775
+ await qe(
2776
+ s.purchaseOrder,
2777
+ X,
2778
+ n,
2779
+ d,
2780
+ re
2781
+ ) === "submitted" && (a.open({
2782
+ title: "Success",
2783
+ message: P,
2784
+ type: "success"
2785
+ }), l("update:show", !1), l("submitted"));
2786
+ } catch (ue) {
2787
+ a.open({
2788
+ title: "Something went wrong",
2789
+ message: "Please try again.",
2790
+ type: "error"
2791
+ }), console.error("Error when submitting PO operation", n, s.purchaseOrder, ue);
2792
+ } finally {
2793
+ o.value = "", u.value = !1, y.value = !0;
2794
+ }
2795
+ }
2796
+ }
2797
+ const B = Y(() => {
2798
+ var n, d;
2799
+ return ((n = s.purchaseOrder) == null ? void 0 : n.status) === se.enum.RECEIVING || ((d = s.purchaseOrder) == null ? void 0 : d.status) === se.enum.COMPLETE;
2800
+ }), le = Y(() => s.purchaseOrder ? ot(s.purchaseOrder) : {}), F = Y(() => {
2801
+ const n = s.purchaseOrder;
2802
+ if (!n) return { status: "", statusClass: "" };
2803
+ const { partial: d, over: P } = ft(le.value), k = yt(n.status, d, P);
2804
+ let j = R(`inventory.transfer.status.${k}`), U = `${n.status}`.toLocaleLowerCase("en-us");
2805
+ return k === se.enum.CLOSE && (j = `${R(`inventory.transfer.status.${se.enum.COMPLETE}`)}`), k === "PARTIAL_RECEIVED" && U === se.enum.PROCESSING.toLocaleLowerCase("en-us") && (U = se.enum.RECEIVING.toLocaleLowerCase("en-us")), {
2806
+ status: j,
2807
+ statusClass: `fm-status-badge fm-status-badge-${U}`
2808
+ };
2809
+ }), b = Y(() => {
2810
+ var U, K;
2811
+ const n = ((U = s.purchaseOrder) == null ? void 0 : U.deliveryOrder) ?? [], d = ((K = s.purchaseOrder) == null ? void 0 : K.deliveryFullfillment) ?? [], P = [
2812
+ ...n.map((w) => ({
2813
+ createdAt: w.createdAt,
2814
+ type: "grn",
2815
+ doc: w
2816
+ })),
2817
+ ...d.map((w) => ({
2818
+ createdAt: w.createdAt,
2819
+ type: "fulfillment",
2820
+ doc: w
2821
+ }))
2822
+ ];
2823
+ P.reverse().sort((w, X) => w.createdAt.localeCompare(X.createdAt));
2824
+ function k(w) {
2825
+ var ue, Z, oe, ye, Ae, Ve, ee, de, ve, ge, we, Pe;
2826
+ const X = d.findIndex((me) => me.id === w.fullfillmentId), re = [
2827
+ (Z = (ue = d[X]) == null ? void 0 : ue.netSuite) != null && Z.id ? {
2828
+ label: "Fulfillment's ref no. (Netsuite)",
2829
+ values: [
2830
+ `${((ye = (oe = d[X]) == null ? void 0 : oe.netSuite) == null ? void 0 : ye.refNo) ?? "N/A"} (${((Ve = (Ae = d[X]) == null ? void 0 : Ae.netSuite) == null ? void 0 : Ve.id) ?? "-"})`
2831
+ ]
2832
+ } : null,
2833
+ (ee = w == null ? void 0 : w.netSuite) != null && ee.id ? {
2834
+ label: "Netsuite ref no.",
2835
+ values: [`${((de = w == null ? void 0 : w.netSuite) == null ? void 0 : de.refNo) ?? "N/A"} (${((ve = w == null ? void 0 : w.netSuite) == null ? void 0 : ve.id) ?? "-"})`]
2836
+ } : null,
2837
+ (ge = w == null ? void 0 : w.netSuite) != null && ge.recordType ? {
2838
+ label: "Netsuite Type",
2839
+ values: [kt((we = w == null ? void 0 : w.netSuite) == null ? void 0 : we.recordType)]
2840
+ } : null
2841
+ ];
2842
+ return {
2843
+ header: "Received",
2844
+ deliveryOrder: w,
2845
+ date: Je(new Date(w.createdAt)),
2846
+ info: [
2847
+ {
2848
+ label: "Adjustment date",
2849
+ values: [
2850
+ w.adjustment ? Je(new Date(tt(w.adjustment))) : "-"
2851
+ ]
2852
+ },
2853
+ {
2854
+ label: "Received by",
2855
+ values: [(Pe = w.createdBy) == null ? void 0 : Pe.name]
2856
+ },
2857
+ {
2858
+ label: "Received items",
2859
+ values: w.received.map((me) => {
2860
+ var he;
2861
+ return M("div", [
2862
+ M(
2863
+ "div",
2864
+ {
2865
+ class: "flex gap-4"
2866
+ },
2867
+ [
2868
+ M(
2869
+ "div",
2870
+ {
2871
+ class: "flex flex-col"
2872
+ },
2873
+ [
2874
+ M(
2875
+ "span",
2876
+ {
2877
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2878
+ },
2879
+ `${me.sku.name}`
2880
+ ),
2881
+ M(
2882
+ "span",
2883
+ {
2884
+ class: "fm-typo-en-body-md-400"
2885
+ },
2886
+ `${me.sku.code} `
2887
+ )
2888
+ ]
2889
+ ),
2890
+ M(
2891
+ "div",
2892
+ {
2893
+ class: "ml-auto flex flex-col"
2894
+ },
2895
+ [
2896
+ M(
2897
+ "div",
2898
+ {
2899
+ class: "ml-auto flex gap-1"
2900
+ },
2901
+ [
2902
+ M(
2903
+ "span",
2904
+ {
2905
+ class: "fm-typo-en-body-lg-600 self-end"
2906
+ },
2907
+ _e(me.amount, !1)
2908
+ ),
2909
+ M(
2910
+ "span",
2911
+ {
2912
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2913
+ },
2914
+ ((he = me.measurement) == null ? void 0 : he.abbrev) ?? me.sku.unit.abbrev
2915
+ )
2916
+ ]
2917
+ ),
2918
+ M(
2919
+ "div",
2920
+ {
2921
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2922
+ },
2923
+ `${me.cost ? `(${Ye(me.cost)})` : ""}`
2924
+ )
2925
+ ]
2926
+ )
2927
+ ]
2928
+ )
2929
+ ]);
2930
+ })
2931
+ },
2932
+ {
2933
+ label: "Delivery order no.",
2934
+ values: [w.deliveryOrderNumber || "N/A"]
2935
+ },
2936
+ {
2937
+ label: "Remark",
2938
+ values: [w.remark || "N/A"]
2939
+ },
2940
+ X > -1 ? {
2941
+ label: "Fulfilment's sequence",
2942
+ values: [`${X + 1}`]
2943
+ } : null,
2944
+ ...re
2945
+ ].filter((me) => !!me)
2946
+ };
2947
+ }
2948
+ function j(w) {
2949
+ var re, ue, Z;
2950
+ const X = d.findIndex((oe) => oe.id === w.id);
2951
+ return {
2952
+ header: "Fulfillment",
2953
+ date: Je(new Date(w.createdAt)),
2954
+ info: [
2955
+ {
2956
+ label: "Sequence",
2957
+ values: [String(X + 1)]
2958
+ },
2959
+ {
2960
+ label: "Receiveable items",
2961
+ values: w.items.map((oe) => {
2962
+ var ye;
2963
+ return M("div", [
2964
+ M(
2965
+ "div",
2966
+ {
2967
+ class: "flex gap-4"
2968
+ },
2969
+ [
2970
+ M(
2971
+ "div",
2972
+ {
2973
+ class: "flex flex-col"
2974
+ },
2975
+ [
2976
+ M(
2977
+ "span",
2978
+ {
2979
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2980
+ },
2981
+ `${oe.sku.name}`
2982
+ ),
2983
+ M(
2984
+ "span",
2985
+ {
2986
+ class: "fm-typo-en-body-md-400"
2987
+ },
2988
+ `${oe.sku.code} `
2989
+ )
2990
+ ]
2991
+ ),
2992
+ M(
2993
+ "div",
2994
+ {
2995
+ class: "ml-auto flex flex-col"
2996
+ },
2997
+ [
2998
+ M(
2999
+ "div",
3000
+ {
3001
+ class: "ml-auto flex gap-1"
3002
+ },
3003
+ [
3004
+ M(
3005
+ "span",
3006
+ {
3007
+ class: "fm-typo-en-body-lg-600 self-end"
3008
+ },
3009
+ _e(oe.amount, !1)
3010
+ ),
3011
+ M(
3012
+ "span",
3013
+ {
3014
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
3015
+ },
3016
+ ((ye = oe.measurement) == null ? void 0 : ye.abbrev) ?? oe.sku.unit.abbrev
3017
+ )
3018
+ ]
3019
+ ),
3020
+ M(
3021
+ "div",
3022
+ {
3023
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3024
+ },
3025
+ `${oe.cost ? `(${Ye(oe.cost)})` : ""}`
3026
+ )
3027
+ ]
3028
+ )
3029
+ ]
3030
+ )
3031
+ ]);
3032
+ })
3033
+ },
3034
+ (re = w.netSuite) != null && re.refNo ? {
3035
+ label: "Netsuite Ref no. (ID)",
3036
+ values: [`${(ue = w.netSuite) == null ? void 0 : ue.refNo} (${((Z = w.netSuite) == null ? void 0 : Z.id) ?? "-"})`]
3037
+ } : null
3038
+ ].filter((oe) => !!oe)
3039
+ };
3040
+ }
3041
+ return P.map((w) => {
3042
+ switch (w.type) {
3043
+ case "grn":
3044
+ return k(w.doc);
3045
+ case "fulfillment":
3046
+ return j(w.doc);
3047
+ }
3048
+ });
3049
+ });
3050
+ function q(n) {
3051
+ var U;
3052
+ const P = (((U = s.purchaseOrder) == null ? void 0 : U.version) ?? Le.enum[1]) === Le.enum[2] ? n.id : n.sku._id, k = s.receivedMap[P];
3053
+ return `<span class="${z(n)} fm-typo-en-body-lg-600">${Ue.toFormatString({ value: k.received })}</span>/${mr(n.quantity, n.sku.unit, n.measurement)}`;
3054
+ }
3055
+ function z(n) {
3056
+ var X;
3057
+ const P = (((X = s.purchaseOrder) == null ? void 0 : X.version) ?? Le.enum[1]) === Le.enum[2] ? n.id : n.sku._id, k = s.receivedMap[P], { isPartialReceive: j, isNoReceive: U, isOverReceive: K, isFullReceive: w } = Rr(k);
3058
+ return U ? "text-fm-color-typo-tertiary" : j ? "text-fm-color-system-warning-300" : K ? "text-fm-color-system-error-300" : w ? "text-fm-color-system-success-300" : "";
3059
+ }
3060
+ const ce = Y(() => {
3061
+ var n, d, P;
3062
+ return (n = s.purchaseOrder) != null && n.itemsAtSubmission ? ((d = s.purchaseOrder) == null ? void 0 : d.version) === Le.enum[2] ? s.purchaseOrder.items.reduce((k, j) => {
3063
+ var K, w;
3064
+ const U = (w = (K = s.purchaseOrder) == null ? void 0 : K.itemsAtSubmission) == null ? void 0 : w.find(
3065
+ (X) => X.id === j.id
3066
+ );
3067
+ return U && U.quantity !== j.quantity && k.set(j.sku.code, {
3068
+ originalAmount: Number(Ue.toFormatString({ value: U.quantity })),
3069
+ newAmount: Number(Ue.toFormatString({ value: j.quantity }))
3070
+ }), k;
3071
+ }, /* @__PURE__ */ new Map()) : (P = s.purchaseOrder) == null ? void 0 : P.items.reduce((k, j) => {
3072
+ var X, re;
3073
+ const U = (re = (X = s.purchaseOrder) == null ? void 0 : X.itemsAtSubmission) == null ? void 0 : re.find(
3074
+ (ue) => ue.sku._id === j.sku._id
3075
+ ), K = U ? Number(Ue.toFormatString({ value: U.quantity })) : 0, w = Number(Ue.toFormatString({ value: j.quantity }));
3076
+ return U && K !== w && k.set(j.sku.code, {
3077
+ originalAmount: K,
3078
+ newAmount: w
3079
+ }), k;
3080
+ }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
3081
+ }), Re = (n) => {
3082
+ var P, k;
3083
+ const d = ce.value;
3084
+ return ((P = s.purchaseOrder) == null ? void 0 : P.version) === Le.enum[2] ? d.has(n.id) : d.has((k = n.sku) == null ? void 0 : k.code);
3085
+ }, Se = (n) => {
3086
+ var P, k;
3087
+ const d = ce.value;
3088
+ return ((P = s.purchaseOrder) == null ? void 0 : P.version) === Le.enum[2] ? d.get(n.id) : d.get((k = n.sku) == null ? void 0 : k.code);
3089
+ }, He = Y(() => {
3090
+ const n = s.purchaseOrder;
3091
+ if (!n) return "";
3092
+ const d = n.actionChangelogs ?? [], P = d.length ? d[d.length - 1] : null;
3093
+ if (P && P.action === "rejectDraft") {
3094
+ const k = P.remarks ?? "";
3095
+ return k && k.toString().trim() !== "" ? k.toString() : "-";
3096
+ }
3097
+ return "";
3098
+ });
3099
+ return (n, d) => {
3100
+ const P = G("FmButton"), k = G("FmButtonGroup"), j = G("FmChip"), U = G("FmIcon"), K = G("FmMenuDivider"), w = G("FmCard"), X = G("FmTooltip"), re = G("FmSpacer"), ue = G("FmSideSheet");
3101
+ return i(), ie(ue, {
3102
+ modelValue: m(W),
3103
+ "onUpdate:modelValue": d[8] || (d[8] = (Z) => Gt(W) ? W.value = Z : null),
3104
+ "dismiss-away": y.value,
3105
+ "max-width": 600,
3106
+ "close-button": !1
3107
+ }, {
3108
+ "side-sheet-header": te(() => {
3109
+ var Z, oe;
3110
+ return [
3111
+ e("div", Vo, [
3112
+ e("div", Eo, [
3113
+ e("div", Lo, p(m(R)("inventory.transfer.receiveRequest.details.title") + ((Z = n.purchaseOrder) != null && Z.seqNumber ? ` #${(oe = n.purchaseOrder) == null ? void 0 : oe.seqNumber}` : "")), 1),
3114
+ T(P, {
3115
+ class: "ml-auto -m-2",
3116
+ variant: "tertiary",
3117
+ "prepend-icon": "close",
3118
+ onClick: d[0] || (d[0] = (ye) => l("update:show", !1))
3119
+ })
3120
+ ]),
3121
+ T(k, {
3122
+ items: ne.value,
3123
+ modelValue: ae.value,
3124
+ "onUpdate:modelValue": d[1] || (d[1] = (ye) => ae.value = ye)
3125
+ }, null, 8, ["items", "modelValue"]),
3126
+ n.purchaseOrder && ae.value.value === "deliveryHistory" ? (i(), ie(_o, {
3127
+ key: 0,
3128
+ "purchase-order": n.purchaseOrder,
3129
+ "received-info-map": le.value,
3130
+ onSubmitted: d[2] || (d[2] = () => {
3131
+ l("update:show", !1), l("submitted");
3132
+ })
3133
+ }, null, 8, ["purchase-order", "received-info-map"])) : L("", !0)
3134
+ ])
3135
+ ];
3136
+ }),
3137
+ default: te(() => {
3138
+ var Z, oe, ye, Ae, Ve;
3139
+ return [
3140
+ e("div", Uo, [
3141
+ ae.value.value === "overview" ? (i(), g(fe, { key: 0 }, [
3142
+ e("div", null, [
3143
+ T(w, {
3144
+ variant: "outlined",
3145
+ class: "flex flex-col gap-8 px-12 py-16"
3146
+ }, {
3147
+ default: te(() => {
3148
+ var ee, de, ve, ge, we, Pe, me, he, Ee, Be;
3149
+ return [
3150
+ e("div", Mo, [
3151
+ e("div", jo, p(m(R)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
3152
+ e("div", Bo, [
3153
+ T(Me, null, {
3154
+ default: te(() => {
3155
+ var Ze;
3156
+ return [
3157
+ Ne(p((Ze = s.purchaseOrder) == null ? void 0 : Ze.status), 1)
3158
+ ];
3159
+ }),
3160
+ _: 1
3161
+ }),
3162
+ T(j, {
3163
+ label: F.value.status,
3164
+ class: ze(F.value.statusClass),
3165
+ compact: ""
3166
+ }, null, 8, ["label", "class"]),
3167
+ S.value ? (i(), g("div", zo, [
3168
+ T(U, {
3169
+ name: "local_shipping",
3170
+ color: "#666666"
3171
+ }),
3172
+ e("span", Ko, p(S.value), 1)
3173
+ ])) : L("", !0)
3174
+ ])
3175
+ ]),
3176
+ T(K),
3177
+ e("div", Go, [
3178
+ e("div", Ho, [
3179
+ e("div", Wo, [
3180
+ e("div", Yo, p(m(R)("inventory.transfer.receiveRequest.details.createdAt")), 1)
3181
+ ]),
3182
+ e("div", Qo, p(m(et)(((ee = n.purchaseOrder) == null ? void 0 : ee._id) ?? "")), 1)
3183
+ ]),
3184
+ (de = n.purchaseOrder) != null && de.effectiveAt ? (i(), g("div", Jo, [
3185
+ e("div", Xo, p(m(R)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
3186
+ e("div", Zo, p(m(At)(new Date((ve = n.purchaseOrder) == null ? void 0 : ve.effectiveAt))), 1)
3187
+ ])) : L("", !0),
3188
+ e("div", en, [
3189
+ e("div", tn, p(m(R)("inventory.transfer.receiveRequest.details.type.title")), 1),
3190
+ e("div", rn, p(m(R)(
3191
+ `inventory.transfer.receiveRequest.details.type.${D.value.toLocaleLowerCase("en-US")}`
3192
+ )), 1)
3193
+ ]),
3194
+ (we = (ge = n.purchaseOrder) == null ? void 0 : ge.supplier) != null && we.name ? (i(), g("div", sn, [
3195
+ e("div", on, p(m(R)("inventory.transfer.receiveRequest.details.from")), 1),
3196
+ e("div", nn, p((me = (Pe = n.purchaseOrder) == null ? void 0 : Pe.supplier) == null ? void 0 : me.name), 1)
3197
+ ])) : L("", !0),
3198
+ n.transferTo ? (i(), g("div", an, [
3199
+ e("div", ln, p(m(R)("inventory.transfer.receiveRequest.details.to")), 1),
3200
+ e("div", cn, p(n.transferTo), 1)
3201
+ ])) : L("", !0),
3202
+ (he = n.purchaseOrder) != null && he.ref ? (i(), g("div", un, [
3203
+ e("div", dn, p(m(R)("inventory.transfer.receiveRequest.details.reference")), 1),
3204
+ e("div", mn, p(n.purchaseOrder.ref), 1)
3205
+ ])) : L("", !0),
3206
+ (Ee = n.purchaseOrder) != null && Ee.remark ? (i(), g("div", pn, [
3207
+ e("div", fn, p(m(R)("inventory.transfer.receiveRequest.details.remark")), 1),
3208
+ e("div", yn, p(n.purchaseOrder.remark), 1)
3209
+ ])) : L("", !0),
3210
+ ((Be = n.purchaseOrder) == null ? void 0 : Be.status) === m(se).enum.DRAFT && He.value ? (i(), g("div", vn, [
3211
+ e("div", hn, p(m(R)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
3212
+ e("div", gn, p(He.value !== "" ? He.value : "-"), 1)
3213
+ ])) : L("", !0)
3214
+ ])
3215
+ ];
3216
+ }),
3217
+ _: 1
3218
+ })
3219
+ ]),
3220
+ T(ks, {
3221
+ "po-request": n.poRequest,
3222
+ purchaseOrder: n.purchaseOrder,
3223
+ transferType: D.value,
3224
+ transferToDbName: n.transferToDbName,
3225
+ scope: n.scope
3226
+ }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
3227
+ e("div", bn, [
3228
+ e("div", _n, [
3229
+ e("div", Sn, [
3230
+ e("span", xn, [
3231
+ Ne(p(B.value ? m(R)("inventory.transfer.receiveRequest.details.receivedItems") : m(R)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
3232
+ (oe = (Z = n.purchaseOrder) == null ? void 0 : Z.netSuite) != null && oe.missingItems && ((Ae = (ye = n.purchaseOrder) == null ? void 0 : ye.netSuite) == null ? void 0 : Ae.missingItems.length) > 0 ? (i(), ie(X, {
3233
+ key: 0,
3234
+ variant: "rich",
3235
+ placement: "top",
3236
+ "z-index": 51
3237
+ }, {
3238
+ content: te(() => {
3239
+ var ee, de;
3240
+ return [
3241
+ e("div", On, [
3242
+ (i(!0), g(fe, null, Ce((de = (ee = n.purchaseOrder) == null ? void 0 : ee.netSuite) == null ? void 0 : de.missingItems, (ve, ge) => (i(), g("div", {
3243
+ class: "flex justify-center align-middle",
3244
+ key: ge
3245
+ }, [
3246
+ T(U, {
3247
+ name: "arrow_right",
3248
+ size: "sm"
3249
+ }),
3250
+ Ne(" " + p(`(${ve.netSuiteId}) ${ve.name}: ${ve.reason}`), 1)
3251
+ ]))), 128))
3252
+ ])
3253
+ ];
3254
+ }),
3255
+ default: te(() => [
3256
+ T(U, {
3257
+ name: "error",
3258
+ color: "#ff2c2c",
3259
+ size: "sm"
3260
+ })
3261
+ ]),
3262
+ _: 1
3263
+ })) : L("", !0)
3264
+ ])
3265
+ ]),
3266
+ T(K),
3267
+ (i(!0), g(fe, null, Ce(((Ve = n.purchaseOrder) == null ? void 0 : Ve.items) ?? [], (ee, de) => {
3268
+ var ve;
3269
+ return i(), g("div", {
3270
+ key: de,
3271
+ class: "flex flex-col"
3272
+ }, [
3273
+ e("div", wn, [
3274
+ e("div", Cn, [
3275
+ Ne(p(ee.name) + " ", 1),
3276
+ Re(ee) ? (i(), ie(X, {
3277
+ key: 0,
3278
+ variant: "rich",
3279
+ placement: "top",
3280
+ "z-index": 51
3281
+ }, {
3282
+ content: te(() => {
3283
+ var ge, we;
3284
+ return [
3285
+ e("div", Dn, [
3286
+ d[9] || (d[9] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
3287
+ e("div", null, "Original Amount: " + p((ge = Se(ee)) == null ? void 0 : ge.originalAmount), 1),
3288
+ e("div", null, " New Amount: " + p((we = Se(ee)) == null ? void 0 : we.newAmount), 1)
3289
+ ])
3290
+ ];
3291
+ }),
3292
+ default: te(() => [
3293
+ T(U, {
3294
+ name: "error",
3295
+ color: "#ff9500",
3296
+ size: "sm"
3297
+ })
3298
+ ]),
3299
+ _: 2
3300
+ }, 1024)) : L("", !0)
3301
+ ]),
3302
+ e("div", Rn, [
3303
+ e("span", {
3304
+ innerHTML: q(ee)
3305
+ }, null, 8, $n)
3306
+ ])
3307
+ ]),
3308
+ e("div", kn, [
3309
+ e("div", An, p(ee.code), 1),
3310
+ m(h).enableTotalCost ? (i(), g("div", Nn, [
3311
+ e("span", Fn, p(m(Ye)(
3312
+ (ve = ee.totalCost) != null && ve.amount ? ee.totalCost : m(O).controller.value.getItemCost(ee, m(Oe)()).cost
3313
+ )), 1),
3314
+ C(ee) ? L("", !0) : (i(), g("span", Pn, [
3315
+ d[10] || (d[10] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
3316
+ Ne(" " + p(m(R)("inventory.transfer.form.items.autoCalculated")), 1)
3317
+ ]))
3318
+ ])) : L("", !0)
3319
+ ])
3320
+ ]);
3321
+ }), 128)),
3322
+ +m(_e)(m(O).controller.value.getTotalCosts()) ? (i(), g(fe, { key: 0 }, [
3323
+ e("div", Tn, [
3324
+ T(K)
3325
+ ]),
3326
+ e("div", In, [
3327
+ d[11] || (d[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
3328
+ e("div", qn, p(m(Oe)()) + " " + p(m(Ye)({
3329
+ ...m(O).controller.value.getTotalCosts(),
3330
+ currency: m(Oe)()
3331
+ }).replace(/[^0-9.,]/g, "")), 1)
3332
+ ])
3333
+ ], 64)) : L("", !0)
3334
+ ])
3335
+ ])
3336
+ ], 64)) : ae.value.value === "deliveryHistory" ? (i(), g("div", Vn, [
3337
+ b.value.length ? (i(), g("div", jn, [
3338
+ (i(!0), g(fe, null, Ce(b.value, (ee, de) => {
3339
+ var ve, ge, we, Pe, me;
3340
+ return i(), g(fe, { key: de }, [
3341
+ e("div", Bn, [
3342
+ e("div", zn, [
3343
+ e("div", Kn, [
3344
+ e("div", {
3345
+ class: ze([
3346
+ {
3347
+ "bg-fm-color-primary": de !== 0,
3348
+ "bg-white": de === 0
3349
+ },
3350
+ "w-[2px] h-full"
3351
+ ])
3352
+ }, null, 2)
3353
+ ]),
3354
+ e("div", Gn, [
3355
+ ee.header === "Received" ? (i(), ie(U, {
3356
+ key: 0,
3357
+ name: "local_shipping",
3358
+ outline: "",
3359
+ color: "#ffffff"
3360
+ })) : L("", !0)
3361
+ ]),
3362
+ e("div", Hn, [
3363
+ e("div", {
3364
+ class: ze([
3365
+ {
3366
+ "bg-fm-color-primary": de < b.value.length - 1,
3367
+ "bg-white": de >= b.value.length - 1
3368
+ },
3369
+ "w-[2px] h-full"
3370
+ ])
3371
+ }, null, 2)
3372
+ ])
3373
+ ]),
3374
+ e("div", Wn, [
3375
+ e("div", Yn, [
3376
+ e("div", Qn, p(ee.header), 1),
3377
+ e("div", Jn, p(ee.date), 1)
3378
+ ]),
3379
+ e("div", Xn, [
3380
+ ee.header === "Received" && ee.deliveryOrder && n.purchaseOrder ? (i(), ie(Ws, {
3381
+ key: 0,
3382
+ deliveryOrder: ee.deliveryOrder,
3383
+ purchaseOrder: n.purchaseOrder,
3384
+ onSubmitted: d[3] || (d[3] = () => {
3385
+ l("update:show", !1), l("submitted");
3386
+ })
3387
+ }, null, 8, ["deliveryOrder", "purchaseOrder"])) : L("", !0),
3388
+ (ge = (ve = ee.deliveryOrder) == null ? void 0 : ve.netSuite) != null && ge.id ? (i(), ie(Me, { key: 1 }, {
3389
+ default: te(() => {
3390
+ var he, Ee;
3391
+ return [
3392
+ T(qo, {
3393
+ "netsuite-id": (Ee = (he = ee.deliveryOrder) == null ? void 0 : he.netSuite) == null ? void 0 : Ee.id
3394
+ }, null, 8, ["netsuite-id"])
3395
+ ];
3396
+ }),
3397
+ _: 2
3398
+ }, 1024)) : L("", !0),
3399
+ n.purchaseOrder && ((we = ee.deliveryOrder) != null && we.id) ? (i(), ie(pr, {
3400
+ key: 2,
3401
+ "purchase-order-id": (Pe = n.purchaseOrder) == null ? void 0 : Pe._id,
3402
+ "delivery-order-id": (me = ee.deliveryOrder) == null ? void 0 : me.id
3403
+ }, null, 8, ["purchase-order-id", "delivery-order-id"])) : L("", !0)
3404
+ ])
3405
+ ])
3406
+ ]),
3407
+ e("div", Zn, [
3408
+ e("div", ea, [
3409
+ e("div", ta, [
3410
+ e("div", {
3411
+ class: ze([
3412
+ {
3413
+ "bg-fm-color-primary": de < b.value.length - 1,
3414
+ "bg-white": de >= b.value.length - 1
3415
+ },
3416
+ "w-[2px] h-full"
3417
+ ])
3418
+ }, null, 2)
3419
+ ])
3420
+ ]),
3421
+ e("div", ra, [
3422
+ T(w, {
3423
+ variant: "outlined",
3424
+ class: "py-12 px-16"
3425
+ }, {
3426
+ default: te(() => [
3427
+ e("div", sa, [
3428
+ (i(!0), g(fe, null, Ce(ee.info, (he, Ee) => (i(), g("div", {
3429
+ key: Ee,
3430
+ class: "flex flex-col gap-4"
3431
+ }, [
3432
+ e("div", oa, p(he == null ? void 0 : he.label), 1),
3433
+ e("div", na, [
3434
+ (i(!0), g(fe, null, Ce(he == null ? void 0 : he.values, (Be, Ze) => (i(), g("div", {
3435
+ key: Ze,
3436
+ class: "fm-typo-en-body-lg-600"
3437
+ }, [
3438
+ typeof Be == "string" ? (i(), g(fe, { key: 0 }, [
3439
+ Ne(p(Be), 1)
3440
+ ], 64)) : (i(), ie(Ht(Be), { key: 1 }))
3441
+ ]))), 128))
3442
+ ])
3443
+ ]))), 128))
3444
+ ])
3445
+ ]),
3446
+ _: 2
3447
+ }, 1024)
3448
+ ])
3449
+ ])
3450
+ ], 64);
3451
+ }), 128))
3452
+ ])) : (i(), g("div", En, [
3453
+ T(re),
3454
+ e("div", null, [
3455
+ e("img", {
3456
+ src: m(cr),
3457
+ alt: "List is empty"
3458
+ }, null, 8, Ln)
3459
+ ]),
3460
+ e("div", Un, p(m(R)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
3461
+ e("div", Mn, p(m(R)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
3462
+ T(re),
3463
+ T(re)
3464
+ ]))
3465
+ ])) : L("", !0)
3466
+ ])
3467
+ ];
3468
+ }),
3469
+ "side-sheet-footer": te(() => [
3470
+ e("div", aa, [
3471
+ (i(!0), g(fe, null, Ce(H.value, (Z) => (i(), g(fe, null, [
3472
+ m(pt)[Z].available != !1 ? (i(), ie(P, {
3473
+ key: Z,
3474
+ label: m(R)(m(pt)[Z].translationKey),
3475
+ onClick: (oe) => E(Z),
3476
+ loading: o.value === Z,
3477
+ disabled: o.value !== Z && u.value,
3478
+ variant: m(pt)[Z].buttonVariant
3479
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : L("", !0)
3480
+ ], 64))), 256)),
3481
+ m($).ableToMarkReceived(n.purchaseOrder) && !H.value.includes("completeReceive") ? (i(), ie(P, {
3482
+ key: 0,
3483
+ label: m(R)("inventory.transfer.receiveRequest.actions.completeReceive"),
3484
+ onClick: d[4] || (d[4] = (Z) => E("completeReceive")),
3485
+ loading: o.value === "completeReceive",
3486
+ disabled: o.value !== "completeReceive" && u.value
3487
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
3488
+ m($).ableToMarkApproved(n.purchaseOrder) && n.canApprove && !H.value.includes("approveRequest") ? (i(), ie(P, {
3489
+ key: 1,
3490
+ label: m(R)("inventory.transfer.approval.actions.approveRequest"),
3491
+ onClick: d[5] || (d[5] = (Z) => E("approveRequest")),
3492
+ loading: o.value === "approveRequest",
3493
+ disabled: o.value !== "approveRequest" && u.value
3494
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
3495
+ m($).ableToCreateFulfillment(n.purchaseOrder, n.poRequest) && s.scope === "approval" ? (i(), ie(P, {
3496
+ key: 2,
3497
+ label: m(R)("inventory.transfer.receiveRequest.actions.processRequest"),
3498
+ onClick: d[6] || (d[6] = (Z) => E("processRequest")),
3499
+ loading: o.value === "processRequest",
3500
+ disabled: o.value !== "processRequest" && u.value
3501
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
3502
+ T(P, {
3503
+ label: m(R)("common.close"),
3504
+ variant: "tertiary",
3505
+ onClick: d[7] || (d[7] = (Z) => l("update:show", !1))
3506
+ }, null, 8, ["label"])
3507
+ ])
3508
+ ]),
3509
+ _: 1
3510
+ }, 8, ["modelValue", "dismiss-away"]);
3511
+ };
3512
+ }
3513
+ });
3514
+ export {
3515
+ vt as P,
3516
+ Ia as _,
3517
+ Pa as a,
3518
+ Ta as b,
3519
+ $r as g,
3520
+ It as u
3521
+ };