@feedmepos/mf-inventory-portal 1.0.7 → 1.0.8-dev.2

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 (95) hide show
  1. package/dist/{App-DF14rGlK.js → App-VjopKXRf.js} +50 -49
  2. package/dist/{ApprovalView-C_xhq-_c.js → ApprovalView-Bc8OqfVg.js} +24 -24
  3. package/dist/{BindingsDialog-CCY1fDj8.js → BindingsDialog-zWAOfSXc.js} +4 -4
  4. package/dist/{BindingsPicker-CnXbK5O3.js → BindingsPicker-Bf5LuJiL.js} +6 -6
  5. package/dist/{BindingsTable-cQIUUuVv.js → BindingsTable-D2N-3mnJ.js} +8 -8
  6. package/dist/{ClosingDraftView-DUZ31x3s.js → ClosingDraftView-BwbzajJY.js} +464 -463
  7. package/dist/{ClosingTemplateView-6ysEDEcV.js → ClosingTemplateView-CsAIbfui.js} +10 -10
  8. package/dist/{DeliveryOrderPrintPreview-BGjFS8h7.js → DeliveryOrderPrintPreview-CjylpaJj.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CanJ2fzb.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C_xdzdLD.js} +32 -32
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BcKtJQMt.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DhgHX4S_.js} +86 -86
  11. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Bb9xMoX-.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DPa8Pto8.js} +1 -1
  12. package/dist/{IngredientGroupView-i08KHlW7.js → IngredientGroupView-D6YzbWdd.js} +11 -11
  13. package/dist/{IngredientsView-D0tBukwK.js → IngredientsView-g-73afqm.js} +15 -14
  14. package/dist/{IntegrationView-BqCrKL13.js → IntegrationView-CEML0dP4.js} +86 -85
  15. package/dist/{InventoryBindingForm-BJwIFQVS.js → InventoryBindingForm-E0wJOA8L.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DU9j1Q8M.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DFXmypAs.js} +27 -27
  17. package/dist/{InventoryBindingSummary-B2M3Th8T.js → InventoryBindingSummary-sBQvAPBw.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BH4A_Lc5.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DOeDgymo.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CdxCyEBi.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DIqYY1-C.js} +10 -10
  20. package/dist/{PublishView-B9x92vDM.js → PublishView-D_psCmiQ.js} +7 -7
  21. package/dist/{PurchaseOrderPrintPreview-MbGDNmgh.js → PurchaseOrderPrintPreview-5QqjPwWN.js} +4 -4
  22. package/dist/{ReceiveRequestView-CTNycYUr.js → ReceiveRequestView-CBGxqac6.js} +53 -52
  23. package/dist/{RecipeView-sHTcJgzP.js → RecipeView-BAjHNWST.js} +32 -32
  24. package/dist/{StockView-CUv4dcGJ.js → StockView-Bc62jbCV.js} +73 -72
  25. package/dist/{SupplierView-hu6OhDss.js → SupplierView-Cyucz_US.js} +159 -159
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CljJoB4v.js +1895 -0
  27. package/dist/{TransferTemplateView-DMSkUc0D.js → TransferTemplateView-BWURlmou.js} +291 -290
  28. package/dist/{UnitView-B5q7IVbT.js → UnitView-cjLpKfoN.js} +23 -23
  29. package/dist/{WarehouseView-Ds6z4Vz6.js → WarehouseView-CUtg5Aiw.js} +26 -26
  30. package/dist/api/bill.d.ts +2 -2
  31. package/dist/api/food-market-hub.d.ts +1 -1
  32. package/dist/api/inventory.d.ts +44 -44
  33. package/dist/api/netsuite.d.ts +3 -3
  34. package/dist/api/purchase-order.d.ts +5 -1
  35. package/dist/{app-BmsY87Mv.js → app-Dgg5mqsW.js} +17155 -17625
  36. package/dist/app.d.ts +7 -7
  37. package/dist/app.js +1 -1
  38. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +8 -8
  39. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +2 -2
  40. package/dist/components/shell/inventory/binding-ui.vue.d.ts +5 -5
  41. package/dist/composable/usePromise.d.ts +41 -0
  42. package/dist/{decimal-Baw9w4_A.js → decimal-DcqP_fAm.js} +1 -1
  43. package/dist/feature-C4mZ_d2m.js +17352 -0
  44. package/dist/{format-unit-display-D0_KiU3j.js → format-unit-display-D2Uk9Ze_.js} +60 -60
  45. package/dist/{index-CDydl7WA.js → index-YuTB_T1B.js} +1 -1
  46. package/dist/{index-C_GU5Tc8.js → index-peSGn9vg.js} +7 -6
  47. package/dist/{stock-C-hm8Kdq.js → stock-CDP8ZqBZ.js} +1 -1
  48. package/dist/stores/feature.d.ts +3 -20
  49. package/dist/stores/integration/foodmarkethub.d.ts +1 -1
  50. package/dist/stores/integration/netsuite.d.ts +7 -7
  51. package/dist/stores/inventory.d.ts +44 -44
  52. package/dist/stores/location.d.ts +137 -137
  53. package/dist/{supplier-RX_yr24c.js → supplier-C5GbDMxT.js} +4 -4
  54. package/dist/tsconfig.app.tsbuildinfo +1 -1
  55. package/dist/{use-ingredient-select-dialog-BZhczMUl.js → use-ingredient-select-dialog-nH01sayt.js} +1 -1
  56. package/dist/{use-inventory-binding-dialog-dV-92pLe.js → use-inventory-binding-dialog-CJe6QdGb.js} +1 -1
  57. package/dist/views/adjustment-template/wastage-template/actions.d.ts +228 -228
  58. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +2 -2
  59. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +1 -1
  60. package/dist/views/adjustment-template/wastage-template/table.d.ts +234 -234
  61. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +68 -68
  62. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +408 -408
  63. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +4 -4
  64. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +252 -252
  65. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +252 -252
  66. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +12 -12
  67. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +2 -2
  68. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +8 -8
  69. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +3 -3
  70. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +4 -4
  71. package/dist/views/integration/components/ApplyProduct.vue.d.ts +2 -2
  72. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +2 -2
  73. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +2 -2
  74. package/dist/views/integration/components/netsuite/AddLocationDialog.vue.d.ts +204 -204
  75. package/dist/views/integration/components/netsuite/LocationConfigurationDialog.vue.d.ts +2 -2
  76. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +665 -637
  77. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +22 -22
  78. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +44 -44
  79. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +11 -11
  80. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +614 -0
  81. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +1190 -1142
  82. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +1192 -1144
  83. package/dist/views/receive-request/constants/po-action-to-ui-style.d.ts +6 -0
  84. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -2
  85. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  86. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +14 -14
  87. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +22 -22
  88. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +17 -17
  89. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +11 -11
  90. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +805 -805
  91. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +805 -805
  92. package/dist/views/transfer-template/composables/useTransferTemplateHelper.d.ts +33 -33
  93. package/dist/{vue-i18n-sbHu6D5a.js → vue-i18n-NNRWZURD.js} +284 -284
  94. package/package.json +5 -3
  95. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CCKlQGMf.js +0 -1746
