@feedmepos/mf-inventory-portal 1.2.21 → 1.2.22-dev.2

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 (58) hide show
  1. package/dist/{App-W6D-o08-.js → App-DtwLZ9Ng.js} +1 -1
  2. package/dist/{ApprovalView-BZbz53sS.js → ApprovalView-DTiPzA1y.js} +9 -9
  3. package/dist/{BindingsDialog-Dfz4UC2D.js → BindingsDialog--1wB_TX2.js} +2 -2
  4. package/dist/{BindingsPicker-CUZ6fUJL.js → BindingsPicker-JjZfjlvz.js} +9 -9
  5. package/dist/{BindingsTable-DLyW3TKI.js → BindingsTable-M2CGWdTD.js} +1 -1
  6. package/dist/{ClosingDraftView-D8rYJLzL.js → ClosingDraftView-B800NjEZ.js} +101 -101
  7. package/dist/ClosingTemplateView-B1TVIzzy.js +2001 -0
  8. package/dist/{DeliveryOrderPrintPreview-DsA24Pnj.js → DeliveryOrderPrintPreview-CUXfCixj.js} +8 -8
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CSgZa48L.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bdw3Q4Dz.js} +33 -33
  10. package/dist/{FmMultiselectDialog-cBcJaj1q.js → FmMultiselectDialog-CyYcvvyg.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-B7bQq5iJ.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-FDSjxY.js} +49 -49
  12. package/dist/{ImportView-BiGFDwgB.js → ImportView-BR7JpsG8.js} +27 -27
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BxMg3wSa.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-Bae5DUA9.js} +8 -8
  14. package/dist/{IngredientGroupView-cOtXBmbd.js → IngredientGroupView-c6XH5Fzg.js} +17 -17
  15. package/dist/{IngredientsView-CZ5DxCkP.js → IngredientsView-D4JiQ6Bp.js} +72 -73
  16. package/dist/{IntegrationView-DhBH_Vdb.js → IntegrationView-BdOTe6FG.js} +3 -3
  17. package/dist/{InventoryBindingForm-CDD_kUI6.js → InventoryBindingForm-kqrZutMr.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-SyVUEz6e.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DZ-Mr8-U.js} +12 -12
  19. package/dist/{InventoryBindingSummary-BqTUX2Vr.js → InventoryBindingSummary-D4p9cOiy.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Bobv93nw.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Bj_2aQiY.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-TA0bATB6.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CX9H2gLU.js} +7 -7
  22. package/dist/{PublishView-CN3AcICc.js → PublishView-DcQQtuF8.js} +10 -10
  23. package/dist/{PurchaseOrderPrintPreview-DkCHxiUR.js → PurchaseOrderPrintPreview-Ueo4Yftu.js} +13 -13
  24. package/dist/{ReceiveRequestView-Cnk3y0pY.js → ReceiveRequestView-Cikz66hY.js} +115 -115
  25. package/dist/{RecipeView-h5BAcpPp.js → RecipeView-DL1kKy2w.js} +50 -50
  26. package/dist/StockView-DzaCcxc5.js +2384 -0
  27. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BtAp8Jyl.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DP5AFZM2.js} +1 -1
  28. package/dist/{SupplierView-mV32uCUV.js → SupplierView-CJuI_jPc.js} +93 -93
  29. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BoZEbHkN.js +3233 -0
  30. package/dist/{TransferTemplateView-0fDZ7h02.js → TransferTemplateView-DiGdnr0-.js} +140 -140
  31. package/dist/{UnitView-BWeYh3xJ.js → UnitView-CA2isH5r.js} +44 -44
  32. package/dist/{WarehouseView-CgOBUpUw.js → WarehouseView-BMUJN1D1.js} +66 -66
  33. package/dist/api/adjustment-template.d.ts +1 -0
  34. package/dist/api/closing-template.d.ts +1 -0
  35. package/dist/{app-DZsfOzL0.js → app-DdrL4md8.js} +11518 -11220
  36. package/dist/app.d.ts +21 -0
  37. package/dist/app.js +4 -4
  38. package/dist/{decimal-utpTSxBA.js → decimal-DJjE7Vf3.js} +1 -1
  39. package/dist/{format-unit-display-JVq8RwWN.js → format-unit-display-CK-PNM0G.js} +33 -33
  40. package/dist/{import-export.helper-DHZ7P1SR.js → import-export.helper-CJeCekEB.js} +6 -6
  41. package/dist/{index-DNzkuf7T.js → index-Crgf6sCC.js} +1 -1
  42. package/dist/{index-Db0orR3s.js → index-D4F6boO1.js} +1 -1
  43. package/dist/layout/SingleColumnLayout.vue.d.ts +6 -3
  44. package/dist/{purchase-order-template-CkUvuhlD.js → purchase-order-template-BOLP3UzN.js} +1 -1
  45. package/dist/{stock-Cbg0VYIw.js → stock-DqL6z9wL.js} +1 -1
  46. package/dist/{supplier-kyi141cP.js → supplier-CW3GGX9U.js} +1 -1
  47. package/dist/tsconfig.app.tsbuildinfo +1 -1
  48. package/dist/{use-ingredient-select-dialog-ByVlB3un.js → use-ingredient-select-dialog-CrCo-DHA.js} +1 -1
  49. package/dist/{use-inventory-binding-dialog-DhuHKXCT.js → use-inventory-binding-dialog-RdX9Q4q9.js} +1 -1
  50. package/dist/views/adjustment-template/wastage-template/actions.d.ts +60 -0
  51. package/dist/views/adjustment-template/wastage-template/table.d.ts +60 -0
  52. package/dist/views/receive-request/components/delivery-order-form/SystemTrailDialog.vue.d.ts +8 -4
  53. package/dist/views/stock/components/dialog/StockAdjustmentSideSheet.vue.d.ts +20 -0
  54. package/package.json +1 -1
  55. package/dist/ClosingTemplateView-BFMoAEiM.js +0 -1970
  56. package/dist/StockView-D_ACLa2e.js +0 -2160
  57. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BXtVtPx2.js +0 -3394
  58. package/dist/closing-template-ixqnpXdN.js +0 -53
