@feedmepos/mf-inventory-portal 0.0.23-dev.31 → 0.0.23-dev.4

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 (107) hide show
  1. package/dist/{App-CEmWJ9lp.js → App-DReDvY0M.js} +73 -85
  2. package/dist/{ApprovalView-jDll4AVe.js → ApprovalView-BMZlYmRk.js} +27 -24
  3. package/dist/{BindingsDialog-BC_gRSif.js → BindingsDialog-Y2K4I7H7.js} +4 -4
  4. package/dist/{BindingsPicker-BJsGoBzM.js → BindingsPicker-DKBq9c37.js} +9 -8
  5. package/dist/{BindingsTable-DSdwNK_q.js → BindingsTable-45v4SDfp.js} +22 -18
  6. package/dist/{ClosingTemplateView-BzG16gl5.js → ClosingTemplateView-CKJVYSbj.js} +286 -272
  7. package/dist/FmDroppableField-8RzKjEdL.js +154 -0
  8. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DW2IOPST.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CMEOp-0r.js} +23 -22
  9. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BhdcqRh-.js +436 -0
  10. package/dist/FmMultiselectDialog-D7YtdoyJ.js +415 -0
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DDuZEf_v.js → FmUnitInput.vue_vue_type_script_setup_true_lang-C1DjyjyH.js} +49 -48
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CiNvnaaE.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-zjvFEF5C.js} +5 -5
  13. package/dist/{IngredientGroupView-DL8eBhkk.js → IngredientGroupView-BuP-HGeg.js} +69 -63
  14. package/dist/IngredientsView-DMRN-odY.js +1613 -0
  15. package/dist/{IntegrationView-BeFT5S24.js → IntegrationView-kYCaKG0o.js} +95 -92
  16. package/dist/{InventoryBindingForm-DJ3uwq_X.js → InventoryBindingForm-BXHq4h-n.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DIviTipZ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CVxJ_bV3.js} +27 -25
  18. package/dist/{InventoryBindingSummary-CvB5j9xq.js → InventoryBindingSummary-Bjasfc_v.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CQPdnXEF.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DM0C4raP.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BdscwUGn.js → PremiumBadge.vue_vue_type_script_setup_true_lang-C3O3JebE.js} +24 -23
  21. package/dist/{PurchaseOrderPrintPreview-3_6nBajH.js → PurchaseOrderPrintPreview-CmjkfTTS.js} +14 -13
  22. package/dist/{ReceiveRequestView-B_0UldQ7.js → ReceiveRequestView-aQZJO8sq.js} +1302 -1325
  23. package/dist/{RecipeView-D9p0Ou_I.js → RecipeView-DXO43tFi.js} +85 -79
  24. package/dist/{StockView-TIdUgG3O.js → StockView-D9no-mrA.js} +1446 -1338
  25. package/dist/{SupplierView-B1b9Otcr.js → SupplierView-DAx7E7sR.js} +787 -2325
  26. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js +135 -0
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DCA0RUfu.js +1209 -0
  28. package/dist/TransferTemplateView-CfxdQF1t.js +1261 -0
  29. package/dist/{UnitView-BrpzJ7D3.js → UnitView-CQPGZ8-r.js} +44 -40
  30. package/dist/{WarehouseView-CjbdEy8o.js → WarehouseView-jy-RNCgy.js} +100 -94
  31. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  32. package/dist/api/closing.d.ts +0 -1
  33. package/dist/api/netsuite.d.ts +3 -3
  34. package/dist/app-KnSMkJBV.js +33496 -0
  35. package/dist/app.d.ts +0 -56
  36. package/dist/app.js +2 -2
  37. package/dist/components/FmMultiselectDialogProps.d.ts +0 -1
  38. package/dist/components/row-action.enum.d.ts +0 -1
  39. package/dist/composable/defineDeepModel.d.ts +1 -1
  40. package/dist/date2-CIeUqUIc.js +117 -0
  41. package/dist/dayjs.min-Df5jSnDJ.js +282 -0
  42. package/dist/{decimal-DHYZglKx.js → decimal-BAc9M88Q.js} +1 -1
  43. package/dist/defineDeepModel-BfuQAIoM.js +13 -0
  44. package/dist/{feature-G-NnqKcY.js → feature-dwB4OxRQ.js} +6 -12
  45. package/dist/format-time-from-id-BbvzyIN6.js +15 -0
  46. package/dist/{format-unit-display-BWqJsV_R.js → format-unit-display-BBWblJEt.js} +171 -162
  47. package/dist/fuzzy-B9ryZ9VZ.js +41 -0
  48. package/dist/index-BN0CY3sZ.js +22277 -0
  49. package/dist/index-Bj1fJum-.js +45 -0
  50. package/dist/index-C4yL_7rR.js +10545 -0
  51. package/dist/netsuite-ByWOS6tI.js +194 -0
  52. package/dist/normalizeArguments-DP7Hrren.js +1552 -0
  53. package/dist/router/name.d.ts +0 -2
  54. package/dist/row-action.enum-PMKMRrZR.js +50 -0
  55. package/dist/rules-C12nWDD1.js +198 -0
  56. package/dist/stores/feature.d.ts +0 -1
  57. package/dist/stores/integration/netsuite.d.ts +2 -70
  58. package/dist/stores/inventory.d.ts +4 -1
  59. package/dist/style.css +1 -1
  60. package/dist/{supplier-DTUUR48O.js → supplier-DJC0UZWv.js} +15 -15
  61. package/dist/tsconfig.app.tsbuildinfo +1 -1
  62. package/dist/{use-inventory-binding-dialog-DvC_i-Ih.js → use-inventory-binding-dialog-PEQbFRvO.js} +11 -10
  63. package/dist/use-template-enabled-locations-2-k9g5t8tt.js +86 -0
  64. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +192 -24
  65. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +193 -25
  66. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +0 -2
  67. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -6
  68. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +0 -9
  69. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +0 -9
  70. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  71. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  72. package/dist/xlsx-B4XHad7S.js +24004 -0
  73. package/dist/xlsx.util-BSO4SHJi.js +78 -0
  74. package/package.json +3 -3
  75. package/dist/ClosingDraftView-UfWdRXb-.js +0 -1190
  76. package/dist/IngredientsView-B_HC9fgq.js +0 -1657
  77. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-jUYB4L8Y.js +0 -1275
  78. package/dist/TransferTemplateView-Dxk5b-2j.js +0 -1264
  79. package/dist/api/adjustment-template.d.ts +0 -23
  80. package/dist/api/closing-draft.d.ts +0 -6
  81. package/dist/app-AcMtTQ07.js +0 -84202
  82. package/dist/index-Bt8vaUdT.js +0 -12087
  83. package/dist/stock-VZXyPw2C.js +0 -125
  84. package/dist/views/adjustment-template/import/AdjustmentTemplateImport.vue.d.ts +0 -2
  85. package/dist/views/adjustment-template/import/AdjustmentTemplateImportItem.vue.d.ts +0 -18
  86. package/dist/views/adjustment-template/import/export.d.ts +0 -60
  87. package/dist/views/adjustment-template/wastage-template/WastageTemplateDetails.vue.d.ts +0 -2
  88. package/dist/views/adjustment-template/wastage-template/WastageTemplateDialog.vue.d.ts +0 -22
  89. package/dist/views/adjustment-template/wastage-template/WastageTemplatePublish.vue.d.ts +0 -6
  90. package/dist/views/adjustment-template/wastage-template/WastageTemplateView.vue.d.ts +0 -2
  91. package/dist/views/adjustment-template/wastage-template/actions.d.ts +0 -1295
  92. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateForm.vue.d.ts +0 -16
  93. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +0 -35
  94. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +0 -20
  95. package/dist/views/adjustment-template/wastage-template/props.d.ts +0 -29
  96. package/dist/views/adjustment-template/wastage-template/table.d.ts +0 -1273
  97. package/dist/views/closing-draft/ClosingDraftView.vue.d.ts +0 -2
  98. package/dist/views/closing-draft/components/closing-draft-action/ClosingDraftAction.vue.d.ts +0 -22
  99. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +0 -621
  100. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +0 -25
  101. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +0 -3621
  102. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +0 -1
  103. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +0 -19
  104. package/dist/views/closing-draft/helpers/get-calculated-total.helper.d.ts +0 -4
  105. package/dist/views/receive-request/components/netsuite/NetSuiteInfo.vue.d.ts +0 -12
  106. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +0 -13
  107. package/dist/views/receive-request/components/netsuite/NetSuiteSync.vue.d.ts +0 -12
