@feedmepos/mf-inventory-portal 1.2.5 → 1.2.7-dev.1

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 (67) hide show
  1. package/dist/{App-BkpSG-20.js → App-Dg4euzi-.js} +1 -1
  2. package/dist/{ApprovalView-B7GuyNL8.js → ApprovalView-CPEajz8D.js} +50 -49
  3. package/dist/{BindingsDialog-DU7WwMQQ.js → BindingsDialog-D69Lz-W9.js} +2 -2
  4. package/dist/{BindingsPicker-DoikTRt9.js → BindingsPicker-CvM0o8k2.js} +1 -1
  5. package/dist/{BindingsTable-CR_HLrBt.js → BindingsTable-DX9KrKZx.js} +1 -1
  6. package/dist/{ClosingDraftView-B-zuhr0m.js → ClosingDraftView-zo2KEPba.js} +213 -213
  7. package/dist/{ClosingTemplateView-BXnzvooK.js → ClosingTemplateView-DfkfCFdy.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-BGii4E5k.js → DeliveryOrderPrintPreview-Cl_G1v2L.js} +8 -8
  9. package/dist/{FmAdminBadge-C7SFFAsw.js → FmAdminBadge--YYdqDeq.js} +1 -1
  10. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BnxjX2Nv.js +230 -0
  11. package/dist/{FmMultiselectDialog-DxrZDApl.js → FmMultiselectDialog-CENHExht.js} +1 -1
  12. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CG8hJ9BY.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DTfMfCVb.js} +15 -15
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CaW3WMvN.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D65OfkW-.js} +1 -1
  14. package/dist/{IngredientGroupView-CZXIEHF9.js → IngredientGroupView-BBw9UqRf.js} +2 -2
  15. package/dist/{IngredientsView-BsD9bz4s.js → IngredientsView-WtOZ9Ara.js} +71 -61
  16. package/dist/{IntegrationView-BwZLCHKQ.js → IntegrationView-YFafrCnU.js} +84 -84
  17. package/dist/{InventoryBindingForm-D1DjZ8GU.js → InventoryBindingForm-DNljyNN-.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-977ZTGqB.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-C2dTKKAj.js} +3 -3
  19. package/dist/{InventoryBindingSummary-DzTHC4EA.js → InventoryBindingSummary-DOONgjR-.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CVjIweiD.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D3Elw6_K.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BOynbtg3.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CYiwHmvH.js} +7 -7
  22. package/dist/{PublishView-Qpnsfl9u.js → PublishView-CL5U8cyq.js} +7 -7
  23. package/dist/{PurchaseOrderPrintPreview-Cu0Huq0q.js → PurchaseOrderPrintPreview-PfG5JjNN.js} +8 -8
  24. package/dist/{ReceiveRequestView-4-0jJ5tI.js → ReceiveRequestView-DB-Df7af.js} +82 -79
  25. package/dist/{RecipeView-CkzCMbst.js → RecipeView-DYYehKGI.js} +3 -3
  26. package/dist/{StockView-C2GZw_2q.js → StockView-lbA_CgVg.js} +7 -7
  27. package/dist/{SupplierView-BMBCSjIF.js → SupplierView-DKq68lkF.js} +862 -831
  28. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DKR568Dl.js +2578 -0
  29. package/dist/{TransferTemplateView-BpGi9pYo.js → TransferTemplateView-CYdVExkv.js} +57 -57
  30. package/dist/{UnitView-CyelRDgW.js → UnitView-BLDTNtXw.js} +3 -3
  31. package/dist/WarehouseView-ByfTvgQq.js +1066 -0
  32. package/dist/api/inventory.d.ts +8 -0
  33. package/dist/api/shipment.d.ts +11 -0
  34. package/dist/api/warehouse.d.ts +3 -1
  35. package/dist/{app-DLJ3tarV.js → app-DEpHnIaM.js} +13795 -13214
  36. package/dist/app.d.ts +24 -9
  37. package/dist/app.js +1 -1
  38. package/dist/{decimal-Y-vsqUV6.js → decimal-BdGG2NHb.js} +1 -1
  39. package/dist/{format-unit-display-52tZYV50.js → format-unit-display-DoCxmNPB.js} +21 -21
  40. package/dist/{index-PtOchBO2.js → index-BI2zM3ru.js} +1 -1
  41. package/dist/{index-Z9YSq95U.js → index-CCmaDOGB.js} +1 -1
  42. package/dist/{stock-CN530yZJ.js → stock-CtzGgdTO.js} +1 -1
  43. package/dist/stores/feature.d.ts +2 -0
  44. package/dist/stores/inventory.d.ts +1 -0
  45. package/dist/stores/location.d.ts +57 -1
  46. package/dist/stores/supplier.d.ts +96 -0
  47. package/dist/stores/warehouse.d.ts +4 -0
  48. package/dist/{supplier-B5VFlEyS.js → supplier-hiLnFx22.js} +1 -1
  49. package/dist/tsconfig.app.tsbuildinfo +1 -1
  50. package/dist/{use-ingredient-select-dialog-CrLCvhtp.js → use-ingredient-select-dialog-BWBy-LTC.js} +1 -1
  51. package/dist/{use-inventory-binding-dialog-zoNELf20.js → use-inventory-binding-dialog-6H3lD9xF.js} +1 -1
  52. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  53. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +60 -0
  54. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +10 -0
  55. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +94 -0
  56. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +72 -1
  57. package/dist/views/supplier/components/SupplierForm.vue.d.ts +8 -0
  58. package/dist/views/supplier/composables/use-supplier-table.d.ts +4 -0
  59. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -0
  60. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +16 -0
  61. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -0
  62. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -0
  63. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -0
  64. package/package.json +2 -2
  65. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CLSMS6lS.js +0 -227
  66. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CNfrMUvj.js +0 -2494
  67. package/dist/WarehouseView-CB1LmtPm.js +0 -1034