@@ -1,3394 +0,0 @@
1
- import { a7 as ft, u as $e, aW as V, aX as et, aH as ee, c as Ue, b as tt, af as $t, ah as Ct, ai as kt, aY as Dt, e as dt, f as yt, a5 as it, aZ as Rt, ac as vt, $ as ht, l as ve, aa as Nt, a_ as bt, am as Ye, h as De, i as mt, j as me, D as ge, a$ as gt, b0 as ct, b1 as we, aI as At, P as _t, aF as xe, t as Je, a8 as He, a9 as Xe, ae as Ke, Z as Ie, b2 as rt, b3 as Fe } from "./app-DZsfOzL0.js";
2
- import { ref as W, computed as Q, h as P, defineComponent as Se, reactive as Tt, onMounted as St, resolveComponent as M, openBlock as u, createBlock as se, withCtx as Y, createElementVNode as e, createVNode as k, unref as S, createElementBlock as $, toDisplayString as g, createCommentVNode as B, Fragment as ue, renderList as _e, createTextVNode as ke, normalizeClass as Be, watch as Ft, isRef as It, resolveDynamicComponent as Pt } from "vue";
3
- import { F as qt } from "./decimal-utpTSxBA.js";
4
- import { useCoreStore as Ge, useI18n as ut } from "@feedmepos/mf-common";
5
- import { useDialog as Qe, useSnackbar as Me, components as We, FmButtonVariant as be, useProxiedModel as Vt } from "@feedmepos/ui-library";
6
- import { a as Lt, u as Et, P as Pe, f as Bt } from "./format-unit-display-JVq8RwWN.js";
7
- import { E as Ut } from "./empty-placeholder-wf6-BWE8.js";
8
- import { _ as Mt, F as jt, a as zt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-B7bQq5iJ.js";
9
- import { u as Kt, R as pt } from "./usePromise-CbVUCxhj.js";
10
- import { u as Ht } from "./index-Db0orR3s.js";
11
- const qe = ft((O, s) => {
12
- const n = $e(), y = Ge();
13
- return {
14
- async readRequests(l, t, i) {
15
- const r = l ?? n.currentLocationDBName, c = `${O.inventoryBackendUrl}/${r}/purchase-request`;
16
- return t && i ? await s.get(`${c}?startDate=${t}&endDate=${i}`) : await s.get(c);
17
- },
18
- async readRequestById(l, t) {
19
- const i = t ?? n.currentLocationDBName, r = `${O.inventoryBackendUrl}/${i}/purchase-request/${l}`;
20
- return await s.get(r);
21
- },
22
- async readRequestByIds(l, t) {
23
- const i = t ?? n.currentLocationDBName, r = `${O.inventoryBackendUrl}/${i}/purchase-request/find`;
24
- return await s.post(r, { requestIds: l });
25
- },
26
- async getPurchaseOrders({
27
- start: l,
28
- end: t
29
- }) {
30
- const i = n.currentLocationDBName, r = `${O.inventoryBackendUrl}/${i}/purchase-order`;
31
- return await s.get(`${r}?start=${l}&end=${t}`);
32
- },
33
- async getLatestPurchaseOrderRequest(l) {
34
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/purchase-request/find-by-purchase-order-id`;
35
- return await s.get(`${i}/${l}`);
36
- },
37
- async getPurchaseOrderById(l) {
38
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/purchase-order`;
39
- return await s.get(`${i}/${l}`);
40
- },
41
- /**
42
- * @deprecated Use `processPurchaseOrderV2` instead.
43
- */
44
- async processPurchaseOrder(l, t) {
45
- const i = n.currentLocationDBName, r = t || i, c = `${O.inventoryBackendUrl}/${r}/purchase-order/run-operation`;
46
- return await s.put(c, l);
47
- },
48
- async createPurchaseOrder(l) {
49
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/purchase-order`;
50
- return await s.post(i, l);
51
- },
52
- async updatePurchaseOrder(l) {
53
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/purchase-order`;
54
- return await s.put(i, l);
55
- },
56
- async importFromXilnex(l) {
57
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/purchase-order/import-from-xilnex`;
58
- return await s.post(i, l);
59
- },
60
- async processPurchaseOrderV2(l, t) {
61
- const i = n.currentLocationDBName, r = t || i, c = `${O.inventoryBackendUrl}/${r}/v2/purchase-order/run-operation`;
62
- return await s.put(c, l);
63
- },
64
- async getWorkflowConfig() {
65
- var r;
66
- const t = `business_${(r = y.currentBusiness.value) == null ? void 0 : r._id}`, i = `${O.inventoryBackendUrl}/${t}/v2/purchase-order/workflow-config`;
67
- return await s.get(i);
68
- },
69
- async updateDeliveryOrder(l) {
70
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/delivery-order`;
71
- return await s.put(i, l);
72
- },
73
- async createDeliveryOrder(l) {
74
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/delivery-order`;
75
- return await s.post(i, l);
76
- },
77
- async getDeliveryOrderTrails(l, t) {
78
- const i = n.currentLocationDBName, r = `${O.inventoryBackendUrl}/${i}/delivery-order/audit-trails`;
79
- return await s.post(r, { purchaseOrderId: l, deliveryOrderId: t });
80
- }
81
- };
82
- }), Wt = ft((O, s) => {
83
- const n = $e();
84
- return {
85
- async getShipments({
86
- start: y,
87
- end: l
88
- }) {
89
- const t = n.currentLocationDBName, i = `${O.inventoryBackendUrl}/${t}/shipments`;
90
- return await s.get(`${i}?start=${y}&end=${l}`);
91
- },
92
- async getShipmentsByIds(y) {
93
- if (y.length === 0)
94
- return [];
95
- const l = n.currentLocationDBName, t = `${O.inventoryBackendUrl}/${l}/shipments/get`;
96
- return await s.post(t, { shipmentIds: y });
97
- }
98
- };
99
- }), Ot = {
100
- [V.enum.confirmDraft]: {
101
- primaryActions: {
102
- text: "Confirm draft",
103
- close: !0
104
- },
105
- title: "Confirm draft?",
106
- message: "Purchase order cannot be changed after confirm draft.",
107
- successMessage: "Purchase order draft has been confirmed"
108
- },
109
- [V.enum.cancelDraft]: {
110
- primaryActions: {
111
- text: "Cancel draft",
112
- close: !0,
113
- variant: "destructive"
114
- },
115
- title: "Cancel draft?",
116
- message: "Purchase order cannot be changed after cancelled draft.",
117
- successMessage: "Purchase order draft has been cancelled"
118
- },
119
- [V.enum.submitRequest]: {
120
- primaryActions: {
121
- text: "Submit request",
122
- close: !0
123
- },
124
- title: "Confirm draft?",
125
- message: "Purchase order cannot be changed after confirm draft.",
126
- successMessage: "Purchase order draft has been submitted"
127
- },
128
- [V.enum.completeReceive]: {
129
- primaryActions: {
130
- text: "Mark received",
131
- close: !0
132
- },
133
- title: "Mark as received",
134
- message: "Purchase order cannot be changed after it has complete receiving.",
135
- successMessage: "Purchase order has been marked as received"
136
- },
137
- [V.enum.approveRequest]: {
138
- primaryActions: {
139
- text: "Accept request",
140
- close: !0
141
- },
142
- title: "Accept request?",
143
- message: "Transfer out request will be accepted.",
144
- successMessage: "Transfer out request has been approved"
145
- },
146
- [V.enum.rejectRequest]: {
147
- primaryActions: {
148
- text: "Reject request",
149
- close: !0,
150
- variant: "destructive"
151
- },
152
- title: "Reject request?",
153
- message: "Purchase order will be rejected.",
154
- successMessage: "Purchase order has been rejected"
155
- },
156
- [V.enum.processRequest]: {
157
- primaryActions: {
158
- text: "Process request",
159
- close: !0,
160
- variant: "destructive"
161
- },
162
- title: "Process request?",
163
- message: "Purchase order will be processed.",
164
- successMessage: "Purchase order has been processed"
165
- }
166
- };
167
- function Ze(O) {
168
- return et.generatedPOReceivedMap({
169
- purchaseOrder: O
170
- });
171
- }
172
- function Gt(O) {
173
- return et.validatePOItemReceivedStatus({
174
- dto: O
175
- });
176
- }
177
- function nt(O) {
178
- return et.validatePOReceivedStatus({
179
- receivedMap: O
180
- });
181
- }
182
- function at(O, s, n) {
183
- if (!ee.safeParse(O).success)
184
- throw new Error(`Invalid purchase order status: ${O}`);
185
- const y = ee.parse(O);
186
- return et.orderStatusCombination({
187
- status: y,
188
- isPOPartialReceive: s,
189
- isPOOverReceive: n
190
- });
191
- }
192
- function wt() {
193
- const O = $e(), s = qe(), n = Ue();
194
- async function y(t, i) {
195
- const r = O.currentLocationDBName;
196
- return t.doc.supplier.internal && t.operation === V.enum.confirmDraft && (t.operation = V.enum.submitRequest), await s.processPurchaseOrder(t, i || r);
197
- }
198
- async function l(t, i) {
199
- const r = O.currentLocationDBName;
200
- return await s.processPurchaseOrderV2(t, i || r);
201
- }
202
- return (t) => n.useOperatePurchaseOrderV2 ? l(t.operateV2, t.transferTo) : y(t.operate, t.transferTo);
203
- }
204
- var lt = /* @__PURE__ */ ((O) => (O.RECEIVE_REQUEST = "receive/request", O.APPROVAL = "approval", O))(lt || {});
205
- const ze = W(), st = W();
206
- function Pn(O, s) {
207
- const n = Qe(), y = $e(), l = Ue();
208
- tt();
209
- const t = Lt(), i = Et(), r = W(!1), c = Me(), x = qe(), h = Wt(), m = W(new Array()), A = W(new Array()), _ = W(
210
- s != null && s.startDate && (s != null && s.endDate) ? s : $t()
211
- ), D = Q(() => {
212
- const q = new Date(_.value.startDate), U = new Date(_.value.endDate);
213
- return {
214
- start: Ct(q).toISOString(),
215
- end: kt(U).toISOString()
216
- };
217
- }), d = W(new Array()), a = Dt(), b = W(null);
218
- async function f(q) {
219
- function U(N) {
220
- const C = {
221
- mode: dt.CREATE,
222
- modelValue: q || void 0,
223
- show: !0,
224
- "onUpdate:show"(I) {
225
- ze.value.show = I;
226
- },
227
- templateId: N,
228
- lastClosingDate: b.value
229
- };
230
- ze.value = C;
231
- }
232
- let ae;
233
- l.mustUsePoTemplate && !(q != null && q.template) ? n.open({
234
- title: "Create transfer",
235
- message: "",
236
- primaryActions: {
237
- text: "Select a template",
238
- close: !0
239
- },
240
- secondaryActions: {
241
- text: "Outlet to Outlet",
242
- variant: "secondary",
243
- close: !0
244
- }
245
- }).onPrimary(async () => {
246
- ae = await t.getTemplateId(), ae && U(ae);
247
- }).onSecondary(() => {
248
- U(void 0);
249
- }) : U(ae);
250
- }
251
- function w(q) {
252
- const U = {
253
- mode: dt.UPDATE,
254
- modelValue: yt(q),
255
- show: !0,
256
- "onUpdate:show"(ae) {
257
- ze.value.show = ae;
258
- },
259
- lastClosingDate: b.value
260
- };
261
- ze.value = U;
262
- }
263
- async function L() {
264
- m.value = [], A.value = [], r.value = !0;
265
- try {
266
- const q = await x.getPurchaseOrders(D.value);
267
- m.value = q.sort((j, o) => o._id.localeCompare(j._id));
268
- const U = q.flatMap((j) => j.shipmentIds || []).filter(Boolean), ae = U.length > 0 ? await h.getShipmentsByIds(U) : [];
269
- A.value = ae;
270
- const N = await a.readCurrentLocationLastClosing(!0), C = N == null ? void 0 : N._id;
271
- C && (b.value = Rt(C)), await l.awaitFeatureLoaded(() => l.mustUsePoTemplate) && await i.fetchTemplates();
272
- const I = m.value.map((j) => {
273
- var o;
274
- return ((o = j.request) == null ? void 0 : o.id) ?? "";
275
- }).filter((j) => j);
276
- d.value = await x.readRequestByIds(I);
277
- } catch {
278
- c.open({
279
- title: "Something went wrong",
280
- message: "Error at fetching purchase orders",
281
- type: "error"
282
- });
283
- } finally {
284
- r.value = !1;
285
- }
286
- }
287
- async function G() {
288
- d.value = [], r.value = !0;
289
- try {
290
- d.value = await x.readRequests(
291
- void 0,
292
- D.value.start,
293
- D.value.end
294
- ).then((q) => q.reverse());
295
- } catch {
296
- c.open({
297
- title: "Something went wrong",
298
- message: "Error at fetching purchase requests",
299
- type: "error"
300
- });
301
- } finally {
302
- r.value = !1;
303
- }
304
- }
305
- function F() {
306
- switch (O) {
307
- case "receive/request":
308
- return L();
309
- case "approval":
310
- return G();
311
- }
312
- }
313
- function J(q, U) {
314
- _.value = {
315
- startDate: q,
316
- endDate: U
317
- }, F();
318
- }
319
- y.watchLocation(async (q) => {
320
- if (!q) {
321
- m.value = [];
322
- return;
323
- }
324
- await F();
325
- });
326
- const X = W(), re = W(Math.random().toString());
327
- async function pe(q, U) {
328
- const ae = Math.random().toString();
329
- re.value = ae, U ?? (U = d.value.computeFirst(
330
- (j) => j.purchaseOrderId === q._id ? j : null
331
- ) ?? void 0);
332
- const N = O === "receive/request" ? y.currentLocation : U == null ? void 0 : U.to, C = O === "approval", I = {
333
- poRequest: U,
334
- purchaseOrder: {
335
- ...q,
336
- status: C && (U != null && U.rejectedAt) ? ee.Enum.REJECT : q.status
337
- },
338
- transferTo: N == null ? void 0 : N.name,
339
- transferToDbName: N == null ? void 0 : N.dbName,
340
- show: !0,
341
- canResubmit: !1,
342
- canApprove: C,
343
- "onUpdate:show"(j) {
344
- X.value.show = j;
345
- },
346
- scope: O,
347
- receivedMap: Ze(q) ?? {},
348
- shipments: A.value
349
- };
350
- X.value = I;
351
- }
352
- async function fe(q, U, ae, N) {
353
- const C = wt();
354
- r.value = !0;
355
- try {
356
- await C({
357
- operate: {
358
- operation: U,
359
- doc: q,
360
- options: (
361
- // auto receive for supplier to warehouse
362
- (U === V.enum.confirmDraft || // auto receive for warehouse to warehouse
363
- U === V.enum.completeReceive) && l.autoReceiveWarehouse ? {
364
- autoReceive: !0
365
- } : void 0
366
- )
367
- },
368
- operateV2: {
369
- _id: q._id,
370
- _rev: q._rev ?? "",
371
- action: U,
372
- payloads: []
373
- },
374
- transferTo: N
375
- }), await new Promise((o) => setTimeout(o, 1e3));
376
- const j = $e().currentLocationDBName.startsWith("restaurant_");
377
- U === V.enum.confirmDraft && q.effectiveAt && j ? c.open({
378
- title: "Success",
379
- message: `${ae}. The backdate will be reflected once your POS has received this change.`,
380
- type: "success"
381
- }) : c.open({
382
- title: "Success",
383
- message: ae,
384
- type: "success"
385
- });
386
- } catch (I) {
387
- c.open({
388
- title: "Something went wrong",
389
- message: "Please try again.",
390
- type: "error"
391
- }), console.error("Error when submitting PO operation", U, q, I);
392
- } finally {
393
- r.value = !1, F();
394
- }
395
- }
396
- async function Re(q, U, ae) {
397
- const N = Ot[U];
398
- if (!N) {
399
- c.open({
400
- title: "Something went wrong",
401
- message: `Cannot process order: ${it(U)}`,
402
- type: "error"
403
- });
404
- return;
405
- }
406
- const { successMessage: C, ...I } = N;
407
- n.open({
408
- title: I.title,
409
- message: I.message,
410
- primaryActions: I.primaryActions
411
- }).onPrimary(() => {
412
- fe(q, U, C, ae);
413
- });
414
- }
415
- async function Ve() {
416
- n.open({
417
- title: "Upload Transfer",
418
- primaryActions: {
419
- text: "Xilnex transfer note",
420
- close: !0
421
- },
422
- secondaryActions: {
423
- text: "Cancel",
424
- close: !0
425
- }
426
- }).onPrimary(() => {
427
- const q = {
428
- show: !0,
429
- "onUpdate:show"(U) {
430
- st.value.show = U;
431
- }
432
- };
433
- st.value = q;
434
- });
435
- }
436
- return {
437
- purchaseOrders: m,
438
- shipments: A,
439
- purchaseRequests: d,
440
- updateDateRange: J,
441
- fetchData: F,
442
- loading: r,
443
- transferDialogProps: ze,
444
- promptCreateTransferDialog: f,
445
- promptUpdateTransferDialog: w,
446
- transferDetailsProps: X,
447
- promptShowTransferDetails: pe,
448
- submitAction: Re,
449
- xilnexImportDialogProps: st,
450
- promptUploadTransferDialog: Ve
451
- };
452
- }
453
- function Qt(O, s) {
454
- return s.reduce(
455
- (y, l) => {
456
- const t = l.received.find((i) => i.sku._id === O._id);
457
- return t && (y = vt(y, t.amount)), y;
458
- },
459
- qt.toPrecision(ht(0), O.unit.precision)
460
- );
461
- }
462
- function Yt(O) {
463
- const { po: s, currentLocation: n, business: y, fulfilling: l, por: t } = O, { name: i, address: r, regNo: c } = n.doc.profile, x = {
464
- name: i,
465
- registrationNumber: c,
466
- line1: r == null ? void 0 : r.line1,
467
- line2: r == null ? void 0 : r.line2,
468
- postcode: r == null ? void 0 : r.postcode,
469
- city: r == null ? void 0 : r.city,
470
- state: r == null ? void 0 : r.state,
471
- country: r == null ? void 0 : r.country
472
- }, h = {
473
- name: s.supplier.name,
474
- phoneNumber: s.supplier.phoneNumber,
475
- registrationNumber: s.supplier.registrationNumber,
476
- line1: s.supplier.address.line1,
477
- line2: s.supplier.address.line2,
478
- postcode: s.supplier.address.postcode,
479
- city: s.supplier.address.city,
480
- state: s.supplier.address.state,
481
- country: s.supplier.address.country
482
- }, m = s.items.map((w) => {
483
- const { sku: L, measurement: G } = w, F = ve(
484
- Qt(w.sku, s.deliveryOrder || []),
485
- !1
486
- );
487
- return {
488
- code: L.code,
489
- description: L.name,
490
- quantity: ve(w.quantity, !1),
491
- unit: (G == null ? void 0 : G.abbrev) || L.unit.abbrev,
492
- received: F,
493
- cost: w.totalCost ? `${w.totalCost.currency} ${Nt.toFormatString({
494
- value: w.totalCost
495
- })}` : void 0
496
- };
497
- }), A = s.deliveryOrder.map((w) => ({
498
- createdAt: bt(new Date(w.createdAt)),
499
- ref: w.deliveryOrderNumber,
500
- remark: w.remark || "",
501
- items: w.received.map((L) => {
502
- var G;
503
- return {
504
- code: L.sku.code,
505
- description: L.sku.name,
506
- quantity: ve(L.amount),
507
- unit: ((G = L.measurement) == null ? void 0 : G.abbrev) || L.sku.unit.abbrev
508
- };
509
- })
510
- })), _ = [
511
- // Production
512
- "67ca5d2c80bd0e001c5bf5bc",
513
- // Dev
514
- "6880b36a3054c5001db19218"
515
- ];
516
- let D = "Inventory Receive Note";
517
- if (s.supplier.internal ? (D = "Inventory Transfer Note", _.includes((y == null ? void 0 : y._id) || "") && (D = "Stock Request")) : D = "Purchase Order", t) {
518
- const w = t.from.dbName;
519
- n.dbName === w || (D = "Inventory Receive Note");
520
- }
521
- const a = {
522
- title: D,
523
- businessName: y == null ? void 0 : y.name,
524
- logo: y == null ? void 0 : y.thumbnail,
525
- orderNumber: s.seqNumber.toString(),
526
- createdAt: Ye(s._id),
527
- ref: s.ref || "",
528
- remark: s.remark || "",
529
- buyer: x,
530
- supplier: h,
531
- items: m,
532
- status: s.status,
533
- deliveryOrders: A
534
- }, b = new URL(window.location.href), f = l && (s.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
535
- b.pathname = b.hostname.includes("portal.feedme") ? `/inventory/${f}` : `/${f}`, b.searchParams.append("data", JSON.stringify(a)), window.open(b.href, "_blank", "noreferrer");
536
- }
537
- const Ee = {
538
- submitRequest: {
539
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
540
- color: "text-fm-color-typo-primary",
541
- value: V.enum.submitRequest
542
- },
543
- confirmDraft: {
544
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
545
- color: "text-fm-color-typo-primary",
546
- value: V.enum.confirmDraft
547
- },
548
- cancelDraft: {
549
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
550
- color: "text-fm-color-typo-error",
551
- value: V.enum.cancelDraft
552
- },
553
- approveRequest: {
554
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
555
- color: "text-fm-color-typo-primary",
556
- value: V.enum.approveRequest
557
- },
558
- rejectRequest: {
559
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
560
- color: "text-fm-color-typo-error",
561
- value: V.enum.rejectRequest
562
- },
563
- processRequest: {
564
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
565
- color: "text-fm-color-typo-primary",
566
- value: V.enum.processRequest
567
- },
568
- receiveStock: {
569
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
570
- color: "text-fm-color-typo-primary",
571
- value: V.enum.receiveStock
572
- },
573
- completeReceive: {
574
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
575
- color: "text-fm-color-typo-primary",
576
- value: V.enum.completeReceive
577
- },
578
- closeRequest: {
579
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
580
- color: "system-error-300",
581
- value: V.enum.closeRequest
582
- },
583
- approveDraft: {
584
- translationKey: "",
585
- color: "",
586
- value: void 0
587
- },
588
- rejectDraft: {
589
- translationKey: "",
590
- color: "",
591
- value: void 0
592
- },
593
- returnStock: {
594
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
595
- color: "text-fm-color-typo-primary",
596
- value: V.enum.returnStock
597
- }
598
- };
599
- function qn(O, s, n) {
600
- const y = $e(), l = tt(), t = Ge(), { t: i } = ut();
601
- function r(_) {
602
- switch (_.status) {
603
- case "DRAFT":
604
- return [
605
- ge[me.Update],
606
- ge[me.Details],
607
- _.supplier.internal === "restaurant" || _.supplier.internal === "warehouse" ? Ee[V.enum.submitRequest] : Ee[V.enum.confirmDraft],
608
- Ee[V.enum.cancelDraft]
609
- ];
610
- case "RECEIVING":
611
- return [
612
- Ee[V.enum.completeReceive],
613
- ge[me.Details],
614
- ge[me.Print]
615
- ];
616
- case "REQUESTING":
617
- return O === "receive/request" ? [ge[me.Details], ge[me.Print]] : [
618
- Ee[V.enum.approveRequest],
619
- Ee[V.enum.rejectRequest],
620
- ge[me.Details]
621
- // DefaultRowActions[RowActionEnum.Print]
622
- ];
623
- case "PROCESSING":
624
- return [ge[me.Details], ge[me.Print]];
625
- case "COMPLETE":
626
- case "CANCEL":
627
- default:
628
- return [ge[me.Details], ge[me.Print]];
629
- }
630
- }
631
- function c(_) {
632
- return Object.values(V.enum).includes(_);
633
- }
634
- async function x(_, D, d) {
635
- var b, f, w, L, G, F;
636
- const a = yt(D);
637
- if (_ === me.Print) {
638
- const J = (d == null ? void 0 : d.toInventoryLocation) ?? y.currentLocation;
639
- ((b = d == null ? void 0 : d.netSuite) != null && b.refNo || (f = a.netSuite) != null && f.refNo) && (a.ref = [((w = d == null ? void 0 : d.netSuite) == null ? void 0 : w.refNo) || ((L = a.netSuite) == null ? void 0 : L.refNo)].filter((X) => X).join(" ")), Yt({
640
- po: a,
641
- currentLocation: J,
642
- business: t.currentBusiness.value,
643
- fulfilling: O === "approval",
644
- por: d
645
- });
646
- return;
647
- }
648
- if (_ === me.Details) {
649
- s.promptShowTransferDetails(a, d);
650
- return;
651
- }
652
- if (_ === me.Update) {
653
- (G = s.promptUpdateTransferDialog) == null || G.call(s, a);
654
- return;
655
- }
656
- if (c(_)) {
657
- s.submitAction(D, _, (F = d == null ? void 0 : d.to) == null ? void 0 : F.dbName);
658
- return;
659
- }
660
- }
661
- function h() {
662
- var D;
663
- const _ = [
664
- {
665
- accessorKey: "seqNumber",
666
- header: () => i("inventory.transfer.table.seqNo"),
667
- enableSorting: !0,
668
- size: 80,
669
- sortUndefined: "last"
670
- },
671
- {
672
- accessorKey: "_id",
673
- header: () => i("inventory.transfer.table.createdAt"),
674
- cell(d) {
675
- return Ye(`${d.getValue()}`);
676
- },
677
- enableSorting: !0
678
- },
679
- {
680
- accessorKey: "supplier.name",
681
- header: () => i("inventory.transfer.table.transferFrom"),
682
- enableSorting: !0,
683
- size: 200
684
- },
685
- {
686
- accessorKey: "items.length",
687
- header: () => i("inventory.transfer.table.noOfItems"),
688
- cell: (d) => {
689
- const a = d.row.original.version || "1", b = d.getValue();
690
- return P("div", { class: "flex items-center gap-2" }, [
691
- b,
692
- a !== "1" ? P(
693
- "div",
694
- { class: "py-3" },
695
- P(
696
- De,
697
- P(
698
- "div",
699
- {
700
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
701
- },
702
- `v${a}`
703
- )
704
- )
705
- ) : null
706
- ]);
707
- },
708
- enableSorting: !1,
709
- meta: {
710
- width: "10rem"
711
- }
712
- },
713
- {
714
- accessorKey: "ref",
715
- header: () => i("inventory.transfer.table.reference"),
716
- enableSorting: !1,
717
- size: "auto"
718
- },
719
- ...(D = t.sessionUser.value) != null && D.role.isAdmin ? [
720
- {
721
- id: "statusForAdmin",
722
- header: () => P(De, {}, () => `${i("inventory.transfer.table.status")}`),
723
- cell(d) {
724
- return d.row.original.status;
725
- },
726
- enableSorting: !0,
727
- size: 200
728
- }
729
- ] : [],
730
- {
731
- accessorKey: "status",
732
- header: () => i("inventory.transfer.table.status"),
733
- cell(d) {
734
- const a = d.getValue(), b = Ze(d.row.original), { partial: f, over: w } = nt(b), L = at(a ?? "", f, w);
735
- let G = i(`inventory.transfer.status.${L}`), F = `${a ?? ""}`.toLocaleLowerCase("en-us");
736
- L === ee.enum.CLOSE && (G = `${i(`inventory.transfer.status.${ee.enum.COMPLETE}`)}`), L === "PARTIAL_RECEIVED" && F === ee.enum.PROCESSING.toLocaleLowerCase("en-us") && (F = ee.enum.RECEIVING.toLocaleLowerCase("en-us"));
737
- let J = null;
738
- const X = n.value.find((re) => re.ref === d.row.original._id);
739
- if (X != null && X.milestones && X.milestones.length > 0) {
740
- const re = X.milestones[X.milestones.length - 1];
741
- if (re.estimatedTime) {
742
- const pe = new Date(re.estimatedTime), fe = pe.getDate().toString().padStart(2, "0");
743
- J = `${pe.toLocaleString("en-US", { month: "short" })} ${fe}`;
744
- }
745
- }
746
- return P(
747
- "div",
748
- {
749
- class: "flex"
750
- },
751
- [
752
- P(
753
- "div",
754
- { class: "flex items-center" },
755
- P(
756
- "div",
757
- {
758
- class: [
759
- "fm-status-badge",
760
- `fm-status-badge-${F}`,
761
- w && "fm-status-badge-error"
762
- ].filter(Boolean).join(" ")
763
- },
764
- `${G}`
765
- )
766
- ),
767
- ...J ? [
768
- P(
769
- "div",
770
- {
771
- class: "flex items-center gap-1 ml-2"
772
- },
773
- [
774
- P(We.FmIcon, {
775
- name: "local_shipping",
776
- size: "md",
777
- color: "neutral-gray-400"
778
- }),
779
- P(
780
- "span",
781
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
782
- J
783
- )
784
- ]
785
- )
786
- ] : []
787
- ]
788
- );
789
- },
790
- enableSorting: !0,
791
- size: 150
792
- },
793
- {
794
- id: "action",
795
- cell(d) {
796
- const a = d.row.original, b = r(a);
797
- return mt(b, (f) => x(f, a));
798
- },
799
- enableSorting: !1,
800
- size: 40,
801
- meta: {
802
- cellClass: "",
803
- headerClass: ""
804
- }
805
- }
806
- ];
807
- if (l.isEnabled) {
808
- const d = [
809
- {
810
- id: "netsuiteTransferOrder",
811
- accessorFn: (a) => {
812
- var b;
813
- return (b = a.netSuite) != null && b.id ? `${a.netSuite.refNo} (${a.netSuite.id})` : "N/A";
814
- },
815
- header: () => "NetSuite Order (ID)",
816
- cell(a) {
817
- var f;
818
- const b = a.row.original;
819
- return (f = b.netSuite) != null && f.id ? `${b.netSuite.refNo} (${b.netSuite.id})` : "N/A";
820
- },
821
- enableSorting: !1,
822
- size: 200,
823
- meta: {
824
- cellClass: "",
825
- headerClass: ""
826
- }
827
- },
828
- {
829
- id: "netsuiteTransactionNumber",
830
- accessorFn: (a) => {
831
- var b, f;
832
- return ((f = (b = a.netSuite) == null ? void 0 : b.additionalInfo) == null ? void 0 : f.transactionnumber) ?? "N/A";
833
- },
834
- header: () => "NetSuite Transaction No.",
835
- cell(a) {
836
- var f, w;
837
- return ((w = (f = a.row.original.netSuite) == null ? void 0 : f.additionalInfo) == null ? void 0 : w.transactionnumber) ?? "N/A";
838
- },
839
- enableSorting: !1,
840
- size: 200,
841
- meta: {
842
- cellClass: "",
843
- headerClass: ""
844
- }
845
- }
846
- ];
847
- _.splice(_.length - 1, 0, ...d);
848
- }
849
- return _;
850
- }
851
- function m() {
852
- var D;
853
- const _ = [
854
- {
855
- accessorKey: "purchaseOrder.seqNumber",
856
- header: () => i("inventory.transfer.table.seqNo"),
857
- enableSorting: !0,
858
- size: 80,
859
- sortUndefined: "last"
860
- },
861
- {
862
- accessorKey: "purchaseOrder._id",
863
- header: () => i("inventory.transfer.table.createdAt"),
864
- cell(d) {
865
- return Ye(`${d.getValue()}`);
866
- },
867
- enableSorting: !0
868
- },
869
- {
870
- accessorKey: "to.name",
871
- header: () => i("inventory.transfer.table.transferTo"),
872
- enableSorting: !1,
873
- size: 200
874
- },
875
- {
876
- accessorKey: "purchaseOrder.items.length",
877
- header: () => i("inventory.transfer.table.noOfItems"),
878
- enableSorting: !1
879
- },
880
- {
881
- accessorKey: "purchaseOrder.ref",
882
- header: () => i("inventory.transfer.table.reference"),
883
- enableSorting: !1,
884
- size: "auto"
885
- },
886
- ...(D = t.sessionUser.value) != null && D.role.isAdmin ? [
887
- {
888
- id: "statusForAdmin",
889
- header: () => P(De, {}, () => `${i("inventory.transfer.table.status")}`),
890
- cell(d) {
891
- return d.row.original.status;
892
- },
893
- enableSorting: !0,
894
- size: 200
895
- }
896
- ] : [],
897
- {
898
- accessorKey: "purchaseOrder.status",
899
- header: () => i("inventory.transfer.table.status"),
900
- cell(d) {
901
- const a = d.row.original, b = d.getValue();
902
- if (!a.purchaseOrder)
903
- return P(We.FmChip, {
904
- label: "N/A",
905
- compact: !0
906
- });
907
- const f = Ze(a.purchaseOrder), { partial: w, over: L } = nt(f), G = at(b ?? "", w, L);
908
- let F = i(`inventory.transfer.status.${G}`), J = `${b ?? ""}`.toLocaleLowerCase("en-us");
909
- return G === ee.enum.CLOSE && (F = `${i(`inventory.transfer.status.${ee.enum.COMPLETE}`)}`), G === "PARTIAL_RECEIVED" && J === ee.enum.PROCESSING.toLocaleLowerCase("en-us") && (J = ee.enum.RECEIVING.toLocaleLowerCase("en-us")), a.rejectedAt && (F = i("inventory.transfer.status.REJECT"), J = ee.enum.REJECT.toLocaleLowerCase("en-us")), P(
910
- "div",
911
- {
912
- class: "flex"
913
- },
914
- P(
915
- "div",
916
- {
917
- class: [
918
- "fm-status-badge",
919
- `fm-status-badge-${J}`,
920
- L && "fm-status-badge-error"
921
- ].filter(Boolean).join(" ")
922
- },
923
- `${F}`
924
- )
925
- );
926
- },
927
- enableSorting: !0
928
- },
929
- {
930
- id: "action",
931
- cell(d) {
932
- const a = d.row.original, f = (a.purchaseOrder ? r(a.purchaseOrder) : []).map((w) => w.value === me.Print ? {
933
- ...w,
934
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
935
- } : w);
936
- return mt(
937
- f,
938
- (w) => a.purchaseOrder ? x(w, a.purchaseOrder, a) : void 0
939
- );
940
- },
941
- enableSorting: !1,
942
- size: 40,
943
- meta: {
944
- cellClass: "",
945
- headerClass: ""
946
- }
947
- }
948
- ];
949
- if (l.isEnabled) {
950
- const d = [
951
- {
952
- id: "netsuiteTransferOrder",
953
- accessorFn: (a) => {
954
- var b;
955
- return (b = a.netSuite) != null && b.id ? `${a.netSuite.refNo} (${a.netSuite.id})` : "N/A";
956
- },
957
- header: () => "NetSuite Order (ID)",
958
- cell(a) {
959
- var f;
960
- const b = a.row.original;
961
- return (f = b.netSuite) != null && f.id ? `${b.netSuite.refNo} (${b.netSuite.id})` : "N/A";
962
- },
963
- enableSorting: !1,
964
- size: 200,
965
- meta: {
966
- cellClass: "",
967
- headerClass: ""
968
- }
969
- },
970
- {
971
- id: "netsuiteTransactionNumber",
972
- accessorFn: (a) => {
973
- var b, f;
974
- return ((f = (b = a.netSuite) == null ? void 0 : b.additionalInfo) == null ? void 0 : f.transactionnumber) ?? "N/A";
975
- },
976
- header: () => "NetSuite Transaction No.",
977
- cell(a) {
978
- var f, w;
979
- return ((w = (f = a.row.original.netSuite) == null ? void 0 : f.additionalInfo) == null ? void 0 : w.transactionnumber) ?? "N/A";
980
- },
981
- enableSorting: !1,
982
- size: 200,
983
- meta: {
984
- cellClass: "",
985
- headerClass: ""
986
- }
987
- }
988
- ];
989
- _.splice(_.length - 2, 0, ...d);
990
- }
991
- return _;
992
- }
993
- return {
994
- columnDefs: Q(() => O === "receive/request" ? h() : m())
995
- };
996
- }
997
- const Jt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Xt = { class: "flex flex-col gap-8" }, Zt = { class: "flex w-full justify-end gap-16" }, er = /* @__PURE__ */ Se({
998
- __name: "FulfillmentForm",
999
- props: {
1000
- purchaseOrder: {},
1001
- confirm: { type: Function }
1002
- },
1003
- emits: ["update:show"],
1004
- setup(O, { emit: s }) {
1005
- const n = O, y = Tt({
1006
- id: "",
1007
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1008
- items: []
1009
- }), l = W(), t = s;
1010
- St(() => {
1011
- n.purchaseOrder && (y.items = n.purchaseOrder.items.map((r) => ({
1012
- id: r.id,
1013
- sku: r.sku,
1014
- measurement: r.measurement,
1015
- amount: r.quantity ?? { amount: 1, precision: 0 }
1016
- })));
1017
- });
1018
- const i = Q(() => y.items.length <= 10);
1019
- return (r, c) => {
1020
- const x = M("FmTable"), h = M("FmButton"), m = M("FmForm");
1021
- return u(), se(m, {
1022
- ref_key: "formRef",
1023
- ref: l,
1024
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1025
- onValidationFailed: console.log,
1026
- onValidationSuccess: c[1] || (c[1] = () => n.confirm(y))
1027
- }, {
1028
- default: Y(() => [
1029
- c[2] || (c[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1030
- e("div", Jt, [
1031
- e("div", Xt, [
1032
- k(x, {
1033
- "column-defs": [
1034
- {
1035
- header: "Code",
1036
- cell: (A) => {
1037
- const _ = n.purchaseOrder.items.find((D) => D.id === A.row.original.id || D.sku._id === A.row.original.sku._id);
1038
- return P(
1039
- S(We).FmTooltip,
1040
- {
1041
- content: _.code,
1042
- placement: "top",
1043
- variant: "plain",
1044
- zIndex: 50
1045
- },
1046
- P(
1047
- "span",
1048
- {
1049
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1050
- },
1051
- _.code
1052
- )
1053
- );
1054
- }
1055
- },
1056
- {
1057
- header: "Name",
1058
- cell: (A) => {
1059
- const _ = n.purchaseOrder.items.find((D) => D.id === A.row.original.id || D.sku._id === A.row.original.sku._id);
1060
- return P(
1061
- S(We).FmTooltip,
1062
- {
1063
- content: _.name,
1064
- placement: "top",
1065
- variant: "plain",
1066
- zIndex: 50
1067
- },
1068
- P(
1069
- "span",
1070
- {
1071
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1072
- },
1073
- _.name
1074
- )
1075
- );
1076
- }
1077
- },
1078
- {
1079
- header: "Amount",
1080
- cell: (A) => {
1081
- const _ = A.row.original, D = n.purchaseOrder.items.find((a) => a.id === _.id || a.sku._id === _.sku._id), d = _.amount ?? {
1082
- amount: 1,
1083
- precision: 0
1084
- };
1085
- return P(Mt, {
1086
- style: {
1087
- flex: "1 1 0%"
1088
- },
1089
- modelValue: {
1090
- amount: d,
1091
- measurement: _.measurement ?? null
1092
- },
1093
- key: _.id ?? _.sku._id,
1094
- unit: _.sku.unit,
1095
- "onUpdate:modelValue": (a) => {
1096
- if (!a) return;
1097
- const b = y.items.find((f) => f.id === _.id || f.sku._id === _.sku._id);
1098
- b && (b.amount = a.amount);
1099
- },
1100
- disableUnit: !0,
1101
- rules: [
1102
- S(jt)(
1103
- +S(ve)({ amount: 0, precision: 0 })
1104
- ),
1105
- S(zt)(+S(ve)(D.quantity))
1106
- ],
1107
- applyDefaultRules: !0
1108
- });
1109
- }
1110
- }
1111
- ],
1112
- "row-data": y.items,
1113
- "hide-footer": i.value
1114
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1115
- ])
1116
- ]),
1117
- e("div", Zt, [
1118
- k(h, {
1119
- class: "px-16",
1120
- label: "Confirm",
1121
- size: "md",
1122
- variant: "primary",
1123
- type: "submit"
1124
- }),
1125
- k(h, {
1126
- class: "px-16",
1127
- label: "Cancel",
1128
- size: "md",
1129
- variant: "secondary",
1130
- onClick: c[0] || (c[0] = () => t("update:show", !1))
1131
- })
1132
- ])
1133
- ]),
1134
- _: 1
1135
- }, 8, ["onValidationFailed"]);
1136
- };
1137
- }
1138
- }), ot = {
1139
- submitRequest: {
1140
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1141
- color: "primary",
1142
- buttonVariant: be.Primary
1143
- },
1144
- confirmDraft: {
1145
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1146
- color: "primary",
1147
- buttonVariant: be.Primary
1148
- },
1149
- cancelDraft: {
1150
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1151
- color: "system-error-300",
1152
- buttonVariant: be.Destructive
1153
- },
1154
- approveDraft: {
1155
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1156
- color: "primary",
1157
- buttonVariant: be.Primary
1158
- },
1159
- rejectDraft: {
1160
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1161
- color: "system-error-300",
1162
- buttonVariant: be.Destructive
1163
- },
1164
- approveRequest: {
1165
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1166
- color: "primary",
1167
- buttonVariant: be.Primary
1168
- },
1169
- processRequest: {
1170
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1171
- color: "primary",
1172
- buttonVariant: be.Primary
1173
- },
1174
- receiveStock: {
1175
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1176
- color: "primary",
1177
- buttonVariant: be.Primary,
1178
- available: !1
1179
- },
1180
- completeReceive: {
1181
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1182
- color: "primary",
1183
- buttonVariant: be.Plain
1184
- },
1185
- rejectRequest: {
1186
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1187
- color: "system-error-300",
1188
- buttonVariant: be.Destructive
1189
- },
1190
- closeRequest: {
1191
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1192
- color: "system-error-300",
1193
- buttonVariant: be.Destructive,
1194
- available: !1
1195
- },
1196
- returnStock: {
1197
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1198
- color: "primary",
1199
- buttonVariant: be.Primary,
1200
- available: !1
1201
- }
1202
- };
1203
- function tr() {
1204
- const O = Ue();
1205
- return {
1206
- ableToMarkReceived(s) {
1207
- if (!s || s.status !== ee.enum.RECEIVING)
1208
- return !1;
1209
- const y = $e().currentLocationDBName;
1210
- return `${s.supplier.internal}_${s.supplier._id}` !== y;
1211
- },
1212
- ableToMarkApproved(s) {
1213
- return !(!s || (s == null ? void 0 : s.status) !== ee.enum.REQUESTING);
1214
- },
1215
- ableToCreateFulfillment(s, n) {
1216
- var t, i;
1217
- if (!O.acceptRequireFulfillment || !s || !n || s.status !== ee.enum.PROCESSING || !n.processedAt)
1218
- return !1;
1219
- const y = (t = n == null ? void 0 : n.from) == null ? void 0 : t.dbName, l = (i = n == null ? void 0 : n.to) == null ? void 0 : i.dbName;
1220
- return !(y.startsWith("restaurant_") && l.startsWith("restaurant_"));
1221
- }
1222
- };
1223
- }
1224
- const rr = { class: "flex flex-row-reverse" }, sr = /* @__PURE__ */ Se({
1225
- __name: "NetSuiteSync",
1226
- props: {
1227
- poRequest: {},
1228
- purchaseOrder: {},
1229
- isTransferBetweenOutlets: { type: Boolean },
1230
- scope: {}
1231
- },
1232
- setup(O) {
1233
- const s = O, n = tt(), y = Me(), l = Qe(), t = W(!1);
1234
- Q(() => {
1235
- var h, m, A, _;
1236
- let r = !0;
1237
- n.isEnabled || (r = !1);
1238
- const c = s.purchaseOrder, x = s.poRequest;
1239
- return c && ((h = c == null ? void 0 : c.supplier) != null && h.internal ? (!x && c.status == ee.enum.DRAFT && (r = !1), x && !((m = x == null ? void 0 : x.netSuite) != null && m.id) && (r = !1), s.isTransferBetweenOutlets && (r = !1)) : ((c == null ? void 0 : c.status) !== ee.enum.REQUESTING && c.supplier.internal && (r = !1), !x && !((A = c == null ? void 0 : c.netSuite) != null && A.id) && (r = !1), !x && ((_ = c == null ? void 0 : c.netSuite) != null && _.id) && (c == null ? void 0 : c.status) == ee.enum.REQUESTING && (r = !1))), r;
1240
- });
1241
- async function i() {
1242
- t.value || l.open({
1243
- title: "Sync with NetSuite",
1244
- contentComponent: P("div", [
1245
- P("p", "Are you sure you want to sync now?"),
1246
- P("br"),
1247
- P(
1248
- "p",
1249
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1250
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1251
- )
1252
- ]),
1253
- primaryActions: {
1254
- text: "Sync",
1255
- close: !0,
1256
- variant: "destructive"
1257
- },
1258
- secondaryActions: { text: "Not now", close: !0 }
1259
- }).onPrimary(async () => {
1260
- var r, c, x;
1261
- try {
1262
- t.value = !0;
1263
- const h = ((r = s.purchaseOrder) == null ? void 0 : r._id) || ((c = s.poRequest) == null ? void 0 : c.purchaseOrderId) || "", m = (x = s.poRequest) == null ? void 0 : x.to.dbName;
1264
- await n.syncPurchaseOrder(
1265
- h,
1266
- s.scope === "approval" ? m : void 0
1267
- ), y.open({
1268
- title: "Sync with NetSuite",
1269
- message: "Requested to sync with NetSuite. Please wait a moment.",
1270
- type: "success"
1271
- }), await new Promise((A) => setTimeout(A, 5e3)), t.value = !1;
1272
- } catch {
1273
- y.open({
1274
- title: "Error",
1275
- message: "Failed to sync with NetSuite",
1276
- type: "error"
1277
- }), t.value = !1;
1278
- }
1279
- });
1280
- }
1281
- return (r, c) => {
1282
- const x = M("FmButton");
1283
- return u(), $("div", rr, [
1284
- k(x, {
1285
- "prepend-icon": "sync",
1286
- variant: "secondary",
1287
- label: "Sync",
1288
- loading: t.value,
1289
- onClick: i,
1290
- "text-color": "primary",
1291
- "bg-color": "transparent",
1292
- "border-color": "primary"
1293
- }, null, 8, ["loading"])
1294
- ]);
1295
- };
1296
- }
1297
- }), or = {
1298
- key: 0,
1299
- class: "flex flex-col gap-8"
1300
- }, nr = { class: "flex flex-col gap-4" }, ar = { class: "fm-typo-en-body-lg-600" }, lr = {
1301
- key: 0,
1302
- class: "flex flex-col gap-4"
1303
- }, ir = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, cr = { class: "fm-typo-en-body-lg-600" }, ur = { key: 0 }, dr = { key: 1 }, mr = {
1304
- key: 1,
1305
- class: "flex flex-col gap-4"
1306
- }, pr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, fr = { class: "fm-typo-en-body-lg-600" }, yr = { key: 0 }, vr = { key: 1 }, hr = {
1307
- key: 2,
1308
- class: "flex flex-col gap-4"
1309
- }, br = { class: "fm-typo-en-body-lg-600" }, gr = {
1310
- key: 3,
1311
- class: "flex flex-col gap-4"
1312
- }, _r = { class: "fm-typo-en-body-lg-600" }, Sr = /* @__PURE__ */ Se({
1313
- __name: "NetSuiteInfo",
1314
- props: {
1315
- transferType: {},
1316
- transferToDbName: {},
1317
- poRequest: {},
1318
- purchaseOrder: {},
1319
- isTransferBetweenOutlets: { type: Boolean },
1320
- scope: {}
1321
- },
1322
- setup(O) {
1323
- const s = O, n = tt(), y = qe(), l = W(s.poRequest);
1324
- St(async () => {
1325
- var c;
1326
- if (!s.poRequest && ((c = s.purchaseOrder) != null && c._id)) {
1327
- const x = await y.getLatestPurchaseOrderRequest(s.purchaseOrder._id);
1328
- l.value = x;
1329
- }
1330
- });
1331
- const t = Q(
1332
- () => {
1333
- var c, x, h, m, A, _;
1334
- return n.getSubsidiaryFullName(
1335
- ((h = (x = (c = s.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : x.subsidiary) == null ? void 0 : h.id) || ((_ = (A = (m = s.poRequest) == null ? void 0 : m.netSuite) == null ? void 0 : A.subsidiary) == null ? void 0 : _.id)
1336
- ).fullName;
1337
- }
1338
- ), i = Q(() => {
1339
- var c, x, h, m, A, _, D, d, a, b, f, w;
1340
- return (h = (x = (c = s.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : x.additionalInfo) != null && h.transactionnumber ? (_ = (A = (m = s.purchaseOrder) == null ? void 0 : m.netSuite) == null ? void 0 : A.additionalInfo) == null ? void 0 : _.transactionnumber : (a = (d = (D = l.value) == null ? void 0 : D.netSuite) == null ? void 0 : d.additionalInfo) != null && a.transactionnumber ? (w = (f = (b = l.value) == null ? void 0 : b.netSuite) == null ? void 0 : f.additionalInfo) == null ? void 0 : w.transactionnumber : null;
1341
- }), r = Q(() => {
1342
- var c, x, h, m, A, _;
1343
- return (x = (c = s.purchaseOrder) == null ? void 0 : c.deliveryFullfillment) != null && x.length && ((m = (h = s.purchaseOrder) == null ? void 0 : h.deliveryFullfillment) == null ? void 0 : m.length) > 0 ? (_ = (A = s.purchaseOrder) == null ? void 0 : A.deliveryFullfillment) == null ? void 0 : _.map((D) => {
1344
- var d;
1345
- return (d = D.netSuite) == null ? void 0 : d.refNo;
1346
- }).join(", ") : "N/A";
1347
- });
1348
- return (c, x) => {
1349
- var h, m, A, _, D, d, a, b, f, w, L, G, F, J, X, re;
1350
- return S(n).isEnabled ? (u(), $("div", or, [
1351
- e("div", nr, [
1352
- x[0] || (x[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1353
- e("div", ar, g(t.value || "N/A"), 1)
1354
- ]),
1355
- !c.isTransferBetweenOutlets && c.scope === S(lt).RECEIVE_REQUEST ? (u(), $("div", lr, [
1356
- e("div", ir, " NetSuite " + g((m = (h = c.purchaseOrder) == null ? void 0 : h.netSuite) != null && m.recordType ? S(gt)((_ = (A = c.purchaseOrder) == null ? void 0 : A.netSuite) == null ? void 0 : _.recordType) : c.transferType === S(Pe).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1357
- e("div", cr, [
1358
- (d = (D = c.purchaseOrder) == null ? void 0 : D.netSuite) != null && d.id ? (u(), $("span", ur, g((b = (a = c.purchaseOrder) == null ? void 0 : a.netSuite) == null ? void 0 : b.refNo) + " (" + g((w = (f = c.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : w.id) + ") ", 1)) : (u(), $("span", dr, "N/A"))
1359
- ])
1360
- ])) : B("", !0),
1361
- !c.isTransferBetweenOutlets && l.value || c.scope === S(lt).APPROVAL ? (u(), $("div", mr, [
1362
- e("div", pr, " (Request) NetSuite " + g(c.transferType === S(Pe).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1363
- e("div", fr, [
1364
- (G = (L = l.value) == null ? void 0 : L.netSuite) != null && G.id ? (u(), $("span", yr, g((J = (F = l.value) == null ? void 0 : F.netSuite) == null ? void 0 : J.refNo) + " (" + g((re = (X = l.value) == null ? void 0 : X.netSuite) == null ? void 0 : re.id) + ") ", 1)) : (u(), $("span", vr, "N/A"))
1365
- ])
1366
- ])) : B("", !0),
1367
- i.value ? (u(), $("div", hr, [
1368
- x[1] || (x[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1369
- e("div", br, g(i.value), 1)
1370
- ])) : B("", !0),
1371
- S(n).isEnabled && c.transferType === S(Pe).TRANSFER && !c.isTransferBetweenOutlets ? (u(), $("div", gr, [
1372
- x[2] || (x[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1373
- e("div", _r, g(r.value), 1)
1374
- ])) : B("", !0)
1375
- ])) : B("", !0);
1376
- };
1377
- }
1378
- }), Or = { class: "flex flex-row-reverse" }, wr = /* @__PURE__ */ Se({
1379
- __name: "NetSuiteLog",
1380
- props: {
1381
- netsuiteId: {},
1382
- purchaseOrderId: {}
1383
- },
1384
- setup(O) {
1385
- const s = Me(), n = ct();
1386
- async function y(l, t) {
1387
- const i = [];
1388
- if (l && i.push(`body.message:*${l}*`), t) {
1389
- const h = t.replace(/:/g, "\\:");
1390
- i.push(`${h}`);
1391
- }
1392
- if (i.length === 0) {
1393
- s.open({
1394
- message: "Cannot open logs without valid filters.",
1395
- type: "error"
1396
- });
1397
- return;
1398
- }
1399
- const c = `attributes.pod:netsuite* AND (${i.join(" OR ")})`, { url: x } = await n.getSyncLogs(c);
1400
- s.open(
1401
- {
1402
- message: "Opening NetSuite logs...",
1403
- type: "info"
1404
- },
1405
- 800
1406
- ), await new Promise((h) => setTimeout(h, 800)), window.open(x, "_blank");
1407
- }
1408
- return (l, t) => {
1409
- const i = M("FmButton");
1410
- return u(), $("div", Or, [
1411
- k(i, {
1412
- "prepend-icon": "history",
1413
- variant: "secondary",
1414
- label: "Logs",
1415
- onClick: t[0] || (t[0] = (r) => y(l.netsuiteId, l.purchaseOrderId)),
1416
- "text-color": "primary",
1417
- "bg-color": "transparent",
1418
- "border-color": "primary"
1419
- })
1420
- ]);
1421
- };
1422
- }
1423
- }), xr = { class: "flex flex-row-reverse" }, $r = { key: 0 }, Cr = { key: 1 }, kr = { class: "mb-6" }, Dr = { class: "fm-typo-en-body-md-400" }, Rr = { key: 0 }, Nr = { key: 1 }, Ar = {
1424
- key: 0,
1425
- class: "flex"
1426
- }, Tr = {
1427
- key: 1,
1428
- class: "border-t pt-6"
1429
- }, Fr = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Ir = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Pr = { class: "w-full" }, qr = {
1430
- class: "p-3 fm-typo-en-body-sm-600",
1431
- style: { "min-width": "130px" }
1432
- }, Vr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Lr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Er = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Br = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ur = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Mr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, jr = { class: "p-3 fm-typo-en-body-sm-600" }, zr = { key: 2 }, Kr = { key: 1 }, Hr = /* @__PURE__ */ Se({
1433
- __name: "NetSuiteLatestInfo",
1434
- props: {
1435
- netsuiteId: {},
1436
- purchaseOrderId: {}
1437
- },
1438
- setup(O) {
1439
- const s = O, n = ct(), y = W(!1), l = $e(), t = W(!0), i = W(!1), r = W(!1), c = W(!1), x = W(null), h = W([]);
1440
- async function m() {
1441
- if (!x.value) {
1442
- y.value = !0;
1443
- try {
1444
- t.value = !0;
1445
- const d = await n.getMoreInfo(
1446
- l.currentLocation.dbName,
1447
- s.purchaseOrderId
1448
- );
1449
- x.value = d, i.value = !1;
1450
- } catch {
1451
- i.value = !0;
1452
- } finally {
1453
- t.value = !1;
1454
- }
1455
- await A();
1456
- }
1457
- }
1458
- async function A() {
1459
- if (!(h.value.length > 0))
1460
- try {
1461
- r.value = !0;
1462
- const d = await n.getChangeLogs(s.netsuiteId);
1463
- h.value = d, c.value = !1;
1464
- } catch {
1465
- c.value = !0;
1466
- } finally {
1467
- r.value = !1;
1468
- }
1469
- }
1470
- function _(d) {
1471
- switch (d) {
1472
- case we.Create:
1473
- return "text-green-600 bg-green-100";
1474
- case we.Set:
1475
- return "text-blue-600 bg-blue-100";
1476
- case we.Change:
1477
- return "text-yellow-600 bg-yellow-100";
1478
- case we.Unset:
1479
- return "text-red-600 bg-red-100";
1480
- default:
1481
- return "text-gray-600 bg-gray-100";
1482
- }
1483
- }
1484
- function D(d) {
1485
- return new Date(d).toLocaleDateString("en-US", {
1486
- year: "numeric",
1487
- month: "short",
1488
- day: "numeric",
1489
- hour: "2-digit",
1490
- minute: "2-digit"
1491
- });
1492
- }
1493
- return (d, a) => {
1494
- const b = M("FmButton"), f = M("FmLabel"), w = M("FmCircularProgress"), L = M("FmIcon"), G = M("FmDialog");
1495
- return u(), $("div", xr, [
1496
- k(G, {
1497
- modelValue: y.value,
1498
- "onUpdate:modelValue": a[2] || (a[2] = (F) => y.value = F),
1499
- overlay: !0,
1500
- "max-width": 800
1501
- }, {
1502
- "dialog-button": Y(() => [
1503
- k(b, {
1504
- "prepend-icon": "info",
1505
- variant: "secondary",
1506
- label: "Latest Info",
1507
- onClick: a[0] || (a[0] = (F) => m()),
1508
- "text-color": "primary",
1509
- "bg-color": "transparent",
1510
- "border-color": "primary"
1511
- })
1512
- ]),
1513
- "dialog-header": Y(() => a[3] || (a[3] = [
1514
- e("div", null, "NetSuite latest info", -1)
1515
- ])),
1516
- default: Y(() => [
1517
- t.value ? (u(), $("div", $r, "Loading...")) : (u(), $("div", Cr, [
1518
- i.value ? (u(), $("p", Kr, "Something went wrong.")) : (u(), $(ue, { key: 0 }, [
1519
- e("div", kr, [
1520
- a[4] || (a[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1521
- (u(!0), $(ue, null, _e(x.value, (F, J) => (u(), $("div", {
1522
- key: J,
1523
- class: "mb-2"
1524
- }, [
1525
- e("div", null, [
1526
- k(f, {
1527
- label: S(it)(J)
1528
- }, null, 8, ["label"]),
1529
- e("div", Dr, [
1530
- Array.isArray(F) ? (u(), $("span", Rr, g(F.length > 0 ? F.join(", ") : "N/A"), 1)) : (u(), $("span", Nr, g(F), 1))
1531
- ])
1532
- ])
1533
- ]))), 128))
1534
- ]),
1535
- r.value ? (u(), $("div", Ar, [
1536
- a[5] || (a[5] = e("span", null, "Change Log Loading...", -1)),
1537
- k(w, { size: "md" })
1538
- ])) : B("", !0),
1539
- !r.value && h.value.length > 0 ? (u(), $("div", Tr, [
1540
- e("h3", Fr, [
1541
- k(L, {
1542
- name: "error",
1543
- color: "#ff9500",
1544
- size: "sm"
1545
- }),
1546
- a[6] || (a[6] = ke(" Change Logs "))
1547
- ]),
1548
- e("div", Ir, [
1549
- e("table", Pr, [
1550
- a[7] || (a[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1551
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1552
- e("th", {
1553
- class: "text-left p-3 fm-typo-en-body-md-600",
1554
- style: { "min-width": "130px" }
1555
- }, " Date "),
1556
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1557
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1558
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1559
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1560
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1561
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1562
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1563
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1564
- ])
1565
- ], -1)),
1566
- e("tbody", null, [
1567
- (u(!0), $(ue, null, _e(h.value, (F, J) => (u(), $("tr", {
1568
- key: J,
1569
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1570
- }, [
1571
- e("td", qr, g(D(F._dateiso8601)), 1),
1572
- e("td", Vr, g(F._rolename), 1),
1573
- e("td", Lr, g(F._employeename), 1),
1574
- e("td", Er, g(F._contextname), 1),
1575
- e("td", {
1576
- class: Be(`p-3 fm-typo-en-body-sm-600 ${_(Number(F.type) - 1)}`)
1577
- }, g(S(we)[Number(F.type) - 1]), 3),
1578
- e("td", Br, g(F.lineid || ""), 1),
1579
- e("td", Ur, g(F._fieldname), 1),
1580
- e("td", Mr, g(F.oldvalue || ""), 1),
1581
- e("td", jr, g(F.newvalue || ""), 1)
1582
- ]))), 128))
1583
- ])
1584
- ])
1585
- ])
1586
- ])) : (u(), $("div", zr, a[8] || (a[8] = [
1587
- e("p", null, "No change logs available.", -1)
1588
- ])))
1589
- ], 64))
1590
- ]))
1591
- ]),
1592
- "dialog-footer": Y(() => [
1593
- k(b, {
1594
- class: "ml-auto sm:w-full xs:w-full",
1595
- label: "Close",
1596
- size: "md",
1597
- variant: "primary",
1598
- onClick: a[1] || (a[1] = (F) => y.value = !1)
1599
- })
1600
- ]),
1601
- _: 1
1602
- }, 8, ["modelValue"])
1603
- ]);
1604
- };
1605
- }
1606
- }), Wr = {
1607
- key: 0,
1608
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1609
- }, Gr = { class: "flex gap-8 items-center" }, Qr = { class: "ml-auto" }, Yr = { class: "flex gap-3" }, Jr = /* @__PURE__ */ Se({
1610
- __name: "NetSuitePanel",
1611
- props: {
1612
- poRequest: {},
1613
- purchaseOrder: {},
1614
- transferType: {},
1615
- transferToDbName: {},
1616
- scope: {}
1617
- },
1618
- setup(O) {
1619
- const s = O, n = Ht();
1620
- Ge();
1621
- const y = Q(() => {
1622
- var r, c, x, h, m, A, _;
1623
- const l = ((r = s.transferToDbName) == null ? void 0 : r.startsWith("restaurant")) && ((x = (c = s.purchaseOrder) == null ? void 0 : c.supplier) == null ? void 0 : x.internal) === "restaurant", t = s.transferType === Pe.PURCHASE, i = s.transferType === Pe.TRANSFER;
1624
- return t || i && !l || ((m = (h = s.purchaseOrder) == null ? void 0 : h.netSuite) == null ? void 0 : m.id) || ((_ = (A = s.poRequest) == null ? void 0 : A.netSuite) == null ? void 0 : _.id);
1625
- });
1626
- return (l, t) => {
1627
- var r, c;
1628
- const i = M("FmMenuDivider");
1629
- return S(n).isNetSuiteEnabled && y.value ? (u(), $("div", Wr, [
1630
- e("div", Gr, [
1631
- t[0] || (t[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1632
- e("div", Qr, [
1633
- e("div", Yr, [
1634
- (c = (r = s.purchaseOrder) == null ? void 0 : r.netSuite) != null && c.id ? (u(), se(De, { key: 0 }, {
1635
- default: Y(() => {
1636
- var x, h, m;
1637
- return [
1638
- k(Hr, {
1639
- "netsuite-id": (h = (x = l.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : h.id,
1640
- "purchase-order-id": (m = l.purchaseOrder) == null ? void 0 : m._id
1641
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1642
- ];
1643
- }),
1644
- _: 1
1645
- })) : B("", !0),
1646
- k(De, null, {
1647
- default: Y(() => {
1648
- var x, h, m;
1649
- return [
1650
- k(wr, {
1651
- "netsuite-id": (h = (x = l.purchaseOrder) == null ? void 0 : x.netSuite) == null ? void 0 : h.id,
1652
- "purchase-order-id": (m = l.purchaseOrder) == null ? void 0 : m._id
1653
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1654
- ];
1655
- }),
1656
- _: 1
1657
- }),
1658
- k(sr, {
1659
- "po-request": l.poRequest,
1660
- "purchase-order": l.purchaseOrder,
1661
- "is-transfer-between-outlets": !y.value,
1662
- scope: l.scope
1663
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1664
- ])
1665
- ])
1666
- ]),
1667
- k(i),
1668
- k(Sr, {
1669
- "po-request": l.poRequest,
1670
- "purchase-order": l.purchaseOrder,
1671
- "transfer-type": l.transferType,
1672
- "transfer-to-db-name": l.transferToDbName,
1673
- "is-transfer-between-outlets": !y.value,
1674
- scope: l.scope
1675
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1676
- ])) : B("", !0);
1677
- };
1678
- }
1679
- }), Xr = { class: "flex flex-col gap-3" }, Zr = { class: "flex flex-col gap-4" }, es = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, ts = { class: "flex flex-col gap-4" }, rs = { class: "flex justify-between items-center py-1 gap-4" }, ss = { class: "flex flex-col" }, os = { class: "fm-typo-en-body-lg-600" }, ns = { class: "fm-typo-en-body-md-400" }, as = { class: "flex flex-col gap-2 items-end" }, ls = { class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, is = {
1680
- key: 0,
1681
- class: "flex items-center gap-2"
1682
- }, cs = {
1683
- key: 0,
1684
- class: "border-b border-fm-color-stroke-secondary"
1685
- }, us = { class: "flex flex-col gap-4" }, ds = { class: "flex flex-col gap-4" }, ms = { class: "flex flex-col gap-4" }, ps = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, fs = {
1686
- key: 0,
1687
- class: "flex flex-col gap-4"
1688
- }, ys = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, vs = /* @__PURE__ */ Se({
1689
- __name: "EditForm",
1690
- props: {
1691
- purchaseOrder: {},
1692
- deliveryOrder: {}
1693
- },
1694
- emits: ["submitted"],
1695
- setup(O, { emit: s }) {
1696
- At();
1697
- const n = Ue(), y = Me(), l = W(!1), t = O, i = s, r = _t("deliveryOrder"), c = qe(), x = Q(
1698
- () => {
1699
- var b;
1700
- return ((b = t.purchaseOrder.deliveryFullfillment) == null ? void 0 : b.findIndex(
1701
- (f) => t.deliveryOrder.fullfillmentId && f.id === t.deliveryOrder.fullfillmentId
1702
- )) ?? -1;
1703
- }
1704
- ), h = n.enablePurchaseOrderReceiveWithCustomCost, m = n.enablePortalDeliveryOrderWrite, A = W({}), _ = Q(() => t.purchaseOrder.items.map((b, f) => Q({
1705
- get: () => {
1706
- var L;
1707
- const w = (L = r.received[f]) == null ? void 0 : L.cost;
1708
- return w ? +ve(w) : 0;
1709
- },
1710
- set: (w) => {
1711
- r.received[f].cost = {
1712
- currency: xe(),
1713
- ...Je(w, 4)
1714
- };
1715
- }
1716
- }))), D = Q(() => t.deliveryOrder.received.map((b, f) => Q({
1717
- get: () => {
1718
- var L;
1719
- const w = (L = r.received[f]) == null ? void 0 : L.amount;
1720
- return w ? +ve(w) : 0;
1721
- },
1722
- set: (w) => {
1723
- r.received[f].amount = Je(w, 2);
1724
- }
1725
- })));
1726
- function d(b) {
1727
- const f = !A.value[b];
1728
- if (A.value[b] = f, f) {
1729
- const w = t.deliveryOrder.received[b];
1730
- w.cost ? r.received[b].cost = {
1731
- currency: w.cost.currency,
1732
- amount: w.cost.amount,
1733
- precision: w.cost.precision
1734
- } : r.received[b].cost = {
1735
- currency: xe(),
1736
- amount: 0,
1737
- precision: 4
1738
- };
1739
- } else
1740
- delete r.received[b].cost;
1741
- }
1742
- function a() {
1743
- c.updateDeliveryOrder({
1744
- deliveryOrder: {
1745
- ...t.deliveryOrder,
1746
- ...r
1747
- },
1748
- purchaseOrderId: t.purchaseOrder._id,
1749
- purchaseOrderRev: t.purchaseOrder._rev
1750
- }).then(() => {
1751
- y.open(
1752
- {
1753
- title: "Success",
1754
- message: `PO# ${t.purchaseOrder.seqNumber} Changes have been saved`,
1755
- type: "success"
1756
- },
1757
- 1e4
1758
- ), l.value = !1, i("submitted");
1759
- });
1760
- }
1761
- return (b, f) => {
1762
- const w = M("FmButton"), L = M("FmStepperField"), G = M("FmSwitch"), F = M("FmTextField"), J = M("FmDialog");
1763
- return u(), se(J, {
1764
- modelValue: l.value,
1765
- "onUpdate:modelValue": f[1] || (f[1] = (X) => l.value = X),
1766
- overlay: !0
1767
- }, {
1768
- "dialog-button": Y(() => [
1769
- S(m) ? (u(), se(w, {
1770
- key: 0,
1771
- variant: "plain",
1772
- label: "Edit",
1773
- size: "md",
1774
- "prepend-icon": "edit"
1775
- })) : B("", !0)
1776
- ]),
1777
- "dialog-header": Y(() => [
1778
- e("div", null, "Received on " + g(S(He)(t.deliveryOrder.createdAt)), 1)
1779
- ]),
1780
- "dialog-footer": Y(() => [
1781
- k(w, {
1782
- class: "ml-auto",
1783
- label: "Apply changes",
1784
- size: "md",
1785
- variant: "destructive",
1786
- onClick: a
1787
- })
1788
- ]),
1789
- default: Y(() => [
1790
- e("div", null, [
1791
- e("div", Xr, [
1792
- e("div", Zr, [
1793
- f[2] || (f[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
1794
- e("div", es, g(t.deliveryOrder.adjustment ? S(He)(new Date(S(Xe)(t.deliveryOrder.adjustment))) : "-"), 1)
1795
- ]),
1796
- e("div", ts, [
1797
- f[4] || (f[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received items", -1)),
1798
- (u(!0), $(ue, null, _e(t.deliveryOrder.received, (X, re) => {
1799
- var pe;
1800
- return u(), $("div", { key: re }, [
1801
- e("div", rs, [
1802
- e("div", ss, [
1803
- e("span", os, g(X.sku.name), 1),
1804
- e("span", ns, g(X.sku.code), 1)
1805
- ]),
1806
- e("div", as, [
1807
- k(L, {
1808
- label: "Receive Quantity",
1809
- modelValue: D.value[re].value,
1810
- "onUpdate:modelValue": (fe) => D.value[re].value = fe,
1811
- min: 0,
1812
- "append-text": ((pe = X.measurement) == null ? void 0 : pe.abbrev) ?? X.sku.unit.abbrev
1813
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"]),
1814
- e("div", ls, g(`${X.cost ? `${S(Ke)(X.cost)}` : ""}`), 1),
1815
- S(h) ? (u(), $("div", is, [
1816
- k(G, {
1817
- "model-value": A.value[re],
1818
- "onUpdate:modelValue": (fe) => d(re),
1819
- size: "sm"
1820
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
1821
- f[3] || (f[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
1822
- ])) : B("", !0),
1823
- S(h) && A.value[re] ? (u(), se(L, {
1824
- key: 1,
1825
- modelValue: _.value[re].value,
1826
- "onUpdate:modelValue": (fe) => _.value[re].value = fe,
1827
- label: "Total Cost",
1828
- step: 1e-4,
1829
- min: 0,
1830
- placeholder: "0.0000",
1831
- size: "sm",
1832
- "append-text": S(xe)()
1833
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : B("", !0)
1834
- ])
1835
- ]),
1836
- re < t.purchaseOrder.items.length - 1 ? (u(), $("div", cs)) : B("", !0)
1837
- ]);
1838
- }), 128))
1839
- ]),
1840
- e("div", us, [
1841
- f[5] || (f[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
1842
- e("div", ds, [
1843
- k(F, {
1844
- modelValue: S(r).deliveryOrderNumber,
1845
- "onUpdate:modelValue": f[0] || (f[0] = (X) => S(r).deliveryOrderNumber = X),
1846
- size: "md",
1847
- placeholder: t.deliveryOrder.deliveryOrderNumber
1848
- }, null, 8, ["modelValue", "placeholder"])
1849
- ])
1850
- ]),
1851
- e("div", ms, [
1852
- f[6] || (f[6] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
1853
- e("div", ps, g(t.deliveryOrder.remark || "N/A"), 1)
1854
- ]),
1855
- x.value >= 0 ? (u(), $("div", fs, [
1856
- f[7] || (f[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fulfilment's sequence ", -1)),
1857
- e("div", ys, g(x.value + 1), 1)
1858
- ])) : B("", !0)
1859
- ])
1860
- ])
1861
- ]),
1862
- _: 1
1863
- }, 8, ["modelValue"]);
1864
- };
1865
- }
1866
- }), hs = { class: "flex flex-col gap-3" }, bs = { class: "flex flex-col gap-4" }, gs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, _s = {
1867
- key: 0,
1868
- class: "flex flex-col gap-4"
1869
- }, Ss = { class: "flex items-center justify-between" }, Os = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ws = {
1870
- key: 0,
1871
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1872
- }, xs = { class: "flex gap-4" }, $s = { class: "flex-1" }, Cs = { class: "flex-1" }, ks = {
1873
- key: 0,
1874
- class: "flex items-center text-fm-color-system-error-300"
1875
- }, Ds = { class: "fm-typo-en-body-md-400" }, Rs = { class: "flex flex-col gap-4" }, Ns = { class: "flex justify-between items-center py-1 gap-4" }, As = { class: "flex flex-col" }, Ts = { class: "fm-typo-en-body-lg-600" }, Fs = { class: "fm-typo-en-body-md-400" }, Is = { class: "flex flex-col gap-2 items-end" }, Ps = {
1876
- key: 0,
1877
- class: "flex items-center gap-2"
1878
- }, qs = {
1879
- key: 0,
1880
- class: "border-b border-fm-color-stroke-secondary"
1881
- }, Vs = { class: "flex flex-col gap-4" }, Ls = { class: "flex flex-col gap-4" }, Es = { class: "flex flex-col gap-4" }, Bs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Us = /* @__PURE__ */ Se({
1882
- __name: "CreateForm",
1883
- props: {
1884
- purchaseOrder: {},
1885
- receivedInfoMap: {}
1886
- },
1887
- emits: ["submitted"],
1888
- setup(O, { emit: s }) {
1889
- var q, U, ae;
1890
- const { t: n } = ut(), y = W(!1), l = Ge(), t = O, i = s, r = _t("", {
1891
- default: {
1892
- deliveryOrderNumber: "",
1893
- remark: "",
1894
- received: t.purchaseOrder.items.map((N) => ({
1895
- sku: N.sku,
1896
- amount: Ie.fromNumber(0),
1897
- measurement: N.measurement
1898
- })),
1899
- createdBy: {
1900
- id: ((q = l.sessionUser.value) == null ? void 0 : q.id) || "",
1901
- name: ((U = l.sessionUser.value) == null ? void 0 : U.displayName) || ""
1902
- },
1903
- createdAt: ""
1904
- }
1905
- }), c = qe(), x = Qe(), h = Ue(), m = ((ae = t.purchaseOrder) == null ? void 0 : ae.supplier.internal) != null, A = m && h.enablePOSTransferRequireFulfillment, _ = h.enablePortalDeliveryOrderWrite && (t.purchaseOrder.status === ee.Enum.RECEIVING || t.purchaseOrder.status === ee.Enum.COMPLETE) && (m ? !A : !0), D = h.enablePurchaseOrderReceiveWithCustomCost, d = h.enableBackdateReceive, a = W({}), b = Me(), f = Q({
1906
- get() {
1907
- if (!r.createdAt) return "";
1908
- const N = new Date(r.createdAt), C = N.getFullYear(), I = String(N.getMonth() + 1).padStart(2, "0"), j = String(N.getDate()).padStart(2, "0");
1909
- return `${C}-${I}-${j}`;
1910
- },
1911
- set(N) {
1912
- if (N) {
1913
- const C = r.createdAt ? new Date(r.createdAt) : /* @__PURE__ */ new Date(), [I, j, o] = N.split("-");
1914
- C.setFullYear(parseInt(I)), C.setMonth(parseInt(j) - 1), C.setDate(parseInt(o)), r.createdAt = C.toISOString();
1915
- }
1916
- }
1917
- }), w = Q({
1918
- get() {
1919
- if (!r.createdAt) return "";
1920
- const N = new Date(r.createdAt), C = String(N.getHours()).padStart(2, "0"), I = String(N.getMinutes()).padStart(2, "0");
1921
- return `${C}:${I}`;
1922
- },
1923
- set(N) {
1924
- if (N) {
1925
- const C = r.createdAt ? new Date(r.createdAt) : /* @__PURE__ */ new Date(), [I, j] = N.split(":");
1926
- C.setHours(parseInt(I)), C.setMinutes(parseInt(j)), r.createdAt = C.toISOString();
1927
- }
1928
- }
1929
- }), L = Q(() => {
1930
- const N = Xe(t.purchaseOrder._id);
1931
- if (!N) return "";
1932
- const C = new Date(N), I = C.getFullYear(), j = String(C.getMonth() + 1).padStart(2, "0"), o = String(C.getDate()).padStart(2, "0");
1933
- return `${I}-${j}-${o}`;
1934
- }), G = Q(() => {
1935
- const N = Xe(t.purchaseOrder._id);
1936
- return N ? new Date(N) : null;
1937
- }), F = Q(() => {
1938
- if (!f.value || !w.value || !G.value) return null;
1939
- if (/* @__PURE__ */ new Date(`${f.value}T${w.value}:00`) < G.value) {
1940
- const C = L.value, I = G.value.getHours(), j = G.value.getMinutes(), o = I >= 12 ? "PM" : "AM", v = I % 12 || 12, T = `${String(v).padStart(2, "0")}:${String(j).padStart(2, "0")} ${o}`;
1941
- return `Delivery date & time cannot be earlier than order creation (${C} ${T})`;
1942
- }
1943
- return null;
1944
- }), J = Q(() => F.value ? !1 : r.received.some((C) => {
1945
- const I = C.amount;
1946
- return I ? +ve(I) > 0 : !1;
1947
- }));
1948
- function X() {
1949
- r.createdAt = "";
1950
- }
1951
- const re = Q(() => t.purchaseOrder.items.map((N, C) => Q({
1952
- get: () => {
1953
- var j;
1954
- const I = (j = r.received[C]) == null ? void 0 : j.amount;
1955
- return I ? +ve(I) : 0;
1956
- },
1957
- set: (I) => {
1958
- r.received[C].amount = Je(I, 2);
1959
- }
1960
- })));
1961
- function pe(N) {
1962
- const C = !a.value[N];
1963
- if (a.value[N] = C, C) {
1964
- const I = t.purchaseOrder.items[N];
1965
- I.totalCost ? r.received[N].cost = {
1966
- currency: I.totalCost.currency,
1967
- amount: I.totalCost.amount,
1968
- precision: 4
1969
- // Standardize to 4 decimals
1970
- } : r.received[N].cost = {
1971
- currency: xe(),
1972
- amount: 0,
1973
- precision: 4
1974
- };
1975
- } else
1976
- delete r.received[N].cost;
1977
- }
1978
- const fe = Q(() => t.purchaseOrder.items.map((N, C) => Q({
1979
- get: () => {
1980
- var j;
1981
- const I = (j = r.received[C]) == null ? void 0 : j.cost;
1982
- return I ? +ve(I) : 0;
1983
- },
1984
- set: (I) => {
1985
- r.received[C].cost = {
1986
- currency: xe(),
1987
- ...Je(I, 4)
1988
- };
1989
- }
1990
- })));
1991
- function Re() {
1992
- x.open({
1993
- title: "Confirm Create Delivery Order",
1994
- message: `Are you sure you want to create delivery order for PO# ${t.purchaseOrder.seqNumber}?`,
1995
- primaryActions: {
1996
- text: "Create",
1997
- close: !0,
1998
- variant: "primary"
1999
- },
2000
- secondaryActions: {
2001
- text: "Cancel",
2002
- close: !0
2003
- }
2004
- }).onPrimary(() => Ve());
2005
- }
2006
- function Ve() {
2007
- c.createDeliveryOrder({
2008
- deliveryOrder: r,
2009
- purchaseOrderId: t.purchaseOrder._id,
2010
- purchaseOrderRev: t.purchaseOrder._rev,
2011
- currency: xe()
2012
- }).then(() => {
2013
- b.open(
2014
- {
2015
- title: "Success",
2016
- message: `New delivery order created for PO# ${t.purchaseOrder.seqNumber}`,
2017
- type: "success"
2018
- },
2019
- 1e4
2020
- ), y.value = !1, i("submitted");
2021
- });
2022
- }
2023
- return (N, C) => {
2024
- const I = M("FmButton"), j = M("FmDatePicker"), o = M("FmTimePicker"), v = M("FmIcon"), T = M("FmStepperField"), R = M("FmSwitch"), K = M("FmTextField"), H = M("FmDialog");
2025
- return u(), se(H, {
2026
- modelValue: y.value,
2027
- "onUpdate:modelValue": C[4] || (C[4] = (te) => y.value = te),
2028
- overlay: !0,
2029
- "min-width": 800
2030
- }, {
2031
- "dialog-button": Y(() => [
2032
- S(_) ? (u(), se(I, {
2033
- key: 0,
2034
- variant: "primary",
2035
- label: "Create",
2036
- size: "md",
2037
- "prepend-icon": "add",
2038
- class: "w-full"
2039
- })) : B("", !0)
2040
- ]),
2041
- "dialog-header": Y(() => [
2042
- e("div", null, "Order #" + g(t.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
2043
- ]),
2044
- "dialog-footer": Y(() => [
2045
- k(I, {
2046
- class: "ml-auto",
2047
- label: "Create",
2048
- size: "md",
2049
- variant: "destructive",
2050
- disabled: !J.value,
2051
- onClick: Re
2052
- }, null, 8, ["disabled"])
2053
- ]),
2054
- default: Y(() => {
2055
- var te;
2056
- return [
2057
- e("div", hs, [
2058
- e("div", bs, [
2059
- C[5] || (C[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
2060
- e("div", gs, g((te = S(l).sessionUser.value) == null ? void 0 : te.displayName), 1)
2061
- ]),
2062
- S(d) ? (u(), $("div", _s, [
2063
- e("div", Ss, [
2064
- e("div", Os, [
2065
- C[6] || (C[6] = ke(" Delivery Date & Time ")),
2066
- !f.value && !w.value ? (u(), $("div", ws, " Leave blank to use current date & time ")) : B("", !0)
2067
- ]),
2068
- f.value || w.value ? (u(), se(I, {
2069
- key: 0,
2070
- variant: "tertiary",
2071
- label: "Clear",
2072
- "prepend-icon": "close",
2073
- onClick: X
2074
- })) : B("", !0)
2075
- ]),
2076
- e("div", xs, [
2077
- e("div", $s, [
2078
- k(j, {
2079
- modelValue: f.value,
2080
- "onUpdate:modelValue": C[0] || (C[0] = (p) => f.value = p)
2081
- }, null, 8, ["modelValue"])
2082
- ]),
2083
- e("div", Cs, [
2084
- k(o, {
2085
- modelValue: w.value,
2086
- "onUpdate:modelValue": C[1] || (C[1] = (p) => w.value = p)
2087
- }, null, 8, ["modelValue"])
2088
- ])
2089
- ]),
2090
- F.value ? (u(), $("div", ks, [
2091
- k(v, {
2092
- name: "error",
2093
- class: "inline-block mr-1",
2094
- size: "sm"
2095
- }),
2096
- e("div", Ds, g(F.value), 1)
2097
- ])) : B("", !0)
2098
- ])) : B("", !0),
2099
- e("div", Rs, [
2100
- C[8] || (C[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2101
- (u(!0), $(ue, null, _e(t.purchaseOrder.items, (p, z) => {
2102
- var le, oe, E;
2103
- return u(), $("div", { key: z }, [
2104
- e("div", Ns, [
2105
- e("div", As, [
2106
- e("span", Ts, g(p.sku.name), 1),
2107
- e("span", Fs, g(p.sku.code), 1)
2108
- ]),
2109
- e("div", Is, [
2110
- k(T, {
2111
- label: "Receive Quantity",
2112
- modelValue: re.value[z].value,
2113
- "onUpdate:modelValue": (ne) => re.value[z].value = ne,
2114
- "helper-text": `${S(n)("inventory.transfer.receiveRequest.details.received")} ${S(Ie).toFormatString(
2115
- {
2116
- value: (le = N.receivedInfoMap[p.sku._id]) == null ? void 0 : le.received
2117
- }
2118
- )} ${((oe = p.measurement) == null ? void 0 : oe.abbrev) ?? p.sku.unit.abbrev}`,
2119
- min: 0,
2120
- "append-text": ((E = p.measurement) == null ? void 0 : E.abbrev) ?? p.sku.unit.abbrev
2121
- }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
2122
- S(D) ? (u(), $("div", Ps, [
2123
- k(R, {
2124
- "model-value": a.value[z],
2125
- "onUpdate:modelValue": (ne) => pe(z),
2126
- size: "sm"
2127
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2128
- C[7] || (C[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2129
- ])) : B("", !0),
2130
- S(D) && a.value[z] ? (u(), se(T, {
2131
- key: 1,
2132
- modelValue: fe.value[z].value,
2133
- "onUpdate:modelValue": (ne) => fe.value[z].value = ne,
2134
- label: "Total Cost",
2135
- step: 1e-4,
2136
- min: 0,
2137
- placeholder: "0.0000",
2138
- size: "sm",
2139
- "append-text": S(xe)()
2140
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : B("", !0)
2141
- ])
2142
- ]),
2143
- z < t.purchaseOrder.items.length - 1 ? (u(), $("div", qs)) : B("", !0)
2144
- ]);
2145
- }), 128))
2146
- ]),
2147
- e("div", Vs, [
2148
- C[9] || (C[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2149
- e("div", Ls, [
2150
- k(K, {
2151
- modelValue: S(r).deliveryOrderNumber,
2152
- "onUpdate:modelValue": C[2] || (C[2] = (p) => S(r).deliveryOrderNumber = p),
2153
- size: "md"
2154
- }, null, 8, ["modelValue"])
2155
- ])
2156
- ]),
2157
- e("div", Es, [
2158
- C[10] || (C[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2159
- e("div", Bs, [
2160
- k(K, {
2161
- modelValue: S(r).remark,
2162
- "onUpdate:modelValue": C[3] || (C[3] = (p) => S(r).remark = p),
2163
- size: "md"
2164
- }, null, 8, ["modelValue"])
2165
- ])
2166
- ])
2167
- ])
2168
- ];
2169
- }),
2170
- _: 1
2171
- }, 8, ["modelValue"]);
2172
- };
2173
- }
2174
- }), Ms = /* @__PURE__ */ Se({
2175
- __name: "SystemTrailDialog",
2176
- props: {
2177
- purchaseOrderId: {},
2178
- deliveryOrderId: {}
2179
- },
2180
- setup(O) {
2181
- const s = O, n = qe(), y = W(!1), l = Qe(), t = W([]), i = W("");
2182
- async function r() {
2183
- await n.getDeliveryOrderTrails(s.purchaseOrderId, s.deliveryOrderId).then((h) => {
2184
- t.value = h;
2185
- });
2186
- }
2187
- function c(h) {
2188
- l.open({
2189
- title: "Metadata",
2190
- contentComponent: P(
2191
- "pre",
2192
- { class: "bg-gray-100 p-4 rounded whitespace-pre-wrap" },
2193
- JSON.stringify(h, null, 2)
2194
- )
2195
- });
2196
- }
2197
- const x = [
2198
- {
2199
- accessorKey: "createdAt",
2200
- header: () => "Created At"
2201
- },
2202
- {
2203
- accessorKey: "createdBy",
2204
- header: () => "Created By",
2205
- cell: (h) => h.getValue().name
2206
- },
2207
- {
2208
- accessorKey: "message",
2209
- header: () => "Message"
2210
- },
2211
- {
2212
- accessorKey: "metadata",
2213
- header: () => "Metadata",
2214
- cell: (h) => P(We.FmButton, {
2215
- label: "View",
2216
- onClick: () => c(h.getValue())
2217
- }),
2218
- meta: {
2219
- cellSpanClass: ""
2220
- }
2221
- }
2222
- ];
2223
- return (h, m) => {
2224
- const A = M("FmButton"), _ = M("FmTable"), D = M("FmDialog");
2225
- return u(), se(D, {
2226
- modelValue: y.value,
2227
- "onUpdate:modelValue": m[0] || (m[0] = (d) => y.value = d),
2228
- overlay: !0,
2229
- dismissAway: "",
2230
- "max-width": "800px"
2231
- }, {
2232
- "dialog-button": Y(() => [
2233
- k(De, null, {
2234
- default: Y(() => [
2235
- k(A, {
2236
- variant: "plain",
2237
- label: "Trails",
2238
- size: "md",
2239
- "prepend-icon": "overview",
2240
- onClick: r
2241
- })
2242
- ]),
2243
- _: 1
2244
- })
2245
- ]),
2246
- "dialog-header": Y(() => [
2247
- e("div", null, 'Delivery Order "' + g(h.deliveryOrderId) + '" Trails', 1)
2248
- ]),
2249
- default: Y(() => [
2250
- e("div", null, [
2251
- k(_, {
2252
- "row-data": t.value,
2253
- "column-defs": x,
2254
- "search-value": i.value,
2255
- "shrink-at": !1
2256
- }, null, 8, ["row-data", "search-value"])
2257
- ])
2258
- ]),
2259
- _: 1
2260
- }, 8, ["modelValue"]);
2261
- };
2262
- }
2263
- }), js = { class: "flex flex-row-reverse" }, zs = {
2264
- key: 0,
2265
- class: "flex"
2266
- }, Ks = {
2267
- key: 1,
2268
- class: "border-t pt-6"
2269
- }, Hs = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Ws = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Gs = { class: "w-full" }, Qs = {
2270
- class: "p-3 fm-typo-en-body-sm-600",
2271
- style: { "min-width": "130px" }
2272
- }, Ys = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Js = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zs = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, eo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, to = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ro = { class: "p-3 fm-typo-en-body-sm-600" }, so = { key: 2 }, oo = /* @__PURE__ */ Se({
2273
- __name: "NetSuiteTransactionChangeLog",
2274
- props: {
2275
- netsuiteId: {}
2276
- },
2277
- setup(O) {
2278
- const s = O, n = ct(), y = W(!1), l = W(!1), t = W(!1), i = W([]);
2279
- async function r() {
2280
- if (!(i.value.length > 0))
2281
- try {
2282
- l.value = !0;
2283
- const h = await n.getChangeLogs(s.netsuiteId);
2284
- i.value = h, t.value = !1;
2285
- } catch {
2286
- t.value = !0;
2287
- } finally {
2288
- l.value = !1;
2289
- }
2290
- }
2291
- function c(h) {
2292
- switch (h) {
2293
- case we.Create:
2294
- return "text-green-600 bg-green-100";
2295
- case we.Set:
2296
- return "text-blue-600 bg-blue-100";
2297
- case we.Change:
2298
- return "text-yellow-600 bg-yellow-100";
2299
- case we.Unset:
2300
- return "text-red-600 bg-red-100";
2301
- default:
2302
- return "text-gray-600 bg-gray-100";
2303
- }
2304
- }
2305
- function x(h) {
2306
- return new Date(h).toLocaleDateString("en-US", {
2307
- year: "numeric",
2308
- month: "short",
2309
- day: "numeric",
2310
- hour: "2-digit",
2311
- minute: "2-digit"
2312
- });
2313
- }
2314
- return (h, m) => {
2315
- const A = M("FmButton"), _ = M("FmCircularProgress"), D = M("FmIcon"), d = M("FmDialog");
2316
- return u(), $("div", js, [
2317
- k(d, {
2318
- modelValue: y.value,
2319
- "onUpdate:modelValue": m[2] || (m[2] = (a) => y.value = a),
2320
- overlay: !0,
2321
- "max-width": 800
2322
- }, {
2323
- "dialog-button": Y(() => [
2324
- k(A, {
2325
- "prepend-icon": "info",
2326
- variant: "secondary",
2327
- label: "NetSuite",
2328
- onClick: m[0] || (m[0] = (a) => r()),
2329
- "text-color": "primary",
2330
- "bg-color": "transparent",
2331
- "border-color": "primary"
2332
- })
2333
- ]),
2334
- "dialog-header": Y(() => m[3] || (m[3] = [
2335
- e("div", null, "NetSuite info", -1)
2336
- ])),
2337
- default: Y(() => [
2338
- l.value ? (u(), $("div", zs, [
2339
- m[4] || (m[4] = e("span", null, "Change Log Loading...", -1)),
2340
- k(_, { size: "md" })
2341
- ])) : B("", !0),
2342
- !l.value && i.value.length > 0 ? (u(), $("div", Ks, [
2343
- e("h3", Hs, [
2344
- k(D, {
2345
- name: "error",
2346
- color: "#ff9500",
2347
- size: "sm"
2348
- }),
2349
- m[5] || (m[5] = ke(" Change Logs "))
2350
- ]),
2351
- e("div", Ws, [
2352
- e("table", Gs, [
2353
- m[6] || (m[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2354
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2355
- e("th", {
2356
- class: "text-left p-3 fm-typo-en-body-md-600",
2357
- style: { "min-width": "130px" }
2358
- }, " Date "),
2359
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2360
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2361
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2362
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2363
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2364
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2365
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2366
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2367
- ])
2368
- ], -1)),
2369
- e("tbody", null, [
2370
- (u(!0), $(ue, null, _e(i.value, (a, b) => (u(), $("tr", {
2371
- key: b,
2372
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2373
- }, [
2374
- e("td", Qs, g(x(a._dateiso8601)), 1),
2375
- e("td", Ys, g(a._rolename), 1),
2376
- e("td", Js, g(a._employeename), 1),
2377
- e("td", Xs, g(a._contextname), 1),
2378
- e("td", {
2379
- class: Be(`p-3 fm-typo-en-body-sm-600 ${c(Number(a.type) - 1)}`)
2380
- }, g(S(we)[Number(a.type) - 1]), 3),
2381
- e("td", Zs, g(a.lineid || ""), 1),
2382
- e("td", eo, g(a._fieldname), 1),
2383
- e("td", to, g(a.oldvalue || ""), 1),
2384
- e("td", ro, g(a.newvalue || ""), 1)
2385
- ]))), 128))
2386
- ])
2387
- ])
2388
- ])
2389
- ])) : (u(), $("div", so, m[7] || (m[7] = [
2390
- e("p", null, "No change logs available.", -1)
2391
- ])))
2392
- ]),
2393
- "dialog-footer": Y(() => [
2394
- k(A, {
2395
- class: "ml-auto sm:w-full xs:w-full",
2396
- label: "Close",
2397
- size: "md",
2398
- variant: "primary",
2399
- onClick: m[1] || (m[1] = (a) => y.value = !1)
2400
- })
2401
- ]),
2402
- _: 1
2403
- }, 8, ["modelValue"])
2404
- ]);
2405
- };
2406
- }
2407
- }), no = { class: "flex flex-col w-full gap-3" }, ao = { class: "flex" }, lo = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, io = { class: "flex flex-col gap-16 w-full h-full" }, co = { class: "flex justify-between" }, uo = { class: "fm-typo-en-body-lg-600" }, mo = { class: "flex gap-2" }, po = {
2408
- key: 0,
2409
- class: "flex items-center gap-1"
2410
- }, fo = { class: "fm-typo-en-body-md-400" }, yo = { class: "flex flex-col gap-8" }, vo = { class: "flex flex-col gap-4" }, ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bo = { class: "flex gap-1" }, go = { class: "fm-typo-en-body-lg-600" }, _o = {
2411
- key: 0,
2412
- class: "flex flex-col gap-4"
2413
- }, So = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Oo = { class: "fm-typo-en-body-lg-600" }, wo = { class: "flex flex-col gap-4" }, xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $o = { class: "fm-typo-en-body-lg-600" }, Co = {
2414
- key: 1,
2415
- class: "flex flex-col gap-4"
2416
- }, ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Do = { class: "fm-typo-en-body-lg-600" }, Ro = {
2417
- key: 2,
2418
- class: "flex flex-col gap-4"
2419
- }, No = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ao = { class: "fm-typo-en-body-lg-600" }, To = {
2420
- key: 3,
2421
- class: "flex flex-col gap-4"
2422
- }, Fo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Io = { class: "fm-typo-en-body-lg-600" }, Po = {
2423
- key: 4,
2424
- class: "flex flex-col gap-4"
2425
- }, qo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vo = { class: "fm-typo-en-body-lg-600" }, Lo = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Eo = { class: "flex flex-col gap-8" }, Bo = { class: "flex gap-8 items-center" }, Uo = { class: "flex-1 fm-typo-en-body-lg-600" }, Mo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, jo = { class: "flex w-full gap-4" }, zo = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, Ho = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Wo = ["innerHTML"], Go = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Qo = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Yo = {
2426
- key: 0,
2427
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2428
- }, Jo = { class: "py-8" }, Xo = { class: "flex justify-end gap-4 items-center" }, Zo = { class: "fm-typo-en-body-lg-600" }, en = {
2429
- key: 1,
2430
- class: "flex-1 xs:w-screen xs:max-w-full"
2431
- }, tn = {
2432
- key: 0,
2433
- class: "flex flex-col items-center gap-8 h-full"
2434
- }, rn = ["src"], sn = { class: "fm-typo-en-body-lg-600" }, on = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, nn = {
2435
- key: 1,
2436
- class: "px-4 flex flex-col"
2437
- }, an = { class: "flex gap-12 content-stretch" }, ln = {
2438
- class: "flex flex-col w-40",
2439
- name: "circles"
2440
- }, cn = { class: "flex-1 flex flex-col items-center" }, un = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, dn = { class: "flex-1 flex flex-col items-center" }, mn = { class: "flex w-full items-center gap-4" }, pn = {
2441
- class: "py-12 flex flex-col gap-4",
2442
- name: "received-at header"
2443
- }, fn = { class: "fm-typo-en-body-lg-400" }, yn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vn = { class: "ml-auto flex gap-1" }, hn = { class: "flex gap-12 content-stretch" }, bn = {
2444
- class: "flex flex-col w-40",
2445
- name: "circles"
2446
- }, gn = { class: "flex-1 flex flex-col items-center" }, _n = {
2447
- class: "py-12 flex flex-col gap-4 flex-1",
2448
- name: "delivery details"
2449
- }, Sn = { class: "flex flex-col gap-8" }, On = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, wn = { class: "flex flex-col gap-4" }, xn = { class: "flex gap-8 xs:flex-col" }, Vn = /* @__PURE__ */ Se({
2450
- __name: "TransferDetails",
2451
- props: {
2452
- poRequest: {},
2453
- purchaseOrder: {},
2454
- transferTo: {},
2455
- transferToDbName: {},
2456
- show: { type: Boolean },
2457
- canResubmit: { type: Boolean },
2458
- canApprove: { type: Boolean },
2459
- scope: {},
2460
- receivedMap: {},
2461
- shipments: {}
2462
- },
2463
- emits: ["update:show", "submitted"],
2464
- setup(O, { emit: s }) {
2465
- const n = O, y = s, l = Qe(), t = Me(), i = Ue(), r = $e(), c = Ge(), x = Q(
2466
- () => {
2467
- var o, v;
2468
- return {
2469
- id: ((o = c.sessionUser.value) == null ? void 0 : o.id) ?? "",
2470
- name: ((v = c.sessionUser.value) == null ? void 0 : v.displayName) ?? ""
2471
- };
2472
- }
2473
- ), h = tr(), { t: m } = ut(), A = Q(
2474
- () => {
2475
- var o, v, T, R;
2476
- return ((v = (o = n.purchaseOrder) == null ? void 0 : o.supplier) == null ? void 0 : v.internal) === "restaurant" || ((R = (T = n.purchaseOrder) == null ? void 0 : T.supplier) == null ? void 0 : R.internal) === "warehouse" ? Pe.TRANSFER : Pe.PURCHASE;
2477
- }
2478
- ), _ = Q(() => {
2479
- var T;
2480
- const o = (T = n.shipments) == null ? void 0 : T.find((R) => {
2481
- var K;
2482
- return R.ref === ((K = n.purchaseOrder) == null ? void 0 : K._id);
2483
- });
2484
- let v = null;
2485
- if (o != null && o.milestones && o.milestones.length > 0) {
2486
- const R = o.milestones[o.milestones.length - 1];
2487
- if (R.estimatedTime) {
2488
- const K = new Date(R.estimatedTime), H = K.getDate().toString().padStart(2, "0");
2489
- v = `${K.toLocaleString("en-US", { month: "short" })} ${H}`;
2490
- }
2491
- }
2492
- return v;
2493
- }), D = W(!1), d = W(""), a = W(!0), b = qe(), f = Kt(b.getWorkflowConfig), w = wt(), L = Q(() => {
2494
- if (!n.purchaseOrder)
2495
- return [];
2496
- const o = f.result.value;
2497
- if (o.state === pt.loading)
2498
- return [];
2499
- const v = {
2500
- user: x.value,
2501
- executedAt: r.locations.computeFirst(
2502
- (R) => {
2503
- var K;
2504
- return R.dbName === ((K = r._currentLocation) == null ? void 0 : K.dbName) ? R : null;
2505
- }
2506
- ),
2507
- purchaseOrderRequest: n.poRequest,
2508
- purchaseOrder: n.purchaseOrder
2509
- };
2510
- let T = [];
2511
- try {
2512
- o.state === pt.error ? (console.error("Error fetching workflow config:", o.error), T = rt.getAvailableActions({
2513
- ...v,
2514
- orderConfig: rt.getDefaultConfig()
2515
- }).actions.filter(
2516
- (R) => (
2517
- // TODO: create receiveStock & processRequest dialog
2518
- // to create their payload
2519
- R !== V.enum.receiveStock && R !== V.enum.processRequest && R !== V.enum.closeRequest
2520
- )
2521
- )) : T = rt.getAvailableActions({
2522
- ...v,
2523
- orderConfig: o.data
2524
- }).actions.filter(
2525
- (R) => R !== V.enum.receiveStock && R !== V.enum.processRequest && R !== V.enum.closeRequest
2526
- );
2527
- } catch (R) {
2528
- console.error("Error getting available actions:", R);
2529
- }
2530
- return n.scope === "approval" && (T = T.filter((R) => R !== V.enum.completeReceive)), T;
2531
- }), G = Vt(n, "show"), F = Q(() => [
2532
- {
2533
- label: m("inventory.transfer.receiveRequest.details.overview"),
2534
- value: "overview"
2535
- },
2536
- {
2537
- label: m("inventory.transfer.receiveRequest.details.deliveryHistory"),
2538
- value: "deliveryHistory"
2539
- }
2540
- ]), J = W(F.value[0]);
2541
- Ft(
2542
- () => n.show,
2543
- (o) => {
2544
- o && (J.value = F.value[0]);
2545
- }
2546
- );
2547
- function X(o) {
2548
- return o.map((v) => ({
2549
- ...v,
2550
- amount: {
2551
- ...v.amount,
2552
- amount: -Math.abs(v.amount.amount)
2553
- }
2554
- }));
2555
- }
2556
- async function re(o, v, T, R, K) {
2557
- return new Promise((H, te) => {
2558
- l.open({
2559
- closeButton: !1,
2560
- title: R.title,
2561
- message: R.message,
2562
- primaryActions: R.primaryActions,
2563
- secondaryActions: { text: "No", close: !1 }
2564
- }).onPrimary(async () => {
2565
- var z, le, oe, E;
2566
- const p = [];
2567
- T === V.enum.approveRequest ? (p.push({
2568
- action: "approveRequest",
2569
- payload: null
2570
- }), v.fulfillment && p.push({
2571
- action: "processRequest",
2572
- payload: {
2573
- fulfillmentId: "",
2574
- deliveryOrderNumber: "",
2575
- deliveryRemark: null,
2576
- items: X(v.fulfillment.items),
2577
- createdBy: x.value
2578
- }
2579
- })) : T === V.enum.processRequest ? v.fulfillment && p.push({
2580
- action: "processRequest",
2581
- payload: {
2582
- fulfillmentId: "",
2583
- deliveryOrderNumber: "",
2584
- deliveryRemark: null,
2585
- items: X(v.fulfillment.items),
2586
- createdBy: x.value
2587
- }
2588
- }) : T === V.enum.rejectRequest ? p.push({
2589
- action: "rejectRequest",
2590
- payload: null
2591
- }) : T === V.enum.closeRequest && p.push({
2592
- action: "closeRequest",
2593
- payload: null
2594
- });
2595
- try {
2596
- await w({
2597
- operate: {
2598
- operation: T,
2599
- doc: o,
2600
- options: v
2601
- },
2602
- operateV2: {
2603
- _id: ((z = n.purchaseOrder) == null ? void 0 : z._id) ?? "",
2604
- _rev: ((le = n.purchaseOrder) == null ? void 0 : le._rev) ?? "",
2605
- action: T,
2606
- payloads: p
2607
- // add payload if action is receiveStock or processRequest
2608
- },
2609
- transferTo: (E = (oe = n.poRequest) == null ? void 0 : oe.to) == null ? void 0 : E.dbName
2610
- }).delayed(1e3), H("submitted");
2611
- } catch (ne) {
2612
- te(ne);
2613
- }
2614
- }).onSecondary(() => {
2615
- H("cancelled");
2616
- for (let p = 0; p < K + 2; p++)
2617
- l.close();
2618
- }).onClose(() => {
2619
- });
2620
- });
2621
- }
2622
- async function pe(o) {
2623
- var K, H, te, p;
2624
- if (o === V.enum.receiveStock)
2625
- return;
2626
- const v = Ot[o];
2627
- if (!v) {
2628
- t.open({
2629
- title: "Something went wrong",
2630
- message: `Cannot process order: ${it(o)}`,
2631
- type: "error"
2632
- });
2633
- return;
2634
- }
2635
- const { successMessage: T, ...R } = v;
2636
- if (n.purchaseOrder) {
2637
- d.value = `${o}`, D.value = !0, a.value = !1;
2638
- const z = {};
2639
- let le = 0;
2640
- if ((o === V.enum.confirmDraft || // auto receive for warehouse to warehouse
2641
- o === V.enum.completeReceive) && i.autoReceiveWarehouse)
2642
- z.autoReceive = !0;
2643
- else if ((o === V.enum.approveRequest || o === V.enum.processRequest) && i.acceptRequireFulfillment) {
2644
- const oe = (H = (K = n.poRequest) == null ? void 0 : K.from) == null ? void 0 : H.dbName, E = (p = (te = n.poRequest) == null ? void 0 : te.to) == null ? void 0 : p.dbName;
2645
- if (oe && E && (oe.startsWith("warehouse_") || E.startsWith("warehouse_"))) {
2646
- const ne = await new Promise((Oe, Ne) => {
2647
- l.open({
2648
- closeButton: !1,
2649
- title: "Confirm transfer amount",
2650
- dialogComponent: er,
2651
- dialogComponentProps: {
2652
- purchaseOrder: n.purchaseOrder,
2653
- confirm: Oe,
2654
- "onUpdate:show": (Ae) => {
2655
- Ae || (d.value = "", D.value = !1, a.value = !0, le++, l.close()), Ne("cancelled");
2656
- }
2657
- }
2658
- });
2659
- });
2660
- z.fulfillment = ne;
2661
- }
2662
- }
2663
- try {
2664
- await re(
2665
- n.purchaseOrder,
2666
- z,
2667
- o,
2668
- v,
2669
- le
2670
- ) === "submitted" && (t.open({
2671
- title: "Success",
2672
- message: T,
2673
- type: "success"
2674
- }), y("update:show", !1), y("submitted"));
2675
- } catch (oe) {
2676
- t.open({
2677
- title: "Something went wrong",
2678
- message: "Please try again.",
2679
- type: "error"
2680
- }), console.error("Error when submitting PO operation", o, n.purchaseOrder, oe);
2681
- } finally {
2682
- d.value = "", D.value = !1, a.value = !0;
2683
- }
2684
- }
2685
- }
2686
- const fe = Q(() => {
2687
- var o, v;
2688
- return ((o = n.purchaseOrder) == null ? void 0 : o.status) === ee.enum.RECEIVING || ((v = n.purchaseOrder) == null ? void 0 : v.status) === ee.enum.COMPLETE;
2689
- }), Re = Q(() => n.purchaseOrder ? Ze(n.purchaseOrder) : {}), Ve = Q(() => {
2690
- const o = n.purchaseOrder;
2691
- if (!o) return { status: "", statusClass: "" };
2692
- const { partial: v, over: T } = nt(Re.value), R = at(o.status, v, T);
2693
- let K = m(`inventory.transfer.status.${R}`), H = `${o.status}`.toLocaleLowerCase("en-us");
2694
- return R === ee.enum.CLOSE && (K = `${m(`inventory.transfer.status.${ee.enum.COMPLETE}`)}`), R === "PARTIAL_RECEIVED" && H === ee.enum.PROCESSING.toLocaleLowerCase("en-us") && (H = ee.enum.RECEIVING.toLocaleLowerCase("en-us")), {
2695
- status: K,
2696
- statusClass: `fm-status-badge fm-status-badge-${H}`
2697
- };
2698
- }), q = Q(() => {
2699
- var H, te;
2700
- const o = ((H = n.purchaseOrder) == null ? void 0 : H.deliveryOrder) ?? [], v = ((te = n.purchaseOrder) == null ? void 0 : te.deliveryFullfillment) ?? [], T = [
2701
- ...o.map((p) => ({
2702
- createdAt: p.createdAt,
2703
- type: "grn",
2704
- doc: p
2705
- })),
2706
- ...v.map((p) => ({
2707
- createdAt: p.createdAt,
2708
- type: "fulfillment",
2709
- doc: p
2710
- }))
2711
- ];
2712
- T.reverse().sort((p, z) => p.createdAt.localeCompare(z.createdAt));
2713
- function R(p) {
2714
- var oe, E, ne, Oe, Ne, Ae, Z, ce, de, ye;
2715
- const z = v.findIndex((ie) => ie.id === p.fullfillmentId), le = [
2716
- (E = (oe = v[z]) == null ? void 0 : oe.netSuite) != null && E.refNo ? {
2717
- label: "Fulfillment's ref no. (Netsuite)",
2718
- values: [(Oe = (ne = v[z]) == null ? void 0 : ne.netSuite) == null ? void 0 : Oe.refNo]
2719
- } : null,
2720
- (Ne = p == null ? void 0 : p.netSuite) != null && Ne.refNo ? {
2721
- label: "Netsuite ref no.",
2722
- values: [`${(Ae = p == null ? void 0 : p.netSuite) == null ? void 0 : Ae.refNo} (${((Z = p == null ? void 0 : p.netSuite) == null ? void 0 : Z.id) ?? "-"})`]
2723
- } : null,
2724
- (ce = p == null ? void 0 : p.netSuite) != null && ce.recordType ? {
2725
- label: "Netsuite Type",
2726
- values: [gt((de = p == null ? void 0 : p.netSuite) == null ? void 0 : de.recordType)]
2727
- } : null
2728
- ];
2729
- return {
2730
- header: "Received",
2731
- deliveryOrder: p,
2732
- date: He(new Date(p.createdAt)),
2733
- info: [
2734
- {
2735
- label: "Adjustment date",
2736
- values: [
2737
- p.adjustment ? He(new Date(Xe(p.adjustment))) : "-"
2738
- ]
2739
- },
2740
- {
2741
- label: "Received by",
2742
- values: [(ye = p.createdBy) == null ? void 0 : ye.name]
2743
- },
2744
- {
2745
- label: "Received items",
2746
- values: p.received.map((ie) => {
2747
- var Ce;
2748
- return P("div", [
2749
- P(
2750
- "div",
2751
- {
2752
- class: "flex gap-4"
2753
- },
2754
- [
2755
- P(
2756
- "div",
2757
- {
2758
- class: "flex flex-col"
2759
- },
2760
- [
2761
- P(
2762
- "span",
2763
- {
2764
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2765
- },
2766
- `${ie.sku.name}`
2767
- ),
2768
- P(
2769
- "span",
2770
- {
2771
- class: "fm-typo-en-body-md-400"
2772
- },
2773
- `${ie.sku.code} `
2774
- )
2775
- ]
2776
- ),
2777
- P(
2778
- "div",
2779
- {
2780
- class: "ml-auto flex flex-col"
2781
- },
2782
- [
2783
- P(
2784
- "div",
2785
- {
2786
- class: "ml-auto flex gap-1"
2787
- },
2788
- [
2789
- P(
2790
- "span",
2791
- {
2792
- class: "fm-typo-en-body-lg-600 self-end"
2793
- },
2794
- ve(ie.amount, !1)
2795
- ),
2796
- P(
2797
- "span",
2798
- {
2799
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2800
- },
2801
- ((Ce = ie.measurement) == null ? void 0 : Ce.abbrev) ?? ie.sku.unit.abbrev
2802
- )
2803
- ]
2804
- ),
2805
- P(
2806
- "div",
2807
- {
2808
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2809
- },
2810
- `${ie.cost ? `(${Ke(ie.cost)})` : ""}`
2811
- )
2812
- ]
2813
- )
2814
- ]
2815
- )
2816
- ]);
2817
- })
2818
- },
2819
- {
2820
- label: "Delivery order no.",
2821
- values: [p.deliveryOrderNumber || "N/A"]
2822
- },
2823
- {
2824
- label: "Remark",
2825
- values: [p.remark || "N/A"]
2826
- },
2827
- z > -1 ? {
2828
- label: "Fulfilment's sequence",
2829
- values: [`${z + 1}`]
2830
- } : null,
2831
- ...le
2832
- ].filter((ie) => !!ie)
2833
- };
2834
- }
2835
- function K(p) {
2836
- var le, oe;
2837
- const z = v.findIndex((E) => E.id === p.id);
2838
- return {
2839
- header: "Fulfillment",
2840
- date: He(new Date(p.createdAt)),
2841
- info: [
2842
- {
2843
- label: "Sequence",
2844
- values: [String(z + 1)]
2845
- },
2846
- {
2847
- label: "Receiveable items",
2848
- values: p.items.map((E) => {
2849
- var ne;
2850
- return P("div", [
2851
- P(
2852
- "div",
2853
- {
2854
- class: "flex gap-4"
2855
- },
2856
- [
2857
- P(
2858
- "div",
2859
- {
2860
- class: "flex flex-col"
2861
- },
2862
- [
2863
- P(
2864
- "span",
2865
- {
2866
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2867
- },
2868
- `${E.sku.name}`
2869
- ),
2870
- P(
2871
- "span",
2872
- {
2873
- class: "fm-typo-en-body-md-400"
2874
- },
2875
- `${E.sku.code} `
2876
- )
2877
- ]
2878
- ),
2879
- P(
2880
- "div",
2881
- {
2882
- class: "ml-auto flex flex-col"
2883
- },
2884
- [
2885
- P(
2886
- "div",
2887
- {
2888
- class: "ml-auto flex gap-1"
2889
- },
2890
- [
2891
- P(
2892
- "span",
2893
- {
2894
- class: "fm-typo-en-body-lg-600 self-end"
2895
- },
2896
- ve(E.amount, !1)
2897
- ),
2898
- P(
2899
- "span",
2900
- {
2901
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2902
- },
2903
- ((ne = E.measurement) == null ? void 0 : ne.abbrev) ?? E.sku.unit.abbrev
2904
- )
2905
- ]
2906
- ),
2907
- P(
2908
- "div",
2909
- {
2910
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2911
- },
2912
- `${E.cost ? `(${Ke(E.cost)})` : ""}`
2913
- )
2914
- ]
2915
- )
2916
- ]
2917
- )
2918
- ]);
2919
- })
2920
- },
2921
- (le = p.netSuite) != null && le.refNo ? {
2922
- label: "Ref no. (Netsuite)",
2923
- values: [(oe = p.netSuite) == null ? void 0 : oe.refNo]
2924
- } : null
2925
- ].filter((E) => !!E)
2926
- };
2927
- }
2928
- return T.map((p) => {
2929
- switch (p.type) {
2930
- case "grn":
2931
- return R(p.doc);
2932
- case "fulfillment":
2933
- return K(p.doc);
2934
- }
2935
- });
2936
- }), U = Q(() => {
2937
- var v;
2938
- const o = {
2939
- ...ht(0),
2940
- currency: xe()
2941
- };
2942
- return ((v = n.purchaseOrder) == null ? void 0 : v.items.reduce((T, R) => ({
2943
- ...vt(T, R.totalCost ?? o),
2944
- currency: xe()
2945
- }), o)) ?? o;
2946
- });
2947
- function ae(o) {
2948
- var H;
2949
- const T = (((H = n.purchaseOrder) == null ? void 0 : H.version) ?? Fe.enum[1]) === Fe.enum[2] ? o.id : o.sku._id, R = n.receivedMap[T];
2950
- return `<span class="${N(o)} fm-typo-en-body-lg-600">${Ie.toFormatString({ value: R.received })}</span>/${Bt(o.quantity, o.sku.unit, o.measurement)}`;
2951
- }
2952
- function N(o) {
2953
- var z;
2954
- const T = (((z = n.purchaseOrder) == null ? void 0 : z.version) ?? Fe.enum[1]) === Fe.enum[2] ? o.id : o.sku._id, R = n.receivedMap[T], { isPartialReceive: K, isNoReceive: H, isOverReceive: te, isFullReceive: p } = Gt(R);
2955
- return H ? "text-fm-color-typo-tertiary" : K ? "text-fm-color-system-warning-300" : te ? "text-fm-color-system-error-300" : p ? "text-fm-color-system-success-300" : "";
2956
- }
2957
- const C = Q(() => {
2958
- var o, v, T;
2959
- return (o = n.purchaseOrder) != null && o.itemsAtSubmission ? ((v = n.purchaseOrder) == null ? void 0 : v.version) === Fe.enum[2] ? n.purchaseOrder.items.reduce((R, K) => {
2960
- var te, p;
2961
- const H = (p = (te = n.purchaseOrder) == null ? void 0 : te.itemsAtSubmission) == null ? void 0 : p.find(
2962
- (z) => z.id === K.id
2963
- );
2964
- return H && H.quantity !== K.quantity && R.set(K.sku.code, {
2965
- originalAmount: Number(Ie.toFormatString({ value: H.quantity })),
2966
- newAmount: Number(Ie.toFormatString({ value: K.quantity }))
2967
- }), R;
2968
- }, /* @__PURE__ */ new Map()) : (T = n.purchaseOrder) == null ? void 0 : T.items.reduce((R, K) => {
2969
- var z, le;
2970
- const H = (le = (z = n.purchaseOrder) == null ? void 0 : z.itemsAtSubmission) == null ? void 0 : le.find(
2971
- (oe) => oe.sku._id === K.sku._id
2972
- ), te = H ? Number(Ie.toFormatString({ value: H.quantity })) : 0, p = Number(Ie.toFormatString({ value: K.quantity }));
2973
- return H && te !== p && R.set(K.sku.code, {
2974
- originalAmount: te,
2975
- newAmount: p
2976
- }), R;
2977
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2978
- }), I = (o) => {
2979
- var T, R;
2980
- const v = C.value;
2981
- return ((T = n.purchaseOrder) == null ? void 0 : T.version) === Fe.enum[2] ? v.has(o.id) : v.has((R = o.sku) == null ? void 0 : R.code);
2982
- }, j = (o) => {
2983
- var T, R;
2984
- const v = C.value;
2985
- return ((T = n.purchaseOrder) == null ? void 0 : T.version) === Fe.enum[2] ? v.get(o.id) : v.get((R = o.sku) == null ? void 0 : R.code);
2986
- };
2987
- return (o, v) => {
2988
- const T = M("FmButton"), R = M("FmButtonGroup"), K = M("FmChip"), H = M("FmIcon"), te = M("FmMenuDivider"), p = M("FmCard"), z = M("FmTooltip"), le = M("FmSpacer"), oe = M("FmSideSheet");
2989
- return u(), se(oe, {
2990
- modelValue: S(G),
2991
- "onUpdate:modelValue": v[8] || (v[8] = (E) => It(G) ? G.value = E : null),
2992
- "dismiss-away": a.value,
2993
- "max-width": 600,
2994
- "close-button": !1
2995
- }, {
2996
- "side-sheet-header": Y(() => {
2997
- var E, ne;
2998
- return [
2999
- e("div", no, [
3000
- e("div", ao, [
3001
- e("div", lo, g(S(m)("inventory.transfer.receiveRequest.details.title") + ((E = o.purchaseOrder) != null && E.seqNumber ? ` #${(ne = o.purchaseOrder) == null ? void 0 : ne.seqNumber}` : "")), 1),
3002
- k(T, {
3003
- class: "ml-auto -m-2",
3004
- variant: "tertiary",
3005
- "prepend-icon": "close",
3006
- onClick: v[0] || (v[0] = (Oe) => y("update:show", !1))
3007
- })
3008
- ]),
3009
- k(R, {
3010
- items: F.value,
3011
- modelValue: J.value,
3012
- "onUpdate:modelValue": v[1] || (v[1] = (Oe) => J.value = Oe)
3013
- }, null, 8, ["items", "modelValue"]),
3014
- o.purchaseOrder && J.value.value === "deliveryHistory" ? (u(), se(Us, {
3015
- key: 0,
3016
- "purchase-order": o.purchaseOrder,
3017
- "received-info-map": Re.value,
3018
- onSubmitted: v[2] || (v[2] = () => {
3019
- y("update:show", !1), y("submitted");
3020
- })
3021
- }, null, 8, ["purchase-order", "received-info-map"])) : B("", !0)
3022
- ])
3023
- ];
3024
- }),
3025
- default: Y(() => {
3026
- var E, ne, Oe, Ne, Ae;
3027
- return [
3028
- e("div", io, [
3029
- J.value.value === "overview" ? (u(), $(ue, { key: 0 }, [
3030
- e("div", null, [
3031
- k(p, {
3032
- variant: "outlined",
3033
- class: "flex flex-col gap-8 px-12 py-16"
3034
- }, {
3035
- default: Y(() => {
3036
- var Z, ce, de, ye, ie, Ce, je, he, Te;
3037
- return [
3038
- e("div", co, [
3039
- e("div", uo, g(S(m)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
3040
- e("div", mo, [
3041
- k(De, null, {
3042
- default: Y(() => {
3043
- var Le;
3044
- return [
3045
- ke(g((Le = n.purchaseOrder) == null ? void 0 : Le.status), 1)
3046
- ];
3047
- }),
3048
- _: 1
3049
- }),
3050
- k(K, {
3051
- label: Ve.value.status,
3052
- class: Be(Ve.value.statusClass),
3053
- compact: ""
3054
- }, null, 8, ["label", "class"]),
3055
- _.value ? (u(), $("div", po, [
3056
- k(H, {
3057
- name: "local_shipping",
3058
- color: "#666666"
3059
- }),
3060
- e("span", fo, g(_.value), 1)
3061
- ])) : B("", !0)
3062
- ])
3063
- ]),
3064
- k(te),
3065
- e("div", yo, [
3066
- e("div", vo, [
3067
- e("div", ho, [
3068
- e("div", bo, g(S(m)("inventory.transfer.receiveRequest.details.createdAt")), 1)
3069
- ]),
3070
- e("div", go, g(S(Ye)(((Z = o.purchaseOrder) == null ? void 0 : Z._id) ?? "")), 1)
3071
- ]),
3072
- (ce = o.purchaseOrder) != null && ce.effectiveAt ? (u(), $("div", _o, [
3073
- e("div", So, g(S(m)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
3074
- e("div", Oo, g(S(bt)(new Date((de = o.purchaseOrder) == null ? void 0 : de.effectiveAt))), 1)
3075
- ])) : B("", !0),
3076
- e("div", wo, [
3077
- e("div", xo, g(S(m)("inventory.transfer.receiveRequest.details.type.title")), 1),
3078
- e("div", $o, g(S(m)(
3079
- `inventory.transfer.receiveRequest.details.type.${A.value.toLocaleLowerCase("en-US")}`
3080
- )), 1)
3081
- ]),
3082
- (ie = (ye = o.purchaseOrder) == null ? void 0 : ye.supplier) != null && ie.name ? (u(), $("div", Co, [
3083
- e("div", ko, g(S(m)("inventory.transfer.receiveRequest.details.from")), 1),
3084
- e("div", Do, g((je = (Ce = o.purchaseOrder) == null ? void 0 : Ce.supplier) == null ? void 0 : je.name), 1)
3085
- ])) : B("", !0),
3086
- o.transferTo ? (u(), $("div", Ro, [
3087
- e("div", No, g(S(m)("inventory.transfer.receiveRequest.details.to")), 1),
3088
- e("div", Ao, g(o.transferTo), 1)
3089
- ])) : B("", !0),
3090
- (he = o.purchaseOrder) != null && he.ref ? (u(), $("div", To, [
3091
- e("div", Fo, g(S(m)("inventory.transfer.receiveRequest.details.reference")), 1),
3092
- e("div", Io, g(o.purchaseOrder.ref), 1)
3093
- ])) : B("", !0),
3094
- (Te = o.purchaseOrder) != null && Te.remark ? (u(), $("div", Po, [
3095
- e("div", qo, g(S(m)("inventory.transfer.receiveRequest.details.remark")), 1),
3096
- e("div", Vo, g(o.purchaseOrder.remark), 1)
3097
- ])) : B("", !0)
3098
- ])
3099
- ];
3100
- }),
3101
- _: 1
3102
- })
3103
- ]),
3104
- k(Jr, {
3105
- "po-request": o.poRequest,
3106
- purchaseOrder: o.purchaseOrder,
3107
- transferType: A.value,
3108
- transferToDbName: o.transferToDbName,
3109
- scope: o.scope
3110
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
3111
- e("div", Lo, [
3112
- e("div", Eo, [
3113
- e("div", Bo, [
3114
- e("span", Uo, [
3115
- ke(g(fe.value ? S(m)("inventory.transfer.receiveRequest.details.receivedItems") : S(m)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
3116
- (ne = (E = o.purchaseOrder) == null ? void 0 : E.netSuite) != null && ne.missingItems && ((Ne = (Oe = o.purchaseOrder) == null ? void 0 : Oe.netSuite) == null ? void 0 : Ne.missingItems.length) > 0 ? (u(), se(z, {
3117
- key: 0,
3118
- variant: "rich",
3119
- placement: "top",
3120
- "z-index": 51
3121
- }, {
3122
- content: Y(() => {
3123
- var Z, ce;
3124
- return [
3125
- e("div", Mo, [
3126
- (u(!0), $(ue, null, _e((ce = (Z = o.purchaseOrder) == null ? void 0 : Z.netSuite) == null ? void 0 : ce.missingItems, (de, ye) => (u(), $("div", {
3127
- class: "flex justify-center align-middle",
3128
- key: ye
3129
- }, [
3130
- k(H, {
3131
- name: "arrow_right",
3132
- size: "sm"
3133
- }),
3134
- ke(" " + g(`(${de.netSuiteId}) ${de.name}: ${de.reason}`), 1)
3135
- ]))), 128))
3136
- ])
3137
- ];
3138
- }),
3139
- default: Y(() => [
3140
- k(H, {
3141
- name: "error",
3142
- color: "#ff2c2c",
3143
- size: "sm"
3144
- })
3145
- ]),
3146
- _: 1
3147
- })) : B("", !0)
3148
- ])
3149
- ]),
3150
- k(te),
3151
- (u(!0), $(ue, null, _e(((Ae = o.purchaseOrder) == null ? void 0 : Ae.items) ?? [], (Z, ce) => {
3152
- var de;
3153
- return u(), $("div", {
3154
- key: ce,
3155
- class: "flex flex-col"
3156
- }, [
3157
- e("div", jo, [
3158
- e("div", zo, [
3159
- ke(g(Z.name) + " ", 1),
3160
- I(Z) ? (u(), se(z, {
3161
- key: 0,
3162
- variant: "rich",
3163
- placement: "top",
3164
- "z-index": 51
3165
- }, {
3166
- content: Y(() => {
3167
- var ye, ie;
3168
- return [
3169
- e("div", Ko, [
3170
- v[9] || (v[9] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
3171
- e("div", null, "Original Amount: " + g((ye = j(Z)) == null ? void 0 : ye.originalAmount), 1),
3172
- e("div", null, " New Amount: " + g((ie = j(Z)) == null ? void 0 : ie.newAmount), 1)
3173
- ])
3174
- ];
3175
- }),
3176
- default: Y(() => [
3177
- k(H, {
3178
- name: "error",
3179
- color: "#ff9500",
3180
- size: "sm"
3181
- })
3182
- ]),
3183
- _: 2
3184
- }, 1024)) : B("", !0)
3185
- ]),
3186
- e("div", Ho, [
3187
- e("span", {
3188
- innerHTML: ae(Z)
3189
- }, null, 8, Wo)
3190
- ])
3191
- ]),
3192
- e("div", Go, [
3193
- e("div", Qo, g(Z.code), 1),
3194
- (de = Z.totalCost) != null && de.amount && S(i).enableTotalCost ? (u(), $("div", Yo, " (" + g(S(Ke)(Z.totalCost)) + ") ", 1)) : B("", !0)
3195
- ])
3196
- ]);
3197
- }), 128)),
3198
- +S(ve)(U.value) ? (u(), $(ue, { key: 0 }, [
3199
- e("div", Jo, [
3200
- k(te)
3201
- ]),
3202
- e("div", Xo, [
3203
- v[10] || (v[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
3204
- e("div", Zo, g(S(Ke)(U.value)), 1)
3205
- ])
3206
- ], 64)) : B("", !0)
3207
- ])
3208
- ])
3209
- ], 64)) : J.value.value === "deliveryHistory" ? (u(), $("div", en, [
3210
- q.value.length ? (u(), $("div", nn, [
3211
- (u(!0), $(ue, null, _e(q.value, (Z, ce) => {
3212
- var de, ye, ie, Ce, je;
3213
- return u(), $(ue, { key: ce }, [
3214
- e("div", an, [
3215
- e("div", ln, [
3216
- e("div", cn, [
3217
- e("div", {
3218
- class: Be([
3219
- {
3220
- "bg-fm-color-primary": ce !== 0,
3221
- "bg-white": ce === 0
3222
- },
3223
- "w-[2px] h-full"
3224
- ])
3225
- }, null, 2)
3226
- ]),
3227
- e("div", un, [
3228
- Z.header === "Received" ? (u(), se(H, {
3229
- key: 0,
3230
- name: "local_shipping",
3231
- outline: "",
3232
- color: "#ffffff"
3233
- })) : B("", !0)
3234
- ]),
3235
- e("div", dn, [
3236
- e("div", {
3237
- class: Be([
3238
- {
3239
- "bg-fm-color-primary": ce < q.value.length - 1,
3240
- "bg-white": ce >= q.value.length - 1
3241
- },
3242
- "w-[2px] h-full"
3243
- ])
3244
- }, null, 2)
3245
- ])
3246
- ]),
3247
- e("div", mn, [
3248
- e("div", pn, [
3249
- e("div", fn, g(Z.header), 1),
3250
- e("div", yn, g(Z.date), 1)
3251
- ]),
3252
- e("div", vn, [
3253
- Z.header === "Received" && Z.deliveryOrder && o.purchaseOrder ? (u(), se(vs, {
3254
- key: 0,
3255
- deliveryOrder: Z.deliveryOrder,
3256
- purchaseOrder: o.purchaseOrder,
3257
- onSubmitted: v[3] || (v[3] = () => {
3258
- y("update:show", !1), y("submitted");
3259
- })
3260
- }, null, 8, ["deliveryOrder", "purchaseOrder"])) : B("", !0),
3261
- (ye = (de = Z.deliveryOrder) == null ? void 0 : de.netSuite) != null && ye.id ? (u(), se(De, { key: 1 }, {
3262
- default: Y(() => {
3263
- var he, Te;
3264
- return [
3265
- k(oo, {
3266
- "netsuite-id": (Te = (he = Z.deliveryOrder) == null ? void 0 : he.netSuite) == null ? void 0 : Te.id
3267
- }, null, 8, ["netsuite-id"])
3268
- ];
3269
- }),
3270
- _: 2
3271
- }, 1024)) : B("", !0),
3272
- o.purchaseOrder && ((ie = Z.deliveryOrder) != null && ie.id) ? (u(), se(Ms, {
3273
- key: 2,
3274
- "purchase-order-id": (Ce = o.purchaseOrder) == null ? void 0 : Ce._id,
3275
- "delivery-order-id": (je = Z.deliveryOrder) == null ? void 0 : je.id
3276
- }, null, 8, ["purchase-order-id", "delivery-order-id"])) : B("", !0)
3277
- ])
3278
- ])
3279
- ]),
3280
- e("div", hn, [
3281
- e("div", bn, [
3282
- e("div", gn, [
3283
- e("div", {
3284
- class: Be([
3285
- {
3286
- "bg-fm-color-primary": ce < q.value.length - 1,
3287
- "bg-white": ce >= q.value.length - 1
3288
- },
3289
- "w-[2px] h-full"
3290
- ])
3291
- }, null, 2)
3292
- ])
3293
- ]),
3294
- e("div", _n, [
3295
- k(p, {
3296
- variant: "outlined",
3297
- class: "py-12 px-16"
3298
- }, {
3299
- default: Y(() => [
3300
- e("div", Sn, [
3301
- (u(!0), $(ue, null, _e(Z.info, (he, Te) => (u(), $("div", {
3302
- key: Te,
3303
- class: "flex flex-col gap-4"
3304
- }, [
3305
- e("div", On, g(he == null ? void 0 : he.label), 1),
3306
- e("div", wn, [
3307
- (u(!0), $(ue, null, _e(he == null ? void 0 : he.values, (Le, xt) => (u(), $("div", {
3308
- key: xt,
3309
- class: "fm-typo-en-body-lg-600"
3310
- }, [
3311
- typeof Le == "string" ? (u(), $(ue, { key: 0 }, [
3312
- ke(g(Le), 1)
3313
- ], 64)) : (u(), se(Pt(Le), { key: 1 }))
3314
- ]))), 128))
3315
- ])
3316
- ]))), 128))
3317
- ])
3318
- ]),
3319
- _: 2
3320
- }, 1024)
3321
- ])
3322
- ])
3323
- ], 64);
3324
- }), 128))
3325
- ])) : (u(), $("div", tn, [
3326
- k(le),
3327
- e("div", null, [
3328
- e("img", {
3329
- src: S(Ut),
3330
- alt: "List is empty"
3331
- }, null, 8, rn)
3332
- ]),
3333
- e("div", sn, g(S(m)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
3334
- e("div", on, g(S(m)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
3335
- k(le),
3336
- k(le)
3337
- ]))
3338
- ])) : B("", !0)
3339
- ])
3340
- ];
3341
- }),
3342
- "side-sheet-footer": Y(() => [
3343
- e("div", xn, [
3344
- (u(!0), $(ue, null, _e(L.value, (E) => (u(), $(ue, null, [
3345
- S(ot)[E].available != !1 ? (u(), se(T, {
3346
- key: E,
3347
- label: S(m)(S(ot)[E].translationKey),
3348
- onClick: (ne) => pe(E),
3349
- loading: d.value === E,
3350
- disabled: d.value !== E && D.value,
3351
- variant: S(ot)[E].buttonVariant
3352
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : B("", !0)
3353
- ], 64))), 256)),
3354
- S(h).ableToMarkReceived(o.purchaseOrder) && !L.value.includes("completeReceive") ? (u(), se(T, {
3355
- key: 0,
3356
- label: S(m)("inventory.transfer.receiveRequest.actions.completeReceive"),
3357
- onClick: v[4] || (v[4] = (E) => pe("completeReceive")),
3358
- loading: d.value === "completeReceive",
3359
- disabled: d.value !== "completeReceive" && D.value
3360
- }, null, 8, ["label", "loading", "disabled"])) : B("", !0),
3361
- S(h).ableToMarkApproved(o.purchaseOrder) && o.canApprove && !L.value.includes("approveRequest") ? (u(), se(T, {
3362
- key: 1,
3363
- label: S(m)("inventory.transfer.approval.actions.approveRequest"),
3364
- onClick: v[5] || (v[5] = (E) => pe("approveRequest")),
3365
- loading: d.value === "approveRequest",
3366
- disabled: d.value !== "approveRequest" && D.value
3367
- }, null, 8, ["label", "loading", "disabled"])) : B("", !0),
3368
- S(h).ableToCreateFulfillment(o.purchaseOrder, o.poRequest) && n.scope === "approval" ? (u(), se(T, {
3369
- key: 2,
3370
- label: S(m)("inventory.transfer.receiveRequest.actions.processRequest"),
3371
- onClick: v[6] || (v[6] = (E) => pe("processRequest")),
3372
- loading: d.value === "processRequest",
3373
- disabled: d.value !== "processRequest" && D.value
3374
- }, null, 8, ["label", "loading", "disabled"])) : B("", !0),
3375
- k(T, {
3376
- label: S(m)("common.close"),
3377
- variant: "tertiary",
3378
- onClick: v[7] || (v[7] = (E) => y("update:show", !1))
3379
- }, null, 8, ["label"])
3380
- ])
3381
- ]),
3382
- _: 1
3383
- }, 8, ["modelValue", "dismiss-away"]);
3384
- };
3385
- }
3386
- });
3387
- export {
3388
- lt as P,
3389
- Vn as _,
3390
- Pn as a,
3391
- qn as b,
3392
- Qt as g,
3393
- qe as u
3394
- };