@feedmepos/mf-inventory-portal 0.0.23-dev.3 → 0.0.23-dev.30

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