@@ -0,0 +1,1895 @@
1
+ import { X as it, u as ue, aH as P, 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 Pe, ar as bt } from "./app-Dgg5mqsW.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 H, createVNode as E, 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-DcqP_fAm.js";
4
+ import { b as Rt, u as Ot, f as nt, P as ve } from "./format-unit-display-D2Uk9Ze_.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-C4mZ_d2m.js";
9
+ import { u as Nt } from "./index-peSGn9vg.js";
10
+ import { _ as At, F as qt, a as Tt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DhgHX4S_.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
+ [P.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
+ [P.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
+ [P.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
+ [P.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
+ [P.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
+ [P.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 I(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 Y(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 W() {
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 X() {
230
+ switch (t) {
231
+ case "receive/request":
232
+ return W();
233
+ case "approval":
234
+ return de();
235
+ }
236
+ }
237
+ function ae(g, k) {
238
+ r.value = {
239
+ startDate: g,
240
+ endDate: k
241
+ }, X();
242
+ }
243
+ h.watchLocation(async (g) => {
244
+ if (!g) {
245
+ f.value = [];
246
+ return;
247
+ }
248
+ await X();
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 === P.enum.confirmDraft || // auto receive for warehouse to warehouse
282
+ k === P.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((B) => setTimeout(B, 1e3));
294
+ const j = ue().currentLocationDBName.startsWith("restaurant_");
295
+ k === P.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, X();
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 Te() {
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: X,
359
+ loading: o,
360
+ transferDialogProps: we,
361
+ promptCreateTransferDialog: I,
362
+ promptUpdateTransferDialog: Y,
363
+ transferDetailsProps: ee,
364
+ promptShowTransferDetails: Ae,
365
+ submitAction: qe,
366
+ xilnexImportDialogProps: Ie,
367
+ promptUploadTransferDialog: Te
368
+ };
369
+ }
370
+ function Pt(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, I = oe(
401
+ Pt(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: I
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: P.enum.submitRequest
444
+ },
445
+ confirmDraft: {
446
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
447
+ color: "text-fm-color-typo-primary",
448
+ value: P.enum.confirmDraft
449
+ },
450
+ cancelDraft: {
451
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
452
+ color: "text-fm-color-typo-error",
453
+ value: P.enum.cancelDraft
454
+ },
455
+ approveRequest: {
456
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
457
+ color: "text-fm-color-typo-primary",
458
+ value: P.enum.approveRequest
459
+ },
460
+ rejectRequest: {
461
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
462
+ color: "text-fm-color-typo-error",
463
+ value: P.enum.rejectRequest
464
+ },
465
+ processRequest: {
466
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
467
+ color: "text-fm-color-typo-primary",
468
+ value: P.enum.processRequest
469
+ },
470
+ receiveStock: {
471
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
472
+ color: "text-fm-color-typo-primary",
473
+ value: P.enum.receiveStock
474
+ },
475
+ completeReceive: {
476
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
477
+ color: "text-fm-color-typo-primary",
478
+ value: P.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[P.enum.submitRequest] : ye[P.enum.confirmDraft],
503
+ ye[P.enum.cancelDraft]
504
+ ];
505
+ case "RECEIVING":
506
+ return [
507
+ ye[P.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[P.enum.approveRequest],
514
+ ye[P.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(P.enum).includes(m);
528
+ }
529
+ async function d(m, f, r) {
530
+ var S, R, A, I;
531
+ const b = tt(f);
532
+ if (m === K.Print) {
533
+ const Y = (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((W) => W).join(" "), $t(b, Y, 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, (I = r == null ? void 0 : r.to) == null ? void 0 : I.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, I, Y, W;
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 ? (W = (Y = (I = i.value) == null ? void 0 : I.netSuite) == null ? void 0 : Y.additionalInfo) == null ? void 0 : W.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, I, Y, W, de, X, 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 && ((I = o.purchaseOrder) == null ? void 0 : I.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
+ (W = (Y = i.value) == null ? void 0 : Y.netSuite) != null && W.id ? (_(), D("span", zt, x((X = (de = i.value) == null ? void 0 : de.netSuite) == null ? void 0 : X.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 = H("FmButton");
856
+ return _(), D("div", Jt, [
857
+ E(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 = H("FmTable"), v = H("FmButton"), m = H("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
+ E(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((I) => I.id === r.id || I.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(Tt)(+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
+ E(v, {
990
+ class: "px-16",
991
+ label: "Confirm",
992
+ size: "md",
993
+ variant: "primary",
994
+ type: "submit"
995
+ }),
996
+ E(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" }, Tr = { class: "fm-typo-en-body-lg-600" }, Pr = {
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(""), I = V(!0), Y = Ne(), W = ar(Y.getWorkflowConfig), de = lt(), X = z(() => {
1172
+ if (!n.purchaseOrder)
1173
+ return [];
1174
+ const e = W.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((B, Q) => {
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, U, G;
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
+ transferTo: (G = (U = n.poRequest) == null ? void 0 : U.to) == null ? void 0 : G.dbName
1236
+ }).delayed(1e3), B("submitted");
1237
+ } catch (C) {
1238
+ Q(C);
1239
+ }
1240
+ }).onSecondary(() => {
1241
+ B("cancelled");
1242
+ for (let u = 0; u < j + 2; u++)
1243
+ i.close();
1244
+ }).onClose(() => {
1245
+ });
1246
+ });
1247
+ }
1248
+ async function he(e) {
1249
+ if (e === P.enum.receiveStock)
1250
+ return;
1251
+ const c = ct[e];
1252
+ if (!c) {
1253
+ a.open({
1254
+ title: "Something went wrong",
1255
+ message: `Cannot process order: ${rt(e)}`,
1256
+ type: "error"
1257
+ });
1258
+ return;
1259
+ }
1260
+ const { successMessage: O } = c;
1261
+ if (n.purchaseOrder) {
1262
+ A.value = `${e}`, R.value = !0, I.value = !1;
1263
+ const w = {};
1264
+ let j = 0;
1265
+ if ((e === P.enum.confirmDraft || // auto receive for warehouse to warehouse
1266
+ e === P.enum.completeReceive) && d.autoReceiveWarehouse)
1267
+ w.autoReceive = !0;
1268
+ else if (e === P.enum.approveRequest && d.acceptRequireFulfillment) {
1269
+ const B = await new Promise((Q, u) => {
1270
+ i.open({
1271
+ closeButton: !1,
1272
+ title: "Confirm transfer amount",
1273
+ dialogComponent: sr,
1274
+ dialogComponentProps: {
1275
+ purchaseOrder: n.purchaseOrder,
1276
+ confirm: Q,
1277
+ "onUpdate:show": (q) => {
1278
+ q || (A.value = "", R.value = !1, I.value = !0, j++, i.close()), u("cancelled");
1279
+ }
1280
+ }
1281
+ });
1282
+ });
1283
+ w.fulfillment = B;
1284
+ }
1285
+ try {
1286
+ const B = await Ae(
1287
+ n.purchaseOrder,
1288
+ w,
1289
+ e,
1290
+ c,
1291
+ j
1292
+ );
1293
+ a.open({
1294
+ title: "Success",
1295
+ message: O,
1296
+ type: "success"
1297
+ }), B === "submitted" && (a.open({
1298
+ title: "Success",
1299
+ message: O,
1300
+ type: "success"
1301
+ }), h("update:show", !1), h("submitted"));
1302
+ } catch (B) {
1303
+ a.open({
1304
+ title: "Something went wrong",
1305
+ message: "Please try again.",
1306
+ type: "error"
1307
+ }), console.error("Error when submitting PO operation", e, n.purchaseOrder, B);
1308
+ } finally {
1309
+ A.value = "", R.value = !1, I.value = !0;
1310
+ }
1311
+ }
1312
+ }
1313
+ const qe = z(() => {
1314
+ var e, c;
1315
+ return ((e = n.purchaseOrder) == null ? void 0 : e.status) === se.enum.RECEIVING || ((c = n.purchaseOrder) == null ? void 0 : c.status) === se.enum.COMPLETE;
1316
+ }), Te = z(() => {
1317
+ var B, Q, u;
1318
+ const O = (((B = n.purchaseOrder) == null ? void 0 : B.deliveryOrder) ?? []).flatMap((q) => q.received ?? []).reduce(
1319
+ (q, U) => {
1320
+ const G = q[U.sku._id] ?? [];
1321
+ return q[U.sku._id] = [...G, U], q;
1322
+ },
1323
+ {}
1324
+ ), w = Object.entries(O).reduce(
1325
+ (q, [U, G]) => {
1326
+ const C = G.reduce((J, F) => {
1327
+ const ne = vt(
1328
+ J,
1329
+ Math.max(J.precision, F.amount.precision)
1330
+ );
1331
+ return Fe(ne, F.amount);
1332
+ }, Oe(0));
1333
+ return q[U] = C, q;
1334
+ },
1335
+ {}
1336
+ ), j = ((Q = n.purchaseOrder) == null ? void 0 : Q.items) ?? [];
1337
+ for (const q of j)
1338
+ w[u = q.sku._id] ?? (w[u] = Oe(0));
1339
+ return w;
1340
+ }), g = z(() => {
1341
+ var B, Q;
1342
+ const e = ((B = n.purchaseOrder) == null ? void 0 : B.deliveryOrder) ?? [], c = ((Q = n.purchaseOrder) == null ? void 0 : Q.deliveryFullfillment) ?? [], O = [
1343
+ ...e.map((u) => ({
1344
+ createdAt: u.createdAt,
1345
+ type: "grn",
1346
+ doc: u
1347
+ })),
1348
+ ...c.map((u) => ({
1349
+ createdAt: u.createdAt,
1350
+ type: "fulfillment",
1351
+ doc: u
1352
+ }))
1353
+ ];
1354
+ O.reverse().sort((u, q) => u.createdAt.localeCompare(q.createdAt));
1355
+ function w(u) {
1356
+ var G, C, J, F, ne, be, ge, _e, $;
1357
+ const q = c.findIndex((T) => T.id === u.fullfillmentId), U = [
1358
+ (C = (G = c[q]) == null ? void 0 : G.netSuite) != null && C.refNo ? {
1359
+ label: "Fulfillment's ref no. (Netsuite)",
1360
+ values: [(F = (J = c[q]) == null ? void 0 : J.netSuite) == null ? void 0 : F.refNo]
1361
+ } : null,
1362
+ (ne = u == null ? void 0 : u.netSuite) != null && ne.refNo ? {
1363
+ label: "Netsuite ref no.",
1364
+ values: [(be = u == null ? void 0 : u.netSuite) == null ? void 0 : be.refNo]
1365
+ } : null,
1366
+ (ge = u == null ? void 0 : u.netSuite) != null && ge.recordType ? {
1367
+ label: "Netsuite Type",
1368
+ values: [ht((_e = u == null ? void 0 : u.netSuite) == null ? void 0 : _e.recordType)]
1369
+ } : null
1370
+ ];
1371
+ return {
1372
+ header: "Received",
1373
+ date: Pe(new Date(u.createdAt)),
1374
+ info: [
1375
+ {
1376
+ label: "Adjustment date",
1377
+ values: [
1378
+ u.adjustment ? Pe(new Date(bt(u.adjustment))) : "-"
1379
+ ]
1380
+ },
1381
+ {
1382
+ label: "Received by",
1383
+ values: [($ = u.createdBy) == null ? void 0 : $.name]
1384
+ },
1385
+ {
1386
+ label: "Received items",
1387
+ values: u.received.map((T) => {
1388
+ var M;
1389
+ return N("div", [
1390
+ N(
1391
+ "div",
1392
+ {
1393
+ class: "flex gap-4"
1394
+ },
1395
+ [
1396
+ N(
1397
+ "div",
1398
+ {
1399
+ class: "flex flex-col"
1400
+ },
1401
+ [
1402
+ N(
1403
+ "span",
1404
+ {
1405
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1406
+ },
1407
+ `${T.sku.name}`
1408
+ ),
1409
+ N(
1410
+ "span",
1411
+ {
1412
+ class: "fm-typo-en-body-md-400"
1413
+ },
1414
+ `${T.sku.code} `
1415
+ )
1416
+ ]
1417
+ ),
1418
+ N(
1419
+ "div",
1420
+ {
1421
+ class: "ml-auto flex flex-col"
1422
+ },
1423
+ [
1424
+ N(
1425
+ "div",
1426
+ {
1427
+ class: "ml-auto flex gap-1"
1428
+ },
1429
+ [
1430
+ N(
1431
+ "span",
1432
+ {
1433
+ class: "fm-typo-en-body-lg-600 self-end"
1434
+ },
1435
+ oe(T.amount, !1)
1436
+ ),
1437
+ N(
1438
+ "span",
1439
+ {
1440
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1441
+ },
1442
+ ((M = T.measurement) == null ? void 0 : M.abbrev) ?? T.sku.unit.abbrev
1443
+ )
1444
+ ]
1445
+ ),
1446
+ N(
1447
+ "div",
1448
+ {
1449
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1450
+ },
1451
+ `${T.cost ? `(${xe(T.cost)})` : ""}`
1452
+ )
1453
+ ]
1454
+ )
1455
+ ]
1456
+ )
1457
+ ]);
1458
+ })
1459
+ },
1460
+ u.deliveryOrderNumber ? {
1461
+ label: "Delivery order no.",
1462
+ values: [u.deliveryOrderNumber]
1463
+ } : null,
1464
+ u.remark ? {
1465
+ label: "Remark",
1466
+ values: [u.remark]
1467
+ } : null,
1468
+ q > -1 ? {
1469
+ label: "Fulfilment's sequence",
1470
+ values: [`${q + 1}`]
1471
+ } : null,
1472
+ ...U
1473
+ ].filter((T) => T)
1474
+ };
1475
+ }
1476
+ function j(u) {
1477
+ var U, G;
1478
+ const q = c.findIndex((C) => C.id === u.id);
1479
+ return {
1480
+ header: "Fulfillment",
1481
+ date: Pe(new Date(u.createdAt)),
1482
+ info: [
1483
+ {
1484
+ label: "Sequence",
1485
+ values: [String(q + 1)]
1486
+ },
1487
+ {
1488
+ label: "Receiveable items",
1489
+ values: u.items.map((C) => {
1490
+ var J;
1491
+ return N("div", [
1492
+ N(
1493
+ "div",
1494
+ {
1495
+ class: "flex gap-4"
1496
+ },
1497
+ [
1498
+ N(
1499
+ "div",
1500
+ {
1501
+ class: "flex flex-col"
1502
+ },
1503
+ [
1504
+ N(
1505
+ "span",
1506
+ {
1507
+ class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1508
+ },
1509
+ `${C.sku.name}`
1510
+ ),
1511
+ N(
1512
+ "span",
1513
+ {
1514
+ class: "fm-typo-en-body-md-400"
1515
+ },
1516
+ `${C.sku.code} `
1517
+ )
1518
+ ]
1519
+ ),
1520
+ N(
1521
+ "div",
1522
+ {
1523
+ class: "ml-auto flex flex-col"
1524
+ },
1525
+ [
1526
+ N(
1527
+ "div",
1528
+ {
1529
+ class: "ml-auto flex gap-1"
1530
+ },
1531
+ [
1532
+ N(
1533
+ "span",
1534
+ {
1535
+ class: "fm-typo-en-body-lg-600 self-end"
1536
+ },
1537
+ oe(C.amount, !1)
1538
+ ),
1539
+ N(
1540
+ "span",
1541
+ {
1542
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1543
+ },
1544
+ ((J = C.measurement) == null ? void 0 : J.abbrev) ?? C.sku.unit.abbrev
1545
+ )
1546
+ ]
1547
+ ),
1548
+ N(
1549
+ "div",
1550
+ {
1551
+ class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1552
+ },
1553
+ `${C.cost ? `(${xe(C.cost)})` : ""}`
1554
+ )
1555
+ ]
1556
+ )
1557
+ ]
1558
+ )
1559
+ ]);
1560
+ })
1561
+ },
1562
+ (U = u.netSuite) != null && U.refNo ? {
1563
+ label: "Ref no. (Netsuite)",
1564
+ values: [(G = u.netSuite) == null ? void 0 : G.refNo]
1565
+ } : null
1566
+ ].filter((C) => C)
1567
+ };
1568
+ }
1569
+ return O.map((u) => {
1570
+ switch (u.type) {
1571
+ case "grn":
1572
+ return w(u.doc);
1573
+ case "fulfillment":
1574
+ return j(u.doc);
1575
+ }
1576
+ });
1577
+ }), k = z(() => {
1578
+ var c;
1579
+ const e = {
1580
+ ...Oe(0),
1581
+ currency: Je()
1582
+ };
1583
+ return ((c = n.purchaseOrder) == null ? void 0 : c.items.reduce((O, w) => ({
1584
+ ...Fe(O, w.totalCost ?? e),
1585
+ currency: Je()
1586
+ }), e)) ?? e;
1587
+ });
1588
+ return (e, c) => {
1589
+ var C, J;
1590
+ const O = H("FmButtonGroup"), w = H("FmChip"), j = H("FmMenuDivider"), B = H("FmCard"), Q = H("FmIcon"), u = H("FmTooltip"), q = H("FmSpacer"), U = H("FmButton"), G = H("FmSideSheet");
1591
+ return _(), le(G, {
1592
+ header: p(r)("inventory.transfer.receiveRequest.details.title") + ((C = e.purchaseOrder) != null && C.seqNumber ? ` #${(J = e.purchaseOrder) == null ? void 0 : J.seqNumber}` : ""),
1593
+ modelValue: p(ae),
1594
+ "onUpdate:modelValue": c[4] || (c[4] = (F) => wt(ae) ? ae.value = F : null),
1595
+ "dismiss-away": I.value,
1596
+ "close-button": "",
1597
+ "max-width": 600
1598
+ }, {
1599
+ default: ie(() => {
1600
+ var F, ne, be, ge, _e;
1601
+ return [
1602
+ s("div", or, [
1603
+ s("div", null, [
1604
+ E(O, {
1605
+ items: ee.value,
1606
+ modelValue: ce.value,
1607
+ "onUpdate:modelValue": c[0] || (c[0] = ($) => ce.value = $)
1608
+ }, null, 8, ["items", "modelValue"])
1609
+ ]),
1610
+ ce.value.value === "overview" ? (_(), D(te, { key: 0 }, [
1611
+ s("div", null, [
1612
+ E(B, {
1613
+ variant: "outlined",
1614
+ class: "flex flex-col gap-8 px-12 py-16"
1615
+ }, {
1616
+ default: ie(() => {
1617
+ var $, T, M, me, fe, Se, Ke, ze, Ge, He, Qe, Ye;
1618
+ return [
1619
+ s("div", cr, [
1620
+ s("div", lr, x(p(r)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1621
+ s("div", null, [
1622
+ E(w, {
1623
+ label: p(r)(`inventory.transfer.status.${($ = e.purchaseOrder) == null ? void 0 : $.status}`),
1624
+ class: Re(`fm-status-badge fm-status-badge-${(M = (T = e.purchaseOrder) == null ? void 0 : T.status) == null ? void 0 : M.toLocaleLowerCase("en-us")}`),
1625
+ compact: ""
1626
+ }, null, 8, ["label", "class"])
1627
+ ])
1628
+ ]),
1629
+ E(j),
1630
+ s("div", ir, [
1631
+ s("div", ur, [
1632
+ s("div", dr, [
1633
+ s("div", mr, x(p(r)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1634
+ ]),
1635
+ s("div", fr, x(p(ke)(((me = e.purchaseOrder) == null ? void 0 : me._id) ?? "")), 1)
1636
+ ]),
1637
+ (fe = e.purchaseOrder) != null && fe.effectiveAt ? (_(), D("div", pr, [
1638
+ s("div", yr, x(p(r)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1639
+ s("div", vr, x(p(st)(new Date((Se = e.purchaseOrder) == null ? void 0 : Se.effectiveAt))), 1)
1640
+ ])) : L("", !0),
1641
+ s("div", hr, [
1642
+ s("div", br, x(p(r)("inventory.transfer.receiveRequest.details.type.title")), 1),
1643
+ s("div", gr, x(p(r)(
1644
+ `inventory.transfer.receiveRequest.details.type.${b.value.toLocaleLowerCase("en-US")}`
1645
+ )), 1)
1646
+ ]),
1647
+ (ze = (Ke = e.purchaseOrder) == null ? void 0 : Ke.supplier) != null && ze.name ? (_(), D("div", _r, [
1648
+ s("div", wr, x(p(r)("inventory.transfer.receiveRequest.details.from")), 1),
1649
+ s("div", Sr, x((He = (Ge = e.purchaseOrder) == null ? void 0 : Ge.supplier) == null ? void 0 : He.name), 1)
1650
+ ])) : L("", !0),
1651
+ e.transferTo ? (_(), D("div", xr, [
1652
+ s("div", Rr, x(p(r)("inventory.transfer.receiveRequest.details.to")), 1),
1653
+ s("div", Or, x(e.transferTo), 1)
1654
+ ])) : L("", !0),
1655
+ (Qe = e.purchaseOrder) != null && Qe.ref ? (_(), D("div", kr, [
1656
+ s("div", Dr, x(p(r)("inventory.transfer.receiveRequest.details.reference")), 1),
1657
+ s("div", Nr, x(e.purchaseOrder.ref), 1)
1658
+ ])) : L("", !0),
1659
+ (Ye = e.purchaseOrder) != null && Ye.remark ? (_(), D("div", Ar, [
1660
+ s("div", qr, x(p(r)("inventory.transfer.receiveRequest.details.remark")), 1),
1661
+ s("div", Tr, x(e.purchaseOrder.remark), 1)
1662
+ ])) : L("", !0)
1663
+ ])
1664
+ ];
1665
+ }),
1666
+ _: 1
1667
+ })
1668
+ ]),
1669
+ p(y).isNetSuiteEnabled && !S.value ? (_(), D("div", Pr, [
1670
+ s("div", $r, [
1671
+ c[5] || (c[5] = s("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1672
+ s("div", null, [
1673
+ E(Zt, {
1674
+ "po-request": e.poRequest,
1675
+ "purchase-order": e.purchaseOrder,
1676
+ "is-transfer-between-outlets": S.value
1677
+ }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets"])
1678
+ ])
1679
+ ]),
1680
+ E(j),
1681
+ E(Xt, {
1682
+ "po-request": e.poRequest,
1683
+ "purchase-order": e.purchaseOrder,
1684
+ "transfer-type": b.value,
1685
+ "transfer-to-db-name": e.transferToDbName,
1686
+ "is-transfer-between-outlets": S.value,
1687
+ scope: e.scope
1688
+ }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1689
+ ])) : L("", !0),
1690
+ s("div", Cr, [
1691
+ s("div", Ir, [
1692
+ s("div", Fr, [
1693
+ s("span", Er, [
1694
+ $e(x(qe.value ? p(r)("inventory.transfer.receiveRequest.details.receivedItems") : p(r)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1695
+ (ne = (F = e.purchaseOrder) == null ? void 0 : F.netSuite) != null && ne.missingItems && ((ge = (be = e.purchaseOrder) == null ? void 0 : be.netSuite) == null ? void 0 : ge.missingItems.length) > 0 ? (_(), le(u, {
1696
+ key: 0,
1697
+ variant: "rich",
1698
+ placement: "top",
1699
+ "z-index": 51
1700
+ }, {
1701
+ content: ie(() => {
1702
+ var $, T;
1703
+ return [
1704
+ s("div", Br, [
1705
+ (_(!0), D(te, null, pe((T = ($ = e.purchaseOrder) == null ? void 0 : $.netSuite) == null ? void 0 : T.missingItems, (M, me) => (_(), D("div", {
1706
+ class: "flex justify-center align-middle",
1707
+ key: me
1708
+ }, [
1709
+ E(Q, {
1710
+ name: "arrow_right",
1711
+ size: "sm"
1712
+ }),
1713
+ $e(" " + x(`(${M.netSuiteId}) ${M.name}: ${M.reason}`), 1)
1714
+ ]))), 128))
1715
+ ])
1716
+ ];
1717
+ }),
1718
+ default: ie(() => [
1719
+ E(Q, {
1720
+ name: "error",
1721
+ color: "#ff2c2c",
1722
+ size: "sm"
1723
+ })
1724
+ ]),
1725
+ _: 1
1726
+ })) : L("", !0)
1727
+ ])
1728
+ ]),
1729
+ E(j),
1730
+ (_(!0), D(te, null, pe(((_e = e.purchaseOrder) == null ? void 0 : _e.items) ?? [], ($) => {
1731
+ var T;
1732
+ return _(), D("div", {
1733
+ key: $.code,
1734
+ class: "flex flex-col"
1735
+ }, [
1736
+ s("div", Ur, [
1737
+ s("div", Lr, x($.name), 1),
1738
+ s("div", Vr, x(p(oe)(Te.value[$.sku._id], !1)) + "/" + x(p(nt)($.quantity, $.sku.unit, $.measurement)), 1)
1739
+ ]),
1740
+ s("div", Mr, [
1741
+ s("div", jr, x($.code), 1),
1742
+ (T = $.totalCost) != null && T.amount && p(d).enableTotalCost ? (_(), D("div", Kr, " (" + x(p(xe)($.totalCost)) + ") ", 1)) : L("", !0)
1743
+ ])
1744
+ ]);
1745
+ }), 128)),
1746
+ +p(oe)(k.value) ? (_(), D(te, { key: 0 }, [
1747
+ s("div", zr, [
1748
+ E(j)
1749
+ ]),
1750
+ s("div", Gr, [
1751
+ c[6] || (c[6] = s("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1752
+ s("div", Hr, x(p(xe)(k.value)), 1)
1753
+ ])
1754
+ ], 64)) : L("", !0)
1755
+ ])
1756
+ ])
1757
+ ], 64)) : ce.value.value === "deliveryHistory" ? (_(), D("div", Qr, [
1758
+ g.value.length ? (_(), D("div", Zr, [
1759
+ (_(!0), D(te, null, pe(g.value, ($, T) => (_(), D(te, { key: T }, [
1760
+ s("div", es, [
1761
+ s("div", ts, [
1762
+ s("div", rs, [
1763
+ s("div", {
1764
+ class: Re([
1765
+ {
1766
+ "bg-fm-color-primary": T !== 0,
1767
+ "bg-white": T === 0
1768
+ },
1769
+ "w-[2px] h-full"
1770
+ ])
1771
+ }, null, 2)
1772
+ ]),
1773
+ c[7] || (c[7] = s("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1774
+ s("div", ss, [
1775
+ s("div", {
1776
+ class: Re([
1777
+ {
1778
+ "bg-fm-color-primary": T < g.value.length - 1,
1779
+ "bg-white": T >= g.value.length - 1
1780
+ },
1781
+ "w-[2px] h-full"
1782
+ ])
1783
+ }, null, 2)
1784
+ ])
1785
+ ]),
1786
+ s("div", as, [
1787
+ s("div", ns, x($.header), 1),
1788
+ s("div", os, x($.date), 1)
1789
+ ])
1790
+ ]),
1791
+ s("div", cs, [
1792
+ s("div", ls, [
1793
+ s("div", is, [
1794
+ s("div", {
1795
+ class: Re([
1796
+ {
1797
+ "bg-fm-color-primary": T < g.value.length - 1,
1798
+ "bg-white": T >= g.value.length - 1
1799
+ },
1800
+ "w-[2px] h-full"
1801
+ ])
1802
+ }, null, 2)
1803
+ ])
1804
+ ]),
1805
+ s("div", us, [
1806
+ E(B, {
1807
+ variant: "outlined",
1808
+ class: "py-12 px-16"
1809
+ }, {
1810
+ default: ie(() => [
1811
+ s("div", ds, [
1812
+ (_(!0), D(te, null, pe($.info, (M, me) => (_(), D("div", {
1813
+ key: me,
1814
+ class: "flex flex-col gap-4"
1815
+ }, [
1816
+ s("div", ms, x(M == null ? void 0 : M.label), 1),
1817
+ s("div", fs, [
1818
+ (_(!0), D(te, null, pe(M == null ? void 0 : M.values, (fe, Se) => (_(), D("div", {
1819
+ key: Se,
1820
+ class: "fm-typo-en-body-lg-600"
1821
+ }, [
1822
+ typeof fe == "string" ? (_(), D(te, { key: 0 }, [
1823
+ $e(x(fe), 1)
1824
+ ], 64)) : (_(), le(St(fe), { key: 1 }))
1825
+ ]))), 128))
1826
+ ])
1827
+ ]))), 128))
1828
+ ])
1829
+ ]),
1830
+ _: 2
1831
+ }, 1024)
1832
+ ])
1833
+ ])
1834
+ ], 64))), 128))
1835
+ ])) : (_(), D("div", Yr, [
1836
+ E(q),
1837
+ s("div", null, [
1838
+ s("img", {
1839
+ src: p(kt),
1840
+ alt: "List is empty"
1841
+ }, null, 8, Wr)
1842
+ ]),
1843
+ s("div", Xr, x(p(r)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1844
+ s("div", Jr, x(p(r)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1845
+ E(q),
1846
+ E(q)
1847
+ ]))
1848
+ ])) : L("", !0)
1849
+ ])
1850
+ ];
1851
+ }),
1852
+ "side-sheet-footer": ie(() => [
1853
+ s("div", ps, [
1854
+ (_(!0), D(te, null, pe(X.value, (F) => (_(), le(U, {
1855
+ key: F,
1856
+ label: p(r)(p(et)[F].translationKey),
1857
+ onClick: (ne) => he(F),
1858
+ loading: A.value === F,
1859
+ disabled: A.value !== F && R.value,
1860
+ variant: p(et)[F].buttonVariant
1861
+ }, null, 8, ["label", "onClick", "loading", "disabled", "variant"]))), 128)),
1862
+ p(f).ableToMarkReceived(e.purchaseOrder) && !X.value.includes("completeReceive") ? (_(), le(U, {
1863
+ key: 0,
1864
+ label: p(r)("inventory.transfer.receiveRequest.actions.completeReceive"),
1865
+ onClick: c[1] || (c[1] = (F) => he("completeReceive")),
1866
+ loading: A.value === "completeReceive",
1867
+ disabled: A.value !== "completeReceive" && R.value
1868
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
1869
+ p(f).ableToMarkApproved(e.purchaseOrder) && e.canApprove && !X.value.includes("approveRequest") ? (_(), le(U, {
1870
+ key: 1,
1871
+ label: p(r)("inventory.transfer.approval.actions.approveRequest"),
1872
+ onClick: c[2] || (c[2] = (F) => he("approveRequest")),
1873
+ loading: A.value === "approveRequest",
1874
+ disabled: A.value !== "approveRequest" && R.value
1875
+ }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
1876
+ E(U, {
1877
+ label: p(r)("common.close"),
1878
+ variant: "tertiary",
1879
+ onClick: c[3] || (c[3] = (F) => h("update:show", !1))
1880
+ }, null, 8, ["label"])
1881
+ ])
1882
+ ]),
1883
+ _: 1
1884
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1885
+ };
1886
+ }
1887
+ });
1888
+ export {
1889
+ Ee as P,
1890
+ Ds as _,
1891
+ Os as a,
1892
+ ks as b,
1893
+ Pt as g,
1894
+ Ne as u
1895
+ };