@@ -0,0 +1,1209 @@
1
+ import { ref as j, computed as Q, h as Z, defineComponent as Ve, resolveComponent as ee, openBlock as v, createBlock as Y, unref as n, isRef as Ge, withCtx as de, createElementVNode as r, createElementBlock as D, createVNode as G, createCommentVNode as A, Fragment as te, toDisplayString as y, normalizeClass as me, renderList as fe } from "vue";
2
+ import { i as He } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BhdcqRh-.js";
3
+ import { j as ze, u as ve, B as w, D as Ye, c as Ee, v as M, s as $e, r as Pe } from "./app-KnSMkJBV.js";
4
+ import { t as Qe, b as We, h as Fe, d as qe } from "./date2-CIeUqUIc.js";
5
+ import { F as Ne, D as U, R as E } from "./row-action.enum-PMKMRrZR.js";
6
+ import { useDialog as Ie, useSnackbar as Me, useProxiedModel as Je } from "@feedmepos/ui-library";
7
+ import { p as Ze, f as ye } from "./format-time-from-id-BbvzyIN6.js";
8
+ import { u as Ue } from "./feature-dwB4OxRQ.js";
9
+ import { b as Xe, u as et, f as Le, P as se } from "./format-unit-display-BBWblJEt.js";
10
+ import { c as Ce } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
11
+ import { i as we, c as pe, a as ne, k as tt, j as Te } from "./rules-C12nWDD1.js";
12
+ import { F as rt } from "./decimal-BAc9M88Q.js";
13
+ import { useI18n as je } from "@feedmepos/mf-common";
14
+ import { E as st } from "./empty-placeholder-wf6-BWE8.js";
15
+ import { u as at } from "./netsuite-ByWOS6tI.js";
16
+ const Be = ze((u, g) => {
17
+ const p = ve();
18
+ return {
19
+ async readRequests(a) {
20
+ const R = a ?? p.currentLocationDBName, _ = `${u.inventoryBackendUrl}/${R}/purchase-request`;
21
+ return await g.get(_);
22
+ },
23
+ async getPurchaseOrders({
24
+ start: a,
25
+ end: R
26
+ }) {
27
+ const _ = p.currentLocationDBName, x = `${u.inventoryBackendUrl}/${_}/purchase-order`;
28
+ return await g.get(`${x}?start=${a}&end=${R}`);
29
+ },
30
+ async getPurchaseOrderById(a) {
31
+ const R = p.currentLocationDBName, _ = `${u.inventoryBackendUrl}/${R}/purchase-order`;
32
+ return await g.get(`${_}/${a}`);
33
+ },
34
+ async processPurchaseOrder(a, R) {
35
+ const _ = p.currentLocationDBName, x = R || _, C = `${u.inventoryBackendUrl}/${x}/purchase-order/run-operation`;
36
+ return await g.put(C, a);
37
+ },
38
+ async createPurchaseOrder(a) {
39
+ const R = p.currentLocationDBName, _ = `${u.inventoryBackendUrl}/${R}/purchase-order`;
40
+ return await g.post(_, a);
41
+ },
42
+ async updatePurchaseOrder(a) {
43
+ const R = p.currentLocationDBName, _ = `${u.inventoryBackendUrl}/${R}/purchase-order`;
44
+ return await g.put(_, a);
45
+ }
46
+ };
47
+ }), Ke = {
48
+ [w.enum.confirmDraft]: {
49
+ primaryActions: {
50
+ text: "Confirm draft",
51
+ close: !0
52
+ },
53
+ title: "Confirm draft?",
54
+ message: "Purchase order cannot be changed after confirm draft.",
55
+ successMessage: "Purchase order draft has been confirmed"
56
+ },
57
+ [w.enum.cancelDraft]: {
58
+ primaryActions: {
59
+ text: "Cancel draft",
60
+ close: !0,
61
+ variant: "destructive"
62
+ },
63
+ title: "Cancel draft?",
64
+ message: "Purchase order cannot be changed after cancelled draft.",
65
+ successMessage: "Purchase order draft has been cancelled"
66
+ },
67
+ [w.enum.submitRequest]: {
68
+ primaryActions: {
69
+ text: "Submit request",
70
+ close: !0
71
+ },
72
+ title: "Confirm draft?",
73
+ message: "Purchase order cannot be changed after confirm draft.",
74
+ successMessage: "Purchase order draft has been submitted"
75
+ },
76
+ [w.enum.completeReceive]: {
77
+ primaryActions: {
78
+ text: "Mark received",
79
+ close: !0
80
+ },
81
+ title: "Mark as received",
82
+ message: "Purchase order cannot be changed after it has complete receiving.",
83
+ successMessage: "Purchase order has been marked as received"
84
+ },
85
+ [w.enum.approveRequest]: {
86
+ primaryActions: {
87
+ text: "Approve request",
88
+ close: !0
89
+ },
90
+ title: "Approve request?",
91
+ message: "Purchase order will be approved.",
92
+ successMessage: "Purchase order has been approved"
93
+ },
94
+ [w.enum.rejectRequest]: {
95
+ primaryActions: {
96
+ text: "Reject request",
97
+ close: !0,
98
+ variant: "destructive"
99
+ },
100
+ title: "Reject request?",
101
+ message: "Purchase order will be rejected.",
102
+ successMessage: "Purchase order has been rejected"
103
+ }
104
+ }, ie = j();
105
+ function $r(u, g) {
106
+ const p = Ie(), a = ve(), R = Ue(), _ = Xe(), x = et(), C = j(!1), i = Me(), F = Be(), c = j(new Array()), d = j(
107
+ g != null && g.startDate && (g != null && g.endDate) ? g : He()
108
+ ), m = Q(() => {
109
+ const e = new Date(d.value.startDate), t = new Date(d.value.endDate);
110
+ return {
111
+ start: Qe(e).toISOString(),
112
+ end: We(t).toISOString()
113
+ };
114
+ }), f = j(new Array()), B = Ye(), W = j(null);
115
+ async function oe(e) {
116
+ let t;
117
+ if (R.mustUsePoTemplate && !(e != null && e.template) && (t = await _.getTemplateId(), !t))
118
+ return;
119
+ const l = {
120
+ mode: Ne.CREATE,
121
+ modelValue: e || void 0,
122
+ show: !0,
123
+ "onUpdate:show"(h) {
124
+ ie.value.show = h;
125
+ },
126
+ templateId: t,
127
+ lastClosingDate: W.value
128
+ };
129
+ ie.value = l;
130
+ }
131
+ function he(e) {
132
+ const t = {
133
+ mode: Ne.UPDATE,
134
+ modelValue: Ee(e),
135
+ show: !0,
136
+ "onUpdate:show"(l) {
137
+ ie.value.show = l;
138
+ },
139
+ lastClosingDate: W.value
140
+ };
141
+ ie.value = t;
142
+ }
143
+ async function H() {
144
+ c.value = [], C.value = !0;
145
+ try {
146
+ c.value = await F.getPurchaseOrders(m.value).then((l) => l.sort((h, O) => O._id.localeCompare(h._id)));
147
+ const e = await B.readLastClosing(!0), t = e == null ? void 0 : e._id;
148
+ t && (W.value = Ze(t)), R.mustUsePoTemplate && await x.fetchTemplates();
149
+ } catch {
150
+ i.open({
151
+ title: "Something went wrong",
152
+ message: "Error at fetching purchase orders",
153
+ type: "error"
154
+ });
155
+ } finally {
156
+ C.value = !1;
157
+ }
158
+ }
159
+ async function be() {
160
+ f.value = [], C.value = !0;
161
+ try {
162
+ f.value = await F.readRequests().then((e) => e.reverse());
163
+ } catch {
164
+ i.open({
165
+ title: "Something went wrong",
166
+ message: "Error at fetching purchase requests",
167
+ type: "error"
168
+ });
169
+ } finally {
170
+ C.value = !1;
171
+ }
172
+ }
173
+ function re() {
174
+ switch (u) {
175
+ case "receive/request":
176
+ return H();
177
+ case "approval":
178
+ return be();
179
+ }
180
+ }
181
+ function ge(e, t) {
182
+ d.value = {
183
+ startDate: e,
184
+ endDate: t
185
+ }, re();
186
+ }
187
+ a.watchLocation(async (e) => {
188
+ if (!e) {
189
+ c.value = [];
190
+ return;
191
+ }
192
+ await re();
193
+ });
194
+ const J = j(), z = j(Math.random().toString());
195
+ async function _e(e, t) {
196
+ var P, o;
197
+ const l = Math.random().toString();
198
+ z.value = l;
199
+ const h = u === "receive/request" ? a.currentLocation : t == null ? void 0 : t.to, O = {
200
+ poRequest: t,
201
+ purchaseOrder: e,
202
+ transferTo: h == null ? void 0 : h.name,
203
+ transferToDbName: h == null ? void 0 : h.dbName,
204
+ show: !0,
205
+ canResubmit: !1,
206
+ canApprove: u === "approval",
207
+ "onUpdate:show"(S) {
208
+ J.value.show = S;
209
+ }
210
+ };
211
+ if (J.value = O, !(t || e.status !== M.enum.REQUESTING)) {
212
+ try {
213
+ t = (await F.readRequests(
214
+ `${e.supplier.internal}_${e.supplier._id}`
215
+ )).find((T) => T.purchaseOrderId === e._id);
216
+ } catch {
217
+ console.error("Error at fetching po request to check");
218
+ }
219
+ l === z.value && (J.value.canResubmit = !t, J.value.transferTo = (P = t == null ? void 0 : t.to) == null ? void 0 : P.name, J.value.transferToDbName = (o = t == null ? void 0 : t.to) == null ? void 0 : o.dbName);
220
+ }
221
+ }
222
+ async function ue(e, t, l, h) {
223
+ C.value = !0;
224
+ try {
225
+ await F.processPurchaseOrder(
226
+ {
227
+ operation: t,
228
+ doc: e,
229
+ options: (
230
+ // auto receive for supplier to warehouse
231
+ (t === w.enum.confirmDraft || // auto receive for warehouse to warehouse
232
+ t === w.enum.completeReceive) && R.autoReceiveWarehouse ? {
233
+ autoReceive: !0
234
+ } : void 0
235
+ )
236
+ },
237
+ h
238
+ ), await new Promise((o) => setTimeout(o, 1e3));
239
+ const P = ve().currentLocationDBName.startsWith("restaurant_");
240
+ t === w.enum.confirmDraft && e.effectiveAt && P ? i.open({
241
+ title: "Success",
242
+ message: `${l}. The backdate will be reflected once your POS has received this change.`,
243
+ type: "success"
244
+ }) : i.open({
245
+ title: "Success",
246
+ message: l,
247
+ type: "success"
248
+ });
249
+ } catch (O) {
250
+ i.open({
251
+ title: "Something went wrong",
252
+ message: "Please try again.",
253
+ type: "error"
254
+ }), console.error("Error when submitting PO operation", t, e, O);
255
+ } finally {
256
+ C.value = !1, re();
257
+ }
258
+ }
259
+ async function s(e, t, l) {
260
+ const h = Ke[t];
261
+ if (!h) {
262
+ i.open({
263
+ title: "Something went wrong",
264
+ message: `Cannot process order: ${$e(t)}`,
265
+ type: "error"
266
+ });
267
+ return;
268
+ }
269
+ const { successMessage: O, ...P } = h;
270
+ p.open({
271
+ title: P.title,
272
+ message: P.message,
273
+ primaryActions: P.primaryActions
274
+ }).onPrimary(() => {
275
+ ue(e, t, O, l);
276
+ });
277
+ }
278
+ return {
279
+ purchaseOrders: c,
280
+ purchaseRequests: f,
281
+ updateDateRange: ge,
282
+ fetchData: re,
283
+ loading: C,
284
+ transferDialogProps: ie,
285
+ promptCreateTransferDialog: oe,
286
+ promptUpdateTransferDialog: he,
287
+ transferDetailsProps: J,
288
+ promptShowTransferDetails: _e,
289
+ submitAction: s
290
+ };
291
+ }
292
+ function nt(u, g) {
293
+ return g.reduce(
294
+ (a, R) => {
295
+ const _ = R.received.find((x) => x.sku._id === u._id);
296
+ return _ && (a = we(a, _.amount)), a;
297
+ },
298
+ rt.toPrecision(pe(0), u.unit.precision)
299
+ );
300
+ }
301
+ function ot(u, g) {
302
+ const { name: p, address: a, regNo: R } = g.doc.profile, _ = {
303
+ name: p,
304
+ registrationNumber: R,
305
+ line1: a == null ? void 0 : a.line1,
306
+ line2: a == null ? void 0 : a.line2,
307
+ postcode: a == null ? void 0 : a.postcode,
308
+ city: a == null ? void 0 : a.city,
309
+ state: a == null ? void 0 : a.state,
310
+ country: a == null ? void 0 : a.country
311
+ }, x = {
312
+ name: u.supplier.name,
313
+ registrationNumber: u.supplier.registrationNumber,
314
+ line1: u.supplier.address.line1,
315
+ line2: u.supplier.address.line2,
316
+ postcode: u.supplier.address.postcode,
317
+ city: u.supplier.address.city,
318
+ state: u.supplier.address.state,
319
+ country: u.supplier.address.country
320
+ }, C = u.items.map((d) => {
321
+ const { sku: m, measurement: f } = d, B = ne(
322
+ nt(d.sku, u.deliveryOrder || []),
323
+ !1
324
+ );
325
+ return {
326
+ code: m.code,
327
+ description: m.name,
328
+ quantity: Le(d.quantity, m.unit, d.measurement),
329
+ unit: (f == null ? void 0 : f.abbrev) || m.unit.abbrev,
330
+ received: B
331
+ };
332
+ }), i = u.deliveryOrder.map((d) => ({
333
+ createdAt: Fe(new Date(d.createdAt)),
334
+ ref: d.deliveryOrderNumber,
335
+ remark: d.remark || "",
336
+ items: d.received.map((m) => {
337
+ var f;
338
+ return {
339
+ code: m.sku.code,
340
+ description: m.sku.name,
341
+ quantity: ne(m.amount),
342
+ unit: ((f = m.measurement) == null ? void 0 : f.abbrev) || m.sku.unit.abbrev
343
+ };
344
+ })
345
+ })), F = {
346
+ orderNumber: u.seqNumber.toString(),
347
+ createdAt: ye(u._id),
348
+ ref: u.ref || "",
349
+ remark: u.remark || "",
350
+ buyer: _,
351
+ supplier: x,
352
+ items: C,
353
+ status: u.status,
354
+ deliveryOrders: i
355
+ }, c = new URL(window.location.href);
356
+ c.pathname = c.hostname.includes("inventory.feedme") ? "/receive-request/print-preview" : "/inventory/receive-request/print-preview", c.searchParams.append("data", JSON.stringify(F)), window.open(c.href, "_blank", "noreferrer");
357
+ }
358
+ const ae = {
359
+ submitRequest: {
360
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
361
+ color: "text-fm-color-typo-primary",
362
+ value: w.enum.submitRequest
363
+ },
364
+ confirmDraft: {
365
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
366
+ color: "text-fm-color-typo-primary",
367
+ value: w.enum.confirmDraft
368
+ },
369
+ cancelDraft: {
370
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
371
+ color: "text-fm-color-typo-error",
372
+ value: w.enum.cancelDraft
373
+ },
374
+ approveRequest: {
375
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
376
+ color: "text-fm-color-typo-primary",
377
+ value: w.enum.approveRequest
378
+ },
379
+ rejectRequest: {
380
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
381
+ color: "text-fm-color-typo-error",
382
+ value: w.enum.rejectRequest
383
+ },
384
+ processRequest: {
385
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
386
+ color: "text-fm-color-typo-primary",
387
+ value: w.enum.processRequest
388
+ },
389
+ receiveStock: {
390
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
391
+ color: "text-fm-color-typo-primary",
392
+ value: w.enum.receiveStock
393
+ },
394
+ completeReceive: {
395
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
396
+ color: "text-fm-color-typo-primary",
397
+ value: w.enum.completeReceive
398
+ }
399
+ };
400
+ function Fr(u, g) {
401
+ const p = ve(), { t: a } = je();
402
+ function R(c) {
403
+ switch (c.status) {
404
+ case "DRAFT":
405
+ return [
406
+ U[E.Update],
407
+ U[E.Details],
408
+ c.supplier.internal === "restaurant" || c.supplier.internal === "warehouse" ? ae[w.enum.submitRequest] : ae[w.enum.confirmDraft],
409
+ ae[w.enum.cancelDraft],
410
+ U[E.Print]
411
+ ];
412
+ case "RECEIVING":
413
+ return [
414
+ ae[w.enum.completeReceive],
415
+ U[E.Details],
416
+ U[E.Print]
417
+ ];
418
+ case "REQUESTING":
419
+ return u === "receive/request" ? [U[E.Details], U[E.Print]] : [
420
+ ae[w.enum.approveRequest],
421
+ ae[w.enum.rejectRequest],
422
+ U[E.Details],
423
+ U[E.Print]
424
+ ];
425
+ case "PROCESSING":
426
+ return [U[E.Details], U[E.Print]];
427
+ case "COMPLETE":
428
+ case "CANCEL":
429
+ default:
430
+ return [U[E.Details], U[E.Print]];
431
+ }
432
+ }
433
+ function _(c) {
434
+ return Object.values(w.enum).includes(c);
435
+ }
436
+ async function x(c, d, m) {
437
+ var B, W;
438
+ const f = Ee(d);
439
+ if (c === E.Print) {
440
+ ot(f, p.currentLocation);
441
+ return;
442
+ }
443
+ if (c === E.Details) {
444
+ g.promptShowTransferDetails(f, m);
445
+ return;
446
+ }
447
+ if (c === E.Update) {
448
+ (B = g.promptUpdateTransferDialog) == null || B.call(g, f);
449
+ return;
450
+ }
451
+ if (_(c)) {
452
+ g.submitAction(d, c, (W = m == null ? void 0 : m.to) == null ? void 0 : W.dbName);
453
+ return;
454
+ }
455
+ }
456
+ function C() {
457
+ return [
458
+ {
459
+ accessorKey: "seqNumber",
460
+ header: () => a("inventory.transfer.table.seqNo"),
461
+ enableSorting: !0,
462
+ size: 80,
463
+ sortUndefined: "last"
464
+ },
465
+ {
466
+ accessorKey: "_id",
467
+ header: () => a("inventory.transfer.table.createdAt"),
468
+ cell(c) {
469
+ return ye(`${c.getValue()}`);
470
+ },
471
+ enableSorting: !0
472
+ },
473
+ {
474
+ accessorKey: "supplier.name",
475
+ header: () => a("inventory.transfer.table.transferFrom"),
476
+ enableSorting: !0,
477
+ size: 200
478
+ },
479
+ {
480
+ accessorKey: "items.length",
481
+ header: () => a("inventory.transfer.table.noOfItems"),
482
+ enableSorting: !1,
483
+ meta: {
484
+ width: "10rem"
485
+ }
486
+ },
487
+ {
488
+ accessorKey: "ref",
489
+ header: () => a("inventory.transfer.table.reference"),
490
+ enableSorting: !1,
491
+ size: "auto"
492
+ },
493
+ {
494
+ accessorKey: "status",
495
+ header: () => a("inventory.transfer.table.status"),
496
+ cell(c) {
497
+ const d = a(`inventory.transfer.status.${c.getValue() ?? ""}`), m = `${c.getValue() ?? ""}`.toLocaleLowerCase("en-us");
498
+ return Z(
499
+ "div",
500
+ {
501
+ class: "flex"
502
+ },
503
+ Z(
504
+ "div",
505
+ {
506
+ class: `fm-status-badge fm-status-badge-${m}`
507
+ },
508
+ d
509
+ )
510
+ );
511
+ },
512
+ enableSorting: !0,
513
+ size: 200
514
+ },
515
+ {
516
+ id: "action",
517
+ cell(c) {
518
+ const d = c.row.original, m = R(d);
519
+ return Ce(m, (f) => x(f, d));
520
+ },
521
+ enableSorting: !1,
522
+ size: 40,
523
+ meta: {
524
+ cellClass: "",
525
+ headerClass: ""
526
+ }
527
+ }
528
+ ];
529
+ }
530
+ function i() {
531
+ return [
532
+ {
533
+ accessorKey: "purchaseOrder.seqNumber",
534
+ header: () => a("inventory.transfer.table.seqNo"),
535
+ enableSorting: !0,
536
+ size: 80,
537
+ sortUndefined: "last"
538
+ },
539
+ {
540
+ accessorKey: "purchaseOrder._id",
541
+ header: () => a("inventory.transfer.table.createdAt"),
542
+ cell(c) {
543
+ return ye(`${c.getValue()}`);
544
+ },
545
+ enableSorting: !0
546
+ },
547
+ {
548
+ accessorKey: "to.name",
549
+ header: () => a("inventory.transfer.table.transferTo"),
550
+ enableSorting: !1,
551
+ size: 200
552
+ },
553
+ {
554
+ accessorKey: "purchaseOrder.items.length",
555
+ header: () => a("inventory.transfer.table.noOfItems"),
556
+ enableSorting: !1
557
+ },
558
+ {
559
+ accessorKey: "purchaseOrder.ref",
560
+ header: () => a("inventory.transfer.table.reference"),
561
+ enableSorting: !1,
562
+ size: "auto"
563
+ },
564
+ {
565
+ accessorKey: "purchaseOrder.status",
566
+ header: () => a("inventory.transfer.table.status"),
567
+ cell(c) {
568
+ const d = a(`inventory.transfer.status.${c.getValue() ?? ""}`), m = `${c.getValue() ?? ""}`.toLocaleLowerCase("en-us");
569
+ return Z(
570
+ "div",
571
+ {
572
+ class: "flex"
573
+ },
574
+ Z(
575
+ "div",
576
+ {
577
+ class: `fm-status-badge fm-status-badge-${m}`
578
+ },
579
+ d
580
+ )
581
+ );
582
+ },
583
+ enableSorting: !0
584
+ },
585
+ {
586
+ id: "action",
587
+ cell(c) {
588
+ const d = c.row.original, m = d.purchaseOrder ? R(d.purchaseOrder) : [];
589
+ return Ce(
590
+ m,
591
+ (f) => d.purchaseOrder ? x(f, d.purchaseOrder, d) : void 0
592
+ );
593
+ },
594
+ enableSorting: !1,
595
+ size: 40,
596
+ meta: {
597
+ cellClass: "",
598
+ headerClass: ""
599
+ }
600
+ }
601
+ ];
602
+ }
603
+ const F = Q(() => u === "receive/request" ? C() : i());
604
+ return {
605
+ get columnDefs() {
606
+ return F.value;
607
+ }
608
+ };
609
+ }
610
+ const lt = { class: "flex flex-col gap-16 w-full h-full" }, ct = {
611
+ key: 0,
612
+ class: "flex flex-row-reverse"
613
+ }, it = { class: "flex justify-between" }, ut = { class: "fm-typo-en-body-lg-600" }, dt = { class: "flex flex-col gap-8" }, mt = { class: "flex flex-col gap-4" }, ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pt = { class: "flex gap-1" }, vt = { class: "fm-typo-en-body-lg-600" }, yt = {
614
+ key: 0,
615
+ class: "flex flex-col gap-4"
616
+ }, ht = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bt = { class: "fm-typo-en-body-lg-600" }, gt = { class: "flex flex-col gap-4" }, _t = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wt = { class: "fm-typo-en-body-lg-600" }, Rt = {
617
+ key: 1,
618
+ class: "flex flex-col gap-4"
619
+ }, St = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ot = { class: "fm-typo-en-body-lg-600" }, Dt = {
620
+ key: 2,
621
+ class: "flex flex-col gap-4"
622
+ }, kt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, At = { class: "fm-typo-en-body-lg-600" }, xt = {
623
+ key: 3,
624
+ class: "flex flex-col gap-4"
625
+ }, Pt = { class: "fm-typo-en-body-lg-600" }, qt = {
626
+ key: 4,
627
+ class: "flex flex-col gap-4"
628
+ }, Nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ct = { class: "fm-typo-en-body-lg-600" }, Tt = {
629
+ key: 5,
630
+ class: "flex flex-col gap-4"
631
+ }, Et = { class: "fm-typo-en-body-lg-600" }, $t = {
632
+ key: 6,
633
+ class: "flex flex-col gap-4"
634
+ }, Ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, It = { class: "fm-typo-en-body-lg-600" }, Mt = {
635
+ key: 7,
636
+ class: "flex flex-col gap-4"
637
+ }, Ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lt = { class: "fm-typo-en-body-lg-600" }, jt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Bt = { class: "flex flex-col gap-8" }, Kt = { class: "fm-typo-en-body-lg-600" }, Vt = { class: "flex w-full gap-4" }, Gt = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, Ht = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, zt = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Yt = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Qt = {
638
+ key: 0,
639
+ class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
640
+ }, Wt = { class: "py-8" }, Jt = { class: "flex justify-end gap-4 items-center" }, Zt = { class: "fm-typo-en-body-lg-600" }, Xt = {
641
+ key: 2,
642
+ class: "flex-1 xs:w-screen xs:max-w-full"
643
+ }, er = {
644
+ key: 0,
645
+ class: "flex flex-col items-center gap-8 h-full"
646
+ }, tr = ["src"], rr = { class: "fm-typo-en-body-lg-600" }, sr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, ar = {
647
+ key: 1,
648
+ class: "px-4 flex flex-col"
649
+ }, nr = { class: "flex gap-12 content-stretch" }, or = {
650
+ class: "flex flex-col w-24",
651
+ name: "circles"
652
+ }, lr = { class: "flex-1 flex flex-col items-center" }, cr = { class: "flex-1 flex flex-col items-center" }, ir = {
653
+ class: "py-12 flex flex-col gap-4",
654
+ name: "received-at header"
655
+ }, ur = { class: "fm-typo-en-body-lg-400" }, dr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, mr = { class: "flex gap-12 content-stretch" }, fr = {
656
+ class: "flex flex-col w-24",
657
+ name: "circles"
658
+ }, pr = { class: "flex-1 flex flex-col items-center" }, vr = {
659
+ class: "py-12 flex flex-col gap-4 flex-1",
660
+ name: "delivery details"
661
+ }, yr = { class: "flex flex-col gap-8" }, hr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, br = { class: "flex flex-col gap-4" }, gr = { class: "flex gap-8 xs:flex-col" }, Ir = /* @__PURE__ */ Ve({
662
+ __name: "TransferDetails",
663
+ props: {
664
+ poRequest: {},
665
+ purchaseOrder: {},
666
+ transferTo: {},
667
+ transferToDbName: {},
668
+ show: { type: Boolean },
669
+ canResubmit: { type: Boolean },
670
+ canApprove: { type: Boolean }
671
+ },
672
+ emits: ["update:show", "submitted"],
673
+ setup(u, { emit: g }) {
674
+ const p = u, a = g, R = Ie(), _ = Me(), x = at(), C = Ue(), { t: i } = je(), F = Q(
675
+ () => {
676
+ var s, e, t, l;
677
+ return ((e = (s = p.purchaseOrder) == null ? void 0 : s.supplier) == null ? void 0 : e.internal) === "restaurant" || ((l = (t = p.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : l.internal) === "warehouse" ? se.TRANSFER : se.PURCHASE;
678
+ }
679
+ ), c = [
680
+ {
681
+ label: i("inventory.transfer.receiveRequest.details.overview"),
682
+ value: "overview"
683
+ },
684
+ {
685
+ label: i("inventory.transfer.receiveRequest.details.deliveryHistory"),
686
+ value: "deliveryHistory"
687
+ }
688
+ ], d = j(c[0]), m = j(!1), f = j(""), B = j(!0), W = Be(), oe = Je(p, "show");
689
+ async function he(s, e, t) {
690
+ f.value = e, m.value = !0, B.value = !1;
691
+ try {
692
+ await W.processPurchaseOrder(
693
+ {
694
+ operation: e,
695
+ doc: s,
696
+ options: (
697
+ // auto receive for supplier to warehouse
698
+ (e === w.enum.confirmDraft || // auto receive for warehouse to warehouse
699
+ e === w.enum.completeReceive) && C.autoReceiveWarehouse ? {
700
+ autoReceive: !0
701
+ } : void 0
702
+ )
703
+ },
704
+ p.transferToDbName
705
+ ), await new Promise((l) => setTimeout(l, 1e3)), _.open({
706
+ title: "Success",
707
+ message: t,
708
+ type: "success"
709
+ }), a("update:show", !1), a("submitted");
710
+ } catch (l) {
711
+ _.open({
712
+ title: "Something went wrong",
713
+ message: "Please try again.",
714
+ type: "error"
715
+ }), console.error("Error when submitting PO operation", e, s, l);
716
+ } finally {
717
+ f.value = "", m.value = !1, B.value = !0;
718
+ }
719
+ }
720
+ async function H(s) {
721
+ const e = Ke[s];
722
+ if (!e) {
723
+ _.open({
724
+ title: "Something went wrong",
725
+ message: `Cannot process order: ${$e(s)}`,
726
+ type: "error"
727
+ });
728
+ return;
729
+ }
730
+ const { successMessage: t, ...l } = e;
731
+ R.open({
732
+ title: l.title,
733
+ message: l.message,
734
+ primaryActions: l.primaryActions
735
+ }).onPrimary(() => {
736
+ p.purchaseOrder && he(p.purchaseOrder, s, t);
737
+ });
738
+ }
739
+ const be = Q(() => {
740
+ var s, e;
741
+ return ((s = p.purchaseOrder) == null ? void 0 : s.status) === M.enum.RECEIVING || ((e = p.purchaseOrder) == null ? void 0 : e.status) === M.enum.COMPLETE;
742
+ }), re = Q(
743
+ () => {
744
+ var s, e, t, l, h, O;
745
+ return x.getLocationSubsidiary(
746
+ ((t = (e = (s = p.purchaseOrder) == null ? void 0 : s.netSuite) == null ? void 0 : e.subsidiary) == null ? void 0 : t.id) || ((O = (h = (l = p.poRequest) == null ? void 0 : l.netSuite) == null ? void 0 : h.subsidiary) == null ? void 0 : O.id)
747
+ ).fullName;
748
+ }
749
+ ), ge = Q(() => {
750
+ var s, e, t, l, h, O;
751
+ return (e = (s = p.purchaseOrder) == null ? void 0 : s.deliveryFullfillment) != null && e.length && ((l = (t = p.purchaseOrder) == null ? void 0 : t.deliveryFullfillment) == null ? void 0 : l.length) > 0 ? (O = (h = p.purchaseOrder) == null ? void 0 : h.deliveryFullfillment) == null ? void 0 : O.map((P) => {
752
+ var o;
753
+ return (o = P.netSuite) == null ? void 0 : o.refNo;
754
+ }).join(", ") : "-";
755
+ }), J = Q(() => {
756
+ var O, P, o;
757
+ const t = (((O = p.purchaseOrder) == null ? void 0 : O.deliveryOrder) ?? []).flatMap((S) => S.received ?? []).reduce(
758
+ (S, T) => {
759
+ const L = S[T.sku._id] ?? [];
760
+ return S[T.sku._id] = [...L, T], S;
761
+ },
762
+ {}
763
+ ), l = Object.entries(t).reduce(
764
+ (S, [T, L]) => {
765
+ const k = L.reduce((I, b) => {
766
+ const q = tt(
767
+ I,
768
+ Math.max(I.precision, b.amount.precision)
769
+ );
770
+ return we(q, b.amount);
771
+ }, pe(0));
772
+ return S[T] = k, S;
773
+ },
774
+ {}
775
+ ), h = ((P = p.purchaseOrder) == null ? void 0 : P.items) ?? [];
776
+ for (const S of h)
777
+ l[o = S.sku._id] ?? (l[o] = pe(0));
778
+ return l;
779
+ }), z = Q(() => {
780
+ var O, P;
781
+ const s = ((O = p.purchaseOrder) == null ? void 0 : O.deliveryOrder) ?? [], e = ((P = p.purchaseOrder) == null ? void 0 : P.deliveryFullfillment) ?? [], t = [
782
+ ...s.map((o) => ({
783
+ createdAt: o.createdAt,
784
+ type: "grn",
785
+ doc: o
786
+ })),
787
+ ...e.map((o) => ({
788
+ createdAt: o.createdAt,
789
+ type: "fulfillment",
790
+ doc: o
791
+ }))
792
+ ];
793
+ t.reverse().sort((o, S) => o.createdAt.localeCompare(S.createdAt));
794
+ function l(o) {
795
+ var T, L, k, I, b, q, $;
796
+ const S = e.findIndex((N) => N.id === o.fullfillmentId);
797
+ return {
798
+ header: "Received",
799
+ date: qe(new Date(o.createdAt)),
800
+ info: [
801
+ {
802
+ label: "Received by",
803
+ values: [(T = o.createdBy) == null ? void 0 : T.name]
804
+ },
805
+ {
806
+ label: "Received items",
807
+ values: o.received.map((N) => {
808
+ var K;
809
+ return `(${N.sku.code}) ${N.sku.name}: ${ne(N.amount, !1)} ${((K = N.measurement) == null ? void 0 : K.abbrev) ?? N.sku.unit.abbrev}`;
810
+ })
811
+ },
812
+ o.deliveryOrderNumber ? {
813
+ label: "Delivery order no.",
814
+ values: [o.deliveryOrderNumber]
815
+ } : null,
816
+ o.remark ? {
817
+ label: "Remark",
818
+ values: [o.remark]
819
+ } : null,
820
+ S > -1 ? {
821
+ label: "Fulfilment's sequence",
822
+ values: [`${S + 1}`]
823
+ } : null,
824
+ (k = (L = e[S]) == null ? void 0 : L.netSuite) != null && k.refNo ? {
825
+ label: "Fulfillment's ref no. (Netsuite)",
826
+ values: [(b = (I = e[S]) == null ? void 0 : I.netSuite) == null ? void 0 : b.refNo]
827
+ } : null,
828
+ (q = o == null ? void 0 : o.netSuite) != null && q.refNo ? {
829
+ label: "Item receipt (Netsuite)",
830
+ values: [($ = o == null ? void 0 : o.netSuite) == null ? void 0 : $.refNo]
831
+ } : null
832
+ ].filter((N) => N)
833
+ };
834
+ }
835
+ function h(o) {
836
+ var T, L;
837
+ const S = e.findIndex((k) => k.id === o.id);
838
+ return {
839
+ header: "Fulfillment",
840
+ date: qe(new Date(o.createdAt)),
841
+ info: [
842
+ {
843
+ label: "Sequence",
844
+ values: [String(S + 1)]
845
+ },
846
+ {
847
+ label: "Receiveable items",
848
+ values: o.items.map((k) => {
849
+ var I;
850
+ return `(${k.sku.code}) ${k.sku.name}: ${ne(k.amount, !1)} ${((I = k.measurement) == null ? void 0 : I.abbrev) ?? k.sku.unit.abbrev}`;
851
+ })
852
+ },
853
+ (T = o.netSuite) != null && T.refNo ? {
854
+ label: "Ref no. (Netsuite)",
855
+ values: [(L = o.netSuite) == null ? void 0 : L.refNo]
856
+ } : null
857
+ ].filter((k) => k)
858
+ };
859
+ }
860
+ return t.map((o) => {
861
+ switch (o.type) {
862
+ case "grn":
863
+ return l(o.doc);
864
+ case "fulfillment":
865
+ return h(o.doc);
866
+ }
867
+ });
868
+ });
869
+ async function _e() {
870
+ R.open({
871
+ title: "Sync with NetSuite",
872
+ contentComponent: Z("div", [
873
+ Z("p", "Are you sure you want to sync now?"),
874
+ Z("br"),
875
+ Z(
876
+ "p",
877
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
878
+ "Please wait a moment before syncing manually to avoid unnecessary actions."
879
+ )
880
+ ]),
881
+ primaryActions: {
882
+ text: "Sync",
883
+ close: !0,
884
+ variant: "destructive"
885
+ },
886
+ secondaryActions: { text: "Not now", close: !0 }
887
+ }).onPrimary(async () => {
888
+ try {
889
+ await x.syncPurchaseOrder(p.purchaseOrder._id), _.open({
890
+ title: "Sync with NetSuite",
891
+ message: "Requested to sync with NetSuite. Please wait a moment.",
892
+ type: "success"
893
+ });
894
+ } catch {
895
+ _.open({
896
+ title: "Error",
897
+ message: "Failed to sync with NetSuite",
898
+ type: "error"
899
+ });
900
+ }
901
+ });
902
+ }
903
+ const ue = Q(() => {
904
+ var e;
905
+ const s = {
906
+ ...pe(0),
907
+ currency: Pe()
908
+ };
909
+ return ((e = p.purchaseOrder) == null ? void 0 : e.items.reduce((t, l) => ({
910
+ ...we(t, l.totalCost ?? s),
911
+ currency: Pe()
912
+ }), s)) ?? s;
913
+ });
914
+ return (s, e) => {
915
+ var T, L;
916
+ const t = ee("FmButton"), l = ee("FmButtonGroup"), h = ee("FmChip"), O = ee("FmMenuDivider"), P = ee("FmCard"), o = ee("FmSpacer"), S = ee("FmSideSheet");
917
+ return v(), Y(S, {
918
+ header: n(i)("inventory.transfer.receiveRequest.details.title") + ((T = s.purchaseOrder) != null && T.seqNumber ? ` #${(L = s.purchaseOrder) == null ? void 0 : L.seqNumber}` : ""),
919
+ modelValue: n(oe),
920
+ "onUpdate:modelValue": e[9] || (e[9] = (k) => Ge(oe) ? oe.value = k : null),
921
+ "dismiss-away": B.value,
922
+ "close-button": "",
923
+ "max-width": 600
924
+ }, {
925
+ default: de(() => {
926
+ var k, I;
927
+ return [
928
+ r("div", lt, [
929
+ n(x).isEnabled && p.purchaseOrder != null && ((k = s.purchaseOrder) == null ? void 0 : k.status) !== n(M).enum.DRAFT ? (v(), D("div", ct, [
930
+ G(t, {
931
+ "prepend-icon": "sync",
932
+ variant: "primary",
933
+ label: "NetSuite",
934
+ onClick: _e
935
+ })
936
+ ])) : A("", !0),
937
+ r("div", null, [
938
+ G(l, {
939
+ items: c,
940
+ modelValue: d.value,
941
+ "onUpdate:modelValue": e[0] || (e[0] = (b) => d.value = b)
942
+ }, null, 8, ["modelValue"])
943
+ ]),
944
+ d.value.value === "overview" ? (v(), D(te, { key: 1 }, [
945
+ r("div", null, [
946
+ G(P, {
947
+ variant: "outlined",
948
+ class: "flex flex-col gap-8 px-12 py-16"
949
+ }, {
950
+ default: de(() => {
951
+ var b, q, $, N, K, X, le, ce, V, Re, Se, Oe, De, ke, Ae, xe;
952
+ return [
953
+ r("div", it, [
954
+ r("div", ut, y(n(i)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
955
+ r("div", null, [
956
+ G(h, {
957
+ label: n(i)(`inventory.transfer.status.${(b = s.purchaseOrder) == null ? void 0 : b.status}`),
958
+ class: me(`fm-status-badge fm-status-badge-${($ = (q = s.purchaseOrder) == null ? void 0 : q.status) == null ? void 0 : $.toLocaleLowerCase("en-us")}`),
959
+ compact: ""
960
+ }, null, 8, ["label", "class"])
961
+ ])
962
+ ]),
963
+ G(O),
964
+ r("div", dt, [
965
+ r("div", mt, [
966
+ r("div", ft, [
967
+ r("div", pt, y(n(i)("inventory.transfer.receiveRequest.details.createdAt")), 1)
968
+ ]),
969
+ r("div", vt, y(n(ye)(((N = s.purchaseOrder) == null ? void 0 : N._id) ?? "")), 1)
970
+ ]),
971
+ (K = s.purchaseOrder) != null && K.effectiveAt ? (v(), D("div", yt, [
972
+ r("div", ht, y(n(i)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
973
+ r("div", bt, y(n(Fe)(new Date((X = s.purchaseOrder) == null ? void 0 : X.effectiveAt))), 1)
974
+ ])) : A("", !0),
975
+ r("div", gt, [
976
+ r("div", _t, y(n(i)("inventory.transfer.receiveRequest.details.type.title")), 1),
977
+ r("div", wt, y(n(i)(
978
+ `inventory.transfer.receiveRequest.details.type.${F.value.toLocaleLowerCase("en-US")}`
979
+ )), 1)
980
+ ]),
981
+ (ce = (le = s.purchaseOrder) == null ? void 0 : le.supplier) != null && ce.name ? (v(), D("div", Rt, [
982
+ r("div", St, y(n(i)("inventory.transfer.receiveRequest.details.from")), 1),
983
+ r("div", Ot, y((Re = (V = s.purchaseOrder) == null ? void 0 : V.supplier) == null ? void 0 : Re.name), 1)
984
+ ])) : A("", !0),
985
+ s.transferTo ? (v(), D("div", Dt, [
986
+ r("div", kt, y(n(i)("inventory.transfer.receiveRequest.details.to")), 1),
987
+ r("div", At, y(s.transferTo), 1)
988
+ ])) : A("", !0),
989
+ n(x).isEnabled ? (v(), D("div", xt, [
990
+ e[10] || (e[10] = r("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite subsidiary ", -1)),
991
+ r("div", Pt, y(re.value || "-"), 1)
992
+ ])) : A("", !0),
993
+ n(x).isEnabled ? (v(), D("div", qt, [
994
+ r("div", Nt, " NetSuite " + y(F.value === n(se).PURCHASE ? "Purchase order" : "Transfer order") + " ID ", 1),
995
+ r("div", Ct, y(((Oe = (Se = s.purchaseOrder) == null ? void 0 : Se.netSuite) == null ? void 0 : Oe.id) || ((ke = (De = s.poRequest) == null ? void 0 : De.netSuite) == null ? void 0 : ke.id) || "-"), 1)
996
+ ])) : A("", !0),
997
+ n(x).isEnabled && F.value === n(se).TRANSFER ? (v(), D("div", Tt, [
998
+ e[11] || (e[11] = r("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
999
+ r("div", Et, y(ge.value), 1)
1000
+ ])) : A("", !0),
1001
+ (Ae = s.purchaseOrder) != null && Ae.ref ? (v(), D("div", $t, [
1002
+ r("div", Ft, y(n(i)("inventory.transfer.receiveRequest.details.reference")), 1),
1003
+ r("div", It, y(s.purchaseOrder.ref), 1)
1004
+ ])) : A("", !0),
1005
+ (xe = s.purchaseOrder) != null && xe.remark ? (v(), D("div", Mt, [
1006
+ r("div", Ut, y(n(i)("inventory.transfer.receiveRequest.details.remark")), 1),
1007
+ r("div", Lt, y(s.purchaseOrder.remark), 1)
1008
+ ])) : A("", !0)
1009
+ ])
1010
+ ];
1011
+ }),
1012
+ _: 1
1013
+ })
1014
+ ]),
1015
+ r("div", jt, [
1016
+ r("div", Bt, [
1017
+ r("div", Kt, y(be.value ? n(i)("inventory.transfer.receiveRequest.details.receivedItems") : n(i)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
1018
+ (v(!0), D(te, null, fe(((I = s.purchaseOrder) == null ? void 0 : I.items) ?? [], (b) => (v(), D("div", {
1019
+ key: b.code,
1020
+ class: "flex flex-col"
1021
+ }, [
1022
+ r("div", Vt, [
1023
+ r("div", Gt, y(b.name), 1),
1024
+ r("div", Ht, y(n(ne)(J.value[b.sku._id], !1)) + "/" + y(n(Le)(b.quantity, b.sku.unit, b.measurement)), 1)
1025
+ ]),
1026
+ r("div", zt, [
1027
+ r("div", Yt, y(b.code), 1),
1028
+ b.totalCost && n(C).enableTotalCost ? (v(), D("div", Qt, " (" + y(n(Te)(b.totalCost)) + ") ", 1)) : A("", !0)
1029
+ ])
1030
+ ]))), 128)),
1031
+ +n(ne)(ue.value) ? (v(), D(te, { key: 0 }, [
1032
+ r("div", Wt, [
1033
+ G(O)
1034
+ ]),
1035
+ r("div", Jt, [
1036
+ e[12] || (e[12] = r("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1037
+ r("div", Zt, y(n(Te)(ue.value)), 1)
1038
+ ])
1039
+ ], 64)) : A("", !0)
1040
+ ])
1041
+ ])
1042
+ ], 64)) : A("", !0),
1043
+ d.value.value === "deliveryHistory" ? (v(), D("div", Xt, [
1044
+ z.value.length ? (v(), D("div", ar, [
1045
+ (v(!0), D(te, null, fe(z.value, (b, q) => (v(), D(te, { key: q }, [
1046
+ r("div", nr, [
1047
+ r("div", or, [
1048
+ r("div", lr, [
1049
+ r("div", {
1050
+ class: me([
1051
+ {
1052
+ "bg-fm-color-primary": q !== 0,
1053
+ "bg-white": q === 0
1054
+ },
1055
+ "w-[2px] h-full"
1056
+ ])
1057
+ }, null, 2)
1058
+ ]),
1059
+ e[13] || (e[13] = r("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1060
+ r("div", cr, [
1061
+ r("div", {
1062
+ class: me([
1063
+ {
1064
+ "bg-fm-color-primary": q < z.value.length - 1,
1065
+ "bg-white": q >= z.value.length - 1
1066
+ },
1067
+ "w-[2px] h-full"
1068
+ ])
1069
+ }, null, 2)
1070
+ ])
1071
+ ]),
1072
+ r("div", ir, [
1073
+ r("div", ur, y(b.header), 1),
1074
+ r("div", dr, y(b.date), 1)
1075
+ ])
1076
+ ]),
1077
+ r("div", mr, [
1078
+ r("div", fr, [
1079
+ r("div", pr, [
1080
+ r("div", {
1081
+ class: me([
1082
+ {
1083
+ "bg-fm-color-primary": q < z.value.length - 1,
1084
+ "bg-white": q >= z.value.length - 1
1085
+ },
1086
+ "w-[2px] h-full"
1087
+ ])
1088
+ }, null, 2)
1089
+ ])
1090
+ ]),
1091
+ r("div", vr, [
1092
+ G(P, {
1093
+ variant: "outlined",
1094
+ class: "py-12 px-16"
1095
+ }, {
1096
+ default: de(() => [
1097
+ r("div", yr, [
1098
+ (v(!0), D(te, null, fe(b.info, ($, N) => (v(), D("div", {
1099
+ key: N,
1100
+ class: "flex flex-col gap-4"
1101
+ }, [
1102
+ r("div", hr, y($ == null ? void 0 : $.label), 1),
1103
+ r("div", br, [
1104
+ (v(!0), D(te, null, fe($ == null ? void 0 : $.values, (K, X) => (v(), D("div", {
1105
+ key: X,
1106
+ class: "fm-typo-en-body-lg-600"
1107
+ }, y(K), 1))), 128))
1108
+ ])
1109
+ ]))), 128))
1110
+ ])
1111
+ ]),
1112
+ _: 2
1113
+ }, 1024)
1114
+ ])
1115
+ ])
1116
+ ], 64))), 128))
1117
+ ])) : (v(), D("div", er, [
1118
+ G(o),
1119
+ r("div", null, [
1120
+ r("img", {
1121
+ src: n(st),
1122
+ alt: "List is empty"
1123
+ }, null, 8, tr)
1124
+ ]),
1125
+ r("div", rr, y(n(i)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1126
+ r("div", sr, y(n(i)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1127
+ G(o),
1128
+ G(o)
1129
+ ]))
1130
+ ])) : A("", !0)
1131
+ ])
1132
+ ];
1133
+ }),
1134
+ "side-sheet-footer": de(() => {
1135
+ var k, I, b, q, $, N, K, X, le, ce;
1136
+ return [
1137
+ r("div", gr, [
1138
+ ((k = s.purchaseOrder) == null ? void 0 : k.status) === n(M).enum.DRAFT && F.value === n(se).PURCHASE ? (v(), Y(t, {
1139
+ key: 0,
1140
+ label: n(i)("inventory.transfer.receiveRequest.actions.confirmDraft"),
1141
+ onClick: e[1] || (e[1] = (V) => H("confirmDraft")),
1142
+ loading: f.value === "confirmDraft",
1143
+ disabled: f.value !== "confirmDraft" && m.value
1144
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1145
+ ((I = s.purchaseOrder) == null ? void 0 : I.status) === n(M).enum.DRAFT && F.value === n(se).TRANSFER ? (v(), Y(t, {
1146
+ key: 1,
1147
+ label: n(i)("inventory.transfer.receiveRequest.actions.submitRequest"),
1148
+ onClick: e[2] || (e[2] = (V) => H("submitRequest")),
1149
+ loading: f.value === "submitRequest",
1150
+ disabled: f.value !== "submitRequest" && m.value
1151
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1152
+ ((b = s.purchaseOrder) == null ? void 0 : b.status) === n(M).enum.DRAFT ? (v(), Y(t, {
1153
+ key: 2,
1154
+ label: n(i)("inventory.transfer.receiveRequest.actions.cancelDraft"),
1155
+ onClick: e[3] || (e[3] = (V) => H("cancelDraft")),
1156
+ loading: f.value === "cancelDraft",
1157
+ disabled: f.value !== "cancelDraft" && m.value,
1158
+ variant: "destructive"
1159
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1160
+ ((q = s.purchaseOrder) == null ? void 0 : q.status) === n(M).enum.RECEIVING ? (v(), Y(t, {
1161
+ key: 3,
1162
+ label: n(i)("inventory.transfer.receiveRequest.actions.completeReceive"),
1163
+ onClick: e[4] || (e[4] = (V) => H("completeReceive")),
1164
+ loading: f.value === "completeReceive",
1165
+ disabled: f.value !== "completeReceive" && m.value
1166
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1167
+ s.canResubmit ? (v(), Y(t, {
1168
+ key: 4,
1169
+ label: n(i)("inventory.transfer.receiveRequest.actions.resubmitRequest"),
1170
+ onClick: e[5] || (e[5] = (V) => H("submitRequest")),
1171
+ loading: f.value === "submitRequest",
1172
+ disabled: f.value !== "submitRequest" && m.value
1173
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1174
+ ((($ = s.purchaseOrder) == null ? void 0 : $.status) === n(M).enum.REQUESTING || ((N = s.purchaseOrder) == null ? void 0 : N.status) === n(M).enum.PROCESSING) && s.canApprove ? (v(), Y(t, {
1175
+ key: 5,
1176
+ label: n(i)("inventory.transfer.approval.actions.approveRequest"),
1177
+ onClick: e[6] || (e[6] = (V) => H("approveRequest")),
1178
+ loading: f.value === "approveRequest",
1179
+ disabled: f.value !== "approveRequest" && m.value
1180
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1181
+ ((K = s.purchaseOrder) == null ? void 0 : K.status) === n(M).enum.REQUESTING && s.canApprove ? (v(), Y(t, {
1182
+ key: 6,
1183
+ label: n(i)("inventory.transfer.approval.actions.rejectRequest"),
1184
+ onClick: e[7] || (e[7] = (V) => H("rejectRequest")),
1185
+ loading: f.value === "rejectRequest",
1186
+ disabled: f.value !== "rejectRequest" && m.value,
1187
+ variant: "destructive"
1188
+ }, null, 8, ["label", "loading", "disabled"])) : A("", !0),
1189
+ ((X = s.purchaseOrder) == null ? void 0 : X.status) !== n(M).enum.COMPLETE && ((le = s.purchaseOrder) == null ? void 0 : le.status) !== n(M).enum.CANCEL && (((ce = s.purchaseOrder) == null ? void 0 : ce.status) !== n(M).enum.REQUESTING || s.canApprove) ? (v(), Y(t, {
1190
+ key: 7,
1191
+ label: n(i)("common.close"),
1192
+ variant: "tertiary",
1193
+ onClick: e[8] || (e[8] = (V) => a("update:show", !1))
1194
+ }, null, 8, ["label"])) : A("", !0)
1195
+ ])
1196
+ ];
1197
+ }),
1198
+ _: 1
1199
+ }, 8, ["header", "modelValue", "dismiss-away"]);
1200
+ };
1201
+ }
1202
+ });
1203
+ export {
1204
+ Ir as _,
1205
+ $r as a,
1206
+ Fr as b,
1207
+ nt as g,
1208
+ Be as u
1209
+ };