@feedmepos/mf-inventory-portal 1.0.5 → 1.0.7-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/{App-BC040Les.js → App-zspCOQeF.js} +50 -49
  2. package/dist/{ApprovalView-DCvl3a_5.js → ApprovalView-CKJV87es.js} +24 -24
  3. package/dist/{BindingsDialog-CrVuhZqk.js → BindingsDialog-CTmuzAWi.js} +4 -4
  4. package/dist/{BindingsPicker-lmFa-poh.js → BindingsPicker-Dabonsov.js} +8 -8
  5. package/dist/{BindingsTable-CT_lSIYf.js → BindingsTable-L0yzAoQq.js} +4 -4
  6. package/dist/{ClosingDraftView-DRc0FjAS.js → ClosingDraftView-CddxqfNi.js} +464 -463
  7. package/dist/{ClosingTemplateView-C_X0J-M4.js → ClosingTemplateView-BsW-nPec.js} +10 -10
  8. package/dist/{DeliveryOrderPrintPreview-BneNiMcQ.js → DeliveryOrderPrintPreview-DQ4msDpJ.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BJWjd3-f.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-TnVI2vdF.js} +32 -32
  10. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-BRvXmLV6.js +338 -0
  11. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BhfVsV9p.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BHLx7Lbo.js} +1 -1
  12. package/dist/{IngredientGroupView-NyW26_DP.js → IngredientGroupView-CF2GLMSD.js} +11 -11
  13. package/dist/{IngredientsView-BN1jydVe.js → IngredientsView-DopQVz7u.js} +15 -14
  14. package/dist/IntegrationView-EnD2l7af.js +2149 -0
  15. package/dist/{InventoryBindingForm-Bf52xXaz.js → InventoryBindingForm-VP2_coNH.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BLCgDC82.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-dQF7h_Jp.js} +27 -27
  17. package/dist/{InventoryBindingSummary-BM48Xk8j.js → InventoryBindingSummary-BCEXzmFu.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DYSoSSzj.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-RfkBlwxw.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-DjtXgvRo.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CGgxjz4P.js} +10 -10
  20. package/dist/{PublishView-C_c9fd-9.js → PublishView-ExvxeKR_.js} +7 -7
  21. package/dist/{PurchaseOrderPrintPreview-CmIP1Zpp.js → PurchaseOrderPrintPreview-59AaXtZ_.js} +4 -4
  22. package/dist/{ReceiveRequestView-DJknUS-e.js → ReceiveRequestView-BxGss8gu.js} +53 -52
  23. package/dist/{RecipeView-nzgPP4xb.js → RecipeView-BqTsG4xX.js} +32 -32
  24. package/dist/{StockView-DERznopJ.js → StockView-D-WvydHv.js} +73 -72
  25. package/dist/{SupplierView-B03zhGGq.js → SupplierView-C6ruAEih.js} +12 -11
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CQ-Om_rI.js +1894 -0
  27. package/dist/{TransferTemplateView-HLrkeo9I.js → TransferTemplateView-qSA3Txpn.js} +291 -290
  28. package/dist/{UnitView-yMNF61nI.js → UnitView-oHDOLM8k.js} +23 -23
  29. package/dist/{WarehouseView-Cl8O3zEO.js → WarehouseView-C3EqYfCf.js} +26 -26
  30. package/dist/api/bill.d.ts +2 -2
  31. package/dist/api/closing.d.ts +7 -1
  32. package/dist/api/food-market-hub.d.ts +1 -1
  33. package/dist/api/inventory.d.ts +44 -44
  34. package/dist/api/netsuite.d.ts +83 -1
  35. package/dist/api/purchase-order.d.ts +5 -1
  36. package/dist/api/stock.d.ts +12 -12
  37. package/dist/{app-ByZGP6to.js → app-DqrcGlGd.js} +20015 -20284
  38. package/dist/app.d.ts +7 -7
  39. package/dist/app.js +1 -1
  40. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +8 -8
  41. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +2 -2
  42. package/dist/components/shell/inventory/binding-ui.vue.d.ts +5 -5
  43. package/dist/composable/usePromise.d.ts +41 -0
  44. package/dist/{decimal-C6ZIb15B.js → decimal-rgCB5DGy.js} +1 -1
  45. package/dist/feature-CifIpcNk.js +17345 -0
  46. package/dist/{format-unit-display-Bixr5QQV.js → format-unit-display-DUWzu8vU.js} +60 -60
  47. package/dist/index-CH3OzDYK.js +126 -0
  48. package/dist/{index-3ud7W_2Y.js → index-YgIaxVhw.js} +1 -1
  49. package/dist/{stock-DpKjVgzG.js → stock-BPNYXwz1.js} +1 -1
  50. package/dist/stores/feature.d.ts +5 -19
  51. package/dist/stores/integration/foodmarkethub.d.ts +1 -1
  52. package/dist/stores/integration/index.d.ts +1 -0
  53. package/dist/stores/integration/netsuite.d.ts +18 -7
  54. package/dist/stores/integration/xilnex.d.ts +12 -0
  55. package/dist/stores/inventory.d.ts +56 -56
  56. package/dist/stores/location.d.ts +137 -137
  57. package/dist/stores/stock.d.ts +12 -12
  58. package/dist/{supplier-DfKwECUI.js → supplier-CnrH580K.js} +4 -4
  59. package/dist/tsconfig.app.tsbuildinfo +1 -1
  60. package/dist/{use-ingredient-select-dialog-Cs5SmNLE.js → use-ingredient-select-dialog-CpnJoeWb.js} +1 -1
  61. package/dist/{use-inventory-binding-dialog-9RGXAtLh.js → use-inventory-binding-dialog-DHvNwt_F.js} +1 -1
  62. package/dist/views/adjustment-template/wastage-template/actions.d.ts +228 -228
  63. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +2 -2
  64. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +1 -1
  65. package/dist/views/adjustment-template/wastage-template/table.d.ts +234 -234
  66. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +76 -76
  67. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +456 -456
  68. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +4 -4
  69. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +252 -252
  70. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +252 -252
  71. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +12 -12
  72. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +2 -2
  73. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +8 -8
  74. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +3 -3
  75. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +4 -4
  76. package/dist/views/integration/XilnexView.vue.d.ts +2 -0
  77. package/dist/views/integration/components/ApplyProduct.vue.d.ts +2 -2
  78. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +2 -2
  79. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +2 -2
  80. package/dist/views/integration/components/Xilnex/XilnexOpeningImport.vue.d.ts +2 -0
  81. package/dist/views/integration/components/Xilnex/XilnexProps.d.ts +7 -0
  82. package/dist/views/integration/components/Xilnex/XilnexSideSheet.vue.d.ts +24 -0
  83. package/dist/views/integration/components/Xilnex/importFn.d.ts +16 -0
  84. package/dist/views/integration/components/netsuite/AddLocationDialog.vue.d.ts +1334 -0
  85. package/dist/views/integration/components/netsuite/LocationConfigurationDialog.vue.d.ts +174 -0
  86. package/dist/views/integration/components/netsuite/LocationConfigurationDialogProps.d.ts +16 -0
  87. package/dist/views/integration/components/netsuite/NetSuiteLocationField.vue.d.ts +71 -0
  88. package/dist/views/receive-request/components/transfer-details/FulfillmentForm.vue.d.ts +5 -1
  89. package/dist/views/receive-request/components/transfer-details/usePurchaseOrderFn.d.ts +4 -0
  90. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +696 -668
  91. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +22 -22
  92. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +44 -44
  93. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +11 -11
  94. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +614 -0
  95. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +1270 -1222
  96. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +1197 -1149
  97. package/dist/views/receive-request/constants/po-action-to-ui-style.d.ts +6 -0
  98. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -2
  99. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  100. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +14 -14
  101. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +22 -22
  102. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +17 -17
  103. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +11 -11
  104. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +805 -805
  105. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +805 -805
  106. package/dist/views/transfer-template/composables/useTransferTemplateHelper.d.ts +33 -33
  107. package/dist/{vue-i18n-DR_smMg1.js → vue-i18n-4m7yAqU2.js} +426 -426
  108. package/package.json +5 -2
  109. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-CAEBtWpw.js +0 -328
  110. package/dist/IntegrationView-CVbR75fb.js +0 -1197
  111. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D709Nkfi.js +0 -1723
  112. package/dist/index-CoqRZydm.js +0 -84