@@ -1,2494 +0,0 @@
1
- import { a4 as gt, u as ge, aS as k, aT as Be, aB as W, c as Ve, b as Ue, ac as _t, ae as St, af as wt, aU as Rt, e as nt, f as ct, a1 as Je, aV as xt, a9 as ut, V as dt, j as be, a7 as Ot, aW as mt, aj as Le, h as at, i as oe, D as ce, aX as ft, aY as pt, aZ as Ae, a_ as ze, az as it, a$ as Se, T as De, ab as Fe, a5 as Ge, a6 as Nt } from "./app-DLJ3tarV.js";
2
- import { ref as z, computed as re, h as C, defineComponent as Re, reactive as $t, onMounted as yt, resolveComponent as Z, openBlock as v, createBlock as ue, withCtx as se, createElementVNode as e, createVNode as F, unref as w, createElementBlock as x, toDisplayString as R, createCommentVNode as H, Fragment as ae, renderList as he, createTextVNode as Ne, normalizeClass as Te, watch as kt, isRef as Ct, resolveDynamicComponent as At } from "vue";
3
- import { F as Dt } from "./decimal-Y-vsqUV6.js";
4
- import { useCoreStore as Me, useI18n as vt } from "@feedmepos/mf-common";
5
- import { useDialog as et, useSnackbar as Ke, components as Ye, FmButtonVariant as le, useProxiedModel as qt } from "@feedmepos/ui-library";
6
- import { F as $e } from "./FmAdminBadge-C7SFFAsw.js";
7
- import { b as Tt, u as Pt, P as we, f as It } from "./format-unit-display-52tZYV50.js";
8
- import { E as Ft } from "./empty-placeholder-wf6-BWE8.js";
9
- import { _ as Lt, F as Et, a as Bt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-CG8hJ9BY.js";
10
- import { u as Vt, R as lt } from "./usePromise-CbVUCxhj.js";
11
- import { u as Ut } from "./index-PtOchBO2.js";
12
- const je = gt((b, t) => {
13
- const s = ge(), _ = Me();
14
- return {
15
- async readRequests(i, r, d) {
16
- const a = i ?? s.currentLocationDBName, o = `${b.inventoryBackendUrl}/${a}/purchase-request`;
17
- return r && d ? await t.get(`${o}?startDate=${r}&endDate=${d}`) : await t.get(o);
18
- },
19
- async readRequestById(i, r) {
20
- const d = r ?? s.currentLocationDBName, a = `${b.inventoryBackendUrl}/${d}/purchase-request/${i}`;
21
- return await t.get(a);
22
- },
23
- async readRequestByIds(i, r) {
24
- const d = r ?? s.currentLocationDBName, a = `${b.inventoryBackendUrl}/${d}/purchase-request/find`;
25
- return await t.post(a, { requestIds: i });
26
- },
27
- async getPurchaseOrders({
28
- start: i,
29
- end: r
30
- }) {
31
- const d = s.currentLocationDBName, a = `${b.inventoryBackendUrl}/${d}/purchase-order`;
32
- return await t.get(`${a}?start=${i}&end=${r}`);
33
- },
34
- async getLatestPurchaseOrderRequest(i) {
35
- const r = s.currentLocationDBName, d = `${b.inventoryBackendUrl}/${r}/purchase-request/find-by-purchase-order-id`;
36
- return await t.get(`${d}/${i}`);
37
- },
38
- async getPurchaseOrderById(i) {
39
- const r = s.currentLocationDBName, d = `${b.inventoryBackendUrl}/${r}/purchase-order`;
40
- return await t.get(`${d}/${i}`);
41
- },
42
- /**
43
- * @deprecated Use `processPurchaseOrderV2` instead.
44
- */
45
- async processPurchaseOrder(i, r) {
46
- const d = s.currentLocationDBName, a = r || d, o = `${b.inventoryBackendUrl}/${a}/purchase-order/run-operation`;
47
- return await t.put(o, i);
48
- },
49
- async createPurchaseOrder(i) {
50
- const r = s.currentLocationDBName, d = `${b.inventoryBackendUrl}/${r}/purchase-order`;
51
- return await t.post(d, i);
52
- },
53
- async updatePurchaseOrder(i) {
54
- const r = s.currentLocationDBName, d = `${b.inventoryBackendUrl}/${r}/purchase-order`;
55
- return await t.put(d, i);
56
- },
57
- async importFromXilnex(i) {
58
- const r = s.currentLocationDBName, d = `${b.inventoryBackendUrl}/${r}/purchase-order/import-from-xilnex`;
59
- return await t.post(d, i);
60
- },
61
- async processPurchaseOrderV2(i, r) {
62
- const d = s.currentLocationDBName, a = r || d, o = `${b.inventoryBackendUrl}/${a}/v2/purchase-order/run-operation`;
63
- return await t.put(o, i);
64
- },
65
- async getWorkflowConfig() {
66
- var a;
67
- const r = `business_${(a = _.currentBusiness.value) == null ? void 0 : a._id}`, d = `${b.inventoryBackendUrl}/${r}/v2/purchase-order/workflow-config`;
68
- return await t.get(d);
69
- }
70
- };
71
- }), ht = {
72
- [k.enum.confirmDraft]: {
73
- primaryActions: {
74
- text: "Confirm draft",
75
- close: !0
76
- },
77
- title: "Confirm draft?",
78
- message: "Purchase order cannot be changed after confirm draft.",
79
- successMessage: "Purchase order draft has been confirmed"
80
- },
81
- [k.enum.cancelDraft]: {
82
- primaryActions: {
83
- text: "Cancel draft",
84
- close: !0,
85
- variant: "destructive"
86
- },
87
- title: "Cancel draft?",
88
- message: "Purchase order cannot be changed after cancelled draft.",
89
- successMessage: "Purchase order draft has been cancelled"
90
- },
91
- [k.enum.submitRequest]: {
92
- primaryActions: {
93
- text: "Submit request",
94
- close: !0
95
- },
96
- title: "Confirm draft?",
97
- message: "Purchase order cannot be changed after confirm draft.",
98
- successMessage: "Purchase order draft has been submitted"
99
- },
100
- [k.enum.completeReceive]: {
101
- primaryActions: {
102
- text: "Mark received",
103
- close: !0
104
- },
105
- title: "Mark as received",
106
- message: "Purchase order cannot be changed after it has complete receiving.",
107
- successMessage: "Purchase order has been marked as received"
108
- },
109
- [k.enum.approveRequest]: {
110
- primaryActions: {
111
- text: "Accept request",
112
- close: !0
113
- },
114
- title: "Accept request?",
115
- message: "Transfer out request will be accepted.",
116
- successMessage: "Transfer out request has been approved"
117
- },
118
- [k.enum.rejectRequest]: {
119
- primaryActions: {
120
- text: "Reject request",
121
- close: !0,
122
- variant: "destructive"
123
- },
124
- title: "Reject request?",
125
- message: "Purchase order will be rejected.",
126
- successMessage: "Purchase order has been rejected"
127
- },
128
- [k.enum.processRequest]: {
129
- primaryActions: {
130
- text: "Process request",
131
- close: !0,
132
- variant: "destructive"
133
- },
134
- title: "Process request?",
135
- message: "Purchase order will be processed.",
136
- successMessage: "Purchase order has been processed"
137
- }
138
- };
139
- function Ee(b) {
140
- return Be.generatedPOReceivedMap({
141
- purchaseOrder: b
142
- });
143
- }
144
- function Mt(b) {
145
- return Be.validatePOItemReceivedStatus({
146
- dto: b
147
- });
148
- }
149
- function Qe(b) {
150
- return Be.validatePOReceivedStatus({
151
- receivedMap: b
152
- });
153
- }
154
- function Xe(b, t, s) {
155
- if (!W.safeParse(b).success)
156
- throw new Error(`Invalid purchase order status: ${b}`);
157
- const _ = W.parse(b);
158
- return Be.orderStatusCombination({
159
- status: _,
160
- isPOPartialReceive: t,
161
- isPOOverReceive: s
162
- });
163
- }
164
- function bt() {
165
- const b = ge(), t = je(), s = Ve();
166
- async function _(r, d) {
167
- const a = b.currentLocationDBName;
168
- return r.doc.supplier.internal && r.operation === k.enum.confirmDraft && (r.operation = k.enum.submitRequest), await t.processPurchaseOrder(r, d || a);
169
- }
170
- async function i(r, d) {
171
- const a = b.currentLocationDBName;
172
- return await t.processPurchaseOrderV2(r, d || a);
173
- }
174
- return (r) => s.useOperatePurchaseOrderV2 ? i(r.operateV2, r.transferTo) : _(r.operate, r.transferTo);
175
- }
176
- var Ze = /* @__PURE__ */ ((b) => (b.RECEIVE_REQUEST = "receive/request", b.APPROVAL = "approval", b))(Ze || {});
177
- const qe = z(), He = z();
178
- function po(b, t) {
179
- const s = et(), _ = ge(), i = Ve();
180
- Ue();
181
- const r = Tt(), d = Pt(), a = z(!1), o = Ke(), h = je(), S = z(new Array()), y = z(
182
- t != null && t.startDate && (t != null && t.endDate) ? t : _t()
183
- ), g = re(() => {
184
- const D = new Date(y.value.startDate), I = new Date(y.value.endDate);
185
- return {
186
- start: St(D).toISOString(),
187
- end: wt(I).toISOString()
188
- };
189
- }), p = z(new Array()), l = Rt(), c = z(null);
190
- async function u(D) {
191
- function I(G) {
192
- const ne = {
193
- mode: nt.CREATE,
194
- modelValue: D || void 0,
195
- show: !0,
196
- "onUpdate:show"(J) {
197
- qe.value.show = J;
198
- },
199
- templateId: G,
200
- lastClosingDate: c.value
201
- };
202
- qe.value = ne;
203
- }
204
- let te;
205
- i.mustUsePoTemplate && !(D != null && D.template) ? s.open({
206
- title: "Create transfer",
207
- message: "",
208
- primaryActions: {
209
- text: "Select a template",
210
- close: !0
211
- },
212
- secondaryActions: {
213
- text: "Outlet to Outlet",
214
- variant: "secondary",
215
- close: !0
216
- }
217
- }).onPrimary(async () => {
218
- te = await r.getTemplateId(), te && I(te);
219
- }).onSecondary(() => {
220
- I(void 0);
221
- }) : I(te);
222
- }
223
- function O(D) {
224
- const I = {
225
- mode: nt.UPDATE,
226
- modelValue: ct(D),
227
- show: !0,
228
- "onUpdate:show"(te) {
229
- qe.value.show = te;
230
- },
231
- lastClosingDate: c.value
232
- };
233
- qe.value = I;
234
- }
235
- async function q() {
236
- S.value = [], a.value = !0;
237
- try {
238
- S.value = await h.getPurchaseOrders(g.value).then((G) => G.sort((ne, J) => J._id.localeCompare(ne._id)));
239
- const D = await l.readCurrentLocationLastClosing(!0), I = D == null ? void 0 : D._id;
240
- I && (c.value = xt(I)), await i.awaitFeatureLoaded(() => i.mustUsePoTemplate) && await d.fetchTemplates();
241
- const te = S.value.map((G) => {
242
- var ne;
243
- return ((ne = G.request) == null ? void 0 : ne.id) ?? "";
244
- }).filter((G) => G);
245
- p.value = await h.readRequestByIds(te);
246
- } catch {
247
- o.open({
248
- title: "Something went wrong",
249
- message: "Error at fetching purchase orders",
250
- type: "error"
251
- });
252
- } finally {
253
- a.value = !1;
254
- }
255
- }
256
- async function T() {
257
- p.value = [], a.value = !0;
258
- try {
259
- p.value = await h.readRequests(
260
- void 0,
261
- g.value.start,
262
- g.value.end
263
- ).then((D) => D.reverse());
264
- } catch {
265
- o.open({
266
- title: "Something went wrong",
267
- message: "Error at fetching purchase requests",
268
- type: "error"
269
- });
270
- } finally {
271
- a.value = !1;
272
- }
273
- }
274
- function P() {
275
- switch (b) {
276
- case "receive/request":
277
- return q();
278
- case "approval":
279
- return T();
280
- }
281
- }
282
- function $(D, I) {
283
- y.value = {
284
- startDate: D,
285
- endDate: I
286
- }, P();
287
- }
288
- _.watchLocation(async (D) => {
289
- if (!D) {
290
- S.value = [];
291
- return;
292
- }
293
- await P();
294
- });
295
- const U = z(), pe = z(Math.random().toString());
296
- async function de(D, I) {
297
- const te = Math.random().toString();
298
- pe.value = te, I ?? (I = p.value.computeFirst(
299
- (J) => J.purchaseOrderId === D._id ? J : null
300
- ) ?? void 0);
301
- const G = b === "receive/request" ? _.currentLocation : I == null ? void 0 : I.to, ne = {
302
- poRequest: I,
303
- purchaseOrder: D,
304
- transferTo: G == null ? void 0 : G.name,
305
- transferToDbName: G == null ? void 0 : G.dbName,
306
- show: !0,
307
- canResubmit: !1,
308
- canApprove: b === "approval",
309
- "onUpdate:show"(J) {
310
- U.value.show = J;
311
- },
312
- scope: b,
313
- receivedMap: Ee(D) ?? {}
314
- };
315
- U.value = ne;
316
- }
317
- async function xe(D, I, te, G) {
318
- const ne = bt();
319
- a.value = !0;
320
- try {
321
- await ne({
322
- operate: {
323
- operation: I,
324
- doc: D,
325
- options: (
326
- // auto receive for supplier to warehouse
327
- (I === k.enum.confirmDraft || // auto receive for warehouse to warehouse
328
- I === k.enum.completeReceive) && i.autoReceiveWarehouse ? {
329
- autoReceive: !0
330
- } : void 0
331
- )
332
- },
333
- operateV2: {
334
- _id: D._id,
335
- _rev: D._rev ?? "",
336
- action: I,
337
- payloads: []
338
- },
339
- transferTo: G
340
- }), await new Promise((m) => setTimeout(m, 1e3));
341
- const n = ge().currentLocationDBName.startsWith("restaurant_");
342
- I === k.enum.confirmDraft && D.effectiveAt && n ? o.open({
343
- title: "Success",
344
- message: `${te}. The backdate will be reflected once your POS has received this change.`,
345
- type: "success"
346
- }) : o.open({
347
- title: "Success",
348
- message: te,
349
- type: "success"
350
- });
351
- } catch (J) {
352
- o.open({
353
- title: "Something went wrong",
354
- message: "Please try again.",
355
- type: "error"
356
- }), console.error("Error when submitting PO operation", I, D, J);
357
- } finally {
358
- a.value = !1, P();
359
- }
360
- }
361
- async function Pe(D, I, te) {
362
- const G = ht[I];
363
- if (!G) {
364
- o.open({
365
- title: "Something went wrong",
366
- message: `Cannot process order: ${Je(I)}`,
367
- type: "error"
368
- });
369
- return;
370
- }
371
- const { successMessage: ne, ...J } = G;
372
- s.open({
373
- title: J.title,
374
- message: J.message,
375
- primaryActions: J.primaryActions
376
- }).onPrimary(() => {
377
- xe(D, I, ne, te);
378
- });
379
- }
380
- async function ye() {
381
- s.open({
382
- title: "Upload Transfer",
383
- primaryActions: {
384
- text: "Xilnex transfer note",
385
- close: !0
386
- },
387
- secondaryActions: {
388
- text: "Cancel",
389
- close: !0
390
- }
391
- }).onPrimary(() => {
392
- const D = {
393
- show: !0,
394
- "onUpdate:show"(I) {
395
- He.value.show = I;
396
- }
397
- };
398
- He.value = D;
399
- });
400
- }
401
- return {
402
- purchaseOrders: S,
403
- purchaseRequests: p,
404
- updateDateRange: $,
405
- fetchData: P,
406
- loading: a,
407
- transferDialogProps: qe,
408
- promptCreateTransferDialog: u,
409
- promptUpdateTransferDialog: O,
410
- transferDetailsProps: U,
411
- promptShowTransferDetails: de,
412
- submitAction: Pe,
413
- xilnexImportDialogProps: He,
414
- promptUploadTransferDialog: ye
415
- };
416
- }
417
- function Kt(b, t) {
418
- return t.reduce(
419
- (_, i) => {
420
- const r = i.received.find((d) => d.sku._id === b._id);
421
- return r && (_ = ut(_, r.amount)), _;
422
- },
423
- Dt.toPrecision(dt(0), b.unit.precision)
424
- );
425
- }
426
- function jt(b) {
427
- const { po: t, currentLocation: s, business: _, fulfilling: i, por: r } = b, { name: d, address: a, regNo: o } = s.doc.profile, h = {
428
- name: d,
429
- registrationNumber: o,
430
- line1: a == null ? void 0 : a.line1,
431
- line2: a == null ? void 0 : a.line2,
432
- postcode: a == null ? void 0 : a.postcode,
433
- city: a == null ? void 0 : a.city,
434
- state: a == null ? void 0 : a.state,
435
- country: a == null ? void 0 : a.country
436
- }, S = {
437
- name: t.supplier.name,
438
- phoneNumber: t.supplier.phoneNumber,
439
- registrationNumber: t.supplier.registrationNumber,
440
- line1: t.supplier.address.line1,
441
- line2: t.supplier.address.line2,
442
- postcode: t.supplier.address.postcode,
443
- city: t.supplier.address.city,
444
- state: t.supplier.address.state,
445
- country: t.supplier.address.country
446
- }, y = t.items.map((T) => {
447
- const { sku: P, measurement: $ } = T, U = be(
448
- Kt(T.sku, t.deliveryOrder || []),
449
- !1
450
- );
451
- return {
452
- code: P.code,
453
- description: P.name,
454
- quantity: be(T.quantity, !1),
455
- unit: ($ == null ? void 0 : $.abbrev) || P.unit.abbrev,
456
- received: U,
457
- cost: T.totalCost ? `${T.totalCost.currency} ${Ot.toFormatString({
458
- value: T.totalCost
459
- })}` : void 0
460
- };
461
- }), g = t.deliveryOrder.map((T) => ({
462
- createdAt: mt(new Date(T.createdAt)),
463
- ref: T.deliveryOrderNumber,
464
- remark: T.remark || "",
465
- items: T.received.map((P) => {
466
- var $;
467
- return {
468
- code: P.sku.code,
469
- description: P.sku.name,
470
- quantity: be(P.amount),
471
- unit: (($ = P.measurement) == null ? void 0 : $.abbrev) || P.sku.unit.abbrev
472
- };
473
- })
474
- })), p = [
475
- // Production
476
- "67ca5d2c80bd0e001c5bf5bc",
477
- // Dev
478
- "6880b36a3054c5001db19218"
479
- ];
480
- let l = "Inventory Receive Note";
481
- if (t.supplier.internal ? (l = "Inventory Transfer Note", p.includes((_ == null ? void 0 : _._id) || "") && (l = "Stock Request")) : l = "Purchase Order", r) {
482
- const T = r.from.dbName;
483
- s.dbName === T || (l = "Inventory Receive Note");
484
- }
485
- const u = {
486
- title: l,
487
- businessName: _ == null ? void 0 : _.name,
488
- logo: _ == null ? void 0 : _.thumbnail,
489
- orderNumber: t.seqNumber.toString(),
490
- createdAt: Le(t._id),
491
- ref: t.ref || "",
492
- remark: t.remark || "",
493
- buyer: h,
494
- supplier: S,
495
- items: y,
496
- status: t.status,
497
- deliveryOrders: g
498
- }, O = new URL(window.location.href), q = i && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
499
- O.pathname = O.hostname.includes("portal.feedme") ? `/inventory/${q}` : `/${q}`, O.searchParams.append("data", JSON.stringify(u)), window.open(O.href, "_blank", "noreferrer");
500
- }
501
- const Oe = {
502
- submitRequest: {
503
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
504
- color: "text-fm-color-typo-primary",
505
- value: k.enum.submitRequest
506
- },
507
- confirmDraft: {
508
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
509
- color: "text-fm-color-typo-primary",
510
- value: k.enum.confirmDraft
511
- },
512
- cancelDraft: {
513
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
514
- color: "text-fm-color-typo-error",
515
- value: k.enum.cancelDraft
516
- },
517
- approveRequest: {
518
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
519
- color: "text-fm-color-typo-primary",
520
- value: k.enum.approveRequest
521
- },
522
- rejectRequest: {
523
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
524
- color: "text-fm-color-typo-error",
525
- value: k.enum.rejectRequest
526
- },
527
- processRequest: {
528
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
529
- color: "text-fm-color-typo-primary",
530
- value: k.enum.processRequest
531
- },
532
- receiveStock: {
533
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
534
- color: "text-fm-color-typo-primary",
535
- value: k.enum.receiveStock
536
- },
537
- completeReceive: {
538
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
539
- color: "text-fm-color-typo-primary",
540
- value: k.enum.completeReceive
541
- },
542
- closeRequest: {
543
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
544
- color: "system-error-300",
545
- value: k.enum.closeRequest
546
- },
547
- approveDraft: {
548
- translationKey: "",
549
- color: "",
550
- value: void 0
551
- },
552
- rejectDraft: {
553
- translationKey: "",
554
- color: "",
555
- value: void 0
556
- },
557
- returnStock: {
558
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
559
- color: "text-fm-color-typo-primary",
560
- value: k.enum.returnStock
561
- }
562
- };
563
- function yo(b, t) {
564
- const s = ge(), _ = Ue(), i = Me(), { t: r } = vt();
565
- function d(g) {
566
- switch (g.status) {
567
- case "DRAFT":
568
- return [
569
- ce[oe.Update],
570
- ce[oe.Details],
571
- g.supplier.internal === "restaurant" || g.supplier.internal === "warehouse" ? Oe[k.enum.submitRequest] : Oe[k.enum.confirmDraft],
572
- Oe[k.enum.cancelDraft]
573
- ];
574
- case "RECEIVING":
575
- return [
576
- Oe[k.enum.completeReceive],
577
- ce[oe.Details],
578
- ce[oe.Print]
579
- ];
580
- case "REQUESTING":
581
- return b === "receive/request" ? [ce[oe.Details], ce[oe.Print]] : [
582
- Oe[k.enum.approveRequest],
583
- Oe[k.enum.rejectRequest],
584
- ce[oe.Details]
585
- // DefaultRowActions[RowActionEnum.Print]
586
- ];
587
- case "PROCESSING":
588
- return [ce[oe.Details], ce[oe.Print]];
589
- case "COMPLETE":
590
- case "CANCEL":
591
- default:
592
- return [ce[oe.Details], ce[oe.Print]];
593
- }
594
- }
595
- function a(g) {
596
- return Object.values(k.enum).includes(g);
597
- }
598
- async function o(g, p, l) {
599
- var u, O, q, T, P, $;
600
- const c = ct(p);
601
- if (g === oe.Print) {
602
- const U = (l == null ? void 0 : l.toInventoryLocation) ?? s.currentLocation;
603
- ((u = l == null ? void 0 : l.netSuite) != null && u.refNo || (O = c.netSuite) != null && O.refNo) && (c.ref = [((q = l == null ? void 0 : l.netSuite) == null ? void 0 : q.refNo) || ((T = c.netSuite) == null ? void 0 : T.refNo)].filter((pe) => pe).join(" ")), jt({
604
- po: c,
605
- currentLocation: U,
606
- business: i.currentBusiness.value,
607
- fulfilling: b === "approval",
608
- por: l
609
- });
610
- return;
611
- }
612
- if (g === oe.Details) {
613
- t.promptShowTransferDetails(c, l);
614
- return;
615
- }
616
- if (g === oe.Update) {
617
- (P = t.promptUpdateTransferDialog) == null || P.call(t, c);
618
- return;
619
- }
620
- if (a(g)) {
621
- t.submitAction(p, g, ($ = l == null ? void 0 : l.to) == null ? void 0 : $.dbName);
622
- return;
623
- }
624
- }
625
- function h() {
626
- var p;
627
- const g = [
628
- {
629
- accessorKey: "seqNumber",
630
- header: () => r("inventory.transfer.table.seqNo"),
631
- enableSorting: !0,
632
- size: 80,
633
- sortUndefined: "last"
634
- },
635
- {
636
- accessorKey: "_id",
637
- header: () => r("inventory.transfer.table.createdAt"),
638
- cell(l) {
639
- return Le(`${l.getValue()}`);
640
- },
641
- enableSorting: !0
642
- },
643
- {
644
- accessorKey: "supplier.name",
645
- header: () => r("inventory.transfer.table.transferFrom"),
646
- enableSorting: !0,
647
- size: 200
648
- },
649
- {
650
- accessorKey: "items.length",
651
- header: () => r("inventory.transfer.table.noOfItems"),
652
- cell: (l) => {
653
- const c = l.row.original.version || "1", u = l.getValue();
654
- return C("div", { class: "flex items-center gap-2" }, [
655
- u,
656
- c !== "1" ? C(
657
- "div",
658
- { class: "py-3" },
659
- C(
660
- $e,
661
- C(
662
- "div",
663
- {
664
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
665
- },
666
- `v${c}`
667
- )
668
- )
669
- ) : null
670
- ]);
671
- },
672
- enableSorting: !1,
673
- meta: {
674
- width: "10rem"
675
- }
676
- },
677
- {
678
- accessorKey: "ref",
679
- header: () => r("inventory.transfer.table.reference"),
680
- enableSorting: !1,
681
- size: "auto"
682
- },
683
- ...(p = i.sessionUser.value) != null && p.role.isAdmin ? [
684
- {
685
- id: "statusForAdmin",
686
- header: () => C($e, {}, () => `${r("inventory.transfer.table.status")}`),
687
- cell(l) {
688
- return l.row.original.status;
689
- },
690
- enableSorting: !0,
691
- size: 200
692
- }
693
- ] : [],
694
- {
695
- accessorKey: "status",
696
- header: () => r("inventory.transfer.table.status"),
697
- cell(l) {
698
- const c = l.getValue(), u = Ee(l.row.original), { partial: O, over: q } = Qe(u), T = Xe(c ?? "", O, q);
699
- let P = r(`inventory.transfer.status.${T}`), $ = `${c ?? ""}`.toLocaleLowerCase("en-us");
700
- return T === W.enum.CLOSE && (P = `${r(`inventory.transfer.status.${W.enum.COMPLETE}`)}`), T === "PARTIAL_RECEIVED" && $ === W.enum.PROCESSING.toLocaleLowerCase("en-us") && ($ = W.enum.RECEIVING.toLocaleLowerCase("en-us")), C(
701
- "div",
702
- {
703
- class: "flex"
704
- },
705
- C(
706
- "div",
707
- {
708
- class: [
709
- "fm-status-badge",
710
- `fm-status-badge-${$}`,
711
- q && "fm-status-badge-error"
712
- ].filter(Boolean).join(" ")
713
- },
714
- `${P}`
715
- )
716
- );
717
- },
718
- enableSorting: !0,
719
- size: 200
720
- },
721
- {
722
- id: "action",
723
- cell(l) {
724
- const c = l.row.original, u = d(c);
725
- return at(u, (O) => o(O, c));
726
- },
727
- enableSorting: !1,
728
- size: 40,
729
- meta: {
730
- cellClass: "",
731
- headerClass: ""
732
- }
733
- }
734
- ];
735
- if (_.isEnabled) {
736
- const l = [
737
- {
738
- id: "netsuiteTransferOrder",
739
- accessorFn: (c) => {
740
- var u;
741
- return (u = c.netSuite) != null && u.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
742
- },
743
- header: () => "NetSuite Order (ID)",
744
- cell(c) {
745
- var O;
746
- const u = c.row.original;
747
- return (O = u.netSuite) != null && O.id ? `${u.netSuite.refNo} (${u.netSuite.id})` : "N/A";
748
- },
749
- enableSorting: !1,
750
- size: 200,
751
- meta: {
752
- cellClass: "",
753
- headerClass: ""
754
- }
755
- },
756
- {
757
- id: "netsuiteTransactionNumber",
758
- accessorFn: (c) => {
759
- var u, O;
760
- return ((O = (u = c.netSuite) == null ? void 0 : u.additionalInfo) == null ? void 0 : O.transactionnumber) ?? "N/A";
761
- },
762
- header: () => "NetSuite Transaction No.",
763
- cell(c) {
764
- var O, q;
765
- return ((q = (O = c.row.original.netSuite) == null ? void 0 : O.additionalInfo) == null ? void 0 : q.transactionnumber) ?? "N/A";
766
- },
767
- enableSorting: !1,
768
- size: 200,
769
- meta: {
770
- cellClass: "",
771
- headerClass: ""
772
- }
773
- }
774
- ];
775
- g.splice(g.length - 1, 0, ...l);
776
- }
777
- return g;
778
- }
779
- function S() {
780
- var p;
781
- const g = [
782
- {
783
- accessorKey: "purchaseOrder.seqNumber",
784
- header: () => r("inventory.transfer.table.seqNo"),
785
- enableSorting: !0,
786
- size: 80,
787
- sortUndefined: "last"
788
- },
789
- {
790
- accessorKey: "purchaseOrder._id",
791
- header: () => r("inventory.transfer.table.createdAt"),
792
- cell(l) {
793
- return Le(`${l.getValue()}`);
794
- },
795
- enableSorting: !0
796
- },
797
- {
798
- accessorKey: "to.name",
799
- header: () => r("inventory.transfer.table.transferTo"),
800
- enableSorting: !1,
801
- size: 200
802
- },
803
- {
804
- accessorKey: "purchaseOrder.items.length",
805
- header: () => r("inventory.transfer.table.noOfItems"),
806
- enableSorting: !1
807
- },
808
- {
809
- accessorKey: "purchaseOrder.ref",
810
- header: () => r("inventory.transfer.table.reference"),
811
- enableSorting: !1,
812
- size: "auto"
813
- },
814
- ...(p = i.sessionUser.value) != null && p.role.isAdmin ? [
815
- {
816
- id: "statusForAdmin",
817
- header: () => C($e, {}, () => `${r("inventory.transfer.table.status")}`),
818
- cell(l) {
819
- return l.row.original.status;
820
- },
821
- enableSorting: !0,
822
- size: 200
823
- }
824
- ] : [],
825
- {
826
- accessorKey: "purchaseOrder.status",
827
- header: () => r("inventory.transfer.table.status"),
828
- cell(l) {
829
- const c = l.row.original, u = l.getValue();
830
- if (!c.purchaseOrder)
831
- return C(Ye.FmChip, {
832
- label: "N/A",
833
- compact: !0
834
- });
835
- const O = Ee(c.purchaseOrder), { partial: q, over: T } = Qe(O), P = Xe(u ?? "", q, T);
836
- let $ = r(`inventory.transfer.status.${P}`), U = `${u ?? ""}`.toLocaleLowerCase("en-us");
837
- return P === W.enum.CLOSE && ($ = `${r(`inventory.transfer.status.${W.enum.COMPLETE}`)}`), P === "PARTIAL_RECEIVED" && U === W.enum.PROCESSING.toLocaleLowerCase("en-us") && (U = W.enum.RECEIVING.toLocaleLowerCase("en-us")), C(
838
- "div",
839
- {
840
- class: "flex"
841
- },
842
- C(
843
- "div",
844
- {
845
- class: [
846
- "fm-status-badge",
847
- `fm-status-badge-${U}`,
848
- T && "fm-status-badge-error"
849
- ].filter(Boolean).join(" ")
850
- },
851
- `${$}`
852
- )
853
- );
854
- },
855
- enableSorting: !0
856
- },
857
- {
858
- id: "action",
859
- cell(l) {
860
- const c = l.row.original, O = (c.purchaseOrder ? d(c.purchaseOrder) : []).map((q) => q.value === oe.Print ? {
861
- ...q,
862
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
863
- } : q);
864
- return at(
865
- O,
866
- (q) => c.purchaseOrder ? o(q, c.purchaseOrder, c) : void 0
867
- );
868
- },
869
- enableSorting: !1,
870
- size: 40,
871
- meta: {
872
- cellClass: "",
873
- headerClass: ""
874
- }
875
- }
876
- ];
877
- if (_.isEnabled) {
878
- const l = [
879
- {
880
- id: "netsuiteTransferOrder",
881
- accessorFn: (c) => {
882
- var u;
883
- return (u = c.netSuite) != null && u.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
884
- },
885
- header: () => "NetSuite Order (ID)",
886
- cell(c) {
887
- var O;
888
- const u = c.row.original;
889
- return (O = u.netSuite) != null && O.id ? `${u.netSuite.refNo} (${u.netSuite.id})` : "N/A";
890
- },
891
- enableSorting: !1,
892
- size: 200,
893
- meta: {
894
- cellClass: "",
895
- headerClass: ""
896
- }
897
- },
898
- {
899
- id: "netsuiteTransactionNumber",
900
- accessorFn: (c) => {
901
- var u, O;
902
- return ((O = (u = c.netSuite) == null ? void 0 : u.additionalInfo) == null ? void 0 : O.transactionnumber) ?? "N/A";
903
- },
904
- header: () => "NetSuite Transaction No.",
905
- cell(c) {
906
- var O, q;
907
- return ((q = (O = c.row.original.netSuite) == null ? void 0 : O.additionalInfo) == null ? void 0 : q.transactionnumber) ?? "N/A";
908
- },
909
- enableSorting: !1,
910
- size: 200,
911
- meta: {
912
- cellClass: "",
913
- headerClass: ""
914
- }
915
- }
916
- ];
917
- g.splice(g.length - 2, 0, ...l);
918
- }
919
- return g;
920
- }
921
- return {
922
- columnDefs: re(() => b === "receive/request" ? h() : S())
923
- };
924
- }
925
- const zt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Gt = { class: "flex flex-col gap-8" }, Ht = { class: "flex w-full justify-end gap-16" }, Wt = /* @__PURE__ */ Re({
926
- __name: "FulfillmentForm",
927
- props: {
928
- purchaseOrder: {},
929
- confirm: { type: Function }
930
- },
931
- emits: ["update:show"],
932
- setup(b, { emit: t }) {
933
- const s = b, _ = $t({
934
- id: "",
935
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
936
- items: []
937
- }), i = z(), r = t;
938
- yt(() => {
939
- s.purchaseOrder && (_.items = s.purchaseOrder.items.map((a) => ({
940
- id: a.id,
941
- sku: a.sku,
942
- measurement: a.measurement,
943
- amount: a.quantity ?? { amount: 1, precision: 0 }
944
- })));
945
- });
946
- const d = re(() => _.items.length <= 10);
947
- return (a, o) => {
948
- const h = Z("FmTable"), S = Z("FmButton"), y = Z("FmForm");
949
- return v(), ue(y, {
950
- ref_key: "formRef",
951
- ref: i,
952
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
953
- onValidationFailed: console.log,
954
- onValidationSuccess: o[1] || (o[1] = () => s.confirm(_))
955
- }, {
956
- default: se(() => [
957
- o[2] || (o[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
958
- e("div", zt, [
959
- e("div", Gt, [
960
- F(h, {
961
- "column-defs": [
962
- {
963
- header: "Code",
964
- cell: (g) => {
965
- const p = s.purchaseOrder.items.find((l) => l.id === g.row.original.id || l.sku._id === g.row.original.sku._id);
966
- return C(
967
- w(Ye).FmTooltip,
968
- {
969
- content: p.code,
970
- placement: "top",
971
- variant: "plain",
972
- zIndex: 50
973
- },
974
- C(
975
- "span",
976
- {
977
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
978
- },
979
- p.code
980
- )
981
- );
982
- }
983
- },
984
- {
985
- header: "Name",
986
- cell: (g) => {
987
- const p = s.purchaseOrder.items.find((l) => l.id === g.row.original.id || l.sku._id === g.row.original.sku._id);
988
- return C(
989
- w(Ye).FmTooltip,
990
- {
991
- content: p.name,
992
- placement: "top",
993
- variant: "plain",
994
- zIndex: 50
995
- },
996
- C(
997
- "span",
998
- {
999
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1000
- },
1001
- p.name
1002
- )
1003
- );
1004
- }
1005
- },
1006
- {
1007
- header: "Amount",
1008
- cell: (g) => {
1009
- const p = g.row.original, l = s.purchaseOrder.items.find((u) => u.id === p.id || u.sku._id === p.sku._id), c = p.amount ?? {
1010
- amount: 1,
1011
- precision: 0
1012
- };
1013
- return C(Lt, {
1014
- style: {
1015
- flex: "1 1 0%"
1016
- },
1017
- modelValue: {
1018
- amount: c,
1019
- measurement: p.measurement ?? null
1020
- },
1021
- key: p.id ?? p.sku._id,
1022
- unit: p.sku.unit,
1023
- "onUpdate:modelValue": (u) => {
1024
- if (!u) return;
1025
- const O = _.items.find((q) => q.id === p.id || q.sku._id === p.sku._id);
1026
- O && (O.amount = u.amount);
1027
- },
1028
- disableUnit: !0,
1029
- rules: [
1030
- w(Et)(
1031
- +w(be)({ amount: 0, precision: 0 })
1032
- ),
1033
- w(Bt)(+w(be)(l.quantity))
1034
- ],
1035
- applyDefaultRules: !0
1036
- });
1037
- }
1038
- }
1039
- ],
1040
- "row-data": _.items,
1041
- "hide-footer": d.value
1042
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1043
- ])
1044
- ]),
1045
- e("div", Ht, [
1046
- F(S, {
1047
- class: "px-16",
1048
- label: "Confirm",
1049
- size: "md",
1050
- variant: "primary",
1051
- type: "submit"
1052
- }),
1053
- F(S, {
1054
- class: "px-16",
1055
- label: "Cancel",
1056
- size: "md",
1057
- variant: "secondary",
1058
- onClick: o[0] || (o[0] = () => r("update:show", !1))
1059
- })
1060
- ])
1061
- ]),
1062
- _: 1
1063
- }, 8, ["onValidationFailed"]);
1064
- };
1065
- }
1066
- }), We = {
1067
- submitRequest: {
1068
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1069
- color: "primary",
1070
- buttonVariant: le.Primary
1071
- },
1072
- confirmDraft: {
1073
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1074
- color: "primary",
1075
- buttonVariant: le.Primary
1076
- },
1077
- cancelDraft: {
1078
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1079
- color: "system-error-300",
1080
- buttonVariant: le.Destructive
1081
- },
1082
- approveDraft: {
1083
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1084
- color: "primary",
1085
- buttonVariant: le.Primary
1086
- },
1087
- rejectDraft: {
1088
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1089
- color: "system-error-300",
1090
- buttonVariant: le.Destructive
1091
- },
1092
- approveRequest: {
1093
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1094
- color: "primary",
1095
- buttonVariant: le.Primary
1096
- },
1097
- processRequest: {
1098
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1099
- color: "primary",
1100
- buttonVariant: le.Primary
1101
- },
1102
- receiveStock: {
1103
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1104
- color: "primary",
1105
- buttonVariant: le.Primary,
1106
- available: !1
1107
- },
1108
- completeReceive: {
1109
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1110
- color: "primary",
1111
- buttonVariant: le.Plain
1112
- },
1113
- rejectRequest: {
1114
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1115
- color: "system-error-300",
1116
- buttonVariant: le.Destructive
1117
- },
1118
- closeRequest: {
1119
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1120
- color: "system-error-300",
1121
- buttonVariant: le.Destructive,
1122
- available: !1
1123
- },
1124
- returnStock: {
1125
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1126
- color: "primary",
1127
- buttonVariant: le.Primary,
1128
- available: !1
1129
- }
1130
- };
1131
- function Yt() {
1132
- const b = Ve();
1133
- return {
1134
- ableToMarkReceived(t) {
1135
- if (!t || t.status !== W.enum.RECEIVING)
1136
- return !1;
1137
- const _ = ge().currentLocationDBName;
1138
- return `${t.supplier.internal}_${t.supplier._id}` !== _;
1139
- },
1140
- ableToMarkApproved(t) {
1141
- return !(!t || (t == null ? void 0 : t.status) !== W.enum.REQUESTING);
1142
- },
1143
- ableToCreateFulfillment(t, s) {
1144
- var r, d;
1145
- if (!b.acceptRequireFulfillment || !t || !s || t.status !== W.enum.PROCESSING || !s.processedAt)
1146
- return !1;
1147
- const _ = (r = s == null ? void 0 : s.from) == null ? void 0 : r.dbName, i = (d = s == null ? void 0 : s.to) == null ? void 0 : d.dbName;
1148
- return !(_.startsWith("restaurant_") && i.startsWith("restaurant_"));
1149
- }
1150
- };
1151
- }
1152
- const Qt = { class: "flex flex-row-reverse" }, Xt = /* @__PURE__ */ Re({
1153
- __name: "NetSuiteSync",
1154
- props: {
1155
- poRequest: {},
1156
- purchaseOrder: {},
1157
- isTransferBetweenOutlets: { type: Boolean },
1158
- scope: {}
1159
- },
1160
- setup(b) {
1161
- const t = b, s = Ue(), _ = Ke(), i = et(), r = z(!1);
1162
- re(() => {
1163
- var S, y, g, p;
1164
- let a = !0;
1165
- s.isEnabled || (a = !1);
1166
- const o = t.purchaseOrder, h = t.poRequest;
1167
- return o && ((S = o == null ? void 0 : o.supplier) != null && S.internal ? (!h && o.status == W.enum.DRAFT && (a = !1), h && !((y = h == null ? void 0 : h.netSuite) != null && y.id) && (a = !1), t.isTransferBetweenOutlets && (a = !1)) : ((o == null ? void 0 : o.status) !== W.enum.REQUESTING && o.supplier.internal && (a = !1), !h && !((g = o == null ? void 0 : o.netSuite) != null && g.id) && (a = !1), !h && ((p = o == null ? void 0 : o.netSuite) != null && p.id) && (o == null ? void 0 : o.status) == W.enum.REQUESTING && (a = !1))), a;
1168
- });
1169
- async function d() {
1170
- r.value || i.open({
1171
- title: "Sync with NetSuite",
1172
- contentComponent: C("div", [
1173
- C("p", "Are you sure you want to sync now?"),
1174
- C("br"),
1175
- C(
1176
- "p",
1177
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1178
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1179
- )
1180
- ]),
1181
- primaryActions: {
1182
- text: "Sync",
1183
- close: !0,
1184
- variant: "destructive"
1185
- },
1186
- secondaryActions: { text: "Not now", close: !0 }
1187
- }).onPrimary(async () => {
1188
- var a, o, h;
1189
- try {
1190
- r.value = !0;
1191
- const S = ((a = t.purchaseOrder) == null ? void 0 : a._id) || ((o = t.poRequest) == null ? void 0 : o.purchaseOrderId) || "", y = (h = t.poRequest) == null ? void 0 : h.to.dbName;
1192
- await s.syncPurchaseOrder(
1193
- S,
1194
- t.scope === "approval" ? y : void 0
1195
- ), _.open({
1196
- title: "Sync with NetSuite",
1197
- message: "Requested to sync with NetSuite. Please wait a moment.",
1198
- type: "success"
1199
- }), await new Promise((g) => setTimeout(g, 5e3)), r.value = !1;
1200
- } catch {
1201
- _.open({
1202
- title: "Error",
1203
- message: "Failed to sync with NetSuite",
1204
- type: "error"
1205
- }), r.value = !1;
1206
- }
1207
- });
1208
- }
1209
- return (a, o) => {
1210
- const h = Z("FmButton");
1211
- return v(), x("div", Qt, [
1212
- F(h, {
1213
- "prepend-icon": "sync",
1214
- variant: "secondary",
1215
- label: "Sync",
1216
- loading: r.value,
1217
- onClick: d,
1218
- "text-color": "primary",
1219
- "bg-color": "transparent",
1220
- "border-color": "primary"
1221
- }, null, 8, ["loading"])
1222
- ]);
1223
- };
1224
- }
1225
- }), Zt = {
1226
- key: 0,
1227
- class: "flex flex-col gap-8"
1228
- }, Jt = { class: "flex flex-col gap-4" }, er = { class: "fm-typo-en-body-lg-600" }, tr = {
1229
- key: 0,
1230
- class: "flex flex-col gap-4"
1231
- }, rr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, sr = { class: "fm-typo-en-body-lg-600" }, or = { key: 0 }, nr = { key: 1 }, ar = {
1232
- key: 1,
1233
- class: "flex flex-col gap-4"
1234
- }, ir = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lr = { class: "fm-typo-en-body-lg-600" }, cr = { key: 0 }, ur = { key: 1 }, dr = {
1235
- key: 2,
1236
- class: "flex flex-col gap-4"
1237
- }, mr = { class: "fm-typo-en-body-lg-600" }, fr = {
1238
- key: 3,
1239
- class: "flex flex-col gap-4"
1240
- }, pr = { class: "fm-typo-en-body-lg-600" }, yr = /* @__PURE__ */ Re({
1241
- __name: "NetSuiteInfo",
1242
- props: {
1243
- transferType: {},
1244
- transferToDbName: {},
1245
- poRequest: {},
1246
- purchaseOrder: {},
1247
- isTransferBetweenOutlets: { type: Boolean },
1248
- scope: {}
1249
- },
1250
- setup(b) {
1251
- const t = b, s = Ue(), _ = je(), i = z(t.poRequest);
1252
- yt(async () => {
1253
- var o;
1254
- if (!t.poRequest && ((o = t.purchaseOrder) != null && o._id)) {
1255
- const h = await _.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1256
- i.value = h;
1257
- }
1258
- });
1259
- const r = re(
1260
- () => {
1261
- var o, h, S, y, g, p;
1262
- return s.getSubsidiaryFullName(
1263
- ((S = (h = (o = t.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : h.subsidiary) == null ? void 0 : S.id) || ((p = (g = (y = t.poRequest) == null ? void 0 : y.netSuite) == null ? void 0 : g.subsidiary) == null ? void 0 : p.id)
1264
- ).fullName;
1265
- }
1266
- ), d = re(() => {
1267
- var o, h, S, y, g, p, l, c, u, O, q, T;
1268
- return (S = (h = (o = t.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : h.additionalInfo) != null && S.transactionnumber ? (p = (g = (y = t.purchaseOrder) == null ? void 0 : y.netSuite) == null ? void 0 : g.additionalInfo) == null ? void 0 : p.transactionnumber : (u = (c = (l = i.value) == null ? void 0 : l.netSuite) == null ? void 0 : c.additionalInfo) != null && u.transactionnumber ? (T = (q = (O = i.value) == null ? void 0 : O.netSuite) == null ? void 0 : q.additionalInfo) == null ? void 0 : T.transactionnumber : null;
1269
- }), a = re(() => {
1270
- var o, h, S, y, g, p;
1271
- return (h = (o = t.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) != null && h.length && ((y = (S = t.purchaseOrder) == null ? void 0 : S.deliveryFullfillment) == null ? void 0 : y.length) > 0 ? (p = (g = t.purchaseOrder) == null ? void 0 : g.deliveryFullfillment) == null ? void 0 : p.map((l) => {
1272
- var c;
1273
- return (c = l.netSuite) == null ? void 0 : c.refNo;
1274
- }).join(", ") : "N/A";
1275
- });
1276
- return (o, h) => {
1277
- var S, y, g, p, l, c, u, O, q, T, P, $, U, pe, de, xe;
1278
- return w(s).isEnabled ? (v(), x("div", Zt, [
1279
- e("div", Jt, [
1280
- h[0] || (h[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1281
- e("div", er, R(r.value || "N/A"), 1)
1282
- ]),
1283
- !o.isTransferBetweenOutlets && o.scope === w(Ze).RECEIVE_REQUEST ? (v(), x("div", tr, [
1284
- e("div", rr, " NetSuite " + R((y = (S = o.purchaseOrder) == null ? void 0 : S.netSuite) != null && y.recordType ? w(ft)((p = (g = o.purchaseOrder) == null ? void 0 : g.netSuite) == null ? void 0 : p.recordType) : o.transferType === w(we).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1285
- e("div", sr, [
1286
- (c = (l = o.purchaseOrder) == null ? void 0 : l.netSuite) != null && c.id ? (v(), x("span", or, R((O = (u = o.purchaseOrder) == null ? void 0 : u.netSuite) == null ? void 0 : O.refNo) + " (" + R((T = (q = o.purchaseOrder) == null ? void 0 : q.netSuite) == null ? void 0 : T.id) + ") ", 1)) : (v(), x("span", nr, "N/A"))
1287
- ])
1288
- ])) : H("", !0),
1289
- !o.isTransferBetweenOutlets && i.value || o.scope === w(Ze).APPROVAL ? (v(), x("div", ar, [
1290
- e("div", ir, " (Request) NetSuite " + R(o.transferType === w(we).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1291
- e("div", lr, [
1292
- ($ = (P = i.value) == null ? void 0 : P.netSuite) != null && $.id ? (v(), x("span", cr, R((pe = (U = i.value) == null ? void 0 : U.netSuite) == null ? void 0 : pe.refNo) + " (" + R((xe = (de = i.value) == null ? void 0 : de.netSuite) == null ? void 0 : xe.id) + ") ", 1)) : (v(), x("span", ur, "N/A"))
1293
- ])
1294
- ])) : H("", !0),
1295
- d.value ? (v(), x("div", dr, [
1296
- h[1] || (h[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1297
- e("div", mr, R(d.value), 1)
1298
- ])) : H("", !0),
1299
- w(s).isEnabled && o.transferType === w(we).TRANSFER && !o.isTransferBetweenOutlets ? (v(), x("div", fr, [
1300
- h[2] || (h[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1301
- e("div", pr, R(a.value), 1)
1302
- ])) : H("", !0)
1303
- ])) : H("", !0);
1304
- };
1305
- }
1306
- }), vr = { class: "flex flex-row-reverse" }, hr = /* @__PURE__ */ Re({
1307
- __name: "NetSuiteLog",
1308
- props: {
1309
- netsuiteId: {},
1310
- purchaseOrderId: {}
1311
- },
1312
- setup(b) {
1313
- const t = Ke(), s = pt();
1314
- async function _(i, r) {
1315
- const d = [];
1316
- if (i && d.push(`body.message:*${i}*`), r) {
1317
- const S = r.replace(/:/g, "\\:");
1318
- d.push(`${S}`);
1319
- }
1320
- if (d.length === 0) {
1321
- t.open({
1322
- message: "Cannot open logs without valid filters.",
1323
- type: "error"
1324
- });
1325
- return;
1326
- }
1327
- const o = `attributes.pod:netsuite* AND (${d.join(" OR ")})`, { url: h } = await s.getSyncLogs(o);
1328
- t.open(
1329
- {
1330
- message: "Opening NetSuite logs...",
1331
- type: "info"
1332
- },
1333
- 800
1334
- ), await new Promise((S) => setTimeout(S, 800)), window.open(h, "_blank");
1335
- }
1336
- return (i, r) => {
1337
- const d = Z("FmButton");
1338
- return v(), x("div", vr, [
1339
- F(d, {
1340
- "prepend-icon": "history",
1341
- variant: "secondary",
1342
- label: "Logs",
1343
- onClick: r[0] || (r[0] = (a) => _(i.netsuiteId, i.purchaseOrderId)),
1344
- "text-color": "primary",
1345
- "bg-color": "transparent",
1346
- "border-color": "primary"
1347
- })
1348
- ]);
1349
- };
1350
- }
1351
- }), br = { class: "flex flex-row-reverse" }, gr = { key: 0 }, _r = { key: 1 }, Sr = { class: "mb-6" }, wr = { class: "fm-typo-en-body-md-400" }, Rr = { key: 0 }, xr = { key: 1 }, Or = { key: 0 }, Nr = {
1352
- key: 1,
1353
- class: "border-t pt-6"
1354
- }, $r = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, kr = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Cr = { class: "w-full" }, Ar = {
1355
- class: "p-3 fm-typo-en-body-sm-600",
1356
- style: { "min-width": "130px" }
1357
- }, Dr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Tr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Pr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ir = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Lr = { class: "p-3 fm-typo-en-body-sm-600" }, Er = { key: 2 }, Br = { key: 1 }, Vr = /* @__PURE__ */ Re({
1358
- __name: "NetSuiteLatestInfo",
1359
- props: {
1360
- netsuiteId: {},
1361
- purchaseOrderId: {}
1362
- },
1363
- setup(b) {
1364
- const t = b, s = pt(), _ = z(!1), i = ge(), r = z(!0), d = z(!1), a = z(!1), o = z(!1), h = z(null), S = z([]);
1365
- async function y() {
1366
- if (!h.value) {
1367
- _.value = !0;
1368
- try {
1369
- r.value = !0;
1370
- const c = await s.getMoreInfo(
1371
- i.currentLocation.dbName,
1372
- t.purchaseOrderId
1373
- );
1374
- h.value = c, d.value = !1;
1375
- } catch {
1376
- d.value = !0;
1377
- } finally {
1378
- r.value = !1;
1379
- }
1380
- await g();
1381
- }
1382
- }
1383
- async function g() {
1384
- if (!(S.value.length > 0))
1385
- try {
1386
- a.value = !0;
1387
- const c = await s.getChangeLogs(t.netsuiteId);
1388
- S.value = c, o.value = !1;
1389
- } catch {
1390
- o.value = !0;
1391
- } finally {
1392
- a.value = !1;
1393
- }
1394
- }
1395
- function p(c) {
1396
- switch (c) {
1397
- case Ae.Create:
1398
- return "text-green-600 bg-green-100";
1399
- case Ae.Set:
1400
- return "text-blue-600 bg-blue-100";
1401
- case Ae.Change:
1402
- return "text-yellow-600 bg-yellow-100";
1403
- case Ae.Unset:
1404
- return "text-red-600 bg-red-100";
1405
- default:
1406
- return "text-gray-600 bg-gray-100";
1407
- }
1408
- }
1409
- function l(c) {
1410
- return new Date(c).toLocaleDateString("en-US", {
1411
- year: "numeric",
1412
- month: "short",
1413
- day: "numeric",
1414
- hour: "2-digit",
1415
- minute: "2-digit"
1416
- });
1417
- }
1418
- return (c, u) => {
1419
- const O = Z("FmButton"), q = Z("FmLabel"), T = Z("FmIcon"), P = Z("FmDialog");
1420
- return v(), x("div", br, [
1421
- F(P, {
1422
- modelValue: _.value,
1423
- "onUpdate:modelValue": u[2] || (u[2] = ($) => _.value = $),
1424
- overlay: !0,
1425
- "max-width": 800
1426
- }, {
1427
- "dialog-button": se(() => [
1428
- F(O, {
1429
- "prepend-icon": "info",
1430
- variant: "secondary",
1431
- label: "Latest Info",
1432
- onClick: u[0] || (u[0] = ($) => y()),
1433
- "text-color": "primary",
1434
- "bg-color": "transparent",
1435
- "border-color": "primary"
1436
- })
1437
- ]),
1438
- "dialog-header": se(() => u[3] || (u[3] = [
1439
- e("div", null, "NetSuite latest info", -1)
1440
- ])),
1441
- default: se(() => [
1442
- r.value ? (v(), x("div", gr, "Loading...")) : (v(), x("div", _r, [
1443
- d.value ? (v(), x("p", Br, "Something went wrong.")) : (v(), x(ae, { key: 0 }, [
1444
- e("div", Sr, [
1445
- u[4] || (u[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1446
- (v(!0), x(ae, null, he(h.value, ($, U) => (v(), x("div", {
1447
- key: U,
1448
- class: "mb-2"
1449
- }, [
1450
- e("div", null, [
1451
- F(q, {
1452
- label: w(Je)(U)
1453
- }, null, 8, ["label"]),
1454
- e("div", wr, [
1455
- Array.isArray($) ? (v(), x("span", Rr, R($.length > 0 ? $.join(", ") : "N/A"), 1)) : (v(), x("span", xr, R($), 1))
1456
- ])
1457
- ])
1458
- ]))), 128))
1459
- ]),
1460
- a.value ? (v(), x("div", Or, "Change Log Loading...")) : H("", !0),
1461
- !a.value && S.value.length > 0 ? (v(), x("div", Nr, [
1462
- e("h3", $r, [
1463
- F(T, {
1464
- name: "error",
1465
- color: "#ff9500",
1466
- size: "sm"
1467
- }),
1468
- u[5] || (u[5] = Ne(" Change Logs "))
1469
- ]),
1470
- e("div", kr, [
1471
- e("table", Cr, [
1472
- u[6] || (u[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1473
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1474
- e("th", {
1475
- class: "text-left p-3 fm-typo-en-body-md-600",
1476
- style: { "min-width": "130px" }
1477
- }, " Date "),
1478
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1479
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1480
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1481
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1482
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1483
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1484
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1485
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1486
- ])
1487
- ], -1)),
1488
- e("tbody", null, [
1489
- (v(!0), x(ae, null, he(S.value, ($, U) => (v(), x("tr", {
1490
- key: U,
1491
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1492
- }, [
1493
- e("td", Ar, R(l($._dateiso8601)), 1),
1494
- e("td", Dr, R($._rolename), 1),
1495
- e("td", qr, R($._employeename), 1),
1496
- e("td", Tr, R($._contextname), 1),
1497
- e("td", {
1498
- class: Te(`p-3 fm-typo-en-body-sm-600 ${p(Number($.type) - 1)}`)
1499
- }, R(w(Ae)[Number($.type) - 1]), 3),
1500
- e("td", Pr, R($.lineid || ""), 1),
1501
- e("td", Ir, R($._fieldname), 1),
1502
- e("td", Fr, R($.oldvalue || ""), 1),
1503
- e("td", Lr, R($.newvalue || ""), 1)
1504
- ]))), 128))
1505
- ])
1506
- ])
1507
- ])
1508
- ])) : (v(), x("div", Er, u[7] || (u[7] = [
1509
- e("p", null, "No change logs available.", -1)
1510
- ])))
1511
- ], 64))
1512
- ]))
1513
- ]),
1514
- "dialog-footer": se(() => [
1515
- F(O, {
1516
- class: "ml-auto sm:w-full xs:w-full",
1517
- label: "Close",
1518
- size: "md",
1519
- variant: "primary",
1520
- onClick: u[1] || (u[1] = ($) => _.value = !1)
1521
- })
1522
- ]),
1523
- _: 1
1524
- }, 8, ["modelValue"])
1525
- ]);
1526
- };
1527
- }
1528
- }), Ur = {
1529
- key: 0,
1530
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1531
- }, Mr = { class: "flex gap-8 items-center" }, Kr = { class: "ml-auto" }, jr = { class: "flex gap-3" }, zr = /* @__PURE__ */ Re({
1532
- __name: "NetSuitePanel",
1533
- props: {
1534
- poRequest: {},
1535
- purchaseOrder: {},
1536
- transferType: {},
1537
- transferToDbName: {},
1538
- scope: {}
1539
- },
1540
- setup(b) {
1541
- const t = b, s = Ut();
1542
- Me();
1543
- const _ = re(() => {
1544
- var a, o, h, S, y, g, p;
1545
- const i = ((a = t.transferToDbName) == null ? void 0 : a.startsWith("restaurant")) && ((h = (o = t.purchaseOrder) == null ? void 0 : o.supplier) == null ? void 0 : h.internal) === "restaurant", r = t.transferType === we.PURCHASE, d = t.transferType === we.TRANSFER;
1546
- return r || d && !i || ((y = (S = t.purchaseOrder) == null ? void 0 : S.netSuite) == null ? void 0 : y.id) || ((p = (g = t.poRequest) == null ? void 0 : g.netSuite) == null ? void 0 : p.id);
1547
- });
1548
- return (i, r) => {
1549
- var a, o;
1550
- const d = Z("FmMenuDivider");
1551
- return w(s).isNetSuiteEnabled && _.value ? (v(), x("div", Ur, [
1552
- e("div", Mr, [
1553
- r[0] || (r[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1554
- e("div", Kr, [
1555
- e("div", jr, [
1556
- (o = (a = t.purchaseOrder) == null ? void 0 : a.netSuite) != null && o.id ? (v(), ue($e, { key: 0 }, {
1557
- default: se(() => {
1558
- var h, S, y;
1559
- return [
1560
- F(Vr, {
1561
- "netsuite-id": (S = (h = i.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : S.id,
1562
- "purchase-order-id": (y = i.purchaseOrder) == null ? void 0 : y._id
1563
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1564
- ];
1565
- }),
1566
- _: 1
1567
- })) : H("", !0),
1568
- F($e, null, {
1569
- default: se(() => {
1570
- var h, S, y;
1571
- return [
1572
- F(hr, {
1573
- "netsuite-id": (S = (h = i.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : S.id,
1574
- "purchase-order-id": (y = i.purchaseOrder) == null ? void 0 : y._id
1575
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1576
- ];
1577
- }),
1578
- _: 1
1579
- }),
1580
- F(Xt, {
1581
- "po-request": i.poRequest,
1582
- "purchase-order": i.purchaseOrder,
1583
- "is-transfer-between-outlets": !_.value,
1584
- scope: i.scope
1585
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1586
- ])
1587
- ])
1588
- ]),
1589
- F(d),
1590
- F(yr, {
1591
- "po-request": i.poRequest,
1592
- "purchase-order": i.purchaseOrder,
1593
- "transfer-type": i.transferType,
1594
- "transfer-to-db-name": i.transferToDbName,
1595
- "is-transfer-between-outlets": !_.value,
1596
- scope: i.scope
1597
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1598
- ])) : H("", !0);
1599
- };
1600
- }
1601
- }), Gr = { class: "flex flex-col gap-16 w-full h-full" }, Hr = { class: "flex justify-between" }, Wr = { class: "fm-typo-en-body-lg-600" }, Yr = { class: "flex gap-5" }, Qr = { class: "flex flex-col gap-8" }, Xr = { class: "flex flex-col gap-4" }, Zr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Jr = { class: "flex gap-1" }, es = { class: "fm-typo-en-body-lg-600" }, ts = {
1602
- key: 0,
1603
- class: "flex flex-col gap-4"
1604
- }, rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ss = { class: "fm-typo-en-body-lg-600" }, os = { class: "flex flex-col gap-4" }, ns = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, as = { class: "fm-typo-en-body-lg-600" }, is = {
1605
- key: 1,
1606
- class: "flex flex-col gap-4"
1607
- }, ls = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, cs = { class: "fm-typo-en-body-lg-600" }, us = {
1608
- key: 2,
1609
- class: "flex flex-col gap-4"
1610
- }, ds = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ms = { class: "fm-typo-en-body-lg-600" }, fs = {
1611
- key: 3,
1612
- class: "flex flex-col gap-4"
1613
- }, ps = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ys = { class: "fm-typo-en-body-lg-600" }, vs = {
1614
- key: 4,
1615
- class: "flex flex-col gap-4"
1616
- }, hs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bs = { class: "fm-typo-en-body-lg-600" }, gs = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, _s = { class: "flex flex-col gap-8" }, Ss = { class: "flex gap-8 items-center" }, ws = { class: "flex-1 fm-typo-en-body-lg-600" }, Rs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, xs = { class: "flex w-full gap-4" }, Os = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Ns = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, $s = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ks = ["innerHTML"], Cs = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, As = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Ds = {
1617
- key: 0,
1618
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1619
- }, qs = { class: "py-8" }, Ts = { class: "flex justify-end gap-4 items-center" }, Ps = { class: "fm-typo-en-body-lg-600" }, Is = {
1620
- key: 1,
1621
- class: "flex-1 xs:w-screen xs:max-w-full"
1622
- }, Fs = {
1623
- key: 0,
1624
- class: "flex flex-col items-center gap-8 h-full"
1625
- }, Ls = ["src"], Es = { class: "fm-typo-en-body-lg-600" }, Bs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Vs = {
1626
- key: 1,
1627
- class: "px-4 flex flex-col"
1628
- }, Us = { class: "flex gap-12 content-stretch" }, Ms = {
1629
- class: "flex flex-col w-24",
1630
- name: "circles"
1631
- }, Ks = { class: "flex-1 flex flex-col items-center" }, js = { class: "flex-1 flex flex-col items-center" }, zs = {
1632
- class: "py-12 flex flex-col gap-4",
1633
- name: "received-at header"
1634
- }, Gs = { class: "fm-typo-en-body-lg-400" }, Hs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ws = { class: "flex gap-12 content-stretch" }, Ys = {
1635
- class: "flex flex-col w-24",
1636
- name: "circles"
1637
- }, Qs = { class: "flex-1 flex flex-col items-center" }, Xs = {
1638
- class: "py-12 flex flex-col gap-4 flex-1",
1639
- name: "delivery details"
1640
- }, Zs = { class: "flex flex-col gap-8" }, Js = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, eo = { class: "flex flex-col gap-4" }, to = { class: "flex gap-8 xs:flex-col" }, vo = /* @__PURE__ */ Re({
1641
- __name: "TransferDetails",
1642
- props: {
1643
- poRequest: {},
1644
- purchaseOrder: {},
1645
- transferTo: {},
1646
- transferToDbName: {},
1647
- show: { type: Boolean },
1648
- canResubmit: { type: Boolean },
1649
- canApprove: { type: Boolean },
1650
- scope: {},
1651
- receivedMap: {}
1652
- },
1653
- emits: ["update:show", "submitted"],
1654
- setup(b, { emit: t }) {
1655
- const s = b, _ = t, i = et(), r = Ke(), d = Ve(), a = ge(), o = Me(), h = re(
1656
- () => {
1657
- var n, m;
1658
- return {
1659
- id: ((n = o.sessionUser.value) == null ? void 0 : n.id) ?? "",
1660
- name: ((m = o.sessionUser.value) == null ? void 0 : m.displayName) ?? ""
1661
- };
1662
- }
1663
- ), S = Yt(), { t: y } = vt(), g = re(
1664
- () => {
1665
- var n, m, A, N;
1666
- return ((m = (n = s.purchaseOrder) == null ? void 0 : n.supplier) == null ? void 0 : m.internal) === "restaurant" || ((N = (A = s.purchaseOrder) == null ? void 0 : A.supplier) == null ? void 0 : N.internal) === "warehouse" ? we.TRANSFER : we.PURCHASE;
1667
- }
1668
- ), p = z(!1), l = z(""), c = z(!0), u = je(), O = Vt(u.getWorkflowConfig), q = bt(), T = re(() => {
1669
- if (!s.purchaseOrder)
1670
- return [];
1671
- const n = O.result.value;
1672
- if (n.state === lt.loading)
1673
- return [];
1674
- const m = {
1675
- user: h.value,
1676
- executedAt: a.locations.computeFirst(
1677
- (N) => {
1678
- var L;
1679
- return N.dbName === ((L = a._currentLocation) == null ? void 0 : L.dbName) ? N : null;
1680
- }
1681
- ),
1682
- purchaseOrderRequest: s.poRequest,
1683
- purchaseOrder: s.purchaseOrder
1684
- };
1685
- let A = [];
1686
- try {
1687
- n.state === lt.error ? (console.error("Error fetching workflow config:", n.error), A = ze.getAvailableActions({
1688
- ...m,
1689
- orderConfig: ze.getDefaultConfig()
1690
- }).actions.filter(
1691
- (N) => (
1692
- // TODO: create receiveStock & processRequest dialog
1693
- // to create their payload
1694
- N !== k.enum.receiveStock && N !== k.enum.processRequest && N !== k.enum.closeRequest
1695
- )
1696
- )) : A = ze.getAvailableActions({
1697
- ...m,
1698
- orderConfig: n.data
1699
- }).actions.filter(
1700
- (N) => N !== k.enum.receiveStock && N !== k.enum.processRequest && N !== k.enum.closeRequest
1701
- );
1702
- } catch (N) {
1703
- console.error("Error getting available actions:", N);
1704
- }
1705
- return s.scope === "approval" && (A = A.filter((N) => N !== k.enum.completeReceive)), A;
1706
- }), P = qt(s, "show"), $ = re(() => [
1707
- {
1708
- label: y("inventory.transfer.receiveRequest.details.overview"),
1709
- value: "overview"
1710
- },
1711
- {
1712
- label: y("inventory.transfer.receiveRequest.details.deliveryHistory"),
1713
- value: "deliveryHistory"
1714
- }
1715
- ]), U = z($.value[0]);
1716
- kt(
1717
- () => s.show,
1718
- (n) => {
1719
- n && (U.value = $.value[0]);
1720
- }
1721
- );
1722
- async function pe(n, m, A, N, L) {
1723
- return new Promise((E, M) => {
1724
- i.open({
1725
- closeButton: !1,
1726
- title: N.title,
1727
- message: N.message,
1728
- primaryActions: N.primaryActions,
1729
- secondaryActions: { text: "No", close: !1 }
1730
- }).onPrimary(async () => {
1731
- var B, Q, ee, K;
1732
- const f = [];
1733
- A === k.enum.approveRequest ? (f.push({
1734
- action: "approveRequest",
1735
- payload: null
1736
- }), m.fulfillment && f.push({
1737
- action: "processRequest",
1738
- payload: {
1739
- fulfillmentId: "",
1740
- deliveryOrderNumber: "",
1741
- deliveryRemark: null,
1742
- items: m.fulfillment.items,
1743
- createdBy: h.value
1744
- }
1745
- })) : A === k.enum.processRequest ? m.fulfillment && f.push({
1746
- action: "processRequest",
1747
- payload: {
1748
- fulfillmentId: "",
1749
- deliveryOrderNumber: "",
1750
- deliveryRemark: null,
1751
- items: m.fulfillment.items,
1752
- createdBy: h.value
1753
- }
1754
- }) : A === k.enum.rejectRequest ? f.push({
1755
- action: "rejectRequest",
1756
- payload: null
1757
- }) : A === k.enum.closeRequest && f.push({
1758
- action: "closeRequest",
1759
- payload: null
1760
- });
1761
- try {
1762
- await q({
1763
- operate: {
1764
- operation: A,
1765
- doc: n,
1766
- options: m
1767
- },
1768
- operateV2: {
1769
- _id: ((B = s.purchaseOrder) == null ? void 0 : B._id) ?? "",
1770
- _rev: ((Q = s.purchaseOrder) == null ? void 0 : Q._rev) ?? "",
1771
- action: A,
1772
- payloads: f
1773
- // add payload if action is receiveStock or processRequest
1774
- },
1775
- transferTo: (K = (ee = s.poRequest) == null ? void 0 : ee.to) == null ? void 0 : K.dbName
1776
- }).delayed(1e3), E("submitted");
1777
- } catch (ie) {
1778
- M(ie);
1779
- }
1780
- }).onSecondary(() => {
1781
- E("cancelled");
1782
- for (let f = 0; f < L + 2; f++)
1783
- i.close();
1784
- }).onClose(() => {
1785
- });
1786
- });
1787
- }
1788
- async function de(n) {
1789
- var L, E, M, f;
1790
- if (n === k.enum.receiveStock)
1791
- return;
1792
- const m = ht[n];
1793
- if (!m) {
1794
- r.open({
1795
- title: "Something went wrong",
1796
- message: `Cannot process order: ${Je(n)}`,
1797
- type: "error"
1798
- });
1799
- return;
1800
- }
1801
- const { successMessage: A, ...N } = m;
1802
- if (s.purchaseOrder) {
1803
- l.value = `${n}`, p.value = !0, c.value = !1;
1804
- const B = {};
1805
- let Q = 0;
1806
- if ((n === k.enum.confirmDraft || // auto receive for warehouse to warehouse
1807
- n === k.enum.completeReceive) && d.autoReceiveWarehouse)
1808
- B.autoReceive = !0;
1809
- else if ((n === k.enum.approveRequest || n === k.enum.processRequest) && d.acceptRequireFulfillment) {
1810
- const ee = (E = (L = s.poRequest) == null ? void 0 : L.from) == null ? void 0 : E.dbName, K = (f = (M = s.poRequest) == null ? void 0 : M.to) == null ? void 0 : f.dbName;
1811
- if (ee && K && (ee.startsWith("warehouse_") || K.startsWith("warehouse_"))) {
1812
- const ie = await new Promise((Y, ve) => {
1813
- i.open({
1814
- closeButton: !1,
1815
- title: "Confirm transfer amount",
1816
- dialogComponent: Wt,
1817
- dialogComponentProps: {
1818
- purchaseOrder: s.purchaseOrder,
1819
- confirm: Y,
1820
- "onUpdate:show": (_e) => {
1821
- _e || (l.value = "", p.value = !1, c.value = !0, Q++, i.close()), ve("cancelled");
1822
- }
1823
- }
1824
- });
1825
- });
1826
- B.fulfillment = ie;
1827
- }
1828
- }
1829
- try {
1830
- await pe(
1831
- s.purchaseOrder,
1832
- B,
1833
- n,
1834
- m,
1835
- Q
1836
- ) === "submitted" && (r.open({
1837
- title: "Success",
1838
- message: A,
1839
- type: "success"
1840
- }), _("update:show", !1), _("submitted"));
1841
- } catch (ee) {
1842
- r.open({
1843
- title: "Something went wrong",
1844
- message: "Please try again.",
1845
- type: "error"
1846
- }), console.error("Error when submitting PO operation", n, s.purchaseOrder, ee);
1847
- } finally {
1848
- l.value = "", p.value = !1, c.value = !0;
1849
- }
1850
- }
1851
- }
1852
- const xe = re(() => {
1853
- var n, m;
1854
- return ((n = s.purchaseOrder) == null ? void 0 : n.status) === W.enum.RECEIVING || ((m = s.purchaseOrder) == null ? void 0 : m.status) === W.enum.COMPLETE;
1855
- }), Pe = re(() => {
1856
- const n = s.purchaseOrder;
1857
- if (!n) return { status: "", statusClass: "" };
1858
- const m = Ee(n), { partial: A, over: N } = Qe(m), L = Xe(n.status, A, N);
1859
- let E = y(`inventory.transfer.status.${L}`), M = `${n.status}`.toLocaleLowerCase("en-us");
1860
- return L === W.enum.CLOSE && (E = `${y(`inventory.transfer.status.${W.enum.COMPLETE}`)}`), L === "PARTIAL_RECEIVED" && M === W.enum.PROCESSING.toLocaleLowerCase("en-us") && (M = W.enum.RECEIVING.toLocaleLowerCase("en-us")), {
1861
- status: E,
1862
- statusClass: `fm-status-badge fm-status-badge-${M}`
1863
- };
1864
- }), ye = re(() => {
1865
- var E, M;
1866
- const n = ((E = s.purchaseOrder) == null ? void 0 : E.deliveryOrder) ?? [], m = ((M = s.purchaseOrder) == null ? void 0 : M.deliveryFullfillment) ?? [], A = [
1867
- ...n.map((f) => ({
1868
- createdAt: f.createdAt,
1869
- type: "grn",
1870
- doc: f
1871
- })),
1872
- ...m.map((f) => ({
1873
- createdAt: f.createdAt,
1874
- type: "fulfillment",
1875
- doc: f
1876
- }))
1877
- ];
1878
- A.reverse().sort((f, B) => f.createdAt.localeCompare(B.createdAt));
1879
- function N(f) {
1880
- var ee, K, ie, Y, ve, _e, ke, Ce, j;
1881
- const B = m.findIndex((V) => V.id === f.fullfillmentId), Q = [
1882
- (K = (ee = m[B]) == null ? void 0 : ee.netSuite) != null && K.refNo ? {
1883
- label: "Fulfillment's ref no. (Netsuite)",
1884
- values: [(Y = (ie = m[B]) == null ? void 0 : ie.netSuite) == null ? void 0 : Y.refNo]
1885
- } : null,
1886
- (ve = f == null ? void 0 : f.netSuite) != null && ve.refNo ? {
1887
- label: "Netsuite ref no.",
1888
- values: [(_e = f == null ? void 0 : f.netSuite) == null ? void 0 : _e.refNo]
1889
- } : null,
1890
- (ke = f == null ? void 0 : f.netSuite) != null && ke.recordType ? {
1891
- label: "Netsuite Type",
1892
- values: [ft((Ce = f == null ? void 0 : f.netSuite) == null ? void 0 : Ce.recordType)]
1893
- } : null
1894
- ];
1895
- return {
1896
- header: "Received",
1897
- date: Ge(new Date(f.createdAt)),
1898
- info: [
1899
- {
1900
- label: "Adjustment date",
1901
- values: [
1902
- f.adjustment ? Ge(new Date(Nt(f.adjustment))) : "-"
1903
- ]
1904
- },
1905
- {
1906
- label: "Received by",
1907
- values: [(j = f.createdBy) == null ? void 0 : j.name]
1908
- },
1909
- {
1910
- label: "Received items",
1911
- values: f.received.map((V) => {
1912
- var X;
1913
- return C("div", [
1914
- C(
1915
- "div",
1916
- {
1917
- class: "flex gap-4"
1918
- },
1919
- [
1920
- C(
1921
- "div",
1922
- {
1923
- class: "flex flex-col"
1924
- },
1925
- [
1926
- C(
1927
- "span",
1928
- {
1929
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1930
- },
1931
- `${V.sku.name}`
1932
- ),
1933
- C(
1934
- "span",
1935
- {
1936
- class: "fm-typo-en-body-md-400"
1937
- },
1938
- `${V.sku.code} `
1939
- )
1940
- ]
1941
- ),
1942
- C(
1943
- "div",
1944
- {
1945
- class: "ml-auto flex flex-col"
1946
- },
1947
- [
1948
- C(
1949
- "div",
1950
- {
1951
- class: "ml-auto flex gap-1"
1952
- },
1953
- [
1954
- C(
1955
- "span",
1956
- {
1957
- class: "fm-typo-en-body-lg-600 self-end"
1958
- },
1959
- be(V.amount, !1)
1960
- ),
1961
- C(
1962
- "span",
1963
- {
1964
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1965
- },
1966
- ((X = V.measurement) == null ? void 0 : X.abbrev) ?? V.sku.unit.abbrev
1967
- )
1968
- ]
1969
- ),
1970
- C(
1971
- "div",
1972
- {
1973
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1974
- },
1975
- `${V.cost ? `(${Fe(V.cost)})` : ""}`
1976
- )
1977
- ]
1978
- )
1979
- ]
1980
- )
1981
- ]);
1982
- })
1983
- },
1984
- f.deliveryOrderNumber ? {
1985
- label: "Delivery order no.",
1986
- values: [f.deliveryOrderNumber]
1987
- } : null,
1988
- f.remark ? {
1989
- label: "Remark",
1990
- values: [f.remark]
1991
- } : null,
1992
- B > -1 ? {
1993
- label: "Fulfilment's sequence",
1994
- values: [`${B + 1}`]
1995
- } : null,
1996
- ...Q
1997
- ].filter((V) => V)
1998
- };
1999
- }
2000
- function L(f) {
2001
- var Q, ee;
2002
- const B = m.findIndex((K) => K.id === f.id);
2003
- return {
2004
- header: "Fulfillment",
2005
- date: Ge(new Date(f.createdAt)),
2006
- info: [
2007
- {
2008
- label: "Sequence",
2009
- values: [String(B + 1)]
2010
- },
2011
- {
2012
- label: "Receiveable items",
2013
- values: f.items.map((K) => {
2014
- var ie;
2015
- return C("div", [
2016
- C(
2017
- "div",
2018
- {
2019
- class: "flex gap-4"
2020
- },
2021
- [
2022
- C(
2023
- "div",
2024
- {
2025
- class: "flex flex-col"
2026
- },
2027
- [
2028
- C(
2029
- "span",
2030
- {
2031
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2032
- },
2033
- `${K.sku.name}`
2034
- ),
2035
- C(
2036
- "span",
2037
- {
2038
- class: "fm-typo-en-body-md-400"
2039
- },
2040
- `${K.sku.code} `
2041
- )
2042
- ]
2043
- ),
2044
- C(
2045
- "div",
2046
- {
2047
- class: "ml-auto flex flex-col"
2048
- },
2049
- [
2050
- C(
2051
- "div",
2052
- {
2053
- class: "ml-auto flex gap-1"
2054
- },
2055
- [
2056
- C(
2057
- "span",
2058
- {
2059
- class: "fm-typo-en-body-lg-600 self-end"
2060
- },
2061
- be(K.amount, !1)
2062
- ),
2063
- C(
2064
- "span",
2065
- {
2066
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2067
- },
2068
- ((ie = K.measurement) == null ? void 0 : ie.abbrev) ?? K.sku.unit.abbrev
2069
- )
2070
- ]
2071
- ),
2072
- C(
2073
- "div",
2074
- {
2075
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2076
- },
2077
- `${K.cost ? `(${Fe(K.cost)})` : ""}`
2078
- )
2079
- ]
2080
- )
2081
- ]
2082
- )
2083
- ]);
2084
- })
2085
- },
2086
- (Q = f.netSuite) != null && Q.refNo ? {
2087
- label: "Ref no. (Netsuite)",
2088
- values: [(ee = f.netSuite) == null ? void 0 : ee.refNo]
2089
- } : null
2090
- ].filter((K) => K)
2091
- };
2092
- }
2093
- return A.map((f) => {
2094
- switch (f.type) {
2095
- case "grn":
2096
- return N(f.doc);
2097
- case "fulfillment":
2098
- return L(f.doc);
2099
- }
2100
- });
2101
- }), D = re(() => {
2102
- var m;
2103
- const n = {
2104
- ...dt(0),
2105
- currency: it()
2106
- };
2107
- return ((m = s.purchaseOrder) == null ? void 0 : m.items.reduce((A, N) => ({
2108
- ...ut(A, N.totalCost ?? n),
2109
- currency: it()
2110
- }), n)) ?? n;
2111
- });
2112
- function I(n) {
2113
- var E;
2114
- const A = (((E = s.purchaseOrder) == null ? void 0 : E.version) ?? Se.enum[1]) === Se.enum[2] ? n.id : n.sku._id, N = s.receivedMap[A];
2115
- return `<span class="${te(n)} fm-typo-en-body-lg-600">${De.toFormatString({ value: N.received })}</span>/${It(n.quantity, n.sku.unit, n.measurement)}`;
2116
- }
2117
- function te(n) {
2118
- var B;
2119
- const A = (((B = s.purchaseOrder) == null ? void 0 : B.version) ?? Se.enum[1]) === Se.enum[2] ? n.id : n.sku._id, N = s.receivedMap[A], { isPartialReceive: L, isNoReceive: E, isOverReceive: M, isFullReceive: f } = Mt(N);
2120
- return E ? "text-fm-color-typo-tertiary" : L ? "text-fm-color-system-warning-300" : M ? "text-fm-color-system-error-300" : f ? "text-fm-color-system-success-300" : "";
2121
- }
2122
- const G = re(() => {
2123
- var n, m, A;
2124
- return (n = s.purchaseOrder) != null && n.itemsAtSubmission ? ((m = s.purchaseOrder) == null ? void 0 : m.version) === Se.enum[2] ? s.purchaseOrder.items.reduce((N, L) => {
2125
- var M, f;
2126
- const E = (f = (M = s.purchaseOrder) == null ? void 0 : M.itemsAtSubmission) == null ? void 0 : f.find(
2127
- (B) => B.id === L.id
2128
- );
2129
- return E && E.quantity !== L.quantity && N.set(L.sku.code, {
2130
- originalAmount: Number(De.toFormatString({ value: E.quantity })),
2131
- newAmount: Number(De.toFormatString({ value: L.quantity }))
2132
- }), N;
2133
- }, /* @__PURE__ */ new Map()) : (A = s.purchaseOrder) == null ? void 0 : A.items.reduce((N, L) => {
2134
- var B, Q;
2135
- const E = (Q = (B = s.purchaseOrder) == null ? void 0 : B.itemsAtSubmission) == null ? void 0 : Q.find(
2136
- (ee) => ee.sku._id === L.sku._id
2137
- ), M = E ? Number(De.toFormatString({ value: E.quantity })) : 0, f = Number(De.toFormatString({ value: L.quantity }));
2138
- return E && M !== f && N.set(L.sku.code, {
2139
- originalAmount: M,
2140
- newAmount: f
2141
- }), N;
2142
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2143
- }), ne = (n) => {
2144
- var A, N;
2145
- const m = G.value;
2146
- return ((A = s.purchaseOrder) == null ? void 0 : A.version) === Se.enum[2] ? m.has(n.id) : m.has((N = n.sku) == null ? void 0 : N.code);
2147
- }, J = (n) => {
2148
- var A, N;
2149
- const m = G.value;
2150
- return ((A = s.purchaseOrder) == null ? void 0 : A.version) === Se.enum[2] ? m.get(n.id) : m.get((N = n.sku) == null ? void 0 : N.code);
2151
- };
2152
- return (n, m) => {
2153
- var K, ie;
2154
- const A = Z("FmButtonGroup"), N = Z("FmChip"), L = Z("FmMenuDivider"), E = Z("FmCard"), M = Z("FmIcon"), f = Z("FmTooltip"), B = Z("FmSpacer"), Q = Z("FmButton"), ee = Z("FmSideSheet");
2155
- return v(), ue(ee, {
2156
- header: w(y)("inventory.transfer.receiveRequest.details.title") + ((K = n.purchaseOrder) != null && K.seqNumber ? ` #${(ie = n.purchaseOrder) == null ? void 0 : ie.seqNumber}` : ""),
2157
- modelValue: w(P),
2158
- "onUpdate:modelValue": m[5] || (m[5] = (Y) => Ct(P) ? P.value = Y : null),
2159
- "dismiss-away": c.value,
2160
- "close-button": "",
2161
- "max-width": 600
2162
- }, {
2163
- default: se(() => {
2164
- var Y, ve, _e, ke, Ce;
2165
- return [
2166
- e("div", Gr, [
2167
- e("div", null, [
2168
- F(A, {
2169
- items: $.value,
2170
- modelValue: U.value,
2171
- "onUpdate:modelValue": m[0] || (m[0] = (j) => U.value = j)
2172
- }, null, 8, ["items", "modelValue"])
2173
- ]),
2174
- U.value.value === "overview" ? (v(), x(ae, { key: 0 }, [
2175
- e("div", null, [
2176
- F(E, {
2177
- variant: "outlined",
2178
- class: "flex flex-col gap-8 px-12 py-16"
2179
- }, {
2180
- default: se(() => {
2181
- var j, V, X, me, fe, Ie, tt, rt, st;
2182
- return [
2183
- e("div", Hr, [
2184
- e("div", Wr, R(w(y)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
2185
- e("div", Yr, [
2186
- F($e, null, {
2187
- default: se(() => {
2188
- var ot;
2189
- return [
2190
- Ne(R((ot = s.purchaseOrder) == null ? void 0 : ot.status), 1)
2191
- ];
2192
- }),
2193
- _: 1
2194
- }),
2195
- F(N, {
2196
- label: Pe.value.status,
2197
- class: Te(Pe.value.statusClass),
2198
- compact: ""
2199
- }, null, 8, ["label", "class"])
2200
- ])
2201
- ]),
2202
- F(L),
2203
- e("div", Qr, [
2204
- e("div", Xr, [
2205
- e("div", Zr, [
2206
- e("div", Jr, R(w(y)("inventory.transfer.receiveRequest.details.createdAt")), 1)
2207
- ]),
2208
- e("div", es, R(w(Le)(((j = n.purchaseOrder) == null ? void 0 : j._id) ?? "")), 1)
2209
- ]),
2210
- (V = n.purchaseOrder) != null && V.effectiveAt ? (v(), x("div", ts, [
2211
- e("div", rs, R(w(y)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
2212
- e("div", ss, R(w(mt)(new Date((X = n.purchaseOrder) == null ? void 0 : X.effectiveAt))), 1)
2213
- ])) : H("", !0),
2214
- e("div", os, [
2215
- e("div", ns, R(w(y)("inventory.transfer.receiveRequest.details.type.title")), 1),
2216
- e("div", as, R(w(y)(
2217
- `inventory.transfer.receiveRequest.details.type.${g.value.toLocaleLowerCase("en-US")}`
2218
- )), 1)
2219
- ]),
2220
- (fe = (me = n.purchaseOrder) == null ? void 0 : me.supplier) != null && fe.name ? (v(), x("div", is, [
2221
- e("div", ls, R(w(y)("inventory.transfer.receiveRequest.details.from")), 1),
2222
- e("div", cs, R((tt = (Ie = n.purchaseOrder) == null ? void 0 : Ie.supplier) == null ? void 0 : tt.name), 1)
2223
- ])) : H("", !0),
2224
- n.transferTo ? (v(), x("div", us, [
2225
- e("div", ds, R(w(y)("inventory.transfer.receiveRequest.details.to")), 1),
2226
- e("div", ms, R(n.transferTo), 1)
2227
- ])) : H("", !0),
2228
- (rt = n.purchaseOrder) != null && rt.ref ? (v(), x("div", fs, [
2229
- e("div", ps, R(w(y)("inventory.transfer.receiveRequest.details.reference")), 1),
2230
- e("div", ys, R(n.purchaseOrder.ref), 1)
2231
- ])) : H("", !0),
2232
- (st = n.purchaseOrder) != null && st.remark ? (v(), x("div", vs, [
2233
- e("div", hs, R(w(y)("inventory.transfer.receiveRequest.details.remark")), 1),
2234
- e("div", bs, R(n.purchaseOrder.remark), 1)
2235
- ])) : H("", !0)
2236
- ])
2237
- ];
2238
- }),
2239
- _: 1
2240
- })
2241
- ]),
2242
- F(zr, {
2243
- "po-request": n.poRequest,
2244
- purchaseOrder: n.purchaseOrder,
2245
- transferType: g.value,
2246
- transferToDbName: n.transferToDbName,
2247
- scope: n.scope
2248
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
2249
- e("div", gs, [
2250
- e("div", _s, [
2251
- e("div", Ss, [
2252
- e("span", ws, [
2253
- Ne(R(xe.value ? w(y)("inventory.transfer.receiveRequest.details.receivedItems") : w(y)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
2254
- (ve = (Y = n.purchaseOrder) == null ? void 0 : Y.netSuite) != null && ve.missingItems && ((ke = (_e = n.purchaseOrder) == null ? void 0 : _e.netSuite) == null ? void 0 : ke.missingItems.length) > 0 ? (v(), ue(f, {
2255
- key: 0,
2256
- variant: "rich",
2257
- placement: "top",
2258
- "z-index": 51
2259
- }, {
2260
- content: se(() => {
2261
- var j, V;
2262
- return [
2263
- e("div", Rs, [
2264
- (v(!0), x(ae, null, he((V = (j = n.purchaseOrder) == null ? void 0 : j.netSuite) == null ? void 0 : V.missingItems, (X, me) => (v(), x("div", {
2265
- class: "flex justify-center align-middle",
2266
- key: me
2267
- }, [
2268
- F(M, {
2269
- name: "arrow_right",
2270
- size: "sm"
2271
- }),
2272
- Ne(" " + R(`(${X.netSuiteId}) ${X.name}: ${X.reason}`), 1)
2273
- ]))), 128))
2274
- ])
2275
- ];
2276
- }),
2277
- default: se(() => [
2278
- F(M, {
2279
- name: "error",
2280
- color: "#ff2c2c",
2281
- size: "sm"
2282
- })
2283
- ]),
2284
- _: 1
2285
- })) : H("", !0)
2286
- ])
2287
- ]),
2288
- F(L),
2289
- (v(!0), x(ae, null, he(((Ce = n.purchaseOrder) == null ? void 0 : Ce.items) ?? [], (j, V) => {
2290
- var X;
2291
- return v(), x("div", {
2292
- key: V,
2293
- class: "flex flex-col"
2294
- }, [
2295
- e("div", xs, [
2296
- e("div", Os, [
2297
- Ne(R(j.name) + " ", 1),
2298
- ne(j) ? (v(), ue(f, {
2299
- key: 0,
2300
- variant: "rich",
2301
- placement: "top",
2302
- "z-index": 51
2303
- }, {
2304
- content: se(() => {
2305
- var me, fe;
2306
- return [
2307
- e("div", Ns, [
2308
- m[6] || (m[6] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
2309
- e("div", null, "Original Amount: " + R((me = J(j)) == null ? void 0 : me.originalAmount), 1),
2310
- e("div", null, " New Amount: " + R((fe = J(j)) == null ? void 0 : fe.newAmount), 1)
2311
- ])
2312
- ];
2313
- }),
2314
- default: se(() => [
2315
- F(M, {
2316
- name: "error",
2317
- color: "#ff9500",
2318
- size: "sm"
2319
- })
2320
- ]),
2321
- _: 2
2322
- }, 1024)) : H("", !0)
2323
- ]),
2324
- e("div", $s, [
2325
- e("span", {
2326
- innerHTML: I(j)
2327
- }, null, 8, ks)
2328
- ])
2329
- ]),
2330
- e("div", Cs, [
2331
- e("div", As, R(j.code), 1),
2332
- (X = j.totalCost) != null && X.amount && w(d).enableTotalCost ? (v(), x("div", Ds, " (" + R(w(Fe)(j.totalCost)) + ") ", 1)) : H("", !0)
2333
- ])
2334
- ]);
2335
- }), 128)),
2336
- +w(be)(D.value) ? (v(), x(ae, { key: 0 }, [
2337
- e("div", qs, [
2338
- F(L)
2339
- ]),
2340
- e("div", Ts, [
2341
- m[7] || (m[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
2342
- e("div", Ps, R(w(Fe)(D.value)), 1)
2343
- ])
2344
- ], 64)) : H("", !0)
2345
- ])
2346
- ])
2347
- ], 64)) : U.value.value === "deliveryHistory" ? (v(), x("div", Is, [
2348
- ye.value.length ? (v(), x("div", Vs, [
2349
- (v(!0), x(ae, null, he(ye.value, (j, V) => (v(), x(ae, { key: V }, [
2350
- e("div", Us, [
2351
- e("div", Ms, [
2352
- e("div", Ks, [
2353
- e("div", {
2354
- class: Te([
2355
- {
2356
- "bg-fm-color-primary": V !== 0,
2357
- "bg-white": V === 0
2358
- },
2359
- "w-[2px] h-full"
2360
- ])
2361
- }, null, 2)
2362
- ]),
2363
- m[8] || (m[8] = e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
2364
- e("div", js, [
2365
- e("div", {
2366
- class: Te([
2367
- {
2368
- "bg-fm-color-primary": V < ye.value.length - 1,
2369
- "bg-white": V >= ye.value.length - 1
2370
- },
2371
- "w-[2px] h-full"
2372
- ])
2373
- }, null, 2)
2374
- ])
2375
- ]),
2376
- e("div", zs, [
2377
- e("div", Gs, R(j.header), 1),
2378
- e("div", Hs, R(j.date), 1)
2379
- ])
2380
- ]),
2381
- e("div", Ws, [
2382
- e("div", Ys, [
2383
- e("div", Qs, [
2384
- e("div", {
2385
- class: Te([
2386
- {
2387
- "bg-fm-color-primary": V < ye.value.length - 1,
2388
- "bg-white": V >= ye.value.length - 1
2389
- },
2390
- "w-[2px] h-full"
2391
- ])
2392
- }, null, 2)
2393
- ])
2394
- ]),
2395
- e("div", Xs, [
2396
- F(E, {
2397
- variant: "outlined",
2398
- class: "py-12 px-16"
2399
- }, {
2400
- default: se(() => [
2401
- e("div", Zs, [
2402
- (v(!0), x(ae, null, he(j.info, (X, me) => (v(), x("div", {
2403
- key: me,
2404
- class: "flex flex-col gap-4"
2405
- }, [
2406
- e("div", Js, R(X == null ? void 0 : X.label), 1),
2407
- e("div", eo, [
2408
- (v(!0), x(ae, null, he(X == null ? void 0 : X.values, (fe, Ie) => (v(), x("div", {
2409
- key: Ie,
2410
- class: "fm-typo-en-body-lg-600"
2411
- }, [
2412
- typeof fe == "string" ? (v(), x(ae, { key: 0 }, [
2413
- Ne(R(fe), 1)
2414
- ], 64)) : (v(), ue(At(fe), { key: 1 }))
2415
- ]))), 128))
2416
- ])
2417
- ]))), 128))
2418
- ])
2419
- ]),
2420
- _: 2
2421
- }, 1024)
2422
- ])
2423
- ])
2424
- ], 64))), 128))
2425
- ])) : (v(), x("div", Fs, [
2426
- F(B),
2427
- e("div", null, [
2428
- e("img", {
2429
- src: w(Ft),
2430
- alt: "List is empty"
2431
- }, null, 8, Ls)
2432
- ]),
2433
- e("div", Es, R(w(y)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
2434
- e("div", Bs, R(w(y)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
2435
- F(B),
2436
- F(B)
2437
- ]))
2438
- ])) : H("", !0)
2439
- ])
2440
- ];
2441
- }),
2442
- "side-sheet-footer": se(() => [
2443
- e("div", to, [
2444
- (v(!0), x(ae, null, he(T.value, (Y) => (v(), x(ae, null, [
2445
- w(We)[Y].available != !1 ? (v(), ue(Q, {
2446
- key: Y,
2447
- label: w(y)(w(We)[Y].translationKey),
2448
- onClick: (ve) => de(Y),
2449
- loading: l.value === Y,
2450
- disabled: l.value !== Y && p.value,
2451
- variant: w(We)[Y].buttonVariant
2452
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : H("", !0)
2453
- ], 64))), 256)),
2454
- w(S).ableToMarkReceived(n.purchaseOrder) && !T.value.includes("completeReceive") ? (v(), ue(Q, {
2455
- key: 0,
2456
- label: w(y)("inventory.transfer.receiveRequest.actions.completeReceive"),
2457
- onClick: m[1] || (m[1] = (Y) => de("completeReceive")),
2458
- loading: l.value === "completeReceive",
2459
- disabled: l.value !== "completeReceive" && p.value
2460
- }, null, 8, ["label", "loading", "disabled"])) : H("", !0),
2461
- w(S).ableToMarkApproved(n.purchaseOrder) && n.canApprove && !T.value.includes("approveRequest") ? (v(), ue(Q, {
2462
- key: 1,
2463
- label: w(y)("inventory.transfer.approval.actions.approveRequest"),
2464
- onClick: m[2] || (m[2] = (Y) => de("approveRequest")),
2465
- loading: l.value === "approveRequest",
2466
- disabled: l.value !== "approveRequest" && p.value
2467
- }, null, 8, ["label", "loading", "disabled"])) : H("", !0),
2468
- w(S).ableToCreateFulfillment(n.purchaseOrder, n.poRequest) && s.scope === "approval" ? (v(), ue(Q, {
2469
- key: 2,
2470
- label: w(y)("inventory.transfer.receiveRequest.actions.processRequest"),
2471
- onClick: m[3] || (m[3] = (Y) => de("processRequest")),
2472
- loading: l.value === "processRequest",
2473
- disabled: l.value !== "processRequest" && p.value
2474
- }, null, 8, ["label", "loading", "disabled"])) : H("", !0),
2475
- F(Q, {
2476
- label: w(y)("common.close"),
2477
- variant: "tertiary",
2478
- onClick: m[4] || (m[4] = (Y) => _("update:show", !1))
2479
- }, null, 8, ["label"])
2480
- ])
2481
- ]),
2482
- _: 1
2483
- }, 8, ["header", "modelValue", "dismiss-away"]);
2484
- };
2485
- }
2486
- });
2487
- export {
2488
- Ze as P,
2489
- vo as _,
2490
- po as a,
2491
- yo as b,
2492
- Kt as g,
2493
- je as u
2494
- };