@feedmepos/mf-inventory-portal 0.0.23-dev.2 → 0.0.23-dev.21

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