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