@feedmepos/mf-inventory-portal 0.0.25-dev.3 → 0.0.25-dev.31

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