@feedmepos/mf-inventory-portal 1.0.15-dev.2 → 1.0.15-dev.3

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 (50) hide show
  1. package/dist/{App-CgxrN-aD.js → App-3Zym4rob.js} +2 -2
  2. package/dist/ApprovalView-C4qLlZua.js +213 -0
  3. package/dist/{BindingsDialog-B_ZMDl-b.js → BindingsDialog-DHaF8DtC.js} +2 -2
  4. package/dist/{BindingsPicker-B84BG8zT.js → BindingsPicker-C04HnWZ-.js} +1 -1
  5. package/dist/{BindingsTable-DrvoykYc.js → BindingsTable-CnZUt7GU.js} +1 -1
  6. package/dist/{ClosingDraftView-Ds9sI2Eg.js → ClosingDraftView-DaMruAln.js} +41 -41
  7. package/dist/{ClosingTemplateView-BhZ1OXkD.js → ClosingTemplateView-B3lyKcz-.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-Yuxf-jCh.js → DeliveryOrderPrintPreview-CGPkYOfW.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-D6ktiUO5.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DFJNtwjV.js} +43 -43
  10. package/dist/{FmMultiselectDialog-4lVsA2Rn.js → FmMultiselectDialog-yR5Mo3U-.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-XmTRSHn_.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DoY67RWl.js} +57 -57
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-B3PvtR0j.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BSuFAwN3.js} +1 -1
  13. package/dist/IngredientGroupView-B-hyo-7W.js +898 -0
  14. package/dist/IngredientsView-Cod5ahQy.js +1778 -0
  15. package/dist/{IntegrationView-BnrCkjWt.js → IntegrationView-D9KZtPN3.js} +5 -5
  16. package/dist/{InventoryBindingForm-uyHh2TI_.js → InventoryBindingForm-CrRoablh.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CECDj9Pw.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-W9p7khOs.js} +46 -46
  18. package/dist/{InventoryBindingSummary-DyHCqgIe.js → InventoryBindingSummary-D88BG4ze.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Dx2lMf6h.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VtM-wvuF.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BCX3vlmU.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Ccx9QvpN.js} +15 -15
  21. package/dist/{PublishView-BVGyY6nn.js → PublishView-DhE7YE-k.js} +13 -13
  22. package/dist/{PurchaseOrderPrintPreview-pbYIFiOG.js → PurchaseOrderPrintPreview-CF_VeOeU.js} +4 -4
  23. package/dist/ReceiveRequestView-Bx9-NHyn.js +2576 -0
  24. package/dist/{RecipeView-DcgoCf4g.js → RecipeView-JhM5Z4CP.js} +4 -4
  25. package/dist/{StockView-zO2uL662.js → StockView-u7jlKoO5.js} +108 -108
  26. package/dist/{SupplierView-I5bqiX_2.js → SupplierView-BDBBQnGy.js} +37 -37
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BJiobEDM.js +2090 -0
  28. package/dist/{TransferTemplateView-BDOt17yc.js → TransferTemplateView-CNMHm8Gy.js} +149 -149
  29. package/dist/{UnitView-BVY5S6-3.js → UnitView-UVgn7ofI.js} +32 -32
  30. package/dist/{WarehouseView-m6MKrtYq.js → WarehouseView-CEw69mhn.js} +26 -26
  31. package/dist/{app-DtICLubM.js → app-cfPLYfcH.js} +33227 -25194
  32. package/dist/app.js +5 -5
  33. package/dist/components/FmInventoryTableToolbar.vue.d.ts +36 -0
  34. package/dist/{decimal-C1dAcCf3.js → decimal-BeCLbdwn.js} +1 -1
  35. package/dist/{feature-Y7qzvbl4.js → feature-dhG2tL_A.js} +79 -79
  36. package/dist/{format-unit-display-CPqfS4vp.js → format-unit-display-D3UdcFM6.js} +48 -48
  37. package/dist/{index-DIEdSG3y.js → index-BUou6R58.js} +1 -1
  38. package/dist/{index-0qsqwB0T.js → index-BkR-Qpc0.js} +4 -4
  39. package/dist/{stock-CowNp_xM.js → stock-DQPwSZX1.js} +1 -1
  40. package/dist/{supplier-JVTTlQNL.js → supplier-CAcd6PiU.js} +2 -2
  41. package/dist/tsconfig.app.tsbuildinfo +1 -1
  42. package/dist/{use-ingredient-select-dialog-Df59lld2.js → use-ingredient-select-dialog-E3qfQso7.js} +5 -5
  43. package/dist/{use-inventory-binding-dialog-Bxxb93Kz.js → use-inventory-binding-dialog-DRKy4nUx.js} +1 -1
  44. package/dist/{vue-i18n-DJOdRwc3.js → vue-i18n-DLrqHK28.js} +271 -271
  45. package/package.json +4 -4
  46. package/dist/ApprovalView-DNGhkVc9.js +0 -147
  47. package/dist/IngredientGroupView-usK9stxT.js +0 -8779
  48. package/dist/IngredientsView-DPx8Z2zo.js +0 -1749
  49. package/dist/ReceiveRequestView-DZAgH2_u.js +0 -2516
  50. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-NyQg_yR9.js +0 -2020