@@ -0,0 +1,1894 @@
1
+ import { X as it, u as ue, aH as T, b as Ue, a2 as ut, a4 as dt, a5 as mt, aI as ft, d as We, e as tt, V as rt, aJ as pt, Z as Fe, K as Oe, i as oe, aK as st, a9 as ke, f as Xe, h as K, D as Z, aq as se, aL as yt, a3 as vt, an as Je, a1 as xe, aM as ht, ae as Te, ar as bt } from "./app-DqrcGlGd.js";
2
+ import { ref as V, computed as z, h as N, defineComponent as De, onMounted as at, unref as p, openBlock as _, createElementBlock as D, createElementVNode as s, toDisplayString as x, createCommentVNode as L, resolveComponent as G, createVNode as F, reactive as gt, createBlock as le, withCtx as ie, watch as _t, isRef as wt, Fragment as te, normalizeClass as Re, createTextVNode as $e, renderList as pe, resolveDynamicComponent as St } from "vue";
3
+ import { F as xt } from "./decimal-rgCB5DGy.js";
4
+ import { b as Rt, u as Ot, f as nt, P as ve } from "./format-unit-display-DUWzu8vU.js";
5
+ import { useCoreStore as Le, useI18n as ot } from "@feedmepos/mf-common";
6
+ import { E as kt } from "./empty-placeholder-wf6-BWE8.js";
7
+ import { useDialog as Ve, useSnackbar as Me, components as Ze, FmButtonVariant as re, useProxiedModel as Dt } from "@feedmepos/ui-library";
8
+ import { u as je, F as Ce } from "./feature-CifIpcNk.js";
9
+ import { u as Nt } from "./index-CH3OzDYK.js";
10
+ import { _ as At, F as qt, a as Pt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-BRvXmLV6.js";
11
+ const Ne = it((t, l) => {
12
+ const n = ue(), h = Le();
13
+ return {
14
+ async readRequests(i, a = !1) {
15
+ const d = i ?? n.currentLocationDBName, y = `${t.inventoryBackendUrl}/${d}/purchase-request?${a ? "includeReturnRequest=true" : ""}`;
16
+ return await l.get(y);
17
+ },
18
+ async readRequestById(i, a) {
19
+ const d = a ?? n.currentLocationDBName, y = `${t.inventoryBackendUrl}/${d}/purchase-request/${i}`;
20
+ return await l.get(y);
21
+ },
22
+ async readRequestByIds(i, a) {
23
+ const d = a ?? n.currentLocationDBName, y = `${t.inventoryBackendUrl}/${d}/purchase-request/find`;
24
+ return await l.post(y, { requestIds: i });
25
+ },
26
+ async getPurchaseOrders({
27
+ start: i,
28
+ end: a
29
+ }) {
30
+ const d = n.currentLocationDBName, y = `${t.inventoryBackendUrl}/${d}/purchase-order`;
31
+ return await l.get(`${y}?start=${i}&end=${a}`);
32
+ },
33
+ async getLatestPurchaseOrderRequest(i) {
34
+ const a = n.currentLocationDBName, d = `${t.inventoryBackendUrl}/${a}/purchase-request/find-by-purchase-order-id`;
35
+ return await l.get(`${d}/${i}`);
36
+ },
37
+ async getPurchaseOrderById(i) {
38
+ const a = n.currentLocationDBName, d = `${t.inventoryBackendUrl}/${a}/purchase-order`;
39
+ return await l.get(`${d}/${i}`);
40
+ },
41
+ async processPurchaseOrder(i, a) {
42
+ const d = n.currentLocationDBName, y = a || d, o = `${t.inventoryBackendUrl}/${y}/purchase-order/run-operation`;
43
+ return await l.put(o, i);
44
+ },
45
+ async processPurchaseOrderV2(i, a) {
46
+ const d = n.currentLocationDBName, y = a || d, o = `${t.inventoryBackendUrl}/${y}/v2/purchase-order/run-operation`;
47
+ return await l.put(o, i);
48
+ },
49
+ async createPurchaseOrder(i) {
50
+ const a = n.currentLocationDBName, d = `${t.inventoryBackendUrl}/${a}/purchase-order`;
51
+ return await l.post(d, i);
52
+ },
53
+ async updatePurchaseOrder(i) {
54
+ const a = n.currentLocationDBName, d = `${t.inventoryBackendUrl}/${a}/purchase-order`;
55
+ return await l.put(d, i);
56
+ },
57
+ async importFromXilnex(i) {
58
+ const a = n.currentLocationDBName, d = `${t.inventoryBackendUrl}/${a}/purchase-order/import-from-xilnex`;
59
+ return await l.post(d, i);
60
+ },
61
+ async getWorkflowConfig() {
62
+ var y;
63
+ const a = `business_${(y = h.currentBusiness.value) == null ? void 0 : y._id}`, d = `${t.inventoryBackendUrl}/${a}/purchase-order/import-from-xilnex`;
64
+ return await l.get(d);
65
+ }
66
+ };
67
+ }), ct = {
68
+ [T.enum.confirmDraft]: {
69
+ primaryActions: {
70
+ text: "Confirm draft",
71
+ close: !0
72
+ },
73
+ title: "Confirm draft?",
74
+ message: "Purchase order cannot be changed after confirm draft.",
75
+ successMessage: "Purchase order draft has been confirmed"
76
+ },
77
+ [T.enum.cancelDraft]: {
78
+ primaryActions: {
79
+ text: "Cancel draft",
80
+ close: !0,
81
+ variant: "destructive"
82
+ },
83
+ title: "Cancel draft?",
84
+ message: "Purchase order cannot be changed after cancelled draft.",
85
+ successMessage: "Purchase order draft has been cancelled"
86
+ },
87
+ [T.enum.submitRequest]: {
88
+ primaryActions: {
89
+ text: "Submit request",
90
+ close: !0
91
+ },
92
+ title: "Confirm draft?",
93
+ message: "Purchase order cannot be changed after confirm draft.",
94
+ successMessage: "Purchase order draft has been submitted"
95
+ },
96
+ [T.enum.completeReceive]: {
97
+ primaryActions: {
98
+ text: "Mark received",
99
+ close: !0
100
+ },
101
+ title: "Mark as received",
102
+ message: "Purchase order cannot be changed after it has complete receiving.",
103
+ successMessage: "Purchase order has been marked as received"
104
+ },
105
+ [T.enum.approveRequest]: {
106
+ primaryActions: {
107
+ text: "Accept request",
108
+ close: !0
109
+ },
110
+ title: "Accept request?",
111
+ message: "Transfer out request will be accepted.",
112
+ successMessage: "Transfer out request has been approved"
113
+ },
114
+ [T.enum.rejectRequest]: {
115
+ primaryActions: {
116
+ text: "Reject request",
117
+ close: !0,
118
+ variant: "destructive"
119
+ },
120
+ title: "Reject request?",
121
+ message: "Purchase order will be rejected.",
122
+ successMessage: "Purchase order has been rejected"
123
+ }
124
+ };
125
+ function lt() {
126
+ const t = ue(), l = Ne(), n = je();
127
+ async function h(a, d) {
128
+ const y = t.currentLocationDBName;
129
+ return await l.processPurchaseOrder(a, d || y);
130
+ }
131
+ async function i(a, d) {
132
+ const y = t.currentLocationDBName;
133
+ return await l.processPurchaseOrderV2(a, d || y);
134
+ }
135
+ return (a) => n.useOperatePurchaseOrderV2 ? i(a.operateV2, a.transferTo) : h(a.operate, a.transferTo);
136
+ }
137
+ var Ee = /* @__PURE__ */ ((t) => (t.RECEIVE_REQUEST = "receive/request", t.APPROVAL = "approval", t))(Ee || {});
138
+ const we = V(), Ie = V();
139
+ function Os(t, l) {
140
+ const n = Ve(), h = ue(), i = je(), a = Ue(), d = Rt(), y = Ot(), o = V(!1), v = Me(), m = Ne(), f = V(new Array()), r = V(
141
+ l != null && l.startDate && (l != null && l.endDate) ? l : ut()
142
+ ), b = z(() => {
143
+ const g = new Date(r.value.startDate), k = new Date(r.value.endDate);
144
+ return {
145
+ start: dt(g).toISOString(),
146
+ end: mt(k).toISOString()
147
+ };
148
+ }), S = V(new Array()), R = ft(), A = V(null);
149
+ async function C(g) {
150
+ function k(c) {
151
+ const O = {
152
+ mode: We.CREATE,
153
+ modelValue: g || void 0,
154
+ show: !0,
155
+ "onUpdate:show"(w) {
156
+ we.value.show = w;
157
+ },
158
+ templateId: c,
159
+ lastClosingDate: A.value
160
+ };
161
+ we.value = O;
162
+ }
163
+ let e;
164
+ i.mustUsePoTemplate && !(g != null && g.template) ? n.open({
165
+ title: "Create transfer",
166
+ message: "",
167
+ primaryActions: {
168
+ text: "Select a template",
169
+ close: !0
170
+ },
171
+ secondaryActions: {
172
+ text: "Outlet to Outlet",
173
+ variant: "secondary",
174
+ close: !0
175
+ }
176
+ }).onPrimary(async () => {
177
+ e = await d.getTemplateId(), e && k(e);
178
+ }).onSecondary(() => {
179
+ k(void 0);
180
+ }) : k(e);
181
+ }
182
+ function Q(g) {
183
+ const k = {
184
+ mode: We.UPDATE,
185
+ modelValue: tt(g),
186
+ show: !0,
187
+ "onUpdate:show"(e) {
188
+ we.value.show = e;
189
+ },
190
+ lastClosingDate: A.value
191
+ };
192
+ we.value = k;
193
+ }
194
+ async function Y() {
195
+ f.value = [], o.value = !0;
196
+ try {
197
+ f.value = await m.getPurchaseOrders(b.value).then((c) => c.sort((O, w) => w._id.localeCompare(O._id)));
198
+ const g = await R.readCurrentLocationLastClosing(!0), k = g == null ? void 0 : g._id;
199
+ k && (A.value = pt(k)), i.mustUsePoTemplate && await y.fetchTemplates();
200
+ const e = f.value.map((c) => {
201
+ var O;
202
+ return ((O = c.request) == null ? void 0 : O.id) ?? "";
203
+ }).filter((c) => c);
204
+ S.value = await m.readRequestByIds(e);
205
+ } catch {
206
+ v.open({
207
+ title: "Something went wrong",
208
+ message: "Error at fetching purchase orders",
209
+ type: "error"
210
+ });
211
+ } finally {
212
+ o.value = !1;
213
+ }
214
+ }
215
+ async function de() {
216
+ S.value = [], o.value = !0;
217
+ try {
218
+ S.value = await m.readRequests(void 0, a.isEnabled).then((g) => g.reverse());
219
+ } catch {
220
+ v.open({
221
+ title: "Something went wrong",
222
+ message: "Error at fetching purchase requests",
223
+ type: "error"
224
+ });
225
+ } finally {
226
+ o.value = !1;
227
+ }
228
+ }
229
+ function W() {
230
+ switch (t) {
231
+ case "receive/request":
232
+ return Y();
233
+ case "approval":
234
+ return de();
235
+ }
236
+ }
237
+ function ae(g, k) {
238
+ r.value = {
239
+ startDate: g,
240
+ endDate: k
241
+ }, W();
242
+ }
243
+ h.watchLocation(async (g) => {
244
+ if (!g) {
245
+ f.value = [];
246
+ return;
247
+ }
248
+ await W();
249
+ });
250
+ const ee = V(), ce = V(Math.random().toString());
251
+ async function Ae(g, k) {
252
+ const e = Math.random().toString();
253
+ ce.value = e, k ?? (k = S.value.computeFirst(
254
+ (w) => w.purchaseOrderId === g._id ? w : null
255
+ ) ?? void 0);
256
+ const c = t === "receive/request" ? h.currentLocation : k == null ? void 0 : k.to, O = {
257
+ poRequest: k,
258
+ purchaseOrder: g,
259
+ transferTo: c == null ? void 0 : c.name,
260
+ transferToDbName: c == null ? void 0 : c.dbName,
261
+ show: !0,
262
+ canResubmit: !1,
263
+ canApprove: t === "approval",
264
+ "onUpdate:show"(w) {
265
+ ee.value.show = w;
266
+ },
267
+ scope: t
268
+ };
269
+ ee.value = O;
270
+ }
271
+ async function he(g, k, e, c) {
272
+ const O = lt();
273
+ o.value = !0;
274
+ try {
275
+ await O({
276
+ operate: {
277
+ operation: k,
278
+ doc: g,
279
+ options: (
280
+ // auto receive for supplier to warehouse
281
+ (k === T.enum.confirmDraft || // auto receive for warehouse to warehouse
282
+ k === T.enum.completeReceive) && i.autoReceiveWarehouse ? {
283
+ autoReceive: !0
284
+ } : void 0
285
+ )
286
+ },
287
+ operateV2: {
288
+ _id: g._id,
289
+ _rev: g._rev ?? "",
290
+ action: k
291
+ },
292
+ transferTo: c
293
+ }), await new Promise((E) => setTimeout(E, 1e3));
294
+ const j = ue().currentLocationDBName.startsWith("restaurant_");
295
+ k === T.enum.confirmDraft && g.effectiveAt && j ? v.open({
296
+ title: "Success",
297
+ message: `${e}. The backdate will be reflected once your POS has received this change.`,
298
+ type: "success"
299
+ }) : v.open({
300
+ title: "Success",
301
+ message: e,
302
+ type: "success"
303
+ });
304
+ } catch (w) {
305
+ v.open({
306
+ title: "Something went wrong",
307
+ message: "Please try again.",
308
+ type: "error"
309
+ }), console.error("Error when submitting PO operation", k, g, w);
310
+ } finally {
311
+ o.value = !1, W();
312
+ }
313
+ }
314
+ async function qe(g, k, e) {
315
+ const c = ct[k];
316
+ if (!c) {
317
+ v.open({
318
+ title: "Something went wrong",
319
+ message: `Cannot process order: ${rt(k)}`,
320
+ type: "error"
321
+ });
322
+ return;
323
+ }
324
+ const { successMessage: O, ...w } = c;
325
+ n.open({
326
+ title: w.title,
327
+ message: w.message,
328
+ primaryActions: w.primaryActions
329
+ }).onPrimary(() => {
330
+ he(g, k, O, e);
331
+ });
332
+ }
333
+ async function Pe() {
334
+ n.open({
335
+ title: "Upload Transfer",
336
+ primaryActions: {
337
+ text: "Xilnex transfer note",
338
+ close: !0
339
+ },
340
+ secondaryActions: {
341
+ text: "Cancel",
342
+ close: !0
343
+ }
344
+ }).onPrimary(() => {
345
+ const g = {
346
+ show: !0,
347
+ "onUpdate:show"(k) {
348
+ Ie.value.show = k;
349
+ }
350
+ };
351
+ Ie.value = g;
352
+ });
353
+ }
354
+ return {
355
+ purchaseOrders: f,
356
+ purchaseRequests: S,
357
+ updateDateRange: ae,
358
+ fetchData: W,
359
+ loading: o,
360
+ transferDialogProps: we,
361
+ promptCreateTransferDialog: C,
362
+ promptUpdateTransferDialog: Q,
363
+ transferDetailsProps: ee,
364
+ promptShowTransferDetails: Ae,
365
+ submitAction: qe,
366
+ xilnexImportDialogProps: Ie,
367
+ promptUploadTransferDialog: Pe
368
+ };
369
+ }
370
+ function Tt(t, l) {
371
+ return l.reduce(
372
+ (h, i) => {
373
+ const a = i.received.find((d) => d.sku._id === t._id);
374
+ return a && (h = Fe(h, a.amount)), h;
375
+ },
376
+ xt.toPrecision(Oe(0), t.unit.precision)
377
+ );
378
+ }
379
+ function $t(t, l, n, h) {
380
+ const { name: i, address: a, regNo: d } = l.doc.profile, y = {
381
+ name: i,
382
+ registrationNumber: d,
383
+ line1: a == null ? void 0 : a.line1,
384
+ line2: a == null ? void 0 : a.line2,
385
+ postcode: a == null ? void 0 : a.postcode,
386
+ city: a == null ? void 0 : a.city,
387
+ state: a == null ? void 0 : a.state,
388
+ country: a == null ? void 0 : a.country
389
+ }, o = {
390
+ name: t.supplier.name,
391
+ phoneNumber: t.supplier.phoneNumber,
392
+ registrationNumber: t.supplier.registrationNumber,
393
+ line1: t.supplier.address.line1,
394
+ line2: t.supplier.address.line2,
395
+ postcode: t.supplier.address.postcode,
396
+ city: t.supplier.address.city,
397
+ state: t.supplier.address.state,
398
+ country: t.supplier.address.country
399
+ }, v = t.items.map((S) => {
400
+ const { sku: R, measurement: A } = S, C = oe(
401
+ Tt(S.sku, t.deliveryOrder || []),
402
+ !1
403
+ );
404
+ return {
405
+ code: R.code,
406
+ description: R.name,
407
+ quantity: nt(S.quantity, R.unit, S.measurement),
408
+ unit: (A == null ? void 0 : A.abbrev) || R.unit.abbrev,
409
+ received: C
410
+ };
411
+ }), m = t.deliveryOrder.map((S) => ({
412
+ createdAt: st(new Date(S.createdAt)),
413
+ ref: S.deliveryOrderNumber,
414
+ remark: S.remark || "",
415
+ items: S.received.map((R) => {
416
+ var A;
417
+ return {
418
+ code: R.sku.code,
419
+ description: R.sku.name,
420
+ quantity: oe(R.amount),
421
+ unit: ((A = R.measurement) == null ? void 0 : A.abbrev) || R.sku.unit.abbrev
422
+ };
423
+ })
424
+ })), f = {
425
+ businessName: n == null ? void 0 : n.name,
426
+ logo: n == null ? void 0 : n.thumbnail,
427
+ orderNumber: t.seqNumber.toString(),
428
+ createdAt: ke(t._id),
429
+ ref: t.ref || "",
430
+ remark: t.remark || "",
431
+ buyer: y,
432
+ supplier: o,
433
+ items: v,
434
+ status: t.status,
435
+ deliveryOrders: m
436
+ }, r = new URL(window.location.href), b = h && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
437
+ r.pathname = r.hostname.includes("portal.feedme") ? `/inventory/${b}` : `/${b}`, r.searchParams.append("data", JSON.stringify(f)), window.open(r.href, "_blank", "noreferrer");
438
+ }
439
+ const ye = {
440
+ submitRequest: {
441
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
442
+ color: "text-fm-color-typo-primary",
443
+ value: T.enum.submitRequest
444
+ },
445
+ confirmDraft: {
446
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
447
+ color: "text-fm-color-typo-primary",
448
+ value: T.enum.confirmDraft
449
+ },
450
+ cancelDraft: {
451
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
452
+ color: "text-fm-color-typo-error",
453
+ value: T.enum.cancelDraft
454
+ },
455
+ approveRequest: {
456
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
457
+ color: "text-fm-color-typo-primary",
458
+ value: T.enum.approveRequest
459
+ },
460
+ rejectRequest: {
461
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
462
+ color: "text-fm-color-typo-error",
463
+ value: T.enum.rejectRequest
464
+ },
465
+ processRequest: {
466
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
467
+ color: "text-fm-color-typo-primary",
468
+ value: T.enum.processRequest
469
+ },
470
+ receiveStock: {
471
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
472
+ color: "text-fm-color-typo-primary",
473
+ value: T.enum.receiveStock
474
+ },
475
+ completeReceive: {
476
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
477
+ color: "text-fm-color-typo-primary",
478
+ value: T.enum.completeReceive
479
+ },
480
+ approveDraft: {
481
+ label: void 0,
482
+ translationKey: "",
483
+ color: "",
484
+ value: void 0
485
+ },
486
+ rejectDraft: {
487
+ label: void 0,
488
+ translationKey: "",
489
+ color: "",
490
+ value: void 0
491
+ }
492
+ };
493
+ function ks(t, l) {
494
+ ue();
495
+ const n = Le(), { t: h } = ot();
496
+ function i(m) {
497
+ switch (m.status) {
498
+ case "DRAFT":
499
+ return [
500
+ Z[K.Update],
501
+ Z[K.Details],
502
+ m.supplier.internal === "restaurant" || m.supplier.internal === "warehouse" ? ye[T.enum.submitRequest] : ye[T.enum.confirmDraft],
503
+ ye[T.enum.cancelDraft]
504
+ ];
505
+ case "RECEIVING":
506
+ return [
507
+ ye[T.enum.completeReceive],
508
+ Z[K.Details],
509
+ Z[K.Print]
510
+ ];
511
+ case "REQUESTING":
512
+ return t === "receive/request" ? [Z[K.Details], Z[K.Print]] : [
513
+ ye[T.enum.approveRequest],
514
+ ye[T.enum.rejectRequest],
515
+ Z[K.Details]
516
+ // DefaultRowActions[RowActionEnum.Print]
517
+ ];
518
+ case "PROCESSING":
519
+ return [Z[K.Details], Z[K.Print]];
520
+ case "COMPLETE":
521
+ case "CANCEL":
522
+ default:
523
+ return [Z[K.Details], Z[K.Print]];
524
+ }
525
+ }
526
+ function a(m) {
527
+ return Object.values(T.enum).includes(m);
528
+ }
529
+ async function d(m, f, r) {
530
+ var S, R, A, C;
531
+ const b = tt(f);
532
+ if (m === K.Print) {
533
+ const Q = (r == null ? void 0 : r.toInventoryLocation) ?? {
534
+ name: "",
535
+ type: "restaurant",
536
+ acceptRequest: !0,
537
+ dbName: "",
538
+ doc: {
539
+ _id: "",
540
+ businessId: "",
541
+ profile: {}
542
+ }
543
+ };
544
+ b.ref = [((S = r == null ? void 0 : r.netSuite) == null ? void 0 : S.refNo) || ((R = b.netSuite) == null ? void 0 : R.refNo)].filter((Y) => Y).join(" "), $t(b, Q, n.currentBusiness.value, t === "approval");
545
+ return;
546
+ }
547
+ if (m === K.Details) {
548
+ l.promptShowTransferDetails(b, r);
549
+ return;
550
+ }
551
+ if (m === K.Update) {
552
+ (A = l.promptUpdateTransferDialog) == null || A.call(l, b);
553
+ return;
554
+ }
555
+ if (a(m)) {
556
+ l.submitAction(f, m, (C = r == null ? void 0 : r.to) == null ? void 0 : C.dbName);
557
+ return;
558
+ }
559
+ }
560
+ function y() {
561
+ return [
562
+ {
563
+ accessorKey: "seqNumber",
564
+ header: () => h("inventory.transfer.table.seqNo"),
565
+ enableSorting: !0,
566
+ size: 80,
567
+ sortUndefined: "last"
568
+ },
569
+ {
570
+ accessorKey: "_id",
571
+ header: () => h("inventory.transfer.table.createdAt"),
572
+ cell(m) {
573
+ return ke(`${m.getValue()}`);
574
+ },
575
+ enableSorting: !0
576
+ },
577
+ {
578
+ accessorKey: "supplier.name",
579
+ header: () => h("inventory.transfer.table.transferFrom"),
580
+ enableSorting: !0,
581
+ size: 200
582
+ },
583
+ {
584
+ accessorKey: "items.length",
585
+ header: () => h("inventory.transfer.table.noOfItems"),
586
+ enableSorting: !1,
587
+ meta: {
588
+ width: "10rem"
589
+ }
590
+ },
591
+ {
592
+ accessorKey: "ref",
593
+ header: () => h("inventory.transfer.table.reference"),
594
+ enableSorting: !1,
595
+ size: "auto"
596
+ },
597
+ {
598
+ accessorKey: "status",
599
+ header: () => h("inventory.transfer.table.status"),
600
+ cell(m) {
601
+ const f = h(`inventory.transfer.status.${m.getValue() ?? ""}`), r = `${m.getValue() ?? ""}`.toLocaleLowerCase("en-us");
602
+ return N(
603
+ "div",
604
+ {
605
+ class: "flex"
606
+ },
607
+ N(
608
+ "div",
609
+ {
610
+ class: `fm-status-badge fm-status-badge-${r}`
611
+ },
612
+ f
613
+ )
614
+ );
615
+ },
616
+ enableSorting: !0,
617
+ size: 200
618
+ },
619
+ {
620
+ id: "action",
621
+ cell(m) {
622
+ const f = m.row.original, r = i(f);
623
+ return Xe(r, (b) => d(b, f));
624
+ },
625
+ enableSorting: !1,
626
+ size: 40,
627
+ meta: {
628
+ cellClass: "",
629
+ headerClass: ""
630
+ }
631
+ }
632
+ ];
633
+ }
634
+ function o() {
635
+ return [
636
+ {
637
+ accessorKey: "purchaseOrder.seqNumber",
638
+ header: () => h("inventory.transfer.table.seqNo"),
639
+ enableSorting: !0,
640
+ size: 80,
641
+ sortUndefined: "last"
642
+ },
643
+ {
644
+ accessorKey: "purchaseOrder._id",
645
+ header: () => h("inventory.transfer.table.createdAt"),
646
+ cell(m) {
647
+ return ke(`${m.getValue()}`);
648
+ },
649
+ enableSorting: !0
650
+ },
651
+ {
652
+ accessorKey: "to.name",
653
+ header: () => h("inventory.transfer.table.transferTo"),
654
+ enableSorting: !1,
655
+ size: 200
656
+ },
657
+ {
658
+ accessorKey: "purchaseOrder.items.length",
659
+ header: () => h("inventory.transfer.table.noOfItems"),
660
+ enableSorting: !1
661
+ },
662
+ {
663
+ accessorKey: "purchaseOrder.ref",
664
+ header: () => h("inventory.transfer.table.reference"),
665
+ enableSorting: !1,
666
+ size: "auto"
667
+ },
668
+ {
669
+ accessorKey: "purchaseOrder.status",
670
+ header: () => h("inventory.transfer.table.status"),
671
+ cell(m) {
672
+ const f = h(`inventory.transfer.status.${m.getValue() ?? ""}`), r = `${m.getValue() ?? ""}`.toLocaleLowerCase("en-us");
673
+ return N(
674
+ "div",
675
+ {
676
+ class: "flex"
677
+ },
678
+ N(
679
+ "div",
680
+ {
681
+ class: `fm-status-badge fm-status-badge-${r}`
682
+ },
683
+ f
684
+ )
685
+ );
686
+ },
687
+ enableSorting: !0
688
+ },
689
+ {
690
+ id: "action",
691
+ cell(m) {
692
+ const f = m.row.original, b = (f.purchaseOrder ? i(f.purchaseOrder) : []).map((S) => S.value === K.Print ? {
693
+ ...S,
694
+ translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
695
+ } : S);
696
+ return Xe(
697
+ b,
698
+ (S) => f.purchaseOrder ? d(S, f.purchaseOrder, f) : void 0
699
+ );
700
+ },
701
+ enableSorting: !1,
702
+ size: 40,
703
+ meta: {
704
+ cellClass: "",
705
+ headerClass: ""
706
+ }
707
+ }
708
+ ];
709
+ }
710
+ const v = z(() => t === "receive/request" ? y() : o());
711
+ return {
712
+ get columnDefs() {
713
+ return v.value;
714
+ }
715
+ };
716
+ }
717
+ const Ct = {
718
+ key: 0,
719
+ class: "flex flex-col gap-8"
720
+ }, It = { class: "flex flex-col gap-4" }, Ft = { class: "fm-typo-en-body-lg-600" }, Et = {
721
+ key: 0,
722
+ class: "flex flex-col gap-4"
723
+ }, Bt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ut = { class: "fm-typo-en-body-lg-600" }, Lt = { key: 0 }, Vt = { key: 1 }, Mt = {
724
+ key: 1,
725
+ class: "flex flex-col gap-4"
726
+ }, jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Kt = { class: "fm-typo-en-body-lg-600" }, zt = { key: 0 }, Gt = { key: 1 }, Ht = {
727
+ key: 2,
728
+ class: "flex flex-col gap-4"
729
+ }, Qt = { class: "fm-typo-en-body-lg-600" }, Yt = {
730
+ key: 3,
731
+ class: "flex flex-col gap-4"
732
+ }, Wt = { class: "fm-typo-en-body-lg-600" }, Xt = /* @__PURE__ */ De({
733
+ __name: "NetSuiteInfo",
734
+ props: {
735
+ transferType: {},
736
+ transferToDbName: {},
737
+ poRequest: {},
738
+ purchaseOrder: {},
739
+ isTransferBetweenOutlets: { type: Boolean },
740
+ scope: {}
741
+ },
742
+ setup(t) {
743
+ const l = t, n = Ue(), h = Ne(), i = V(l.poRequest);
744
+ at(async () => {
745
+ var o;
746
+ if (!l.poRequest && ((o = l.purchaseOrder) != null && o._id)) {
747
+ const v = await h.getLatestPurchaseOrderRequest(l.purchaseOrder._id);
748
+ i.value = v;
749
+ }
750
+ });
751
+ const a = z(
752
+ () => {
753
+ var o, v, m, f, r, b;
754
+ return n.getSubsidiaryFullName(
755
+ ((m = (v = (o = l.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : v.subsidiary) == null ? void 0 : m.id) || ((b = (r = (f = l.poRequest) == null ? void 0 : f.netSuite) == null ? void 0 : r.subsidiary) == null ? void 0 : b.id)
756
+ ).fullName;
757
+ }
758
+ ), d = z(() => {
759
+ var o, v, m, f, r, b, S, R, A, C, Q, Y;
760
+ return (m = (v = (o = l.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : v.additionalInfo) != null && m.transactionnumber ? (b = (r = (f = l.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : r.additionalInfo) == null ? void 0 : b.transactionnumber : (A = (R = (S = i.value) == null ? void 0 : S.netSuite) == null ? void 0 : R.additionalInfo) != null && A.transactionnumber ? (Y = (Q = (C = i.value) == null ? void 0 : C.netSuite) == null ? void 0 : Q.additionalInfo) == null ? void 0 : Y.transactionnumber : null;
761
+ }), y = z(() => {
762
+ var o, v, m, f, r, b;
763
+ return (v = (o = l.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) != null && v.length && ((f = (m = l.purchaseOrder) == null ? void 0 : m.deliveryFullfillment) == null ? void 0 : f.length) > 0 ? (b = (r = l.purchaseOrder) == null ? void 0 : r.deliveryFullfillment) == null ? void 0 : b.map((S) => {
764
+ var R;
765
+ return (R = S.netSuite) == null ? void 0 : R.refNo;
766
+ }).join(", ") : "N/A";
767
+ });
768
+ return (o, v) => {
769
+ var m, f, r, b, S, R, A, C, Q, Y, de, W, ae, ee;
770
+ return p(n).isEnabled ? (_(), D("div", Ct, [
771
+ s("div", It, [
772
+ v[0] || (v[0] = s("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
773
+ s("div", Ft, x(a.value || "N/A"), 1)
774
+ ]),
775
+ !o.isTransferBetweenOutlets && ((m = o.purchaseOrder) == null ? void 0 : m.status) !== p(se).Enum.REQUESTING && o.scope === p(Ee).RECEIVE_REQUEST ? (_(), D("div", Et, [
776
+ s("div", Bt, " NetSuite " + x(o.transferType === p(ve).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
777
+ s("div", Ut, [
778
+ (r = (f = o.purchaseOrder) == null ? void 0 : f.netSuite) != null && r.id ? (_(), D("span", Lt, x((S = (b = o.purchaseOrder) == null ? void 0 : b.netSuite) == null ? void 0 : S.refNo) + " (" + x((A = (R = o.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : A.id) + ") ", 1)) : (_(), D("span", Vt, "N/A"))
779
+ ])
780
+ ])) : L("", !0),
781
+ !o.isTransferBetweenOutlets && i.value && ((C = o.purchaseOrder) == null ? void 0 : C.status) === p(se).Enum.REQUESTING || o.scope === p(Ee).APPROVAL ? (_(), D("div", Mt, [
782
+ s("div", jt, " (Request) NetSuite " + x(o.transferType === p(ve).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
783
+ s("div", Kt, [
784
+ (Y = (Q = i.value) == null ? void 0 : Q.netSuite) != null && Y.id ? (_(), D("span", zt, x((W = (de = i.value) == null ? void 0 : de.netSuite) == null ? void 0 : W.refNo) + " (" + x((ee = (ae = i.value) == null ? void 0 : ae.netSuite) == null ? void 0 : ee.id) + ") ", 1)) : (_(), D("span", Gt, "N/A"))
785
+ ])
786
+ ])) : L("", !0),
787
+ d.value ? (_(), D("div", Ht, [
788
+ v[1] || (v[1] = s("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
789
+ s("div", Qt, x(d.value), 1)
790
+ ])) : L("", !0),
791
+ p(n).isEnabled && o.transferType === p(ve).TRANSFER && !o.isTransferBetweenOutlets ? (_(), D("div", Yt, [
792
+ v[2] || (v[2] = s("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
793
+ s("div", Wt, x(y.value), 1)
794
+ ])) : L("", !0)
795
+ ])) : L("", !0);
796
+ };
797
+ }
798
+ }), Jt = { class: "flex flex-row-reverse" }, Zt = /* @__PURE__ */ De({
799
+ __name: "NetSuiteSync",
800
+ props: {
801
+ poRequest: {},
802
+ purchaseOrder: {},
803
+ isTransferBetweenOutlets: { type: Boolean }
804
+ },
805
+ setup(t) {
806
+ const l = t, n = Ue(), h = Me(), i = Ve(), a = V(!1);
807
+ z(() => {
808
+ var m, f, r, b;
809
+ let y = !0;
810
+ n.isEnabled || (y = !1);
811
+ const o = l.purchaseOrder, v = l.poRequest;
812
+ return o && ((m = o == null ? void 0 : o.supplier) != null && m.internal ? (!v && o.status == se.enum.DRAFT && (y = !1), v && !((f = v == null ? void 0 : v.netSuite) != null && f.id) && (y = !1), l.isTransferBetweenOutlets && (y = !1)) : ((o == null ? void 0 : o.status) !== se.enum.REQUESTING && o.supplier.internal && (y = !1), !v && !((r = o == null ? void 0 : o.netSuite) != null && r.id) && (y = !1), !v && ((b = o == null ? void 0 : o.netSuite) != null && b.id) && (o == null ? void 0 : o.status) == se.enum.REQUESTING && (y = !1))), y;
813
+ });
814
+ async function d() {
815
+ a.value || i.open({
816
+ title: "Sync with NetSuite",
817
+ contentComponent: N("div", [
818
+ N("p", "Are you sure you want to sync now?"),
819
+ N("br"),
820
+ N(
821
+ "p",
822
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
823
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
824
+ )
825
+ ]),
826
+ primaryActions: {
827
+ text: "Sync",
828
+ close: !0,
829
+ variant: "destructive"
830
+ },
831
+ secondaryActions: { text: "Not now", close: !0 }
832
+ }).onPrimary(async () => {
833
+ var y, o;
834
+ try {
835
+ a.value = !0;
836
+ const v = ((y = l.purchaseOrder) == null ? void 0 : y._id) || ((o = l.poRequest) == null ? void 0 : o.purchaseOrderId) || "";
837
+ await n.syncPurchaseOrder(v), h.open({
838
+ title: "Sync with NetSuite",
839
+ message: "Requested to sync with NetSuite. Please wait a moment.",
840
+ type: "success"
841
+ });
842
+ } catch {
843
+ h.open({
844
+ title: "Error",
845
+ message: "Failed to sync with NetSuite",
846
+ type: "error"
847
+ });
848
+ }
849
+ setTimeout(() => {
850
+ a.value = !1;
851
+ }, 5e3);
852
+ });
853
+ }
854
+ return (y, o) => {
855
+ const v = G("FmButton");
856
+ return _(), D("div", Jt, [
857
+ F(v, {
858
+ "prepend-icon": "sync",
859
+ variant: "secondary",
860
+ label: "Sync",
861
+ loading: a.value,
862
+ onClick: d,
863
+ "text-color": "primary",
864
+ "bg-color": "transparent",
865
+ "border-color": "primary"
866
+ }, null, 8, ["loading"])
867
+ ]);
868
+ };
869
+ }
870
+ }), er = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, tr = { class: "flex flex-col gap-8" }, rr = { class: "flex w-full justify-end gap-16" }, sr = /* @__PURE__ */ De({
871
+ __name: "FulfillmentForm",
872
+ props: {
873
+ purchaseOrder: {},
874
+ confirm: { type: Function }
875
+ },
876
+ emits: ["update:show"],
877
+ setup(t, { emit: l }) {
878
+ const n = t, h = gt({
879
+ id: "",
880
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
881
+ items: []
882
+ }), i = V(), a = l;
883
+ return at(() => {
884
+ n.purchaseOrder && (console.log("props", n.purchaseOrder), h.items = n.purchaseOrder.items.map((d) => ({
885
+ id: d.id,
886
+ sku: d.sku,
887
+ measurement: d.measurement,
888
+ amount: d.quantity ?? { amount: 1, precision: 0 }
889
+ })));
890
+ }), (d, y) => {
891
+ const o = G("FmTable"), v = G("FmButton"), m = G("FmForm");
892
+ return _(), le(m, {
893
+ ref_key: "formRef",
894
+ ref: i,
895
+ class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
896
+ onValidationFailed: console.log,
897
+ onValidationSuccess: y[1] || (y[1] = () => n.confirm(h))
898
+ }, {
899
+ default: ie(() => [
900
+ y[2] || (y[2] = s("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
901
+ s("div", er, [
902
+ s("div", tr, [
903
+ F(o, {
904
+ "column-defs": [
905
+ {
906
+ header: "Code",
907
+ cell: (f) => {
908
+ const r = n.purchaseOrder.items.find((b) => b.id === f.row.original.id || b.sku._id === f.row.original.sku._id);
909
+ return N(
910
+ p(Ze).FmTooltip,
911
+ {
912
+ content: r.code,
913
+ placement: "top",
914
+ variant: "plain",
915
+ zIndex: 50
916
+ },
917
+ N(
918
+ "span",
919
+ {
920
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
921
+ },
922
+ r.code
923
+ )
924
+ );
925
+ }
926
+ },
927
+ {
928
+ header: "Name",
929
+ cell: (f) => {
930
+ const r = n.purchaseOrder.items.find((b) => b.id === f.row.original.id || b.sku._id === f.row.original.sku._id);
931
+ return N(
932
+ p(Ze).FmTooltip,
933
+ {
934
+ content: r.name,
935
+ placement: "top",
936
+ variant: "plain",
937
+ zIndex: 50
938
+ },
939
+ N(
940
+ "span",
941
+ {
942
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
943
+ },
944
+ r.name
945
+ )
946
+ );
947
+ }
948
+ },
949
+ {
950
+ header: "Amount",
951
+ cell: (f) => {
952
+ const r = f.row.original, b = n.purchaseOrder.items.find((R) => R.id === r.id || R.sku._id === r.sku._id), S = r.amount ?? {
953
+ amount: 1,
954
+ precision: 0
955
+ };
956
+ return N(At, {
957
+ style: {
958
+ flex: "1 1 0%"
959
+ },
960
+ modelValue: {
961
+ amount: S,
962
+ measurement: r.measurement ?? null
963
+ },
964
+ key: r.id ?? r.sku._id,
965
+ unit: r.sku.unit,
966
+ "onUpdate:modelValue": (R) => {
967
+ if (!R) return;
968
+ const A = h.items.find((C) => C.id === r.id || C.sku._id === r.sku._id);
969
+ A && (A.amount = R.amount);
970
+ },
971
+ disableUnit: !0,
972
+ rules: [
973
+ p(qt)(
974
+ +p(oe)({ amount: 0, precision: 0 })
975
+ ),
976
+ p(Pt)(+p(oe)(b.quantity))
977
+ ],
978
+ applyDefaultRules: !0
979
+ });
980
+ }
981
+ }
982
+ ],
983
+ "row-data": h.items,
984
+ "hide-footer": !0
985
+ }, null, 8, ["column-defs", "row-data"])
986
+ ])
987
+ ]),
988
+ s("div", rr, [
989
+ F(v, {
990
+ class: "px-16",
991
+ label: "Confirm",
992
+ size: "md",
993
+ variant: "primary",
994
+ type: "submit"
995
+ }),
996
+ F(v, {
997
+ class: "px-16",
998
+ label: "Cancel",
999
+ size: "md",
1000
+ variant: "secondary",
1001
+ onClick: y[0] || (y[0] = () => a("update:show", !1))
1002
+ })
1003
+ ])
1004
+ ]),
1005
+ _: 1
1006
+ }, 8, ["onValidationFailed"]);
1007
+ };
1008
+ }
1009
+ });
1010
+ var Be = /* @__PURE__ */ ((t) => (t.loading = "loading", t.error = "error", t.success = "success", t))(Be || {});
1011
+ function ar(t) {
1012
+ const l = V({
1013
+ state: "loading"
1014
+ /* loading */
1015
+ }), n = async (h) => {
1016
+ const i = h || t;
1017
+ if (!i) {
1018
+ l.value = { state: "error", error: new Error("No promise task provided") };
1019
+ return;
1020
+ }
1021
+ l.value = {
1022
+ state: "loading"
1023
+ /* loading */
1024
+ };
1025
+ try {
1026
+ const a = await i();
1027
+ l.value = { state: "success", data: a };
1028
+ } catch (a) {
1029
+ l.value = { state: "error", error: a };
1030
+ }
1031
+ };
1032
+ return t && n(), { result: l, execute: n };
1033
+ }
1034
+ const et = {
1035
+ submitRequest: {
1036
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1037
+ color: "primary",
1038
+ buttonVariant: re.Primary
1039
+ },
1040
+ confirmDraft: {
1041
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1042
+ color: "primary",
1043
+ buttonVariant: re.Primary
1044
+ },
1045
+ cancelDraft: {
1046
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1047
+ color: "system-error-300",
1048
+ buttonVariant: re.Destructive
1049
+ },
1050
+ approveDraft: {
1051
+ translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1052
+ color: "primary",
1053
+ buttonVariant: re.Primary
1054
+ },
1055
+ rejectDraft: {
1056
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1057
+ color: "system-error-300",
1058
+ buttonVariant: re.Destructive
1059
+ },
1060
+ approveRequest: {
1061
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1062
+ color: "primary",
1063
+ buttonVariant: re.Primary
1064
+ },
1065
+ processRequest: {
1066
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1067
+ color: "primary",
1068
+ buttonVariant: re.Primary
1069
+ },
1070
+ receiveStock: {
1071
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1072
+ color: "primary",
1073
+ buttonVariant: re.Primary
1074
+ },
1075
+ completeReceive: {
1076
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1077
+ color: "primary",
1078
+ buttonVariant: re.Plain
1079
+ },
1080
+ rejectRequest: {
1081
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1082
+ color: "system-error-300",
1083
+ buttonVariant: re.Destructive
1084
+ }
1085
+ };
1086
+ function nr() {
1087
+ return {
1088
+ ableToMarkReceived(t) {
1089
+ if (!t || t.status !== se.enum.RECEIVING)
1090
+ return !1;
1091
+ const n = ue().currentLocationDBName;
1092
+ return `${t.supplier.internal}_${t.supplier._id}` !== n;
1093
+ },
1094
+ ableToMarkApproved(t) {
1095
+ return !(!t || (t == null ? void 0 : t.status) !== se.enum.REQUESTING && (t == null ? void 0 : t.status) !== se.enum.PROCESSING);
1096
+ }
1097
+ };
1098
+ }
1099
+ const or = { class: "flex flex-col gap-16 w-full h-full" }, cr = { class: "flex justify-between" }, lr = { class: "fm-typo-en-body-lg-600" }, ir = { class: "flex flex-col gap-8" }, ur = { class: "flex flex-col gap-4" }, dr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, mr = { class: "flex gap-1" }, fr = { class: "fm-typo-en-body-lg-600" }, pr = {
1100
+ key: 0,
1101
+ class: "flex flex-col gap-4"
1102
+ }, yr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vr = { class: "fm-typo-en-body-lg-600" }, hr = { class: "flex flex-col gap-4" }, br = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, gr = { class: "fm-typo-en-body-lg-600" }, _r = {
1103
+ key: 1,
1104
+ class: "flex flex-col gap-4"
1105
+ }, wr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sr = { class: "fm-typo-en-body-lg-600" }, xr = {
1106
+ key: 2,
1107
+ class: "flex flex-col gap-4"
1108
+ }, Rr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Or = { class: "fm-typo-en-body-lg-600" }, kr = {
1109
+ key: 3,
1110
+ class: "flex flex-col gap-4"
1111
+ }, Dr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Nr = { class: "fm-typo-en-body-lg-600" }, Ar = {
1112
+ key: 4,
1113
+ class: "flex flex-col gap-4"
1114
+ }, qr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pr = { class: "fm-typo-en-body-lg-600" }, Tr = {
1115
+ key: 0,
1116
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1117
+ }, $r = { class: "flex gap-8 items-center" }, Cr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ir = { class: "flex flex-col gap-8" }, Fr = { class: "flex gap-8 items-center" }, Er = { class: "flex-1 fm-typo-en-body-lg-600" }, Br = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ur = { class: "flex w-full gap-4" }, Lr = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, Vr = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, Mr = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, jr = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Kr = {
1118
+ key: 0,
1119
+ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1120
+ }, zr = { class: "py-8" }, Gr = { class: "flex justify-end gap-4 items-center" }, Hr = { class: "fm-typo-en-body-lg-600" }, Qr = {
1121
+ key: 1,
1122
+ class: "flex-1 xs:w-screen xs:max-w-full"
1123
+ }, Yr = {
1124
+ key: 0,
1125
+ class: "flex flex-col items-center gap-8 h-full"
1126
+ }, Wr = ["src"], Xr = { class: "fm-typo-en-body-lg-600" }, Jr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Zr = {
1127
+ key: 1,
1128
+ class: "px-4 flex flex-col"
1129
+ }, es = { class: "flex gap-12 content-stretch" }, ts = {
1130
+ class: "flex flex-col w-24",
1131
+ name: "circles"
1132
+ }, rs = { class: "flex-1 flex flex-col items-center" }, ss = { class: "flex-1 flex flex-col items-center" }, as = {
1133
+ class: "py-12 flex flex-col gap-4",
1134
+ name: "received-at header"
1135
+ }, ns = { class: "fm-typo-en-body-lg-400" }, os = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, cs = { class: "flex gap-12 content-stretch" }, ls = {
1136
+ class: "flex flex-col w-24",
1137
+ name: "circles"
1138
+ }, is = { class: "flex-1 flex flex-col items-center" }, us = {
1139
+ class: "py-12 flex flex-col gap-4 flex-1",
1140
+ name: "delivery details"
1141
+ }, ds = { class: "flex flex-col gap-8" }, ms = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, fs = { class: "flex flex-col gap-4" }, ps = { class: "flex gap-8 xs:flex-col" }, Ds = /* @__PURE__ */ De({
1142
+ __name: "TransferDetails",
1143
+ props: {
1144
+ poRequest: {},
1145
+ purchaseOrder: {},
1146
+ transferTo: {},
1147
+ transferToDbName: {},
1148
+ show: { type: Boolean },
1149
+ canResubmit: { type: Boolean },
1150
+ canApprove: { type: Boolean },
1151
+ scope: {}
1152
+ },
1153
+ emits: ["update:show", "submitted"],
1154
+ setup(t, { emit: l }) {
1155
+ const n = t, h = l, i = Ve(), a = Me(), d = je(), y = Nt(), o = ue(), v = Le(), m = z(
1156
+ () => {
1157
+ var e, c;
1158
+ return {
1159
+ id: ((e = v.sessionUser.value) == null ? void 0 : e.id) ?? "",
1160
+ name: ((c = v.sessionUser.value) == null ? void 0 : c.displayName) ?? ""
1161
+ };
1162
+ }
1163
+ ), f = nr(), { t: r } = ot(), b = z(
1164
+ () => {
1165
+ var e, c, O, w;
1166
+ return ((c = (e = n.purchaseOrder) == null ? void 0 : e.supplier) == null ? void 0 : c.internal) === "restaurant" || ((w = (O = n.purchaseOrder) == null ? void 0 : O.supplier) == null ? void 0 : w.internal) === "warehouse" ? ve.TRANSFER : ve.PURCHASE;
1167
+ }
1168
+ ), S = z(() => {
1169
+ var e, c, O;
1170
+ return b.value === ve.TRANSFER && ((e = n.transferToDbName) == null ? void 0 : e.startsWith("restaurant")) && ((O = (c = n.purchaseOrder) == null ? void 0 : c.supplier) == null ? void 0 : O.internal) === "restaurant";
1171
+ }), R = V(!1), A = V(""), C = V(!0), Q = Ne(), Y = ar(Q.getWorkflowConfig), de = lt(), W = z(() => {
1172
+ if (!n.purchaseOrder)
1173
+ return [];
1174
+ const e = Y.result.value;
1175
+ if (e.state === Be.loading)
1176
+ return [];
1177
+ const c = {
1178
+ user: m.value,
1179
+ executedAt: o.locations.computeFirst(
1180
+ (O) => {
1181
+ var w;
1182
+ return O.dbName === ((w = o._currentLocation) == null ? void 0 : w.dbName) ? O : null;
1183
+ }
1184
+ ),
1185
+ purchaseOrderRequest: n.poRequest,
1186
+ purchaseOrder: n.purchaseOrder,
1187
+ platform: yt.enum.portal
1188
+ };
1189
+ return e.state === Be.error ? (console.error("Error fetching workflow config:", e.error), Ce.getAvailableActions({
1190
+ ...c,
1191
+ purchaseOrderConfig: Ce.getDefaultConfig()
1192
+ }).actions) : Ce.getAvailableActions({
1193
+ ...c,
1194
+ purchaseOrderConfig: e.data
1195
+ }).actions;
1196
+ }), ae = Dt(n, "show"), ee = z(() => [
1197
+ {
1198
+ label: r("inventory.transfer.receiveRequest.details.overview"),
1199
+ value: "overview"
1200
+ },
1201
+ {
1202
+ label: r("inventory.transfer.receiveRequest.details.deliveryHistory"),
1203
+ value: "deliveryHistory"
1204
+ }
1205
+ ]), ce = V(ee.value[0]);
1206
+ _t(
1207
+ () => n.show,
1208
+ (e) => {
1209
+ e && (ce.value = ee.value[0]);
1210
+ }
1211
+ );
1212
+ async function Ae(e, c, O, w, j) {
1213
+ return new Promise((E, H) => {
1214
+ i.open({
1215
+ closeButton: !1,
1216
+ title: w.title,
1217
+ message: w.message,
1218
+ primaryActions: w.primaryActions,
1219
+ secondaryActions: { text: "No", close: !1 }
1220
+ }).onPrimary(async () => {
1221
+ var u, q;
1222
+ try {
1223
+ await de({
1224
+ operate: {
1225
+ operation: O,
1226
+ doc: e,
1227
+ options: c
1228
+ },
1229
+ operateV2: {
1230
+ _id: ((u = n.purchaseOrder) == null ? void 0 : u._id) ?? "",
1231
+ _rev: ((q = n.purchaseOrder) == null ? void 0 : q._rev) ?? "",
1232
+ action: O
1233
+ // add payload if action is receiveStock or processRequest
1234
+ }
1235
+ }).delayed(1e3), E("submitted");
1236
+ } catch (U) {
1237
+ H(U);
1238
+ }
1239
+ }).onSecondary(() => {
1240
+ E("cancelled");
1241
+ for (let u = 0; u < j + 2; u++)
1242
+ i.close();
1243
+ }).onClose(() => {
1244
+ });
1245
+ });
1246
+ }
1247
+ async function he(e) {
1248
+ if (e === T.enum.receiveStock)
1249
+ return;
1250
+ const c = ct[e];
1251
+ if (!c) {
1252
+ a.open({
1253
+ title: "Something went wrong",
1254
+ message: `Cannot process order: ${rt(e)}`,
1255
+ type: "error"
1256
+ });
1257
+ return;
1258
+ }
1259
+ const { successMessage: O } = c;
1260
+ if (n.purchaseOrder) {
1261
+ A.value = `${e}`, R.value = !0, C.value = !1;
1262
+ const w = {};
1263
+ let j = 0;
1264
+ if ((e === T.enum.confirmDraft || // auto receive for warehouse to warehouse
1265
+ e === T.enum.completeReceive) && d.autoReceiveWarehouse)
1266
+ w.autoReceive = !0;
1267
+ else if (e === T.enum.approveRequest && d.acceptRequireFulfillment) {
1268
+ const E = await new Promise((H, u) => {
1269
+ i.open({
1270
+ closeButton: !1,
1271
+ title: "Confirm transfer amount",
1272
+ dialogComponent: sr,
1273
+ dialogComponentProps: {
1274
+ purchaseOrder: n.purchaseOrder,
1275
+ confirm: H,
1276
+ "onUpdate:show": (q) => {
1277
+ q || (A.value = "", R.value = !1, C.value = !0, j++, i.close()), u("cancelled");
1278
+ }
1279
+ }
1280
+ });
1281
+ });
1282
+ w.fulfillment = E;
1283
+ }
1284
+ try {
1285
+ const E = await Ae(
1286
+ n.purchaseOrder,
1287
+ w,
1288
+ e,
1289
+ c,
1290
+ j
1291
+ );
1292
+ a.open({
1293
+ title: "Success",
1294
+ message: O,
1295
+ type: "success"
1296
+ }), E === "submitted" && (a.open({
1297
+ title: "Success",
1298
+ message: O,
1299
+ type: "success"
1300
+ }), h("update:show", !1), h("submitted"));
1301
+ } catch (E) {
1302
+ a.open({
1303
+ title: "Something went wrong",
1304
+ message: "Please try again.",
1305
+ type: "error"
1306
+ }), console.error("Error when submitting PO operation", e, n.purchaseOrder, E);
1307
+ } finally {
1308
+ A.value = "", R.value = !1, C.value = !0;
1309
+ }
1310
+ }
1311
+ }
1312
+ const qe = z(() => {
1313
+ var e, c;
1314
+ return ((e = n.purchaseOrder) == null ? void 0 : e.status) === se.enum.RECEIVING || ((c = n.purchaseOrder) == null ? void 0 : c.status) === se.enum.COMPLETE;
1315
+ }), Pe = z(() => {
1316
+ var E, H, u;
1317
+ const O = (((E = n.purchaseOrder) == null ? void 0 : E.deliveryOrder) ?? []).flatMap((q) => q.received ?? []).reduce(
1318
+ (q, U) => {
1319
+ const X = q[U.sku._id] ?? [];
1320
+ return q[U.sku._id] = [...X, U], q;
1321
+ },
1322
+ {}
1323
+ ), w = Object.entries(O).reduce(
1324
+ (q, [U, X]) => {
1325
+ const B = X.reduce((J, I) => {
1326
+ const ne = vt(
1327
+ J,
1328
+ Math.max(J.precision, I.amount.precision)
1329
+ );
1330
+ return Fe(ne, I.amount);
1331
+ }, Oe(0));
1332
+ return q[U] = B, q;
1333
+ },
1334
+ {}
1335
+ ), j = ((H = n.purchaseOrder) == null ? void 0 : H.items) ?? [];
1336
+ for (const q of j)
1337
+ w[u = q.sku._id] ?? (w[u] = Oe(0));
1338
+ return w;
1339
+ }), g = z(() => {
1340
+ var E, H;
1341
+ const e = ((E = n.purchaseOrder) == null ? void 0 : E.deliveryOrder) ?? [], c = ((H = n.purchaseOrder) == null ? void 0 : H.deliveryFullfillment) ?? [], O = [
1342
+ ...e.map((u) => ({
1343
+ createdAt: u.createdAt,
1344
+ type: "grn",
1345
+ doc: u
1346
+ })),
1347
+ ...c.map((u) => ({
1348
+ createdAt: u.createdAt,
1349
+ type: "fulfillment",
1350
+ doc: u
1351
+ }))
1352
+ ];
1353
+ O.reverse().sort((u, q) => u.createdAt.localeCompare(q.createdAt));
1354
+ function w(u) {
1355
+ var X, B, J, I, ne, be, ge, _e, $;
1356
+ const q = c.findIndex((P) => P.id === u.fullfillmentId), U = [
1357
+ (B = (X = c[q]) == null ? void 0 : X.netSuite) != null && B.refNo ? {
1358
+ label: "Fulfillment's ref no. (Netsuite)",
1359
+ values: [(I = (J = c[q]) == null ? void 0 : J.netSuite) == null ? void 0 : I.refNo]
1360
+ } : null,
1361
+ (ne = u == null ? void 0 : u.netSuite) != null && ne.refNo ? {
1362
+ label: "Netsuite ref no.",
1363
+ values: [(be = u == null ? void 0 : u.netSuite) == null ? void 0 : be.refNo]
1364
+ } : null,
1365
+ (ge = u == null ? void 0 : u.netSuite) != null && ge.recordType ? {
1366
+ label: "Netsuite Type",
1367
+ values: [ht((_e = u == null ? void 0 : u.netSuite) == null ? void 0 : _e.recordType)]
1368
+ } : null
1369
+ ];
1370
+ return {
1371
+ header: "Received",
1372
+ date: Te(new Date(u.createdAt)),
1373
+ info: [
1374
+ {
1375
+ label: "Adjustment date",
1376
+ values: [
1377
+ u.adjustment ? Te(new Date(bt(u.adjustment))) : "-"
1378
+ ]
1379
+ },
1380
+ {
1381
+ label: "Received by",
1382
+ values: [($ = u.createdBy) == null ? void 0 : $.name]
1383
+ },
1384
+ {
1385
+ label: "Received items",
1386
+ values: u.received.map((P) => {
1387
+ var M;
1388
+ return N("div", [
1389
+ N(
1390
+ "div",
1391
+ {
1392
+ class: "flex gap-4"
1393
+ },
1394
+ [
1395
+ N(
1396
+ "div",
1397
+ {
1398
+ class: "flex flex-col"
1399
+ },
1400
+ [
1401
+ N(
1402
+ "span",
1403
+ {
1404
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1405
+ },
1406
+ `${P.sku.name}`
1407
+ ),
1408
+ N(
1409
+ "span",
1410
+ {
1411
+ class: "fm-typo-en-body-md-400"
1412
+ },
1413
+ `${P.sku.code} `
1414
+ )
1415
+ ]
1416
+ ),
1417
+ N(
1418
+ "div",
1419
+ {
1420
+ class: "ml-auto flex flex-col"
1421
+ },
1422
+ [
1423
+ N(
1424
+ "div",
1425
+ {
1426
+ class: "ml-auto flex gap-1"
1427
+ },
1428
+ [
1429
+ N(
1430
+ "span",
1431
+ {
1432
+ class: "fm-typo-en-body-lg-600 self-end"
1433
+ },
1434
+ oe(P.amount, !1)
1435
+ ),
1436
+ N(
1437
+ "span",
1438
+ {
1439
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1440
+ },
1441
+ ((M = P.measurement) == null ? void 0 : M.abbrev) ?? P.sku.unit.abbrev
1442
+ )
1443
+ ]
1444
+ ),
1445
+ N(
1446
+ "div",
1447
+ {
1448
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1449
+ },
1450
+ `${P.cost ? `(${xe(P.cost)})` : ""}`
1451
+ )
1452
+ ]
1453
+ )
1454
+ ]
1455
+ )
1456
+ ]);
1457
+ })
1458
+ },
1459
+ u.deliveryOrderNumber ? {
1460
+ label: "Delivery order no.",
1461
+ values: [u.deliveryOrderNumber]
1462
+ } : null,
1463
+ u.remark ? {
1464
+ label: "Remark",
1465
+ values: [u.remark]
1466
+ } : null,
1467
+ q > -1 ? {
1468
+ label: "Fulfilment's sequence",
1469
+ values: [`${q + 1}`]
1470
+ } : null,
1471
+ ...U
1472
+ ].filter((P) => P)
1473
+ };
1474
+ }
1475
+ function j(u) {
1476
+ var U, X;
1477
+ const q = c.findIndex((B) => B.id === u.id);
1478
+ return {
1479
+ header: "Fulfillment",
1480
+ date: Te(new Date(u.createdAt)),
1481
+ info: [
1482
+ {
1483
+ label: "Sequence",
1484
+ values: [String(q + 1)]
1485
+ },
1486
+ {
1487
+ label: "Receiveable items",
1488
+ values: u.items.map((B) => {
1489
+ var J;
1490
+ return N("div", [
1491
+ N(
1492
+ "div",
1493
+ {
1494
+ class: "flex gap-4"
1495
+ },
1496
+ [
1497
+ N(
1498
+ "div",
1499
+ {
1500
+ class: "flex flex-col"
1501
+ },
1502
+ [
1503
+ N(
1504
+ "span",
1505
+ {
1506
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1507
+ },
1508
+ `${B.sku.name}`
1509
+ ),
1510
+ N(
1511
+ "span",
1512
+ {
1513
+ class: "fm-typo-en-body-md-400"
1514
+ },
1515
+ `${B.sku.code} `
1516
+ )
1517
+ ]
1518
+ ),
1519
+ N(
1520
+ "div",
1521
+ {
1522
+ class: "ml-auto flex flex-col"
1523
+ },
1524
+ [
1525
+ N(
1526
+ "div",
1527
+ {
1528
+ class: "ml-auto flex gap-1"
1529
+ },
1530
+ [
1531
+ N(
1532
+ "span",
1533
+ {
1534
+ class: "fm-typo-en-body-lg-600 self-end"
1535
+ },
1536
+ oe(B.amount, !1)
1537
+ ),
1538
+ N(
1539
+ "span",
1540
+ {
1541
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1542
+ },
1543
+ ((J = B.measurement) == null ? void 0 : J.abbrev) ?? B.sku.unit.abbrev
1544
+ )
1545
+ ]
1546
+ ),
1547
+ N(
1548
+ "div",
1549
+ {
1550
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1551
+ },
1552
+ `${B.cost ? `(${xe(B.cost)})` : ""}`
1553
+ )
1554
+ ]
1555
+ )
1556
+ ]
1557
+ )
1558
+ ]);
1559
+ })
1560
+ },
1561
+ (U = u.netSuite) != null && U.refNo ? {
1562
+ label: "Ref no. (Netsuite)",
1563
+ values: [(X = u.netSuite) == null ? void 0 : X.refNo]
1564
+ } : null
1565
+ ].filter((B) => B)
1566
+ };
1567
+ }
1568
+ return O.map((u) => {
1569
+ switch (u.type) {
1570
+ case "grn":
1571
+ return w(u.doc);
1572
+ case "fulfillment":
1573
+ return j(u.doc);
1574
+ }
1575
+ });
1576
+ }), k = z(() => {
1577
+ var c;
1578
+ const e = {
1579
+ ...Oe(0),
1580
+ currency: Je()
1581
+ };
1582
+ return ((c = n.purchaseOrder) == null ? void 0 : c.items.reduce((O, w) => ({
1583
+ ...Fe(O, w.totalCost ?? e),
1584
+ currency: Je()
1585
+ }), e)) ?? e;
1586
+ });
1587
+ return (e, c) => {
1588
+ var B, J;
1589
+ const O = G("FmButtonGroup"), w = G("FmChip"), j = G("FmMenuDivider"), E = G("FmCard"), H = G("FmIcon"), u = G("FmTooltip"), q = G("FmSpacer"), U = G("FmButton"), X = G("FmSideSheet");
1590
+ return _(), le(X, {
1591
+ header: p(r)("inventory.transfer.receiveRequest.details.title") + ((B = e.purchaseOrder) != null && B.seqNumber ? ` #${(J = e.purchaseOrder) == null ? void 0 : J.seqNumber}` : ""),
1592
+ modelValue: p(ae),
1593
+ "onUpdate:modelValue": c[4] || (c[4] = (I) => wt(ae) ? ae.value = I : null),
1594
+ "dismiss-away": C.value,
1595
+ "close-button": "",
1596
+ "max-width": 600
1597
+ }, {
1598
+ default: ie(() => {
1599
+ var I, ne, be, ge, _e;
1600
+ return [
1601
+ s("div", or, [
1602
+ s("div", null, [
1603
+ F(O, {
1604
+ items: ee.value,
1605
+ modelValue: ce.value,
1606
+ "onUpdate:modelValue": c[0] || (c[0] = ($) => ce.value = $)
1607
+ }, null, 8, ["items", "modelValue"])
1608
+ ]),
1609
+ ce.value.value === "overview" ? (_(), D(te, { key: 0 }, [
1610
+ s("div", null, [
1611
+ F(E, {
1612
+ variant: "outlined",
1613
+ class: "flex flex-col gap-8 px-12 py-16"
1614
+ }, {
1615
+ default: ie(() => {
1616
+ var $, P, M, me, fe, Se, Ke, ze, Ge, He, Qe, Ye;
1617
+ return [
1618
+ s("div", cr, [
1619
+ s("div", lr, x(p(r)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1620
+ s("div", null, [
1621
+ F(w, {
1622
+ label: p(r)(`inventory.transfer.status.${($ = e.purchaseOrder) == null ? void 0 : $.status}`),
1623
+ class: Re(`fm-status-badge fm-status-badge-${(M = (P = e.purchaseOrder) == null ? void 0 : P.status) == null ? void 0 : M.toLocaleLowerCase("en-us")}`),
1624
+ compact: ""
1625
+ }, null, 8, ["label", "class"])
1626
+ ])
1627
+ ]),
1628
+ F(j),
1629
+ s("div", ir, [
1630
+ s("div", ur, [
1631
+ s("div", dr, [
1632
+ s("div", mr, x(p(r)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1633
+ ]),
1634
+ s("div", fr, x(p(ke)(((me = e.purchaseOrder) == null ? void 0 : me._id) ?? "")), 1)
1635
+ ]),
1636
+ (fe = e.purchaseOrder) != null && fe.effectiveAt ? (_(), D("div", pr, [
1637
+ s("div", yr, x(p(r)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1638
+ s("div", vr, x(p(st)(new Date((Se = e.purchaseOrder) == null ? void 0 : Se.effectiveAt))), 1)
1639
+ ])) : L("", !0),
1640
+ s("div", hr, [
1641
+ s("div", br, x(p(r)("inventory.transfer.receiveRequest.details.type.title")), 1),
1642
+ s("div", gr, x(p(r)(
1643
+ `inventory.transfer.receiveRequest.details.type.${b.value.toLocaleLowerCase("en-US")}`
1644
+ )), 1)
1645
+ ]),
1646
+ (ze = (Ke = e.purchaseOrder) == null ? void 0 : Ke.supplier) != null && ze.name ? (_(), D("div", _r, [
1647
+ s("div", wr, x(p(r)("inventory.transfer.receiveRequest.details.from")), 1),
1648
+ s("div", Sr, x((He = (Ge = e.purchaseOrder) == null ? void 0 : Ge.supplier) == null ? void 0 : He.name), 1)
1649
+ ])) : L("", !0),
1650
+ e.transferTo ? (_(), D("div", xr, [
1651
+ s("div", Rr, x(p(r)("inventory.transfer.receiveRequest.details.to")), 1),
1652
+ s("div", Or, x(e.transferTo), 1)
1653
+ ])) : L("", !0),
1654
+ (Qe = e.purchaseOrder) != null && Qe.ref ? (_(), D("div", kr, [
1655
+ s("div", Dr, x(p(r)("inventory.transfer.receiveRequest.details.reference")), 1),
1656
+ s("div", Nr, x(e.purchaseOrder.ref), 1)
1657
+ ])) : L("", !0),
1658
+ (Ye = e.purchaseOrder) != null && Ye.remark ? (_(), D("div", Ar, [
1659
+ s("div", qr, x(p(r)("inventory.transfer.receiveRequest.details.remark")), 1),
1660
+ s("div", Pr, x(e.purchaseOrder.remark), 1)
1661
+ ])) : L("", !0)
1662
+ ])
1663
+ ];
1664
+ }),
1665
+ _: 1
1666
+ })
1667
+ ]),
1668
+ p(y).isNetSuiteEnabled && !S.value ? (_(), D("div", Tr, [
1669
+ s("div", $r, [
1670
+ c[5] || (c[5] = s("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1671
+ s("div", null, [
1672
+ F(Zt, {
1673
+ "po-request": e.poRequest,
1674
+ "purchase-order": e.purchaseOrder,
1675
+ "is-transfer-between-outlets": S.value
1676
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets"])
1677
+ ])
1678
+ ]),
1679
+ F(j),
1680
+ F(Xt, {
1681
+ "po-request": e.poRequest,
1682
+ "purchase-order": e.purchaseOrder,
1683
+ "transfer-type": b.value,
1684
+ "transfer-to-db-name": e.transferToDbName,
1685
+ "is-transfer-between-outlets": S.value,
1686
+ scope: e.scope
1687
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1688
+ ])) : L("", !0),
1689
+ s("div", Cr, [
1690
+ s("div", Ir, [
1691
+ s("div", Fr, [
1692
+ s("span", Er, [
1693
+ $e(x(qe.value ? p(r)("inventory.transfer.receiveRequest.details.receivedItems") : p(r)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1694
+ (ne = (I = e.purchaseOrder) == null ? void 0 : I.netSuite) != null && ne.missingItems && ((ge = (be = e.purchaseOrder) == null ? void 0 : be.netSuite) == null ? void 0 : ge.missingItems.length) > 0 ? (_(), le(u, {
1695
+ key: 0,
1696
+ variant: "rich",
1697
+ placement: "top",
1698
+ "z-index": 51
1699
+ }, {
1700
+ content: ie(() => {
1701
+ var $, P;
1702
+ return [
1703
+ s("div", Br, [
1704
+ (_(!0), D(te, null, pe((P = ($ = e.purchaseOrder) == null ? void 0 : $.netSuite) == null ? void 0 : P.missingItems, (M, me) => (_(), D("div", {
1705
+ class: "flex justify-center align-middle",
1706
+ key: me
1707
+ }, [
1708
+ F(H, {
1709
+ name: "arrow_right",
1710
+ size: "sm"
1711
+ }),
1712
+ $e(" " + x(`(${M.netSuiteId}) ${M.name}: ${M.reason}`), 1)
1713
+ ]))), 128))
1714
+ ])
1715
+ ];
1716
+ }),
1717
+ default: ie(() => [
1718
+ F(H, {
1719
+ name: "error",
1720
+ color: "#ff2c2c",
1721
+ size: "sm"
1722
+ })
1723
+ ]),
1724
+ _: 1
1725
+ })) : L("", !0)
1726
+ ])
1727
+ ]),
1728
+ F(j),
1729
+ (_(!0), D(te, null, pe(((_e = e.purchaseOrder) == null ? void 0 : _e.items) ?? [], ($) => {
1730
+ var P;
1731
+ return _(), D("div", {
1732
+ key: $.code,
1733
+ class: "flex flex-col"
1734
+ }, [
1735
+ s("div", Ur, [
1736
+ s("div", Lr, x($.name), 1),
1737
+ s("div", Vr, x(p(oe)(Pe.value[$.sku._id], !1)) + "/" + x(p(nt)($.quantity, $.sku.unit, $.measurement)), 1)
1738
+ ]),
1739
+ s("div", Mr, [
1740
+ s("div", jr, x($.code), 1),
1741
+ (P = $.totalCost) != null && P.amount && p(d).enableTotalCost ? (_(), D("div", Kr, " (" + x(p(xe)($.totalCost)) + ") ", 1)) : L("", !0)
1742
+ ])
1743
+ ]);
1744
+ }), 128)),
1745
+ +p(oe)(k.value) ? (_(), D(te, { key: 0 }, [
1746
+ s("div", zr, [
1747
+ F(j)
1748
+ ]),
1749
+ s("div", Gr, [
1750
+ c[6] || (c[6] = s("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1751
+ s("div", Hr, x(p(xe)(k.value)), 1)
1752
+ ])
1753
+ ], 64)) : L("", !0)
1754
+ ])
1755
+ ])
1756
+ ], 64)) : ce.value.value === "deliveryHistory" ? (_(), D("div", Qr, [
1757
+ g.value.length ? (_(), D("div", Zr, [
1758
+ (_(!0), D(te, null, pe(g.value, ($, P) => (_(), D(te, { key: P }, [
1759
+ s("div", es, [
1760
+ s("div", ts, [
1761
+ s("div", rs, [
1762
+ s("div", {
1763
+ class: Re([
1764
+ {
1765
+ "bg-fm-color-primary": P !== 0,
1766
+ "bg-white": P === 0
1767
+ },
1768
+ "w-[2px] h-full"
1769
+ ])
1770
+ }, null, 2)
1771
+ ]),
1772
+ c[7] || (c[7] = s("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1773
+ s("div", ss, [
1774
+ s("div", {
1775
+ class: Re([
1776
+ {
1777
+ "bg-fm-color-primary": P < g.value.length - 1,
1778
+ "bg-white": P >= g.value.length - 1
1779
+ },
1780
+ "w-[2px] h-full"
1781
+ ])
1782
+ }, null, 2)
1783
+ ])
1784
+ ]),
1785
+ s("div", as, [
1786
+ s("div", ns, x($.header), 1),
1787
+ s("div", os, x($.date), 1)
1788
+ ])
1789
+ ]),
1790
+ s("div", cs, [
1791
+ s("div", ls, [
1792
+ s("div", is, [
1793
+ s("div", {
1794
+ class: Re([
1795
+ {
1796
+ "bg-fm-color-primary": P < g.value.length - 1,
1797
+ "bg-white": P >= g.value.length - 1
1798
+ },
1799
+ "w-[2px] h-full"
1800
+ ])
1801
+ }, null, 2)
1802
+ ])
1803
+ ]),
1804
+ s("div", us, [
1805
+ F(E, {
1806
+ variant: "outlined",
1807
+ class: "py-12 px-16"
1808
+ }, {
1809
+ default: ie(() => [
1810
+ s("div", ds, [
1811
+ (_(!0), D(te, null, pe($.info, (M, me) => (_(), D("div", {
1812
+ key: me,
1813
+ class: "flex flex-col gap-4"
1814
+ }, [
1815
+ s("div", ms, x(M == null ? void 0 : M.label), 1),
1816
+ s("div", fs, [
1817
+ (_(!0), D(te, null, pe(M == null ? void 0 : M.values, (fe, Se) => (_(), D("div", {
1818
+ key: Se,
1819
+ class: "fm-typo-en-body-lg-600"
1820
+ }, [
1821
+ typeof fe == "string" ? (_(), D(te, { key: 0 }, [
1822
+ $e(x(fe), 1)
1823
+ ], 64)) : (_(), le(St(fe), { key: 1 }))
1824
+ ]))), 128))
1825
+ ])
1826
+ ]))), 128))
1827
+ ])
1828
+ ]),
1829
+ _: 2
1830
+ }, 1024)
1831
+ ])
1832
+ ])
1833
+ ], 64))), 128))
1834
+ ])) : (_(), D("div", Yr, [
1835
+ F(q),
1836
+ s("div", null, [
1837
+ s("img", {
1838
+ src: p(kt),
1839
+ alt: "List is empty"
1840
+ }, null, 8, Wr)
1841
+ ]),
1842
+ s("div", Xr, x(p(r)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1843
+ s("div", Jr, x(p(r)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1844
+ F(q),
1845
+ F(q)
1846
+ ]))
1847
+ ])) : L("", !0)
1848
+ ])
1849
+ ];
1850
+ }),
1851
+ "side-sheet-footer": ie(() => [
1852
+ s("div", ps, [
1853
+ (_(!0), D(te, null, pe(W.value, (I) => (_(), le(U, {
1854
+ key: I,
1855
+ label: p(r)(p(et)[I].translationKey),
1856
+ onClick: (ne) => he(I),
1857
+ loading: A.value === I,
1858
+ disabled: A.value !== I && R.value,
1859
+ variant: p(et)[I].buttonVariant
1860
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"]))), 128)),
1861
+ p(f).ableToMarkReceived(e.purchaseOrder) && !W.value.includes("completeReceive") ? (_(), le(U, {
1862
+ key: 0,
1863
+ label: p(r)("inventory.transfer.receiveRequest.actions.completeReceive"),
1864
+ onClick: c[1] || (c[1] = (I) => he("completeReceive")),
1865
+ loading: A.value === "completeReceive",
1866
+ disabled: A.value !== "completeReceive" && R.value
1867
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
1868
+ p(f).ableToMarkApproved(e.purchaseOrder) && e.canApprove && !W.value.includes("approveRequest") ? (_(), le(U, {
1869
+ key: 1,
1870
+ label: p(r)("inventory.transfer.approval.actions.approveRequest"),
1871
+ onClick: c[2] || (c[2] = (I) => he("approveRequest")),
1872
+ loading: A.value === "approveRequest",
1873
+ disabled: A.value !== "approveRequest" && R.value
1874
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
1875
+ F(U, {
1876
+ label: p(r)("common.close"),
1877
+ variant: "tertiary",
1878
+ onClick: c[3] || (c[3] = (I) => h("update:show", !1))
1879
+ }, null, 8, ["label"])
1880
+ ])
1881
+ ]),
1882
+ _: 1
1883
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1884
+ };
1885
+ }
1886
+ });
1887
+ export {
1888
+ Ee as P,
1889
+ Ds as _,
1890
+ Os as a,
1891
+ ks as b,
1892
+ Tt as g,
1893
+ Ne as u
1894
+ };