@feedmepos/mf-inventory-portal 0.0.23-dev.1 → 0.0.23-dev.10

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