@@ -1,2020 +0,0 @@
1
- import { Y as lt, u as de, aH as S, b as Ue, a2 as ct, a4 as ut, a5 as dt, aI as mt, d as We, e as Ze, V as et, aJ as ft, $ as Ee, K as ke, i as ie, aK as tt, a9 as qe, f as Ye, h as H, D as ee, aq as le, aL as rt, aM as pt, a3 as yt, ao as Qe, a1 as xe, ae as $e, ar as vt } from "./app-DtICLubM.js";
2
- import { ref as K, computed as W, h as D, defineComponent as be, reactive as ht, onMounted as st, resolveComponent as G, openBlock as g, createBlock as ae, withCtx as ce, createElementVNode as o, createVNode as B, unref as y, createElementBlock as q, toDisplayString as x, createCommentVNode as E, watch as bt, isRef as gt, Fragment as te, normalizeClass as Oe, createTextVNode as Ce, renderList as ve, resolveDynamicComponent as _t } from "vue";
3
- import { F as wt } from "./decimal-C1dAcCf3.js";
4
- import { b as St, u as Rt, f as at, P as ue } from "./format-unit-display-CPqfS4vp.js";
5
- import { useCoreStore as De, useI18n as nt } from "@feedmepos/mf-common";
6
- import { E as xt } from "./empty-placeholder-wf6-BWE8.js";
7
- import { useDialog as Ve, useSnackbar as Ne, components as Je, FmButtonVariant as Z, useProxiedModel as Ot } from "@feedmepos/ui-library";
8
- import { u as Ae, F as Fe } from "./feature-Y7qzvbl4.js";
9
- import { _ as kt, F as qt, a as Dt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-XmTRSHn_.js";
10
- import { u as Nt, R as Xe } from "./usePromise-CbVUCxhj.js";
11
- import { u as At } from "./index-0qsqwB0T.js";
12
- const Te = lt((d, s) => {
13
- const a = de(), k = De();
14
- return {
15
- async readRequests(i, e, c) {
16
- const m = i ?? a.currentLocationDBName, n = `${d.inventoryBackendUrl}/${m}/purchase-request`;
17
- return e && c ? await s.get(`${n}?startDate=${e}&endDate=${c}`) : await s.get(n);
18
- },
19
- async readRequestById(i, e) {
20
- const c = e ?? a.currentLocationDBName, m = `${d.inventoryBackendUrl}/${c}/purchase-request/${i}`;
21
- return await s.get(m);
22
- },
23
- async readRequestByIds(i, e) {
24
- const c = e ?? a.currentLocationDBName, m = `${d.inventoryBackendUrl}/${c}/purchase-request/find`;
25
- return await s.post(m, { requestIds: i });
26
- },
27
- async getPurchaseOrders({
28
- start: i,
29
- end: e
30
- }) {
31
- const c = a.currentLocationDBName, m = `${d.inventoryBackendUrl}/${c}/purchase-order`;
32
- return await s.get(`${m}?start=${i}&end=${e}`);
33
- },
34
- async getLatestPurchaseOrderRequest(i) {
35
- const e = a.currentLocationDBName, c = `${d.inventoryBackendUrl}/${e}/purchase-request/find-by-purchase-order-id`;
36
- return await s.get(`${c}/${i}`);
37
- },
38
- async getPurchaseOrderById(i) {
39
- const e = a.currentLocationDBName, c = `${d.inventoryBackendUrl}/${e}/purchase-order`;
40
- return await s.get(`${c}/${i}`);
41
- },
42
- /**
43
- * @deprecated Use `processPurchaseOrderV2` instead.
44
- */
45
- async processPurchaseOrder(i, e) {
46
- const c = a.currentLocationDBName, m = e || c, n = `${d.inventoryBackendUrl}/${m}/purchase-order/run-operation`;
47
- return await s.put(n, i);
48
- },
49
- async createPurchaseOrder(i) {
50
- const e = a.currentLocationDBName, c = `${d.inventoryBackendUrl}/${e}/purchase-order`;
51
- return await s.post(c, i);
52
- },
53
- async updatePurchaseOrder(i) {
54
- const e = a.currentLocationDBName, c = `${d.inventoryBackendUrl}/${e}/purchase-order`;
55
- return await s.put(c, i);
56
- },
57
- async importFromXilnex(i) {
58
- const e = a.currentLocationDBName, c = `${d.inventoryBackendUrl}/${e}/purchase-order/import-from-xilnex`;
59
- return await s.post(c, i);
60
- },
61
- async processPurchaseOrderV2(i, e) {
62
- const c = a.currentLocationDBName, m = e || c, n = `${d.inventoryBackendUrl}/${m}/v2/purchase-order/run-operation`;
63
- return await s.put(n, i);
64
- },
65
- async getWorkflowConfig() {
66
- var m;
67
- const e = `business_${(m = k.currentBusiness.value) == null ? void 0 : m._id}`, c = `${d.inventoryBackendUrl}/${e}/v2/purchase-order/workflow-config`;
68
- return await s.get(c);
69
- }
70
- };
71
- }), ot = {
72
- [S.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
- [S.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
- [S.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
- [S.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
- [S.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
- [S.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
- [S.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 it() {
140
- const d = de(), s = Te(), a = Ae();
141
- async function k(e, c) {
142
- const m = d.currentLocationDBName;
143
- return e.doc.supplier.internal && e.operation === S.enum.confirmDraft && (e.operation = S.enum.submitRequest), await s.processPurchaseOrder(e, c || m);
144
- }
145
- async function i(e, c) {
146
- const m = d.currentLocationDBName;
147
- return await s.processPurchaseOrderV2(e, c || m);
148
- }
149
- return (e) => a.useOperatePurchaseOrderV2 ? i(e.operateV2, e.transferTo) : k(e.operate, e.transferTo);
150
- }
151
- var Le = /* @__PURE__ */ ((d) => (d.RECEIVE_REQUEST = "receive/request", d.APPROVAL = "approval", d))(Le || {});
152
- const Se = K(), Ie = K();
153
- function Ns(d, s) {
154
- const a = Ve(), k = de(), i = Ae();
155
- Ue();
156
- const e = St(), c = Rt(), m = K(!1), n = Ne(), v = Te(), R = K(new Array()), r = K(
157
- s != null && s.startDate && (s != null && s.endDate) ? s : ct()
158
- ), l = W(() => {
159
- const O = new Date(r.value.startDate), t = new Date(r.value.endDate);
160
- return {
161
- start: ut(O).toISOString(),
162
- end: dt(t).toISOString()
163
- };
164
- }), f = K(new Array()), b = mt(), w = K(null);
165
- async function I(O) {
166
- function t(_) {
167
- const h = {
168
- mode: We.CREATE,
169
- modelValue: O || void 0,
170
- show: !0,
171
- "onUpdate:show"(N) {
172
- Se.value.show = N;
173
- },
174
- templateId: _,
175
- lastClosingDate: w.value
176
- };
177
- Se.value = h;
178
- }
179
- let u;
180
- i.mustUsePoTemplate && !(O != null && O.template) ? a.open({
181
- title: "Create transfer",
182
- message: "",
183
- primaryActions: {
184
- text: "Select a template",
185
- close: !0
186
- },
187
- secondaryActions: {
188
- text: "Outlet to Outlet",
189
- variant: "secondary",
190
- close: !0
191
- }
192
- }).onPrimary(async () => {
193
- u = await e.getTemplateId(), u && t(u);
194
- }).onSecondary(() => {
195
- t(void 0);
196
- }) : t(u);
197
- }
198
- function L(O) {
199
- const t = {
200
- mode: We.UPDATE,
201
- modelValue: Ze(O),
202
- show: !0,
203
- "onUpdate:show"(u) {
204
- Se.value.show = u;
205
- },
206
- lastClosingDate: w.value
207
- };
208
- Se.value = t;
209
- }
210
- async function J() {
211
- R.value = [], m.value = !0;
212
- try {
213
- R.value = await v.getPurchaseOrders(l.value).then((_) => _.sort((h, N) => N._id.localeCompare(h._id)));
214
- const O = await b.readCurrentLocationLastClosing(!0), t = O == null ? void 0 : O._id;
215
- t && (w.value = ft(t)), await i.awaitFeatureLoaded(() => i.mustUsePoTemplate) && await c.fetchTemplates();
216
- const u = R.value.map((_) => {
217
- var h;
218
- return ((h = _.request) == null ? void 0 : h.id) ?? "";
219
- }).filter((_) => _);
220
- f.value = await v.readRequestByIds(u);
221
- } catch {
222
- n.open({
223
- title: "Something went wrong",
224
- message: "Error at fetching purchase orders",
225
- type: "error"
226
- });
227
- } finally {
228
- m.value = !1;
229
- }
230
- }
231
- async function Y() {
232
- f.value = [], m.value = !0;
233
- try {
234
- f.value = await v.readRequests(
235
- void 0,
236
- l.value.start,
237
- l.value.end
238
- ).then((O) => O.reverse());
239
- } catch {
240
- n.open({
241
- title: "Something went wrong",
242
- message: "Error at fetching purchase requests",
243
- type: "error"
244
- });
245
- } finally {
246
- m.value = !1;
247
- }
248
- }
249
- function Q() {
250
- switch (d) {
251
- case "receive/request":
252
- return J();
253
- case "approval":
254
- return Y();
255
- }
256
- }
257
- function ne(O, t) {
258
- r.value = {
259
- startDate: O,
260
- endDate: t
261
- }, Q();
262
- }
263
- k.watchLocation(async (O) => {
264
- if (!O) {
265
- R.value = [];
266
- return;
267
- }
268
- await Q();
269
- });
270
- const X = K(), me = K(Math.random().toString());
271
- async function se(O, t) {
272
- const u = Math.random().toString();
273
- me.value = u, t ?? (t = f.value.computeFirst(
274
- (N) => N.purchaseOrderId === O._id ? N : null
275
- ) ?? void 0);
276
- const _ = d === "receive/request" ? k.currentLocation : t == null ? void 0 : t.to, h = {
277
- poRequest: t,
278
- purchaseOrder: O,
279
- transferTo: _ == null ? void 0 : _.name,
280
- transferToDbName: _ == null ? void 0 : _.dbName,
281
- show: !0,
282
- canResubmit: !1,
283
- canApprove: d === "approval",
284
- "onUpdate:show"(N) {
285
- X.value.show = N;
286
- },
287
- scope: d
288
- };
289
- X.value = h;
290
- }
291
- async function fe(O, t, u, _) {
292
- const h = it();
293
- m.value = !0;
294
- try {
295
- await h({
296
- operate: {
297
- operation: t,
298
- doc: O,
299
- options: (
300
- // auto receive for supplier to warehouse
301
- (t === S.enum.confirmDraft || // auto receive for warehouse to warehouse
302
- t === S.enum.completeReceive) && i.autoReceiveWarehouse ? {
303
- autoReceive: !0
304
- } : void 0
305
- )
306
- },
307
- operateV2: {
308
- _id: O._id,
309
- _rev: O._rev ?? "",
310
- action: t
311
- },
312
- transferTo: _
313
- }), await new Promise((j) => setTimeout(j, 1e3));
314
- const V = de().currentLocationDBName.startsWith("restaurant_");
315
- t === S.enum.confirmDraft && O.effectiveAt && V ? n.open({
316
- title: "Success",
317
- message: `${u}. The backdate will be reflected once your POS has received this change.`,
318
- type: "success"
319
- }) : n.open({
320
- title: "Success",
321
- message: u,
322
- type: "success"
323
- });
324
- } catch (N) {
325
- n.open({
326
- title: "Something went wrong",
327
- message: "Please try again.",
328
- type: "error"
329
- }), console.error("Error when submitting PO operation", t, O, N);
330
- } finally {
331
- m.value = !1, Q();
332
- }
333
- }
334
- async function Pe(O, t, u) {
335
- const _ = ot[t];
336
- if (!_) {
337
- n.open({
338
- title: "Something went wrong",
339
- message: `Cannot process order: ${et(t)}`,
340
- type: "error"
341
- });
342
- return;
343
- }
344
- const { successMessage: h, ...N } = _;
345
- a.open({
346
- title: N.title,
347
- message: N.message,
348
- primaryActions: N.primaryActions
349
- }).onPrimary(() => {
350
- fe(O, t, h, u);
351
- });
352
- }
353
- async function oe() {
354
- a.open({
355
- title: "Upload Transfer",
356
- primaryActions: {
357
- text: "Xilnex transfer note",
358
- close: !0
359
- },
360
- secondaryActions: {
361
- text: "Cancel",
362
- close: !0
363
- }
364
- }).onPrimary(() => {
365
- const O = {
366
- show: !0,
367
- "onUpdate:show"(t) {
368
- Ie.value.show = t;
369
- }
370
- };
371
- Ie.value = O;
372
- });
373
- }
374
- return {
375
- purchaseOrders: R,
376
- purchaseRequests: f,
377
- updateDateRange: ne,
378
- fetchData: Q,
379
- loading: m,
380
- transferDialogProps: Se,
381
- promptCreateTransferDialog: I,
382
- promptUpdateTransferDialog: L,
383
- transferDetailsProps: X,
384
- promptShowTransferDetails: se,
385
- submitAction: Pe,
386
- xilnexImportDialogProps: Ie,
387
- promptUploadTransferDialog: oe
388
- };
389
- }
390
- function Tt(d, s) {
391
- return s.reduce(
392
- (k, i) => {
393
- const e = i.received.find((c) => c.sku._id === d._id);
394
- return e && (k = Ee(k, e.amount)), k;
395
- },
396
- wt.toPrecision(ke(0), d.unit.precision)
397
- );
398
- }
399
- function Pt(d, s, a, k) {
400
- const { name: i, address: e, regNo: c } = s.doc.profile, m = {
401
- name: i,
402
- registrationNumber: c,
403
- line1: e == null ? void 0 : e.line1,
404
- line2: e == null ? void 0 : e.line2,
405
- postcode: e == null ? void 0 : e.postcode,
406
- city: e == null ? void 0 : e.city,
407
- state: e == null ? void 0 : e.state,
408
- country: e == null ? void 0 : e.country
409
- }, n = {
410
- name: d.supplier.name,
411
- phoneNumber: d.supplier.phoneNumber,
412
- registrationNumber: d.supplier.registrationNumber,
413
- line1: d.supplier.address.line1,
414
- line2: d.supplier.address.line2,
415
- postcode: d.supplier.address.postcode,
416
- city: d.supplier.address.city,
417
- state: d.supplier.address.state,
418
- country: d.supplier.address.country
419
- }, v = d.items.map((b) => {
420
- const { sku: w, measurement: I } = b, L = ie(
421
- Tt(b.sku, d.deliveryOrder || []),
422
- !1
423
- );
424
- return {
425
- code: w.code,
426
- description: w.name,
427
- quantity: at(b.quantity, w.unit, b.measurement),
428
- unit: (I == null ? void 0 : I.abbrev) || w.unit.abbrev,
429
- received: L
430
- };
431
- }), R = d.deliveryOrder.map((b) => ({
432
- createdAt: tt(new Date(b.createdAt)),
433
- ref: b.deliveryOrderNumber,
434
- remark: b.remark || "",
435
- items: b.received.map((w) => {
436
- var I;
437
- return {
438
- code: w.sku.code,
439
- description: w.sku.name,
440
- quantity: ie(w.amount),
441
- unit: ((I = w.measurement) == null ? void 0 : I.abbrev) || w.sku.unit.abbrev
442
- };
443
- })
444
- })), r = {
445
- businessName: a == null ? void 0 : a.name,
446
- logo: a == null ? void 0 : a.thumbnail,
447
- orderNumber: d.seqNumber.toString(),
448
- createdAt: qe(d._id),
449
- ref: d.ref || "",
450
- remark: d.remark || "",
451
- buyer: m,
452
- supplier: n,
453
- items: v,
454
- status: d.status,
455
- deliveryOrders: R
456
- }, l = new URL(window.location.href), f = k && (d.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
457
- l.pathname = l.hostname.includes("portal.feedme") ? `/inventory/${f}` : `/${f}`, l.searchParams.append("data", JSON.stringify(r)), window.open(l.href, "_blank", "noreferrer");
458
- }
459
- const he = {
460
- submitRequest: {
461
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
462
- color: "text-fm-color-typo-primary",
463
- value: S.enum.submitRequest
464
- },
465
- confirmDraft: {
466
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
467
- color: "text-fm-color-typo-primary",
468
- value: S.enum.confirmDraft
469
- },
470
- cancelDraft: {
471
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
472
- color: "text-fm-color-typo-error",
473
- value: S.enum.cancelDraft
474
- },
475
- approveRequest: {
476
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
477
- color: "text-fm-color-typo-primary",
478
- value: S.enum.approveRequest
479
- },
480
- rejectRequest: {
481
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
482
- color: "text-fm-color-typo-error",
483
- value: S.enum.rejectRequest
484
- },
485
- processRequest: {
486
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
487
- color: "text-fm-color-typo-primary",
488
- value: S.enum.processRequest
489
- },
490
- receiveStock: {
491
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
492
- color: "text-fm-color-typo-primary",
493
- value: S.enum.receiveStock
494
- },
495
- completeReceive: {
496
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
497
- color: "text-fm-color-typo-primary",
498
- value: S.enum.completeReceive
499
- },
500
- closeRequest: {
501
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
502
- color: "system-error-300",
503
- value: S.enum.closeRequest
504
- },
505
- approveDraft: {
506
- translationKey: "",
507
- color: "",
508
- value: void 0
509
- },
510
- rejectDraft: {
511
- translationKey: "",
512
- color: "",
513
- value: void 0
514
- },
515
- returnStock: {
516
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
517
- color: "text-fm-color-typo-primary",
518
- value: S.enum.returnStock
519
- }
520
- };
521
- function As(d, s) {
522
- const a = de(), k = De(), { t: i } = nt();
523
- function e(r) {
524
- switch (r.status) {
525
- case "DRAFT":
526
- return [
527
- ee[H.Update],
528
- ee[H.Details],
529
- r.supplier.internal === "restaurant" || r.supplier.internal === "warehouse" ? he[S.enum.submitRequest] : he[S.enum.confirmDraft],
530
- he[S.enum.cancelDraft]
531
- ];
532
- case "RECEIVING":
533
- return [
534
- he[S.enum.completeReceive],
535
- ee[H.Details],
536
- ee[H.Print]
537
- ];
538
- case "REQUESTING":
539
- return d === "receive/request" ? [ee[H.Details], ee[H.Print]] : [
540
- he[S.enum.approveRequest],
541
- he[S.enum.rejectRequest],
542
- ee[H.Details]
543
- // DefaultRowActions[RowActionEnum.Print]
544
- ];
545
- case "PROCESSING":
546
- return [ee[H.Details], ee[H.Print]];
547
- case "COMPLETE":
548
- case "CANCEL":
549
- default:
550
- return [ee[H.Details], ee[H.Print]];
551
- }
552
- }
553
- function c(r) {
554
- return Object.values(S.enum).includes(r);
555
- }
556
- async function m(r, l, f) {
557
- var w, I, L, J;
558
- const b = Ze(l);
559
- if (r === H.Print) {
560
- const Y = (f == null ? void 0 : f.toInventoryLocation) ?? a.currentLocation;
561
- b.ref = [((w = f == null ? void 0 : f.netSuite) == null ? void 0 : w.refNo) || ((I = b.netSuite) == null ? void 0 : I.refNo)].filter((Q) => Q).join(" "), Pt(b, Y, k.currentBusiness.value, d === "approval");
562
- return;
563
- }
564
- if (r === H.Details) {
565
- s.promptShowTransferDetails(b, f);
566
- return;
567
- }
568
- if (r === H.Update) {
569
- (L = s.promptUpdateTransferDialog) == null || L.call(s, b);
570
- return;
571
- }
572
- if (c(r)) {
573
- s.submitAction(l, r, (J = f == null ? void 0 : f.to) == null ? void 0 : J.dbName);
574
- return;
575
- }
576
- }
577
- function n() {
578
- return [
579
- {
580
- accessorKey: "seqNumber",
581
- header: () => i("inventory.transfer.table.seqNo"),
582
- enableSorting: !0,
583
- size: 80,
584
- sortUndefined: "last"
585
- },
586
- {
587
- accessorKey: "_id",
588
- header: () => i("inventory.transfer.table.createdAt"),
589
- cell(r) {
590
- return qe(`${r.getValue()}`);
591
- },
592
- enableSorting: !0
593
- },
594
- {
595
- accessorKey: "supplier.name",
596
- header: () => i("inventory.transfer.table.transferFrom"),
597
- enableSorting: !0,
598
- size: 200
599
- },
600
- {
601
- accessorKey: "items.length",
602
- header: () => i("inventory.transfer.table.noOfItems"),
603
- enableSorting: !1,
604
- meta: {
605
- width: "10rem"
606
- }
607
- },
608
- {
609
- accessorKey: "ref",
610
- header: () => i("inventory.transfer.table.reference"),
611
- enableSorting: !1,
612
- size: "auto"
613
- },
614
- {
615
- accessorKey: "status",
616
- header: () => i("inventory.transfer.table.status"),
617
- cell(r) {
618
- const l = i(`inventory.transfer.status.${r.getValue() ?? ""}`), f = `${r.getValue() ?? ""}`.toLocaleLowerCase("en-us");
619
- return D(
620
- "div",
621
- {
622
- class: "flex"
623
- },
624
- D(
625
- "div",
626
- {
627
- class: `fm-status-badge fm-status-badge-${f}`
628
- },
629
- l
630
- )
631
- );
632
- },
633
- enableSorting: !0,
634
- size: 200
635
- },
636
- {
637
- id: "action",
638
- cell(r) {
639
- const l = r.row.original, f = e(l);
640
- return Ye(f, (b) => m(b, l));
641
- },
642
- enableSorting: !1,
643
- size: 40,
644
- meta: {
645
- cellClass: "",
646
- headerClass: ""
647
- }
648
- }
649
- ];
650
- }
651
- function v() {
652
- return [
653
- {
654
- accessorKey: "purchaseOrder.seqNumber",
655
- header: () => i("inventory.transfer.table.seqNo"),
656
- enableSorting: !0,
657
- size: 80,
658
- sortUndefined: "last"
659
- },
660
- {
661
- accessorKey: "purchaseOrder._id",
662
- header: () => i("inventory.transfer.table.createdAt"),
663
- cell(r) {
664
- return qe(`${r.getValue()}`);
665
- },
666
- enableSorting: !0
667
- },
668
- {
669
- accessorKey: "to.name",
670
- header: () => i("inventory.transfer.table.transferTo"),
671
- enableSorting: !1,
672
- size: 200
673
- },
674
- {
675
- accessorKey: "purchaseOrder.items.length",
676
- header: () => i("inventory.transfer.table.noOfItems"),
677
- enableSorting: !1
678
- },
679
- {
680
- accessorKey: "purchaseOrder.ref",
681
- header: () => i("inventory.transfer.table.reference"),
682
- enableSorting: !1,
683
- size: "auto"
684
- },
685
- {
686
- accessorKey: "purchaseOrder.status",
687
- header: () => i("inventory.transfer.table.status"),
688
- cell(r) {
689
- const l = i(`inventory.transfer.status.${r.getValue() ?? ""}`), f = `${r.getValue() ?? ""}`.toLocaleLowerCase("en-us");
690
- return D(
691
- "div",
692
- {
693
- class: "flex"
694
- },
695
- D(
696
- "div",
697
- {
698
- class: `fm-status-badge fm-status-badge-${f}`
699
- },
700
- l
701
- )
702
- );
703
- },
704
- enableSorting: !0
705
- },
706
- {
707
- id: "action",
708
- cell(r) {
709
- const l = r.row.original, b = (l.purchaseOrder ? e(l.purchaseOrder) : []).map((w) => w.value === H.Print ? {
710
- ...w,
711
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
712
- } : w);
713
- return Ye(
714
- b,
715
- (w) => l.purchaseOrder ? m(w, l.purchaseOrder, l) : void 0
716
- );
717
- },
718
- enableSorting: !1,
719
- size: 40,
720
- meta: {
721
- cellClass: "",
722
- headerClass: ""
723
- }
724
- }
725
- ];
726
- }
727
- const R = W(() => d === "receive/request" ? n() : v());
728
- return {
729
- get columnDefs() {
730
- return R.value;
731
- }
732
- };
733
- }
734
- const $t = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ct = { class: "flex flex-col gap-8" }, Ft = { class: "flex w-full justify-end gap-16" }, It = /* @__PURE__ */ be({
735
- __name: "FulfillmentForm",
736
- props: {
737
- purchaseOrder: {},
738
- confirm: { type: Function }
739
- },
740
- emits: ["update:show"],
741
- setup(d, { emit: s }) {
742
- const a = d, k = ht({
743
- id: "",
744
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
745
- items: []
746
- }), i = K(), e = s;
747
- return st(() => {
748
- a.purchaseOrder && (k.items = a.purchaseOrder.items.map((c) => ({
749
- id: c.id,
750
- sku: c.sku,
751
- measurement: c.measurement,
752
- amount: c.quantity ?? { amount: 1, precision: 0 }
753
- })));
754
- }), (c, m) => {
755
- const n = G("FmTable"), v = G("FmButton"), R = G("FmForm");
756
- return g(), ae(R, {
757
- ref_key: "formRef",
758
- ref: i,
759
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
760
- onValidationFailed: console.log,
761
- onValidationSuccess: m[1] || (m[1] = () => a.confirm(k))
762
- }, {
763
- default: ce(() => [
764
- m[2] || (m[2] = o("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
765
- o("div", $t, [
766
- o("div", Ct, [
767
- B(n, {
768
- "column-defs": [
769
- {
770
- header: "Code",
771
- cell: (r) => {
772
- const l = a.purchaseOrder.items.find((f) => f.id === r.row.original.id || f.sku._id === r.row.original.sku._id);
773
- return D(
774
- y(Je).FmTooltip,
775
- {
776
- content: l.code,
777
- placement: "top",
778
- variant: "plain",
779
- zIndex: 50
780
- },
781
- D(
782
- "span",
783
- {
784
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
785
- },
786
- l.code
787
- )
788
- );
789
- }
790
- },
791
- {
792
- header: "Name",
793
- cell: (r) => {
794
- const l = a.purchaseOrder.items.find((f) => f.id === r.row.original.id || f.sku._id === r.row.original.sku._id);
795
- return D(
796
- y(Je).FmTooltip,
797
- {
798
- content: l.name,
799
- placement: "top",
800
- variant: "plain",
801
- zIndex: 50
802
- },
803
- D(
804
- "span",
805
- {
806
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
807
- },
808
- l.name
809
- )
810
- );
811
- }
812
- },
813
- {
814
- header: "Amount",
815
- cell: (r) => {
816
- const l = r.row.original, f = a.purchaseOrder.items.find((w) => w.id === l.id || w.sku._id === l.sku._id), b = l.amount ?? {
817
- amount: 1,
818
- precision: 0
819
- };
820
- return D(kt, {
821
- style: {
822
- flex: "1 1 0%"
823
- },
824
- modelValue: {
825
- amount: b,
826
- measurement: l.measurement ?? null
827
- },
828
- key: l.id ?? l.sku._id,
829
- unit: l.sku.unit,
830
- "onUpdate:modelValue": (w) => {
831
- if (!w) return;
832
- const I = k.items.find((L) => L.id === l.id || L.sku._id === l.sku._id);
833
- I && (I.amount = w.amount);
834
- },
835
- disableUnit: !0,
836
- rules: [
837
- y(qt)(
838
- +y(ie)({ amount: 0, precision: 0 })
839
- ),
840
- y(Dt)(+y(ie)(f.quantity))
841
- ],
842
- applyDefaultRules: !0
843
- });
844
- }
845
- }
846
- ],
847
- "row-data": k.items,
848
- "hide-footer": !0
849
- }, null, 8, ["column-defs", "row-data"])
850
- ])
851
- ]),
852
- o("div", Ft, [
853
- B(v, {
854
- class: "px-16",
855
- label: "Confirm",
856
- size: "md",
857
- variant: "primary",
858
- type: "submit"
859
- }),
860
- B(v, {
861
- class: "px-16",
862
- label: "Cancel",
863
- size: "md",
864
- variant: "secondary",
865
- onClick: m[0] || (m[0] = () => e("update:show", !1))
866
- })
867
- ])
868
- ]),
869
- _: 1
870
- }, 8, ["onValidationFailed"]);
871
- };
872
- }
873
- }), Be = {
874
- submitRequest: {
875
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
876
- color: "primary",
877
- buttonVariant: Z.Primary
878
- },
879
- confirmDraft: {
880
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
881
- color: "primary",
882
- buttonVariant: Z.Primary
883
- },
884
- cancelDraft: {
885
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
886
- color: "system-error-300",
887
- buttonVariant: Z.Destructive
888
- },
889
- approveDraft: {
890
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
891
- color: "primary",
892
- buttonVariant: Z.Primary
893
- },
894
- rejectDraft: {
895
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
896
- color: "system-error-300",
897
- buttonVariant: Z.Destructive
898
- },
899
- approveRequest: {
900
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
901
- color: "primary",
902
- buttonVariant: Z.Primary
903
- },
904
- processRequest: {
905
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
906
- color: "primary",
907
- buttonVariant: Z.Primary
908
- },
909
- receiveStock: {
910
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
911
- color: "primary",
912
- buttonVariant: Z.Primary,
913
- available: !1
914
- },
915
- completeReceive: {
916
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
917
- color: "primary",
918
- buttonVariant: Z.Plain
919
- },
920
- rejectRequest: {
921
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
922
- color: "system-error-300",
923
- buttonVariant: Z.Destructive
924
- },
925
- closeRequest: {
926
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
927
- color: "system-error-300",
928
- buttonVariant: Z.Destructive,
929
- available: !1
930
- },
931
- returnStock: {
932
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
933
- color: "primary",
934
- buttonVariant: Z.Primary,
935
- available: !1
936
- }
937
- };
938
- function Bt() {
939
- const d = Ae();
940
- return {
941
- ableToMarkReceived(s) {
942
- if (!s || s.status !== le.enum.RECEIVING)
943
- return !1;
944
- const k = de().currentLocationDBName;
945
- return `${s.supplier.internal}_${s.supplier._id}` !== k;
946
- },
947
- ableToMarkApproved(s) {
948
- return !(!s || (s == null ? void 0 : s.status) !== le.enum.REQUESTING);
949
- },
950
- ableToCreateFulfillment(s, a) {
951
- var e, c;
952
- if (!d.acceptRequireFulfillment || !s || !a || s.status !== le.enum.PROCESSING || !a.processedAt)
953
- return !1;
954
- const k = (e = a == null ? void 0 : a.from) == null ? void 0 : e.dbName, i = (c = a == null ? void 0 : a.to) == null ? void 0 : c.dbName;
955
- return !(k.startsWith("restaurant_") && i.startsWith("restaurant_"));
956
- }
957
- };
958
- }
959
- const Et = { class: "flex flex-row-reverse" }, Lt = /* @__PURE__ */ be({
960
- __name: "NetSuiteSync",
961
- props: {
962
- poRequest: {},
963
- purchaseOrder: {},
964
- isTransferBetweenOutlets: { type: Boolean },
965
- scope: {}
966
- },
967
- setup(d) {
968
- const s = d, a = Ue(), k = Ne(), i = Ve(), e = K(!1);
969
- W(() => {
970
- var R, r, l, f;
971
- let m = !0;
972
- a.isEnabled || (m = !1);
973
- const n = s.purchaseOrder, v = s.poRequest;
974
- return n && ((R = n == null ? void 0 : n.supplier) != null && R.internal ? (!v && n.status == le.enum.DRAFT && (m = !1), v && !((r = v == null ? void 0 : v.netSuite) != null && r.id) && (m = !1), s.isTransferBetweenOutlets && (m = !1)) : ((n == null ? void 0 : n.status) !== le.enum.REQUESTING && n.supplier.internal && (m = !1), !v && !((l = n == null ? void 0 : n.netSuite) != null && l.id) && (m = !1), !v && ((f = n == null ? void 0 : n.netSuite) != null && f.id) && (n == null ? void 0 : n.status) == le.enum.REQUESTING && (m = !1))), m;
975
- });
976
- async function c() {
977
- e.value || i.open({
978
- title: "Sync with NetSuite",
979
- contentComponent: D("div", [
980
- D("p", "Are you sure you want to sync now?"),
981
- D("br"),
982
- D(
983
- "p",
984
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
985
- "Please wait a moment before syncing manually to avoid unnecessary actions."
986
- )
987
- ]),
988
- primaryActions: {
989
- text: "Sync",
990
- close: !0,
991
- variant: "destructive"
992
- },
993
- secondaryActions: { text: "Not now", close: !0 }
994
- }).onPrimary(async () => {
995
- var m, n, v;
996
- try {
997
- e.value = !0;
998
- const R = ((m = s.purchaseOrder) == null ? void 0 : m._id) || ((n = s.poRequest) == null ? void 0 : n.purchaseOrderId) || "", r = (v = s.poRequest) == null ? void 0 : v.to.dbName;
999
- await a.syncPurchaseOrder(
1000
- R,
1001
- s.scope === "approval" ? r : void 0
1002
- ), k.open({
1003
- title: "Sync with NetSuite",
1004
- message: "Requested to sync with NetSuite. Please wait a moment.",
1005
- type: "success"
1006
- }), await new Promise((l) => setTimeout(l, 5e3)), e.value = !1;
1007
- } catch {
1008
- k.open({
1009
- title: "Error",
1010
- message: "Failed to sync with NetSuite",
1011
- type: "error"
1012
- }), e.value = !1;
1013
- }
1014
- });
1015
- }
1016
- return (m, n) => {
1017
- const v = G("FmButton");
1018
- return g(), q("div", Et, [
1019
- B(v, {
1020
- "prepend-icon": "sync",
1021
- variant: "secondary",
1022
- label: "Sync",
1023
- loading: e.value,
1024
- onClick: c,
1025
- "text-color": "primary",
1026
- "bg-color": "transparent",
1027
- "border-color": "primary"
1028
- }, null, 8, ["loading"])
1029
- ]);
1030
- };
1031
- }
1032
- }), Ut = {
1033
- key: 0,
1034
- class: "flex flex-col gap-8"
1035
- }, Vt = { class: "flex flex-col gap-4" }, Mt = { class: "fm-typo-en-body-lg-600" }, Kt = {
1036
- key: 0,
1037
- class: "flex flex-col gap-4"
1038
- }, jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-lg-600" }, Ht = { key: 0 }, Gt = { key: 1 }, Wt = {
1039
- key: 1,
1040
- class: "flex flex-col gap-4"
1041
- }, Yt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Qt = { class: "fm-typo-en-body-lg-600" }, Jt = { key: 0 }, Xt = { key: 1 }, Zt = {
1042
- key: 2,
1043
- class: "flex flex-col gap-4"
1044
- }, er = { class: "fm-typo-en-body-lg-600" }, tr = {
1045
- key: 3,
1046
- class: "flex flex-col gap-4"
1047
- }, rr = { class: "fm-typo-en-body-lg-600" }, sr = /* @__PURE__ */ be({
1048
- __name: "NetSuiteInfo",
1049
- props: {
1050
- transferType: {},
1051
- transferToDbName: {},
1052
- poRequest: {},
1053
- purchaseOrder: {},
1054
- isTransferBetweenOutlets: { type: Boolean },
1055
- scope: {}
1056
- },
1057
- setup(d) {
1058
- const s = d, a = Ue(), k = Te(), i = K(s.poRequest);
1059
- st(async () => {
1060
- var n;
1061
- if (!s.poRequest && ((n = s.purchaseOrder) != null && n._id)) {
1062
- const v = await k.getLatestPurchaseOrderRequest(s.purchaseOrder._id);
1063
- i.value = v;
1064
- }
1065
- });
1066
- const e = W(
1067
- () => {
1068
- var n, v, R, r, l, f;
1069
- return a.getSubsidiaryFullName(
1070
- ((R = (v = (n = s.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : v.subsidiary) == null ? void 0 : R.id) || ((f = (l = (r = s.poRequest) == null ? void 0 : r.netSuite) == null ? void 0 : l.subsidiary) == null ? void 0 : f.id)
1071
- ).fullName;
1072
- }
1073
- ), c = W(() => {
1074
- var n, v, R, r, l, f, b, w, I, L, J, Y;
1075
- return (R = (v = (n = s.purchaseOrder) == null ? void 0 : n.netSuite) == null ? void 0 : v.additionalInfo) != null && R.transactionnumber ? (f = (l = (r = s.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : l.additionalInfo) == null ? void 0 : f.transactionnumber : (I = (w = (b = i.value) == null ? void 0 : b.netSuite) == null ? void 0 : w.additionalInfo) != null && I.transactionnumber ? (Y = (J = (L = i.value) == null ? void 0 : L.netSuite) == null ? void 0 : J.additionalInfo) == null ? void 0 : Y.transactionnumber : null;
1076
- }), m = W(() => {
1077
- var n, v, R, r, l, f;
1078
- return (v = (n = s.purchaseOrder) == null ? void 0 : n.deliveryFullfillment) != null && v.length && ((r = (R = s.purchaseOrder) == null ? void 0 : R.deliveryFullfillment) == null ? void 0 : r.length) > 0 ? (f = (l = s.purchaseOrder) == null ? void 0 : l.deliveryFullfillment) == null ? void 0 : f.map((b) => {
1079
- var w;
1080
- return (w = b.netSuite) == null ? void 0 : w.refNo;
1081
- }).join(", ") : "N/A";
1082
- });
1083
- return (n, v) => {
1084
- var R, r, l, f, b, w, I, L, J, Y, Q, ne, X, me, se, fe;
1085
- return y(a).isEnabled ? (g(), q("div", Ut, [
1086
- o("div", Vt, [
1087
- v[0] || (v[0] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1088
- o("div", Mt, x(e.value || "N/A"), 1)
1089
- ]),
1090
- !n.isTransferBetweenOutlets && n.scope === y(Le).RECEIVE_REQUEST ? (g(), q("div", Kt, [
1091
- o("div", jt, " NetSuite " + x((r = (R = n.purchaseOrder) == null ? void 0 : R.netSuite) != null && r.recordType ? y(rt)((f = (l = n.purchaseOrder) == null ? void 0 : l.netSuite) == null ? void 0 : f.recordType) : n.transferType === y(ue).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1092
- o("div", zt, [
1093
- (w = (b = n.purchaseOrder) == null ? void 0 : b.netSuite) != null && w.id ? (g(), q("span", Ht, x((L = (I = n.purchaseOrder) == null ? void 0 : I.netSuite) == null ? void 0 : L.refNo) + " (" + x((Y = (J = n.purchaseOrder) == null ? void 0 : J.netSuite) == null ? void 0 : Y.id) + ") ", 1)) : (g(), q("span", Gt, "N/A"))
1094
- ])
1095
- ])) : E("", !0),
1096
- !n.isTransferBetweenOutlets && i.value || n.scope === y(Le).APPROVAL ? (g(), q("div", Wt, [
1097
- o("div", Yt, " (Request) NetSuite " + x(n.transferType === y(ue).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1098
- o("div", Qt, [
1099
- (ne = (Q = i.value) == null ? void 0 : Q.netSuite) != null && ne.id ? (g(), q("span", Jt, x((me = (X = i.value) == null ? void 0 : X.netSuite) == null ? void 0 : me.refNo) + " (" + x((fe = (se = i.value) == null ? void 0 : se.netSuite) == null ? void 0 : fe.id) + ") ", 1)) : (g(), q("span", Xt, "N/A"))
1100
- ])
1101
- ])) : E("", !0),
1102
- c.value ? (g(), q("div", Zt, [
1103
- v[1] || (v[1] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1104
- o("div", er, x(c.value), 1)
1105
- ])) : E("", !0),
1106
- y(a).isEnabled && n.transferType === y(ue).TRANSFER && !n.isTransferBetweenOutlets ? (g(), q("div", tr, [
1107
- v[2] || (v[2] = o("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1108
- o("div", rr, x(m.value), 1)
1109
- ])) : E("", !0)
1110
- ])) : E("", !0);
1111
- };
1112
- }
1113
- }), ar = { class: "flex flex-row-reverse" }, nr = /* @__PURE__ */ be({
1114
- __name: "NetSuiteLog",
1115
- props: {
1116
- netsuiteId: {},
1117
- purchaseOrderId: {}
1118
- },
1119
- setup(d) {
1120
- const s = Ne(), a = pt();
1121
- async function k(i, e) {
1122
- let c = `attributes.pod:netsuite* AND body.message:*${i}*`;
1123
- const { url: m } = await a.getLogs(c);
1124
- s.open(
1125
- {
1126
- message: "Opening NetSuite logs...",
1127
- type: "info"
1128
- },
1129
- 800
1130
- ), await new Promise((n) => setTimeout(n, 800)), window.open(m, "_blank");
1131
- }
1132
- return (i, e) => {
1133
- const c = G("FmButton");
1134
- return g(), q("div", ar, [
1135
- B(c, {
1136
- "prepend-icon": "history",
1137
- variant: "secondary",
1138
- label: "Logs",
1139
- onClick: e[0] || (e[0] = (m) => k(i.netsuiteId, i.purchaseOrderId)),
1140
- "text-color": "primary",
1141
- "bg-color": "transparent",
1142
- "border-color": "primary"
1143
- })
1144
- ]);
1145
- };
1146
- }
1147
- }), or = {
1148
- key: 0,
1149
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1150
- }, ir = { class: "flex gap-8 items-center" }, lr = { class: "ml-auto" }, cr = { class: "flex gap-4" }, ur = /* @__PURE__ */ be({
1151
- __name: "NetSuitePanel",
1152
- props: {
1153
- poRequest: {},
1154
- purchaseOrder: {},
1155
- transferType: {},
1156
- transferToDbName: {},
1157
- scope: {}
1158
- },
1159
- setup(d) {
1160
- const s = d, a = At(), k = De(), i = W(() => {
1161
- var n, v, R, r, l, f, b;
1162
- const e = ((n = s.transferToDbName) == null ? void 0 : n.startsWith("restaurant")) && ((R = (v = s.purchaseOrder) == null ? void 0 : v.supplier) == null ? void 0 : R.internal) === "restaurant", c = s.transferType === ue.PURCHASE, m = s.transferType === ue.TRANSFER;
1163
- return c || m && !e || ((l = (r = s.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : l.id) || ((b = (f = s.poRequest) == null ? void 0 : f.netSuite) == null ? void 0 : b.id);
1164
- });
1165
- return (e, c) => {
1166
- var n, v, R, r, l, f;
1167
- const m = G("FmMenuDivider");
1168
- return y(a).isNetSuiteEnabled && i.value ? (g(), q("div", or, [
1169
- o("div", ir, [
1170
- c[0] || (c[0] = o("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1171
- o("div", lr, [
1172
- o("div", cr, [
1173
- (n = y(k).sessionUser.value) != null && n.role.isAdmin && ((R = (v = s.purchaseOrder) == null ? void 0 : v.netSuite) != null && R.id) ? (g(), ae(nr, {
1174
- key: 0,
1175
- "netsuite-id": (l = (r = e.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : l.id,
1176
- "purchase-order-id": (f = e.purchaseOrder) == null ? void 0 : f._id
1177
- }, null, 8, ["netsuite-id", "purchase-order-id"])) : E("", !0),
1178
- B(Lt, {
1179
- "po-request": e.poRequest,
1180
- "purchase-order": e.purchaseOrder,
1181
- "is-transfer-between-outlets": !i.value,
1182
- scope: e.scope
1183
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1184
- ])
1185
- ])
1186
- ]),
1187
- B(m),
1188
- B(sr, {
1189
- "po-request": e.poRequest,
1190
- "purchase-order": e.purchaseOrder,
1191
- "transfer-type": e.transferType,
1192
- "transfer-to-db-name": e.transferToDbName,
1193
- "is-transfer-between-outlets": !i.value,
1194
- scope: e.scope
1195
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1196
- ])) : E("", !0);
1197
- };
1198
- }
1199
- }), dr = { class: "flex flex-col gap-16 w-full h-full" }, mr = { class: "flex justify-between" }, fr = { class: "fm-typo-en-body-lg-600" }, pr = { class: "flex flex-col gap-8" }, yr = { class: "flex flex-col gap-4" }, vr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, hr = { class: "flex gap-1" }, br = { class: "fm-typo-en-body-lg-600" }, gr = {
1200
- key: 0,
1201
- class: "flex flex-col gap-4"
1202
- }, _r = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wr = { class: "fm-typo-en-body-lg-600" }, Sr = { class: "flex flex-col gap-4" }, Rr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, xr = { class: "fm-typo-en-body-lg-600" }, Or = {
1203
- key: 1,
1204
- class: "flex flex-col gap-4"
1205
- }, kr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qr = { class: "fm-typo-en-body-lg-600" }, Dr = {
1206
- key: 2,
1207
- class: "flex flex-col gap-4"
1208
- }, Nr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ar = { class: "fm-typo-en-body-lg-600" }, Tr = {
1209
- key: 3,
1210
- class: "flex flex-col gap-4"
1211
- }, Pr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $r = { class: "fm-typo-en-body-lg-600" }, Cr = {
1212
- key: 4,
1213
- class: "flex flex-col gap-4"
1214
- }, Fr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ir = { class: "fm-typo-en-body-lg-600" }, Br = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Er = { class: "flex flex-col gap-8" }, Lr = { class: "flex gap-8 items-center" }, Ur = { class: "flex-1 fm-typo-en-body-lg-600" }, Vr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Mr = { class: "flex w-full gap-4" }, Kr = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, jr = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, zr = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Hr = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Gr = {
1215
- key: 0,
1216
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1217
- }, Wr = { class: "py-8" }, Yr = { class: "flex justify-end gap-4 items-center" }, Qr = { class: "fm-typo-en-body-lg-600" }, Jr = {
1218
- key: 1,
1219
- class: "flex-1 xs:w-screen xs:max-w-full"
1220
- }, Xr = {
1221
- key: 0,
1222
- class: "flex flex-col items-center gap-8 h-full"
1223
- }, Zr = ["src"], es = { class: "fm-typo-en-body-lg-600" }, ts = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, rs = {
1224
- key: 1,
1225
- class: "px-4 flex flex-col"
1226
- }, ss = { class: "flex gap-12 content-stretch" }, as = {
1227
- class: "flex flex-col w-24",
1228
- name: "circles"
1229
- }, ns = { class: "flex-1 flex flex-col items-center" }, os = { class: "flex-1 flex flex-col items-center" }, is = {
1230
- class: "py-12 flex flex-col gap-4",
1231
- name: "received-at header"
1232
- }, ls = { class: "fm-typo-en-body-lg-400" }, cs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, us = { class: "flex gap-12 content-stretch" }, ds = {
1233
- class: "flex flex-col w-24",
1234
- name: "circles"
1235
- }, ms = { class: "flex-1 flex flex-col items-center" }, fs = {
1236
- class: "py-12 flex flex-col gap-4 flex-1",
1237
- name: "delivery details"
1238
- }, ps = { class: "flex flex-col gap-8" }, ys = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vs = { class: "flex flex-col gap-4" }, hs = { class: "flex gap-8 xs:flex-col" }, Ts = /* @__PURE__ */ be({
1239
- __name: "TransferDetails",
1240
- props: {
1241
- poRequest: {},
1242
- purchaseOrder: {},
1243
- transferTo: {},
1244
- transferToDbName: {},
1245
- show: { type: Boolean },
1246
- canResubmit: { type: Boolean },
1247
- canApprove: { type: Boolean },
1248
- scope: {}
1249
- },
1250
- emits: ["update:show", "submitted"],
1251
- setup(d, { emit: s }) {
1252
- const a = d, k = s, i = Ve(), e = Ne(), c = Ae(), m = de(), n = De(), v = W(
1253
- () => {
1254
- var t, u;
1255
- return {
1256
- id: ((t = n.sessionUser.value) == null ? void 0 : t.id) ?? "",
1257
- name: ((u = n.sessionUser.value) == null ? void 0 : u.displayName) ?? ""
1258
- };
1259
- }
1260
- ), R = Bt(), { t: r } = nt(), l = W(
1261
- () => {
1262
- var t, u, _, h;
1263
- return ((u = (t = a.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : u.internal) === "restaurant" || ((h = (_ = a.purchaseOrder) == null ? void 0 : _.supplier) == null ? void 0 : h.internal) === "warehouse" ? ue.TRANSFER : ue.PURCHASE;
1264
- }
1265
- ), f = K(!1), b = K(""), w = K(!0), I = Te(), L = Nt(I.getWorkflowConfig), J = it(), Y = W(() => {
1266
- if (!a.purchaseOrder)
1267
- return [];
1268
- const t = L.result.value;
1269
- if (t.state === Xe.loading)
1270
- return [];
1271
- const u = {
1272
- user: v.value,
1273
- executedAt: m.locations.computeFirst(
1274
- (h) => {
1275
- var N;
1276
- return h.dbName === ((N = m._currentLocation) == null ? void 0 : N.dbName) ? h : null;
1277
- }
1278
- ),
1279
- purchaseOrderRequest: a.poRequest,
1280
- purchaseOrder: a.purchaseOrder
1281
- };
1282
- let _ = [];
1283
- try {
1284
- t.state === Xe.error ? (console.error("Error fetching workflow config:", t.error), _ = Fe.getAvailableActions({
1285
- ...u,
1286
- orderConfig: Fe.getDefaultConfig()
1287
- }).actions.filter(
1288
- (h) => (
1289
- // TODO: create receiveStock & processRequest dialog
1290
- // to create their payload
1291
- h !== S.enum.receiveStock && h !== S.enum.processRequest && h !== S.enum.closeRequest
1292
- )
1293
- )) : _ = Fe.getAvailableActions({
1294
- ...u,
1295
- orderConfig: t.data
1296
- }).actions.filter(
1297
- (h) => h !== S.enum.receiveStock && h !== S.enum.processRequest && h !== S.enum.closeRequest
1298
- );
1299
- } catch (h) {
1300
- console.error("Error getting available actions:", h);
1301
- }
1302
- return a.scope === "approval" && (_ = _.filter((h) => h !== S.enum.completeReceive)), _;
1303
- }), Q = Ot(a, "show"), ne = W(() => [
1304
- {
1305
- label: r("inventory.transfer.receiveRequest.details.overview"),
1306
- value: "overview"
1307
- },
1308
- {
1309
- label: r("inventory.transfer.receiveRequest.details.deliveryHistory"),
1310
- value: "deliveryHistory"
1311
- }
1312
- ]), X = K(ne.value[0]);
1313
- bt(
1314
- () => a.show,
1315
- (t) => {
1316
- t && (X.value = ne.value[0]);
1317
- }
1318
- );
1319
- async function me(t, u, _, h, N) {
1320
- return new Promise((V, j) => {
1321
- i.open({
1322
- closeButton: !1,
1323
- title: h.title,
1324
- message: h.message,
1325
- primaryActions: h.primaryActions,
1326
- secondaryActions: { text: "No", close: !1 }
1327
- }).onPrimary(async () => {
1328
- var A, P, U, $;
1329
- const p = [];
1330
- _ === S.enum.approveRequest ? (p.push({
1331
- action: "approveRequest",
1332
- payload: null
1333
- }), u.fulfillment && p.push({
1334
- action: "processRequest",
1335
- payload: {
1336
- fulfillmentId: "",
1337
- deliveryOrderNumber: "",
1338
- deliveryRemark: null,
1339
- items: u.fulfillment.items,
1340
- createdBy: v.value
1341
- }
1342
- })) : _ === S.enum.processRequest && u.fulfillment && p.push({
1343
- action: "processRequest",
1344
- payload: {
1345
- fulfillmentId: "",
1346
- deliveryOrderNumber: "",
1347
- deliveryRemark: null,
1348
- items: u.fulfillment.items,
1349
- createdBy: v.value
1350
- }
1351
- });
1352
- try {
1353
- await J({
1354
- operate: {
1355
- operation: _,
1356
- doc: t,
1357
- options: u
1358
- },
1359
- operateV2: {
1360
- _id: ((A = a.purchaseOrder) == null ? void 0 : A._id) ?? "",
1361
- _rev: ((P = a.purchaseOrder) == null ? void 0 : P._rev) ?? "",
1362
- action: _,
1363
- payloads: p
1364
- // add payload if action is receiveStock or processRequest
1365
- },
1366
- transferTo: ($ = (U = a.poRequest) == null ? void 0 : U.to) == null ? void 0 : $.dbName
1367
- }).delayed(1e3), V("submitted");
1368
- } catch (z) {
1369
- j(z);
1370
- }
1371
- }).onSecondary(() => {
1372
- V("cancelled");
1373
- for (let p = 0; p < N + 2; p++)
1374
- i.close();
1375
- }).onClose(() => {
1376
- });
1377
- });
1378
- }
1379
- async function se(t) {
1380
- var h, N, V, j;
1381
- if (t === S.enum.receiveStock)
1382
- return;
1383
- const u = ot[t];
1384
- if (!u) {
1385
- e.open({
1386
- title: "Something went wrong",
1387
- message: `Cannot process order: ${et(t)}`,
1388
- type: "error"
1389
- });
1390
- return;
1391
- }
1392
- const { successMessage: _ } = u;
1393
- if (a.purchaseOrder) {
1394
- b.value = `${t}`, f.value = !0, w.value = !1;
1395
- const p = {};
1396
- let A = 0;
1397
- if ((t === S.enum.confirmDraft || // auto receive for warehouse to warehouse
1398
- t === S.enum.completeReceive) && c.autoReceiveWarehouse)
1399
- p.autoReceive = !0;
1400
- else if ((t === S.enum.approveRequest || t === S.enum.processRequest) && c.acceptRequireFulfillment) {
1401
- const P = (N = (h = a.poRequest) == null ? void 0 : h.from) == null ? void 0 : N.dbName, U = (j = (V = a.poRequest) == null ? void 0 : V.to) == null ? void 0 : j.dbName;
1402
- if (P && U && (P.startsWith("warehouse_") || U.startsWith("warehouse_"))) {
1403
- const $ = await new Promise((z, C) => {
1404
- i.open({
1405
- closeButton: !1,
1406
- title: "Confirm transfer amount",
1407
- dialogComponent: It,
1408
- dialogComponentProps: {
1409
- purchaseOrder: a.purchaseOrder,
1410
- confirm: z,
1411
- "onUpdate:show": (re) => {
1412
- re || (b.value = "", f.value = !1, w.value = !0, A++, i.close()), C("cancelled");
1413
- }
1414
- }
1415
- });
1416
- });
1417
- p.fulfillment = $;
1418
- }
1419
- }
1420
- try {
1421
- await me(
1422
- a.purchaseOrder,
1423
- p,
1424
- t,
1425
- u,
1426
- A
1427
- ) === "submitted" && (e.open({
1428
- title: "Success",
1429
- message: _,
1430
- type: "success"
1431
- }), k("update:show", !1), k("submitted"));
1432
- } catch (P) {
1433
- e.open({
1434
- title: "Something went wrong",
1435
- message: "Please try again.",
1436
- type: "error"
1437
- }), console.error("Error when submitting PO operation", t, a.purchaseOrder, P);
1438
- } finally {
1439
- b.value = "", f.value = !1, w.value = !0;
1440
- }
1441
- }
1442
- }
1443
- const fe = W(() => {
1444
- var t, u;
1445
- return ((t = a.purchaseOrder) == null ? void 0 : t.status) === le.enum.RECEIVING || ((u = a.purchaseOrder) == null ? void 0 : u.status) === le.enum.COMPLETE;
1446
- }), Pe = W(() => {
1447
- var V, j, p;
1448
- const _ = (((V = a.purchaseOrder) == null ? void 0 : V.deliveryOrder) ?? []).flatMap((A) => A.received ?? []).reduce(
1449
- (A, P) => {
1450
- const U = A[P.sku._id] ?? [];
1451
- return A[P.sku._id] = [...U, P], A;
1452
- },
1453
- {}
1454
- ), h = Object.entries(_).reduce(
1455
- (A, [P, U]) => {
1456
- const $ = U.reduce((z, C) => {
1457
- const re = yt(
1458
- z,
1459
- Math.max(z.precision, C.amount.precision)
1460
- );
1461
- return Ee(re, C.amount);
1462
- }, ke(0));
1463
- return A[P] = $, A;
1464
- },
1465
- {}
1466
- ), N = ((j = a.purchaseOrder) == null ? void 0 : j.items) ?? [];
1467
- for (const A of N)
1468
- h[p = A.sku._id] ?? (h[p] = ke(0));
1469
- return h;
1470
- }), oe = W(() => {
1471
- var V, j;
1472
- const t = ((V = a.purchaseOrder) == null ? void 0 : V.deliveryOrder) ?? [], u = ((j = a.purchaseOrder) == null ? void 0 : j.deliveryFullfillment) ?? [], _ = [
1473
- ...t.map((p) => ({
1474
- createdAt: p.createdAt,
1475
- type: "grn",
1476
- doc: p
1477
- })),
1478
- ...u.map((p) => ({
1479
- createdAt: p.createdAt,
1480
- type: "fulfillment",
1481
- doc: p
1482
- }))
1483
- ];
1484
- _.reverse().sort((p, A) => p.createdAt.localeCompare(A.createdAt));
1485
- function h(p) {
1486
- var U, $, z, C, re, ge, _e, we, F;
1487
- const A = u.findIndex((T) => T.id === p.fullfillmentId), P = [
1488
- ($ = (U = u[A]) == null ? void 0 : U.netSuite) != null && $.refNo ? {
1489
- label: "Fulfillment's ref no. (Netsuite)",
1490
- values: [(C = (z = u[A]) == null ? void 0 : z.netSuite) == null ? void 0 : C.refNo]
1491
- } : null,
1492
- (re = p == null ? void 0 : p.netSuite) != null && re.refNo ? {
1493
- label: "Netsuite ref no.",
1494
- values: [(ge = p == null ? void 0 : p.netSuite) == null ? void 0 : ge.refNo]
1495
- } : null,
1496
- (_e = p == null ? void 0 : p.netSuite) != null && _e.recordType ? {
1497
- label: "Netsuite Type",
1498
- values: [rt((we = p == null ? void 0 : p.netSuite) == null ? void 0 : we.recordType)]
1499
- } : null
1500
- ];
1501
- return {
1502
- header: "Received",
1503
- date: $e(new Date(p.createdAt)),
1504
- info: [
1505
- {
1506
- label: "Adjustment date",
1507
- values: [
1508
- p.adjustment ? $e(new Date(vt(p.adjustment))) : "-"
1509
- ]
1510
- },
1511
- {
1512
- label: "Received by",
1513
- values: [(F = p.createdBy) == null ? void 0 : F.name]
1514
- },
1515
- {
1516
- label: "Received items",
1517
- values: p.received.map((T) => {
1518
- var M;
1519
- return D("div", [
1520
- D(
1521
- "div",
1522
- {
1523
- class: "flex gap-4"
1524
- },
1525
- [
1526
- D(
1527
- "div",
1528
- {
1529
- class: "flex flex-col"
1530
- },
1531
- [
1532
- D(
1533
- "span",
1534
- {
1535
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1536
- },
1537
- `${T.sku.name}`
1538
- ),
1539
- D(
1540
- "span",
1541
- {
1542
- class: "fm-typo-en-body-md-400"
1543
- },
1544
- `${T.sku.code} `
1545
- )
1546
- ]
1547
- ),
1548
- D(
1549
- "div",
1550
- {
1551
- class: "ml-auto flex flex-col"
1552
- },
1553
- [
1554
- D(
1555
- "div",
1556
- {
1557
- class: "ml-auto flex gap-1"
1558
- },
1559
- [
1560
- D(
1561
- "span",
1562
- {
1563
- class: "fm-typo-en-body-lg-600 self-end"
1564
- },
1565
- ie(T.amount, !1)
1566
- ),
1567
- D(
1568
- "span",
1569
- {
1570
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1571
- },
1572
- ((M = T.measurement) == null ? void 0 : M.abbrev) ?? T.sku.unit.abbrev
1573
- )
1574
- ]
1575
- ),
1576
- D(
1577
- "div",
1578
- {
1579
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1580
- },
1581
- `${T.cost ? `(${xe(T.cost)})` : ""}`
1582
- )
1583
- ]
1584
- )
1585
- ]
1586
- )
1587
- ]);
1588
- })
1589
- },
1590
- p.deliveryOrderNumber ? {
1591
- label: "Delivery order no.",
1592
- values: [p.deliveryOrderNumber]
1593
- } : null,
1594
- p.remark ? {
1595
- label: "Remark",
1596
- values: [p.remark]
1597
- } : null,
1598
- A > -1 ? {
1599
- label: "Fulfilment's sequence",
1600
- values: [`${A + 1}`]
1601
- } : null,
1602
- ...P
1603
- ].filter((T) => T)
1604
- };
1605
- }
1606
- function N(p) {
1607
- var P, U;
1608
- const A = u.findIndex(($) => $.id === p.id);
1609
- return {
1610
- header: "Fulfillment",
1611
- date: $e(new Date(p.createdAt)),
1612
- info: [
1613
- {
1614
- label: "Sequence",
1615
- values: [String(A + 1)]
1616
- },
1617
- {
1618
- label: "Receiveable items",
1619
- values: p.items.map(($) => {
1620
- var z;
1621
- return D("div", [
1622
- D(
1623
- "div",
1624
- {
1625
- class: "flex gap-4"
1626
- },
1627
- [
1628
- D(
1629
- "div",
1630
- {
1631
- class: "flex flex-col"
1632
- },
1633
- [
1634
- D(
1635
- "span",
1636
- {
1637
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1638
- },
1639
- `${$.sku.name}`
1640
- ),
1641
- D(
1642
- "span",
1643
- {
1644
- class: "fm-typo-en-body-md-400"
1645
- },
1646
- `${$.sku.code} `
1647
- )
1648
- ]
1649
- ),
1650
- D(
1651
- "div",
1652
- {
1653
- class: "ml-auto flex flex-col"
1654
- },
1655
- [
1656
- D(
1657
- "div",
1658
- {
1659
- class: "ml-auto flex gap-1"
1660
- },
1661
- [
1662
- D(
1663
- "span",
1664
- {
1665
- class: "fm-typo-en-body-lg-600 self-end"
1666
- },
1667
- ie($.amount, !1)
1668
- ),
1669
- D(
1670
- "span",
1671
- {
1672
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1673
- },
1674
- ((z = $.measurement) == null ? void 0 : z.abbrev) ?? $.sku.unit.abbrev
1675
- )
1676
- ]
1677
- ),
1678
- D(
1679
- "div",
1680
- {
1681
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1682
- },
1683
- `${$.cost ? `(${xe($.cost)})` : ""}`
1684
- )
1685
- ]
1686
- )
1687
- ]
1688
- )
1689
- ]);
1690
- })
1691
- },
1692
- (P = p.netSuite) != null && P.refNo ? {
1693
- label: "Ref no. (Netsuite)",
1694
- values: [(U = p.netSuite) == null ? void 0 : U.refNo]
1695
- } : null
1696
- ].filter(($) => $)
1697
- };
1698
- }
1699
- return _.map((p) => {
1700
- switch (p.type) {
1701
- case "grn":
1702
- return h(p.doc);
1703
- case "fulfillment":
1704
- return N(p.doc);
1705
- }
1706
- });
1707
- }), O = W(() => {
1708
- var u;
1709
- const t = {
1710
- ...ke(0),
1711
- currency: Qe()
1712
- };
1713
- return ((u = a.purchaseOrder) == null ? void 0 : u.items.reduce((_, h) => ({
1714
- ...Ee(_, h.totalCost ?? t),
1715
- currency: Qe()
1716
- }), t)) ?? t;
1717
- });
1718
- return (t, u) => {
1719
- var $, z;
1720
- const _ = G("FmButtonGroup"), h = G("FmChip"), N = G("FmMenuDivider"), V = G("FmCard"), j = G("FmIcon"), p = G("FmTooltip"), A = G("FmSpacer"), P = G("FmButton"), U = G("FmSideSheet");
1721
- return g(), ae(U, {
1722
- header: y(r)("inventory.transfer.receiveRequest.details.title") + (($ = t.purchaseOrder) != null && $.seqNumber ? ` #${(z = t.purchaseOrder) == null ? void 0 : z.seqNumber}` : ""),
1723
- modelValue: y(Q),
1724
- "onUpdate:modelValue": u[5] || (u[5] = (C) => gt(Q) ? Q.value = C : null),
1725
- "dismiss-away": w.value,
1726
- "close-button": "",
1727
- "max-width": 600
1728
- }, {
1729
- default: ce(() => {
1730
- var C, re, ge, _e, we;
1731
- return [
1732
- o("div", dr, [
1733
- o("div", null, [
1734
- B(_, {
1735
- items: ne.value,
1736
- modelValue: X.value,
1737
- "onUpdate:modelValue": u[0] || (u[0] = (F) => X.value = F)
1738
- }, null, 8, ["items", "modelValue"])
1739
- ]),
1740
- X.value.value === "overview" ? (g(), q(te, { key: 0 }, [
1741
- o("div", null, [
1742
- B(V, {
1743
- variant: "outlined",
1744
- class: "flex flex-col gap-8 px-12 py-16"
1745
- }, {
1746
- default: ce(() => {
1747
- var F, T, M, pe, ye, Re, Me, Ke, je, ze, He, Ge;
1748
- return [
1749
- o("div", mr, [
1750
- o("div", fr, x(y(r)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1751
- o("div", null, [
1752
- B(h, {
1753
- label: y(r)(`inventory.transfer.status.${(F = t.purchaseOrder) == null ? void 0 : F.status}`),
1754
- class: Oe(`fm-status-badge fm-status-badge-${(M = (T = t.purchaseOrder) == null ? void 0 : T.status) == null ? void 0 : M.toLocaleLowerCase("en-us")}`),
1755
- compact: ""
1756
- }, null, 8, ["label", "class"])
1757
- ])
1758
- ]),
1759
- B(N),
1760
- o("div", pr, [
1761
- o("div", yr, [
1762
- o("div", vr, [
1763
- o("div", hr, x(y(r)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1764
- ]),
1765
- o("div", br, x(y(qe)(((pe = t.purchaseOrder) == null ? void 0 : pe._id) ?? "")), 1)
1766
- ]),
1767
- (ye = t.purchaseOrder) != null && ye.effectiveAt ? (g(), q("div", gr, [
1768
- o("div", _r, x(y(r)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1769
- o("div", wr, x(y(tt)(new Date((Re = t.purchaseOrder) == null ? void 0 : Re.effectiveAt))), 1)
1770
- ])) : E("", !0),
1771
- o("div", Sr, [
1772
- o("div", Rr, x(y(r)("inventory.transfer.receiveRequest.details.type.title")), 1),
1773
- o("div", xr, x(y(r)(
1774
- `inventory.transfer.receiveRequest.details.type.${l.value.toLocaleLowerCase("en-US")}`
1775
- )), 1)
1776
- ]),
1777
- (Ke = (Me = t.purchaseOrder) == null ? void 0 : Me.supplier) != null && Ke.name ? (g(), q("div", Or, [
1778
- o("div", kr, x(y(r)("inventory.transfer.receiveRequest.details.from")), 1),
1779
- o("div", qr, x((ze = (je = t.purchaseOrder) == null ? void 0 : je.supplier) == null ? void 0 : ze.name), 1)
1780
- ])) : E("", !0),
1781
- t.transferTo ? (g(), q("div", Dr, [
1782
- o("div", Nr, x(y(r)("inventory.transfer.receiveRequest.details.to")), 1),
1783
- o("div", Ar, x(t.transferTo), 1)
1784
- ])) : E("", !0),
1785
- (He = t.purchaseOrder) != null && He.ref ? (g(), q("div", Tr, [
1786
- o("div", Pr, x(y(r)("inventory.transfer.receiveRequest.details.reference")), 1),
1787
- o("div", $r, x(t.purchaseOrder.ref), 1)
1788
- ])) : E("", !0),
1789
- (Ge = t.purchaseOrder) != null && Ge.remark ? (g(), q("div", Cr, [
1790
- o("div", Fr, x(y(r)("inventory.transfer.receiveRequest.details.remark")), 1),
1791
- o("div", Ir, x(t.purchaseOrder.remark), 1)
1792
- ])) : E("", !0)
1793
- ])
1794
- ];
1795
- }),
1796
- _: 1
1797
- })
1798
- ]),
1799
- B(ur, {
1800
- "po-request": t.poRequest,
1801
- purchaseOrder: t.purchaseOrder,
1802
- transferType: l.value,
1803
- transferToDbName: t.transferToDbName,
1804
- scope: t.scope
1805
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
1806
- o("div", Br, [
1807
- o("div", Er, [
1808
- o("div", Lr, [
1809
- o("span", Ur, [
1810
- Ce(x(fe.value ? y(r)("inventory.transfer.receiveRequest.details.receivedItems") : y(r)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1811
- (re = (C = t.purchaseOrder) == null ? void 0 : C.netSuite) != null && re.missingItems && ((_e = (ge = t.purchaseOrder) == null ? void 0 : ge.netSuite) == null ? void 0 : _e.missingItems.length) > 0 ? (g(), ae(p, {
1812
- key: 0,
1813
- variant: "rich",
1814
- placement: "top",
1815
- "z-index": 51
1816
- }, {
1817
- content: ce(() => {
1818
- var F, T;
1819
- return [
1820
- o("div", Vr, [
1821
- (g(!0), q(te, null, ve((T = (F = t.purchaseOrder) == null ? void 0 : F.netSuite) == null ? void 0 : T.missingItems, (M, pe) => (g(), q("div", {
1822
- class: "flex justify-center align-middle",
1823
- key: pe
1824
- }, [
1825
- B(j, {
1826
- name: "arrow_right",
1827
- size: "sm"
1828
- }),
1829
- Ce(" " + x(`(${M.netSuiteId}) ${M.name}: ${M.reason}`), 1)
1830
- ]))), 128))
1831
- ])
1832
- ];
1833
- }),
1834
- default: ce(() => [
1835
- B(j, {
1836
- name: "error",
1837
- color: "#ff2c2c",
1838
- size: "sm"
1839
- })
1840
- ]),
1841
- _: 1
1842
- })) : E("", !0)
1843
- ])
1844
- ]),
1845
- B(N),
1846
- (g(!0), q(te, null, ve(((we = t.purchaseOrder) == null ? void 0 : we.items) ?? [], (F) => {
1847
- var T;
1848
- return g(), q("div", {
1849
- key: F.code,
1850
- class: "flex flex-col"
1851
- }, [
1852
- o("div", Mr, [
1853
- o("div", Kr, x(F.name), 1),
1854
- o("div", jr, x(y(ie)(Pe.value[F.sku._id], !1)) + "/" + x(y(at)(F.quantity, F.sku.unit, F.measurement)), 1)
1855
- ]),
1856
- o("div", zr, [
1857
- o("div", Hr, x(F.code), 1),
1858
- (T = F.totalCost) != null && T.amount && y(c).enableTotalCost ? (g(), q("div", Gr, " (" + x(y(xe)(F.totalCost)) + ") ", 1)) : E("", !0)
1859
- ])
1860
- ]);
1861
- }), 128)),
1862
- +y(ie)(O.value) ? (g(), q(te, { key: 0 }, [
1863
- o("div", Wr, [
1864
- B(N)
1865
- ]),
1866
- o("div", Yr, [
1867
- u[6] || (u[6] = o("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1868
- o("div", Qr, x(y(xe)(O.value)), 1)
1869
- ])
1870
- ], 64)) : E("", !0)
1871
- ])
1872
- ])
1873
- ], 64)) : X.value.value === "deliveryHistory" ? (g(), q("div", Jr, [
1874
- oe.value.length ? (g(), q("div", rs, [
1875
- (g(!0), q(te, null, ve(oe.value, (F, T) => (g(), q(te, { key: T }, [
1876
- o("div", ss, [
1877
- o("div", as, [
1878
- o("div", ns, [
1879
- o("div", {
1880
- class: Oe([
1881
- {
1882
- "bg-fm-color-primary": T !== 0,
1883
- "bg-white": T === 0
1884
- },
1885
- "w-[2px] h-full"
1886
- ])
1887
- }, null, 2)
1888
- ]),
1889
- u[7] || (u[7] = o("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1890
- o("div", os, [
1891
- o("div", {
1892
- class: Oe([
1893
- {
1894
- "bg-fm-color-primary": T < oe.value.length - 1,
1895
- "bg-white": T >= oe.value.length - 1
1896
- },
1897
- "w-[2px] h-full"
1898
- ])
1899
- }, null, 2)
1900
- ])
1901
- ]),
1902
- o("div", is, [
1903
- o("div", ls, x(F.header), 1),
1904
- o("div", cs, x(F.date), 1)
1905
- ])
1906
- ]),
1907
- o("div", us, [
1908
- o("div", ds, [
1909
- o("div", ms, [
1910
- o("div", {
1911
- class: Oe([
1912
- {
1913
- "bg-fm-color-primary": T < oe.value.length - 1,
1914
- "bg-white": T >= oe.value.length - 1
1915
- },
1916
- "w-[2px] h-full"
1917
- ])
1918
- }, null, 2)
1919
- ])
1920
- ]),
1921
- o("div", fs, [
1922
- B(V, {
1923
- variant: "outlined",
1924
- class: "py-12 px-16"
1925
- }, {
1926
- default: ce(() => [
1927
- o("div", ps, [
1928
- (g(!0), q(te, null, ve(F.info, (M, pe) => (g(), q("div", {
1929
- key: pe,
1930
- class: "flex flex-col gap-4"
1931
- }, [
1932
- o("div", ys, x(M == null ? void 0 : M.label), 1),
1933
- o("div", vs, [
1934
- (g(!0), q(te, null, ve(M == null ? void 0 : M.values, (ye, Re) => (g(), q("div", {
1935
- key: Re,
1936
- class: "fm-typo-en-body-lg-600"
1937
- }, [
1938
- typeof ye == "string" ? (g(), q(te, { key: 0 }, [
1939
- Ce(x(ye), 1)
1940
- ], 64)) : (g(), ae(_t(ye), { key: 1 }))
1941
- ]))), 128))
1942
- ])
1943
- ]))), 128))
1944
- ])
1945
- ]),
1946
- _: 2
1947
- }, 1024)
1948
- ])
1949
- ])
1950
- ], 64))), 128))
1951
- ])) : (g(), q("div", Xr, [
1952
- B(A),
1953
- o("div", null, [
1954
- o("img", {
1955
- src: y(xt),
1956
- alt: "List is empty"
1957
- }, null, 8, Zr)
1958
- ]),
1959
- o("div", es, x(y(r)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1960
- o("div", ts, x(y(r)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1961
- B(A),
1962
- B(A)
1963
- ]))
1964
- ])) : E("", !0)
1965
- ])
1966
- ];
1967
- }),
1968
- "side-sheet-footer": ce(() => [
1969
- o("div", hs, [
1970
- (g(!0), q(te, null, ve(Y.value, (C) => (g(), q(te, null, [
1971
- y(Be)[C].available != !1 ? (g(), ae(P, {
1972
- key: C,
1973
- label: y(r)(y(Be)[C].translationKey),
1974
- onClick: (re) => se(C),
1975
- loading: b.value === C,
1976
- disabled: b.value !== C && f.value,
1977
- variant: y(Be)[C].buttonVariant
1978
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : E("", !0)
1979
- ], 64))), 256)),
1980
- y(R).ableToMarkReceived(t.purchaseOrder) && !Y.value.includes("completeReceive") ? (g(), ae(P, {
1981
- key: 0,
1982
- label: y(r)("inventory.transfer.receiveRequest.actions.completeReceive"),
1983
- onClick: u[1] || (u[1] = (C) => se("completeReceive")),
1984
- loading: b.value === "completeReceive",
1985
- disabled: b.value !== "completeReceive" && f.value
1986
- }, null, 8, ["label", "loading", "disabled"])) : E("", !0),
1987
- y(R).ableToMarkApproved(t.purchaseOrder) && t.canApprove && !Y.value.includes("approveRequest") ? (g(), ae(P, {
1988
- key: 1,
1989
- label: y(r)("inventory.transfer.approval.actions.approveRequest"),
1990
- onClick: u[2] || (u[2] = (C) => se("approveRequest")),
1991
- loading: b.value === "approveRequest",
1992
- disabled: b.value !== "approveRequest" && f.value
1993
- }, null, 8, ["label", "loading", "disabled"])) : E("", !0),
1994
- y(R).ableToCreateFulfillment(t.purchaseOrder, t.poRequest) ? (g(), ae(P, {
1995
- key: 2,
1996
- label: y(r)("inventory.transfer.receiveRequest.actions.processRequest"),
1997
- onClick: u[3] || (u[3] = (C) => se("processRequest")),
1998
- loading: b.value === "processRequest",
1999
- disabled: b.value !== "processRequest" && f.value
2000
- }, null, 8, ["label", "loading", "disabled"])) : E("", !0),
2001
- B(P, {
2002
- label: y(r)("common.close"),
2003
- variant: "tertiary",
2004
- onClick: u[4] || (u[4] = (C) => k("update:show", !1))
2005
- }, null, 8, ["label"])
2006
- ])
2007
- ]),
2008
- _: 1
2009
- }, 8, ["header", "modelValue", "dismiss-away"]);
2010
- };
2011
- }
2012
- });
2013
- export {
2014
- Le as P,
2015
- Ts as _,
2016
- Ns as a,
2017
- As as b,
2018
- Tt as g,
2019
- Te as u
2020
- };