@feedmepos/mf-inventory-portal 1.7.5-dev.1 → 1.7.5-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 (112) hide show
  1. package/dist/{App-Cajcbi7C.js → App-D4pfsscT.js} +4 -4
  2. package/dist/{ApprovalView-pn-qHYIX.js → ApprovalView-CYnp3Gv5.js} +25 -24
  3. package/dist/{BindingsDialog-zcBevwFb.js → BindingsDialog-Dm0kKlg-.js} +2 -2
  4. package/dist/{BindingsPicker-DRWl6zQ4.js → BindingsPicker-CdGHTlqD.js} +2 -2
  5. package/dist/{BindingsTable-8m6QfTWo.js → BindingsTable-DEZHwIgw.js} +3 -3
  6. package/dist/BulkReceiveRequestView-ClvGD9vp.js +2584 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CJlb8KSr.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DVFOpysl.js} +1 -1
  8. package/dist/{ClosingDraftView-DSB7J84e.js → ClosingDraftView-CXTf30OO.js} +21 -21
  9. package/dist/{ClosingHistoryView-BmVm5PZ0.js → ClosingHistoryView-3yfjab3s.js} +5 -5
  10. package/dist/{ClosingTemplateView-D8epJry0.js → ClosingTemplateView-DhDRDJfg.js} +18 -18
  11. package/dist/CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-C0DjydRr.js +145 -0
  12. package/dist/{DefaultView-5NqNxkyj.js → DefaultView-BQyve9e7.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-hUWHCkIg.js → DeliveryOrderPrintPreview-Cx85J915.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-D2Am8ZDJ.js → EmailDialog.vue_vue_type_script_setup_true_lang-BjSzg-to.js} +3612 -3575
  15. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DB2tvpP6.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DOY0FHF8.js} +1 -1
  16. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-KCBmg5AJ.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DRLRTNJn.js} +2 -2
  17. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B_0D62ne.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CnQPXIkP.js} +2 -2
  18. package/dist/{FmMultiselectDialog-DU7IzWG_.js → FmMultiselectDialog-DK737zIz.js} +1 -1
  19. package/dist/{FmMultiselectDialog-Ds_f8gua.js → FmMultiselectDialog-IIFXWxUT.js} +2 -2
  20. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DSDqCW3P.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Bonb9Hnk.js} +5 -5
  21. package/dist/{ImportView-0gnR-m1B.js → ImportView-D4xpncdw.js} +6 -6
  22. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BXsS60iO.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-CYjvjRhH.js} +1 -1
  23. package/dist/{IngredientGroupView-D3M3aA_H.js → IngredientGroupView-Bh7ShplN.js} +7 -7
  24. package/dist/{IngredientsView-BoJUcVQE.js → IngredientsView-B03s_wbT.js} +17 -17
  25. package/dist/{IntegrationExplorerView-CANrFCne.js → IntegrationExplorerView-DgsllLAF.js} +4 -4
  26. package/dist/{IntegrationView-CNA-8zrj.js → IntegrationView-9BCyzPdb.js} +14 -14
  27. package/dist/{InventoryBindingForm-DT-YXt4c.js → InventoryBindingForm-C8LY1sc4.js} +1 -1
  28. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CxNSflJ8.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang--mFdjT9b.js} +5 -5
  29. package/dist/{InventoryBindingSummary-BCnTxQhc.js → InventoryBindingSummary-BEvw0lWr.js} +1 -1
  30. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DyRx5MmF.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CxgaZqAW.js} +1 -1
  31. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CJf9wT6o.js → PremiumBadge.vue_vue_type_script_setup_true_lang--sxV3FYV.js} +1 -1
  32. package/dist/{ProductionView-09wAcGA-.js → ProductionView-B86EyiCZ.js} +7 -7
  33. package/dist/{PublishView-glA2ipo1.js → PublishView-DlETEaGs.js} +3 -3
  34. package/dist/{PurchaseOrderPrintPreview-DpLO-1KW.js → PurchaseOrderPrintPreview-Be0U7Ler.js} +2 -2
  35. package/dist/{ReceiveRequestView-CzAVket3.js → ReceiveRequestView-DucbkxwJ.js} +80 -79
  36. package/dist/{RecipeView-LT5XJ6kA.js → RecipeView-BIlGYL8-.js} +19 -19
  37. package/dist/{SettingsView-BZfh4JMs.js → SettingsView-CUAHre50.js} +4 -4
  38. package/dist/{StockView-DFY1LgMH.js → StockView-kf_zhpO5.js} +22 -22
  39. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CK6SIQza.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Bpr7q8r9.js} +1 -1
  40. package/dist/{SupplierView-CL2IuwVZ.js → SupplierView-caFI7Yd6.js} +14 -14
  41. package/dist/{SurchargeView-BhfGyNu5.js → SurchargeView-DyO0ZOGa.js} +8 -8
  42. package/dist/SystemTrailDialog.vue_vue_type_script_setup_true_lang--QyVwKtB.js +263 -0
  43. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bw8cubwk.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-2JCHCRHp.js} +1 -1
  44. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Dhll972g.js +4717 -0
  45. package/dist/{TransferTemplateView-DLOjb7km.js → TransferTemplateView-DUlH8K4Y.js} +21 -21
  46. package/dist/{UnitCostHistoryView-BtPucyKW.js → UnitCostHistoryView-OXv6kJgE.js} +4 -4
  47. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DJ6kRWhP.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-1ekj_uc6.js} +4 -4
  48. package/dist/{UnitView-BvfkCvbb.js → UnitView-iwIzfipw.js} +9 -9
  49. package/dist/{WarehouseView-DqQY_NXe.js → WarehouseView-C9rSeAaV.js} +7 -7
  50. package/dist/{WastageTemplateView--Wrq7ge5.js → WastageTemplateView-OvD51JSq.js} +16 -16
  51. package/dist/api/purchase-order.d.ts +46 -0
  52. package/dist/{app-D_hKuHEq.js → app-D-nwdsYm.js} +19305 -19130
  53. package/dist/app.d.ts +64 -36
  54. package/dist/app.js +1 -1
  55. package/dist/{closing-template-mf0Hz0sS.js → closing-template-jWeRa4dz.js} +1 -1
  56. package/dist/component-BmLAdDiY.js +79 -0
  57. package/dist/components/job-progress/BulkJobProgressPanel.vue.d.ts +2 -0
  58. package/dist/components/row-action.enum.d.ts +1 -0
  59. package/dist/{date2-C3dcj9fz.js → date2-B_xDuM7M.js} +1 -1
  60. package/dist/{dayjs.min-BI88EzTz.js → dayjs.min-B-AZ8_mI.js} +5 -5
  61. package/dist/{decimal-BxOL6Gld.js → decimal-0ev5Hr6J.js} +2 -2
  62. package/dist/{defineDeepModel-Cvl7eN3k.js → defineDeepModel-DvI75jvB.js} +1 -1
  63. package/dist/{duplicate-template-DgS5Tm9P.js → duplicate-template-CVOoyyS0.js} +1 -1
  64. package/dist/{feature-Dd8HiMBk.js → feature-Cb-HS1Qb.js} +2 -2
  65. package/dist/{format-time-from-id-Cp2E5196.js → format-time-from-id-BCqZq29n.js} +1 -1
  66. package/dist/{format-unit-display-MACP_q07.js → format-unit-display-kSYRHsdn.js} +16 -16
  67. package/dist/{import-export.helper-DWMCTOY0.js → import-export.helper-B3bnD5gf.js} +6 -6
  68. package/dist/{index-D3jWqvZX.js → index-BmjXNcEU.js} +1 -1
  69. package/dist/{index-B2RsNEfe.js → index-CDiyP2Ua.js} +3 -3
  70. package/dist/{index-DFK8bQ6j.js → index-G6SYSs1V.js} +1 -1
  71. package/dist/{inventory-core-dart.default-D942GWzb.js → inventory-core-dart.default-B0kHPJ3I.js} +1 -1
  72. package/dist/{lz-string-CBjMP9eH.js → lz-string-CUfkGubt.js} +1 -1
  73. package/dist/{netsuite-D2953JgL.js → netsuite-CYNhS6XV.js} +2 -2
  74. package/dist/{number-DPVL24ED.js → number-BZuHTNem.js} +3 -3
  75. package/dist/{predefined-templates-C-1kU49_.js → predefined-templates-D--Y4747.js} +1 -1
  76. package/dist/{purchase-order-template-Dr2otb_Q.js → purchase-order-template-DGzn629O.js} +1 -1
  77. package/dist/{recalculationUtils-DOLRXWIr.js → recalculationUtils-B2mxdDHX.js} +1 -1
  78. package/dist/{row-action.enum-DQ9bJ_uv.js → row-action.enum-ncgDYAjP.js} +7 -1
  79. package/dist/{rules-CgbPIL_A.js → rules-C9dDCNg3.js} +2 -2
  80. package/dist/{stock-Bqj8CPcA.js → stock-Bys68KZZ.js} +3 -3
  81. package/dist/{stock-No7BQLB4.js → stock-DL4oech9.js} +1 -1
  82. package/dist/stores/bulk-job.d.ts +192 -0
  83. package/dist/stores/bulk-job.spec.d.ts +1 -0
  84. package/dist/{supplier-DNlISdQo.js → supplier-DPVpEG2w.js} +2 -2
  85. package/dist/{surcharge-BGZGoC81.js → surcharge-SHYN1X8A.js} +1 -1
  86. package/dist/tsconfig.app.tsbuildinfo +1 -1
  87. package/dist/{uom-rules-B6ZB1FSB.js → uom-rules-nPqfI8Yz.js} +1 -1
  88. package/dist/{use-ingredient-select-dialog-CU5OTWPl.js → use-ingredient-select-dialog-BMvWiKB6.js} +2 -2
  89. package/dist/{use-inventory-binding-dialog-DhxC5qLq.js → use-inventory-binding-dialog-CNOe57bY.js} +2 -2
  90. package/dist/{use-template-enabled-locations-Bv5HpHAV.js → use-template-enabled-locations-B7JBvvZ4.js} +2 -2
  91. package/dist/{use-transfer-locations-CRR5I64l.js → use-transfer-locations-BCu9xHNr.js} +2 -2
  92. package/dist/{useHrmPermission-bZrxydnr.js → useHrmPermission-WM9TCd_D.js} +1 -1
  93. package/dist/{useNavigationMenu-CazRNUsz.js → useNavigationMenu-6DdsN1jP.js} +2 -2
  94. package/dist/{useSseClient-l9O1iPny.js → useSseClient-B9Z0kGeF.js} +1 -1
  95. package/dist/views/receive-request/components/email-dialog/EmailDialogProps.d.ts +11 -0
  96. package/dist/views/receive-request/composables/fn.spec.d.ts +1 -0
  97. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +1 -0
  98. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +13 -1
  99. package/dist/views/receive-request/helper/extra-items.d.ts +12 -2
  100. package/dist/views/receive-request/helper/format-unit-display.d.ts +1 -1
  101. package/dist/views/receive-request-bulk/components/PdfPreviewDialog.vue.d.ts +23 -0
  102. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +6 -18
  103. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.spec.d.ts +1 -0
  104. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +3 -4
  105. package/dist/{vue-i18n-eAaLOca6.js → vue-i18n-DWcHQ0rm.js} +51 -51
  106. package/dist/{xlsx.util-Dp7SqdrI.js → xlsx.util-DC2xGyFF.js} +2 -2
  107. package/package.json +4 -5
  108. package/dist/BulkReceiveRequestView-MxPx0Gio.js +0 -2208
  109. package/dist/SystemTrailDialog.vue_vue_type_script_setup_true_lang-Du8ygQNn.js +0 -209
  110. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-Dy79I2YB.js +0 -4712
  111. package/dist/component-kqxARxvM.js +0 -91
  112. package/dist/jszip.min-Pl_JnG-H.js +0 -2322
@@ -1,4712 +0,0 @@
1
- import { defineComponent as Te, ref as Y, watch as Ye, nextTick as bs, createBlock as me, openBlock as l, Teleport as gs, createElementBlock as f, createCommentVNode as R, withModifiers as _s, createElementVNode as e, normalizeClass as ze, toDisplayString as b, withDirectives as xs, unref as y, vModelText as Ss, toRaw as ks, shallowRef as ct, onUnmounted as ts, triggerRef as Os, computed as z, readonly as ws, h as ee, resolveComponent as te, createVNode as D, Fragment as $e, renderList as Pe, reactive as $s, onMounted as ss, withCtx as ae, createTextVNode as We, renderSlot as Cs, isRef as Ds, resolveDynamicComponent as As } from "vue";
2
- import { f as Rs, h as Ns, r as Ps, s as rs } from "./predefined-templates-C-1kU49_.js";
3
- import { f as at, p as Fs } from "./format-time-from-id-Cp2E5196.js";
4
- import { c as zt } from "./component-kqxARxvM.js";
5
- import { D as Ee, R as Ae } from "./row-action.enum-DQ9bJ_uv.js";
6
- import { q as Ce, H as st, m as Ts, u as Ke, V as U, _ as Is, $ as ft, T as be, a as Ct, a0 as Kt, a1 as Es, a2 as qs, G as Vs, s as Dt, c as kt, M as Ht, a3 as os, r as nt, C as Ve, w as Fe, B as ut } from "./app-D_hKuHEq.js";
7
- import { h as At, d as Ls, t as js, a as et } from "./date2-C3dcj9fz.js";
8
- import { j as Us, c as Ms, a as _e, t as Qe, d as lt } from "./number-DPVL24ED.js";
9
- import { F as Be, a as Bs, b as Gt, d as gt } from "./inventory-core-dart.default-D942GWzb.js";
10
- import { L as zs } from "./lz-string-CBjMP9eH.js";
11
- import { useI18n as vt, useCoreStore as yt } from "@feedmepos/mf-common";
12
- import { u as ht, a as Rt, S as Me } from "./netsuite-D2953JgL.js";
13
- import { useDialog as bt, useSnackbar as Xe, components as dt, FmButtonVariant as Ue, useProxiedModel as Ks } from "@feedmepos/ui-library";
14
- import { F as tt } from "./FmAdminBadge-DlplQOHb.js";
15
- import { u as Je } from "./feature-Dd8HiMBk.js";
16
- import { _ as Wt } from "./empty-placeholder-B0QU467o.js";
17
- import { a as Hs, b as Gs, f as mt } from "./format-unit-display-MACP_q07.js";
18
- import { u as Ze, _ as Ws } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-Du8ygQNn.js";
19
- import { _ as Qs, a as Ys, b as Js } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DSDqCW3P.js";
20
- import { u as Xs, R as Qt } from "./usePromise-CbVUCxhj.js";
21
- import { e as Zs } from "./index-B2RsNEfe.js";
22
- import { i as er } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DB2tvpP6.js";
23
- import { F as Yt } from "./form-mode.enum-BKiNVH6A.js";
24
- import { u as ns } from "./supplier-DNlISdQo.js";
25
- import { u as tr } from "./surcharge-BGZGoC81.js";
26
- import { F as sr } from "./decimal-BxOL6Gld.js";
27
- import { d as as } from "./defineDeepModel-Cvl7eN3k.js";
28
- import { u as rr } from "./vue-i18n-eAaLOca6.js";
29
- import { u as or } from "./useHrmPermission-bZrxydnr.js";
30
- function ls(p, t) {
31
- return t.reduce(
32
- (a, m) => {
33
- const u = m.received.find((c) => c.sku._id === p._id);
34
- return u && (a = Us(a, u.amount)), a;
35
- },
36
- sr.toPrecision(Ms(0), p.unit.precision)
37
- );
38
- }
39
- function is(p) {
40
- var a;
41
- const t = Ce(), o = (a = p.supplier.supplyItems) != null && a.length ? { ...p.supplier, registrationNumber: p.supplier.registrationNumber ?? "" } : void 0;
42
- return (m) => {
43
- var u, c;
44
- if ((u = m.totalCost) != null && u.amount) return m.totalCost;
45
- if (!m.isCustomCost)
46
- try {
47
- const { cost: s } = Be.calculateDefaultCost({
48
- item: m.sku,
49
- amount: m.quantity,
50
- measurement: m.measurement,
51
- overrides: o ? { supplier: o } : void 0,
52
- defaultCurrency: t
53
- });
54
- return s.amount ? s : void 0;
55
- } catch (s) {
56
- console.warn("[print] cost auto-calculation failed for item", (c = m.sku) == null ? void 0 : c._id, s);
57
- return;
58
- }
59
- };
60
- }
61
- function nr(p) {
62
- var ge, K, ce, I, w, q, W;
63
- const { po: t, currentLocation: o, business: a, fulfilling: m, por: u } = p, c = o.doc.profile || {}, { name: s, address: r, regNo: d, legalName: _ } = c, k = {
64
- name: s || o.name || "",
65
- legalName: _ || void 0,
66
- registrationNumber: d || void 0,
67
- line1: (r == null ? void 0 : r.line1) || "",
68
- line2: (r == null ? void 0 : r.line2) || void 0,
69
- postcode: (r == null ? void 0 : r.postcode) || "",
70
- city: (r == null ? void 0 : r.city) || "",
71
- state: (r == null ? void 0 : r.state) || "",
72
- country: (r == null ? void 0 : r.country) || ""
73
- }, F = {
74
- name: t.supplier.name,
75
- phoneNumber: t.supplier.phoneNumber || void 0,
76
- registrationNumber: t.supplier.registrationNumber || void 0,
77
- line1: ((ge = t.supplier.address) == null ? void 0 : ge.line1) || "",
78
- line2: ((K = t.supplier.address) == null ? void 0 : K.line2) || void 0,
79
- postcode: ((ce = t.supplier.address) == null ? void 0 : ce.postcode) || "",
80
- city: ((I = t.supplier.address) == null ? void 0 : I.city) || "",
81
- state: ((w = t.supplier.address) == null ? void 0 : w.state) || "",
82
- country: ((q = t.supplier.address) == null ? void 0 : q.country) || ""
83
- }, C = is(t), g = [], M = t.items.filter((B) => B.sku).map((B) => {
84
- var X;
85
- const { sku: ie, measurement: pe } = B, L = _e(
86
- ls(B.sku, t.deliveryOrder || []),
87
- !1
88
- ), O = C(B);
89
- return O && g.push(O), {
90
- code: ie.code,
91
- description: ie.name,
92
- quantity: _e(B.quantity, !1),
93
- unit: (pe == null ? void 0 : pe.abbrev) || ((X = ie.unit) == null ? void 0 : X.abbrev) || "",
94
- received: L,
95
- unitCost: O ? `${O.currency} ${Be.toFormatString({
96
- value: B.quantity.amount === 0 ? Be.fromNumber(0) : Be.divide([O, B.quantity])
97
- })}` : void 0,
98
- cost: O ? `${O.currency} ${Be.toFormatString({
99
- value: O
100
- })}` : void 0
101
- };
102
- }), T = g.length ? `${g[0].currency} ${Be.toFormatString({
103
- value: g.reduce((B, ie) => Be.add([B, ie]), Be.reset())
104
- })}` : void 0, J = (t.deliveryOrder || []).map((B) => ({
105
- createdAt: At(new Date(B.createdAt)),
106
- ref: B.deliveryOrderNumber,
107
- remark: B.remark || "",
108
- items: (B.received || []).map((ie) => {
109
- var pe, L, O, X, P;
110
- return {
111
- code: ((pe = ie.sku) == null ? void 0 : pe.code) || "",
112
- description: ((L = ie.sku) == null ? void 0 : L.name) || "",
113
- quantity: _e(ie.amount),
114
- unit: ((O = ie.measurement) == null ? void 0 : O.abbrev) || ((P = (X = ie.sku) == null ? void 0 : X.unit) == null ? void 0 : P.abbrev) || ""
115
- };
116
- })
117
- }));
118
- let Q = st.Enum.purchaseOrder, le = "Inventory Receive Note";
119
- if (t.supplier.internal ? (le = "Inventory Transfer Note", Q = st.Enum.transferOrder) : (le = "Purchase Order", Q = st.Enum.purchaseOrder), (W = u == null ? void 0 : u.from) != null && W.dbName) {
120
- const B = u.from.dbName;
121
- o.dbName === B || (le = "Inventory Receive Note", Q = st.Enum.goodsReceivedNote);
122
- }
123
- const ye = {
124
- title: le,
125
- businessName: a == null ? void 0 : a.name,
126
- logo: a == null ? void 0 : a.thumbnail,
127
- orderNumber: t.seqNumber.toString(),
128
- createdAt: at(t._id),
129
- ref: t.ref || "",
130
- remark: t.remark || "",
131
- buyer: k,
132
- supplier: F,
133
- items: M,
134
- grandTotal: T,
135
- status: t.status,
136
- deliveryOrders: J
137
- }, ne = m && (t.deliveryFullfillment || []).length > 0;
138
- return ne && (Q = st.Enum.deliveryOrder), { printData: ye, templateType: Q, isDeliveryPrint: ne };
139
- }
140
- function cs(p) {
141
- var _;
142
- const { printData: t, templateType: o } = nr(p), m = Rs().getTemplateByType(o), u = !!((_ = m == null ? void 0 : m.blocks) != null && _.length), c = Ns(o), s = u ? m.blocks : c.blocks, r = u ? m.name : c.name, d = !u;
143
- try {
144
- const k = Ps(s, t), F = k.match(/<style>([\s\S]*?)<\/style>/), C = F ? `<style>${F[1]}</style>` : "", g = k.replace(/<style>[\s\S]*?<\/style>/, "");
145
- return {
146
- html: `<!DOCTYPE html>
147
- <html>
148
- <head>
149
- <meta charset="utf-8">
150
- <title>Print Preview</title>
151
- <style>
152
- @page { margin: 0; }
153
- @media print {
154
- body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
155
- }
156
- * { box-sizing: border-box; margin: 0; padding: 0; }
157
- </style>
158
- ${C}
159
- </head>
160
- <body>${g}</body>
161
- </html>`,
162
- templateName: r,
163
- isDefault: d
164
- };
165
- } catch {
166
- return alert("Failed to render print template. Please try recreating the template."), null;
167
- }
168
- }
169
- const ar = { class: "w-[95vw] h-[95vh] bg-white rounded-lg flex flex-col shadow-2xl overflow-hidden" }, lr = { class: "flex justify-between items-center px-16 py-3 border-b border-gray-200 bg-gray-50" }, ir = { class: "flex items-center gap-2.5" }, cr = {
170
- key: 1,
171
- class: "text-xs text-gray-100 bg-gray-500 px-2 py-0.5 rounded font-medium"
172
- }, ur = { class: "flex-1 overflow-auto bg-gray-100" }, xi = /* @__PURE__ */ Te({
173
- __name: "CustomPrintTemplatePreview",
174
- props: {
175
- html: {},
176
- modelValue: { type: Boolean },
177
- templateName: {},
178
- isDefault: { type: Boolean }
179
- },
180
- emits: ["update:modelValue"],
181
- setup(p, { emit: t }) {
182
- const o = p, a = t, m = Y(null);
183
- function u() {
184
- a("update:modelValue", !1);
185
- }
186
- function c() {
187
- var r, d;
188
- try {
189
- (d = (r = m.value) == null ? void 0 : r.contentWindow) == null || d.print();
190
- } catch {
191
- alert("Failed to trigger print.");
192
- }
193
- }
194
- Ye(
195
- () => o.modelValue,
196
- async (r) => {
197
- r && (await bs(), s(), setTimeout(() => {
198
- c();
199
- }, 300));
200
- }
201
- );
202
- function s() {
203
- var k;
204
- const r = m.value;
205
- if (!r) return;
206
- const d = rs(o.html), _ = r.contentDocument || ((k = r.contentWindow) == null ? void 0 : k.document);
207
- _ && (_.open(), _.write(`
208
- <!DOCTYPE html>
209
- <html>
210
- <head>
211
- <meta charset="utf-8">
212
- <meta http-equiv="Content-Security-Policy" content="
213
- default-src 'none';
214
- style-src 'unsafe-inline';
215
- img-src 'self' data: https:;
216
- font-src 'self' data:;
217
- script-src 'none';
218
- object-src 'none';
219
- frame-src 'none';
220
- base-uri 'none';
221
- form-action 'none';
222
- ">
223
- <style>
224
- * {
225
- box-sizing: border-box;
226
- }
227
- body {
228
- margin: 0;
229
- padding: 40px 20px;
230
- background: #f0f0f0;
231
- min-height: 100vh;
232
- }
233
- .print-container {
234
- max-width: 800px;
235
- margin: 0 auto;
236
- padding: 30px;
237
- border: 1px solid #ddd;
238
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
239
- background: #ffffff;
240
- font-size: 16px;
241
- line-height: 1.5;
242
- font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
243
- color: #555;
244
- }
245
- @media print {
246
- body {
247
- background: white !important;
248
- padding: 0 !important;
249
- margin: 0 !important;
250
- }
251
- .print-container {
252
- border: none !important;
253
- box-shadow: none !important;
254
- padding: 0 !important;
255
- margin: 0 !important;
256
- max-width: none !important;
257
- }
258
- }
259
- </style>
260
- </head>
261
- <body>
262
- <div class="print-container">
263
- ${d}
264
- </div>
265
- </body>
266
- </html>
267
- `), _.close());
268
- }
269
- return (r, d) => (l(), me(gs, { to: "body" }, [
270
- r.modelValue ? (l(), f("div", {
271
- key: 0,
272
- class: "fixed inset-0 z-[9999] bg-black/50 flex justify-center items-center",
273
- onClick: _s(u, ["self"])
274
- }, [
275
- e("div", ar, [
276
- e("div", lr, [
277
- e("div", ir, [
278
- d[0] || (d[0] = e("span", { class: "text-base font-semibold text-gray-700" }, "Print Preview", -1)),
279
- r.templateName ? (l(), f("span", {
280
- key: 0,
281
- class: ze(["text-xs font-medium px-2 py-0.5 rounded", r.isDefault ? "text-gray-500 bg-gray-100" : "text-blue-700 bg-blue-50"])
282
- }, b(r.templateName), 3)) : R("", !0),
283
- r.isDefault ? (l(), f("span", cr, "Default")) : R("", !0)
284
- ]),
285
- e("div", { class: "flex gap-2 items-center" }, [
286
- e("button", {
287
- class: "px-8 py-1.5 bg-blue-500 text-white border-none rounded text-sm cursor-pointer hover:bg-blue-700",
288
- onClick: c
289
- }, " Print "),
290
- e("button", {
291
- class: "px-2.5 py-1 bg-transparent border border-gray-300 rounded text-xl leading-none cursor-pointer text-gray-500 hover:bg-gray-100",
292
- onClick: u
293
- }, " × ")
294
- ])
295
- ]),
296
- e("div", ur, [
297
- e("iframe", {
298
- ref_key: "iframeRef",
299
- ref: m,
300
- class: "w-full h-full border-none",
301
- sandbox: "allow-same-origin allow-modals"
302
- }, null, 512)
303
- ])
304
- ])
305
- ])) : R("", !0)
306
- ]));
307
- }
308
- }), dr = Ts((p, t) => {
309
- const o = Ke();
310
- return {
311
- async getShipments({
312
- start: a,
313
- end: m
314
- }) {
315
- const u = o.currentLocationDBName, c = `${p.inventoryBackendUrl}/${u}/shipments`;
316
- return await t.get(`${c}?start=${a}&end=${m}`);
317
- },
318
- async getShipmentsByIds(a) {
319
- if (a.length === 0)
320
- return [];
321
- const m = o.currentLocationDBName, u = `${p.inventoryBackendUrl}/${m}/shipments/get`;
322
- return await t.post(u, { shipmentIds: a });
323
- }
324
- };
325
- }), us = {
326
- [U.enum.confirmDraft]: {
327
- primaryActions: {
328
- text: "Confirm draft",
329
- close: !0
330
- },
331
- title: "Confirm draft?",
332
- message: "Purchase order cannot be changed after confirm draft.",
333
- successMessage: "Purchase order draft has been confirmed"
334
- },
335
- [U.enum.cancelDraft]: {
336
- primaryActions: {
337
- text: "Cancel draft",
338
- close: !0,
339
- variant: "destructive"
340
- },
341
- title: "Cancel draft?",
342
- message: "Purchase order cannot be changed after cancelled draft.",
343
- successMessage: "Purchase order draft has been cancelled"
344
- },
345
- [U.enum.approveDraft]: {
346
- primaryActions: {
347
- text: "Approve draft",
348
- close: !0
349
- },
350
- title: "Approve draft?",
351
- message: "Purchase order request will be accepted.",
352
- successMessage: "Purchase order has been approved"
353
- },
354
- [U.enum.rejectDraft]: {
355
- primaryActions: {
356
- text: "Reject draft",
357
- close: !0
358
- },
359
- title: "Reject draft?",
360
- message: "Purchase order request will be rejected. You may provide an optional reason for rejection.",
361
- successMessage: "Purchase order has been rejected"
362
- },
363
- [U.enum.submitRequest]: {
364
- primaryActions: {
365
- text: "Submit request",
366
- close: !0
367
- },
368
- title: "Confirm draft?",
369
- message: "Purchase order cannot be changed after confirm draft.",
370
- successMessage: "Purchase order draft has been submitted"
371
- },
372
- [U.enum.completeReceive]: {
373
- primaryActions: {
374
- text: "Mark received",
375
- close: !0
376
- },
377
- title: "Mark as received",
378
- message: "Purchase order cannot be changed after it has complete receiving.",
379
- successMessage: "Purchase order has been marked as received"
380
- },
381
- [U.enum.approveRequest]: {
382
- primaryActions: {
383
- text: "Accept request",
384
- close: !0
385
- },
386
- title: "Accept request?",
387
- message: "Transfer out request will be accepted.",
388
- successMessage: "Transfer out request has been approved"
389
- },
390
- [U.enum.rejectRequest]: {
391
- primaryActions: {
392
- text: "Reject request",
393
- close: !0,
394
- variant: "destructive"
395
- },
396
- title: "Reject request?",
397
- message: "Purchase order will be rejected.",
398
- successMessage: "Purchase order has been rejected"
399
- },
400
- [U.enum.processRequest]: {
401
- primaryActions: {
402
- text: "Process request",
403
- close: !0,
404
- variant: "destructive"
405
- },
406
- title: "Process request?",
407
- message: "Purchase order will be processed.",
408
- successMessage: "Purchase order has been processed"
409
- }
410
- }, mr = { class: "p-4" }, pr = {
411
- key: 0,
412
- class: "fm-typo-en-body-md-400 mb-3"
413
- }, fr = { class: "fm-typo-en-body-md-400" }, ds = /* @__PURE__ */ Te({
414
- __name: "RejectDraftForm",
415
- props: {
416
- message: {},
417
- confirm: { type: Function },
418
- onChange: { type: Function }
419
- },
420
- setup(p) {
421
- const t = p, { t: o } = vt(), a = Y("");
422
- Ye(a, (u) => {
423
- var c;
424
- (c = t.onChange) == null || c.call(t, u ?? "");
425
- });
426
- function m() {
427
- a.value = "";
428
- }
429
- return (u, c) => (l(), f("div", mr, [
430
- t.message ? (l(), f("div", pr, b(t.message), 1)) : R("", !0),
431
- e("label", fr, b(y(o)("inventory.transfer.receiveRequest.details.rejectionReason")) + " (" + b(y(o)("inventory.common.optional")) + ")", 1),
432
- xs(e("textarea", {
433
- "onUpdate:modelValue": c[0] || (c[0] = (s) => a.value = s),
434
- rows: "4",
435
- class: "w-full mt-2 p-2 border rounded"
436
- }, null, 512), [
437
- [Ss, a.value]
438
- ]),
439
- e("div", { class: "mt-3 flex gap-2" }, [
440
- e("button", {
441
- type: "button",
442
- class: "fm-btn fm-btn-tertiary",
443
- onClick: m
444
- }, "Clear")
445
- ])
446
- ]));
447
- }
448
- });
449
- function pt(p) {
450
- if (p.items == null)
451
- return {};
452
- const t = Is.safeParse(p);
453
- if (!t.success) {
454
- const o = t.error.issues.map((a) => `${a.path.join(".") || "(root)"}: ${a.message}`).join("; ");
455
- return console.error(
456
- `Cannot compute receive status for PO ${p == null ? void 0 : p._id}: invalid shape at ${o}`
457
- ), {};
458
- }
459
- return ft.generatedPOReceivedMap({
460
- purchaseOrder: p
461
- });
462
- }
463
- function vr(p) {
464
- return ft.validatePOItemReceivedStatus({
465
- dto: p
466
- });
467
- }
468
- function Ot(p) {
469
- return ft.validatePOReceivedStatus({
470
- receivedMap: p
471
- });
472
- }
473
- function wt(p, t, o) {
474
- if (!be.safeParse(p).success)
475
- throw new Error(`Invalid purchase order status: ${p}`);
476
- const a = be.parse(p);
477
- return ft.orderStatusCombination({
478
- status: a,
479
- isPOPartialReceive: t,
480
- isPOOverReceive: o
481
- });
482
- }
483
- function ms() {
484
- const p = Ke(), t = Ze(), o = Je();
485
- async function a(u, c) {
486
- const s = p.currentLocationDBName;
487
- return u.doc.supplier.internal && u.operation === U.enum.confirmDraft && (u.operation = U.enum.submitRequest), await t.processPurchaseOrder(u, c || s);
488
- }
489
- async function m(u, c) {
490
- const s = p.currentLocationDBName;
491
- return await t.processPurchaseOrderV2(u, c || s);
492
- }
493
- return (u) => o.useOperatePurchaseOrderV2 ? m(u.operateV2, u.transferTo) : a(u.operate, u.transferTo);
494
- }
495
- function Ge(p) {
496
- const t = ks(p);
497
- if (Array.isArray(t))
498
- return t.map(Ge);
499
- if (t !== null && typeof t == "object") {
500
- const o = {};
501
- for (const a in t)
502
- Object.prototype.hasOwnProperty.call(t, a) && (o[a] = Ge(t[a]));
503
- return o;
504
- }
505
- return t;
506
- }
507
- const _t = {
508
- set: "set",
509
- add: "add",
510
- delete: "delete"
511
- };
512
- function Jt(p) {
513
- return {
514
- dbName: p.dbName,
515
- type: p.type,
516
- name: p.name,
517
- acceptRequest: p.acceptRequest ?? !1,
518
- doc: p.doc
519
- };
520
- }
521
- function Xt(p, t, o, a, m) {
522
- const u = Ge(p.suppliers ?? []), c = Ge(t.allLocations ?? []).map(Jt), s = t._currentLocation ? Jt(Ge(t._currentLocation)) : null, r = o.inventory ? [Ge(o.inventory)] : [], d = a.state.setting ? Ge(a.state.setting) : null, _ = Ge(m.surcharges ?? []);
523
- return {
524
- suppliers: u,
525
- locations: c,
526
- currentLocation: s,
527
- inventoryDoc: r,
528
- netSuiteSetting: d,
529
- surcharges: _
530
- };
531
- }
532
- function ps() {
533
- const p = ns(), t = Ke(), o = Ct(), a = ht(), m = tr(), u = Xt(
534
- p,
535
- t,
536
- o,
537
- a,
538
- m
539
- ), c = ct(Bs({ env: u }));
540
- c.value.setUsePartialUpdates(!0);
541
- const s = ct(c.value.state()), r = (F) => {
542
- s.value = c.value.state();
543
- };
544
- c.value.addListener(r);
545
- const d = (F, C, g) => {
546
- switch (F) {
547
- case _t.set:
548
- Kt(s.value, C, g);
549
- break;
550
- case _t.add:
551
- qs(s.value, C, g);
552
- break;
553
- case _t.delete:
554
- Es(s.value, C);
555
- break;
556
- default:
557
- console.warn(`Unknown partial update operation: ${F}, falling back to 'set'`), Kt(s.value, C, g);
558
- }
559
- C !== "remark" && C !== "ref" && Os(s);
560
- };
561
- c.value.addPartialListener(d);
562
- function _() {
563
- const F = Xt(
564
- p,
565
- t,
566
- o,
567
- a,
568
- m
569
- );
570
- c.value.updateFullEnv(F), s.value = c.value.state();
571
- }
572
- Ye(
573
- [
574
- () => p.suppliers,
575
- () => t.allLocations,
576
- () => t._currentLocation,
577
- () => o.inventory,
578
- () => a.state.setting,
579
- () => m.surcharges
580
- ],
581
- () => {
582
- _();
583
- },
584
- { deep: !0 }
585
- ), ts(() => {
586
- c.value.removeListener(r), c.value.removePartialListener(d);
587
- });
588
- function k(F) {
589
- var C;
590
- if (F != null && F._id) {
591
- c.value.loadPurchaseOrder(F);
592
- return;
593
- }
594
- if (!Je().mustUsePoTemplate) {
595
- c.value.init();
596
- return;
597
- }
598
- F != null && F.template && ((C = F.templateDoc) != null && C.purchaseOrder) ? (F.items = F.templateDoc.purchaseOrder.items, c.value.initFromTemplate(F)) : c.value.initOutletToOutlet();
599
- }
600
- return {
601
- controller: c,
602
- state: s,
603
- init: k
604
- };
605
- }
606
- var $t = /* @__PURE__ */ ((p) => (p.RECEIVE_REQUEST = "receive/request", p.APPROVAL = "approval", p))($t || {});
607
- const rt = Y(), xt = Y(), St = Y();
608
- function Si(p, t) {
609
- const o = bt(), a = Ke(), m = Je(), u = ns(), c = yt(), s = Hs(), r = Gs(), d = Y(!1), _ = Xe(), k = Ze(), F = dr(), C = Y(new Array()), g = Y(new Array()), M = Y(
610
- t != null && t.startDate && (t != null && t.endDate) ? t : er()
611
- ), T = z(() => {
612
- const L = new Date(M.value.startDate), O = new Date(M.value.endDate);
613
- return {
614
- start: js(L).toISOString(),
615
- end: Ls(O).toISOString()
616
- };
617
- }), J = Y(new Array()), Q = Vs(), le = Y(null);
618
- async function xe(L) {
619
- function O(P) {
620
- const x = {
621
- mode: Yt.CREATE,
622
- modelValue: L || void 0,
623
- show: !0,
624
- "onUpdate:show"(N) {
625
- rt.value.show = N;
626
- },
627
- templateId: P,
628
- lastClosingDate: le.value
629
- };
630
- rt.value = x;
631
- }
632
- let X;
633
- m.mustUsePoTemplate && !(L != null && L.template) ? o.open({
634
- title: "Create transfer",
635
- message: "",
636
- primaryActions: {
637
- text: "Select a template",
638
- close: !0
639
- },
640
- secondaryActions: {
641
- text: "Outlet to Outlet",
642
- variant: "secondary",
643
- close: !0
644
- }
645
- }).onPrimary(async () => {
646
- X = await s.getTemplateId(), X && O(X);
647
- }).onSecondary(() => {
648
- O(void 0);
649
- }) : O(X);
650
- }
651
- function ye(L) {
652
- const O = {
653
- mode: Yt.UPDATE,
654
- modelValue: kt(L),
655
- show: !0,
656
- "onUpdate:show"(X) {
657
- rt.value.show = X;
658
- },
659
- lastClosingDate: le.value
660
- };
661
- rt.value = O;
662
- }
663
- function ne(L) {
664
- if (!c.currentBusiness.value) return;
665
- const O = a.currentLocation;
666
- if (O.type === "restaurant") {
667
- const V = a.locationRestaurantFromCore(O.doc._id);
668
- V !== null && (O.doc = V);
669
- }
670
- const X = cs({
671
- po: L,
672
- currentLocation: O,
673
- business: c.currentBusiness.value,
674
- fulfilling: p === "approval",
675
- por: L.request
676
- });
677
- if (!X) return;
678
- const P = rs(X.html), x = u.supplierById[L.supplier._id], N = {
679
- recipientName: x.name,
680
- email: (x == null ? void 0 : x.email) ?? "",
681
- business: c.currentBusiness.value,
682
- modelValue: P,
683
- show: !0,
684
- "onUpdate:show"(V) {
685
- xt.value.show = V;
686
- }
687
- };
688
- xt.value = N;
689
- }
690
- async function ge() {
691
- C.value = [], g.value = [], d.value = !0;
692
- try {
693
- const L = await k.getPurchaseOrders(T.value);
694
- C.value = L.sort((V, se) => se._id.localeCompare(V._id));
695
- const O = L.flatMap((V) => V.shipmentIds || []).filter(Boolean), X = O.length > 0 ? await F.getShipmentsByIds(O) : [];
696
- g.value = X;
697
- const P = await Q.readCurrentLocationLastClosing(!0), x = P == null ? void 0 : P._id;
698
- x && (le.value = Fs(x)), await m.awaitFeatureLoaded(() => m.mustUsePoTemplate) && await r.fetchTemplates();
699
- const N = C.value.map((V) => {
700
- var se;
701
- return ((se = V.request) == null ? void 0 : se.id) ?? "";
702
- }).filter((V) => V);
703
- J.value = await k.readRequestByIds(N);
704
- } catch {
705
- _.open({
706
- title: "Something went wrong",
707
- message: "Error at fetching purchase orders",
708
- type: "error"
709
- });
710
- } finally {
711
- d.value = !1;
712
- }
713
- }
714
- async function K() {
715
- J.value = [], d.value = !0;
716
- try {
717
- J.value = await k.readRequests(
718
- void 0,
719
- T.value.start,
720
- T.value.end
721
- ).then((L) => L.reverse());
722
- } catch {
723
- _.open({
724
- title: "Something went wrong",
725
- message: "Error at fetching purchase requests",
726
- type: "error"
727
- });
728
- } finally {
729
- d.value = !1;
730
- }
731
- }
732
- function ce() {
733
- switch (p) {
734
- case "receive/request":
735
- return ge();
736
- case "approval":
737
- return K();
738
- }
739
- }
740
- function I(L, O) {
741
- M.value = {
742
- startDate: L,
743
- endDate: O
744
- }, ce();
745
- }
746
- a.watchLocation(async (L) => {
747
- if (!L) {
748
- C.value = [];
749
- return;
750
- }
751
- await ce();
752
- });
753
- const w = Y(), q = Y(Math.random().toString());
754
- async function W(L, O) {
755
- const X = Math.random().toString();
756
- q.value = X, O ?? (O = J.value.computeFirst(
757
- (V) => V.purchaseOrderId === L._id ? V : null
758
- ) ?? void 0);
759
- const P = p === "receive/request" ? a.currentLocation : O == null ? void 0 : O.to, x = p === "approval", N = {
760
- poRequest: O,
761
- purchaseOrder: {
762
- ...L,
763
- status: x && (O != null && O.rejectedAt) ? be.Enum.REJECT : L.status
764
- },
765
- transferTo: P == null ? void 0 : P.name,
766
- transferToDbName: P == null ? void 0 : P.dbName,
767
- show: !0,
768
- canResubmit: !1,
769
- canApprove: x,
770
- "onUpdate:show"(V) {
771
- w.value.show = V;
772
- },
773
- scope: p,
774
- receivedMap: pt(L) ?? {},
775
- shipments: g.value
776
- };
777
- w.value = N;
778
- }
779
- async function B(L, O, X, P, x) {
780
- const N = ms();
781
- d.value = !0;
782
- try {
783
- await N({
784
- operate: {
785
- operation: O,
786
- doc: L,
787
- options: (
788
- // auto receive for supplier to warehouse
789
- (O === U.enum.confirmDraft || // auto receive for warehouse to warehouse
790
- O === U.enum.completeReceive) && m.autoReceiveWarehouse ? {
791
- autoReceive: !0
792
- } : void 0
793
- )
794
- },
795
- operateV2: {
796
- _id: L._id,
797
- _rev: L._rev ?? "",
798
- action: O === U.enum.submitRequest ? U.enum.confirmDraft : O,
799
- payloads: x ?? []
800
- },
801
- transferTo: P
802
- }), await new Promise((Se) => setTimeout(Se, 1e3));
803
- const se = Ke().currentLocationDBName.startsWith("restaurant_");
804
- O === U.enum.confirmDraft && L.effectiveAt && se ? _.open({
805
- title: "Success",
806
- message: `${X}. The backdate will be reflected once your POS has received this change.`,
807
- type: "success"
808
- }) : _.open({
809
- title: "Success",
810
- message: X,
811
- type: "success"
812
- });
813
- } catch (V) {
814
- _.open({
815
- title: "Something went wrong",
816
- message: V instanceof Error ? V.message : "Please try again.",
817
- type: "error"
818
- }), console.error("Error when submitting PO operation", O, L, V);
819
- } finally {
820
- d.value = !1, ce();
821
- }
822
- }
823
- async function ie(L, O, X) {
824
- const P = us[O];
825
- if (!P) {
826
- _.open({
827
- title: "Something went wrong",
828
- message: `Cannot process order: ${Dt(O)}`,
829
- type: "error"
830
- });
831
- return;
832
- }
833
- const { successMessage: x, ...N } = P;
834
- if (O === U.enum.rejectDraft) {
835
- let Se = "";
836
- o.open({
837
- title: N.title,
838
- message: N.message,
839
- primaryActions: N.primaryActions,
840
- contentComponent: ds,
841
- contentComponentProps: {
842
- message: N.message,
843
- onChange: (ke) => Se = ke
844
- }
845
- }).onPrimary(() => {
846
- const ke = [];
847
- ke.push({
848
- action: "rejectDraft",
849
- payload: {
850
- rejectReason: Se
851
- }
852
- }), B(L, O, x, X, ke);
853
- });
854
- return;
855
- }
856
- const V = [], se = ps();
857
- se.init(L), (O === U.enum.confirmDraft || O === U.enum.submitRequest) && V.push({
858
- action: "confirmDraft",
859
- payload: se.controller.value.toConfirmDraftData(Ce())
860
- }), o.open({
861
- title: N.title,
862
- message: N.message,
863
- primaryActions: N.primaryActions
864
- }).onPrimary(() => {
865
- B(L, O, x, X, V);
866
- });
867
- }
868
- async function pe() {
869
- o.open({
870
- title: "Upload Transfer",
871
- primaryActions: {
872
- text: "Xilnex transfer note",
873
- close: !0
874
- },
875
- secondaryActions: {
876
- text: "Cancel",
877
- close: !0
878
- }
879
- }).onPrimary(() => {
880
- const L = {
881
- show: !0,
882
- "onUpdate:show"(O) {
883
- St.value.show = O;
884
- }
885
- };
886
- St.value = L;
887
- });
888
- }
889
- return {
890
- purchaseOrders: C,
891
- shipments: g,
892
- purchaseRequests: J,
893
- updateDateRange: I,
894
- fetchData: ce,
895
- loading: d,
896
- transferDialogProps: rt,
897
- promptCreateTransferDialog: xe,
898
- promptUpdateTransferDialog: ye,
899
- transferDetailsProps: w,
900
- promptShowTransferDetails: W,
901
- submitAction: ie,
902
- xilnexImportDialogProps: St,
903
- promptUploadTransferDialog: pe,
904
- emailDialogProps: xt,
905
- promptEmailDialog: ne
906
- };
907
- }
908
- function yr(p) {
909
- var ne, ge, K, ce, I, w;
910
- const { po: t, currentLocation: o, business: a, fulfilling: m, por: u } = p, { name: c, address: s, regNo: r, legalName: d } = o.doc.profile, _ = {
911
- name: c,
912
- legalName: d,
913
- registrationNumber: r,
914
- line1: s == null ? void 0 : s.line1,
915
- line2: s == null ? void 0 : s.line2,
916
- postcode: s == null ? void 0 : s.postcode,
917
- city: s == null ? void 0 : s.city,
918
- state: s == null ? void 0 : s.state,
919
- country: s == null ? void 0 : s.country
920
- }, k = {
921
- name: t.supplier.name,
922
- phoneNumber: t.supplier.phoneNumber,
923
- registrationNumber: t.supplier.registrationNumber,
924
- line1: (ne = t.supplier.address) == null ? void 0 : ne.line1,
925
- line2: (ge = t.supplier.address) == null ? void 0 : ge.line2,
926
- postcode: (K = t.supplier.address) == null ? void 0 : K.postcode,
927
- city: (ce = t.supplier.address) == null ? void 0 : ce.city,
928
- state: (I = t.supplier.address) == null ? void 0 : I.state,
929
- country: (w = t.supplier.address) == null ? void 0 : w.country
930
- }, F = is(t), C = t.items.map((q) => {
931
- const { sku: W, measurement: B } = q, ie = _e(
932
- ls(q.sku, t.deliveryOrder || []),
933
- !1
934
- ), pe = F(q);
935
- return {
936
- code: W.code,
937
- description: W.name,
938
- quantity: _e(q.quantity, !1),
939
- unit: (B == null ? void 0 : B.abbrev) || W.unit.abbrev,
940
- received: ie,
941
- cost: pe ? `${pe.currency} ${Be.toFormatString({
942
- value: pe
943
- })}` : void 0
944
- };
945
- }), g = t.deliveryOrder.map((q) => ({
946
- createdAt: At(new Date(q.createdAt)),
947
- ref: q.deliveryOrderNumber,
948
- remark: q.remark || "",
949
- items: q.received.map((W) => {
950
- var B;
951
- return {
952
- code: W.sku.code,
953
- description: W.sku.name,
954
- quantity: _e(W.amount),
955
- unit: ((B = W.measurement) == null ? void 0 : B.abbrev) || W.sku.unit.abbrev
956
- };
957
- })
958
- })), M = [
959
- // Production
960
- "67ca5d2c80bd0e001c5bf5bc",
961
- // Dev
962
- "6880b36a3054c5001db19218"
963
- ];
964
- let T = "Inventory Receive Note";
965
- if (t.supplier.internal ? (T = "Inventory Transfer Note", M.includes((a == null ? void 0 : a._id) || "") && (T = "Stock Request")) : T = "Purchase Order", u) {
966
- const q = u.from.dbName;
967
- o.dbName === q || (T = "Inventory Receive Note");
968
- }
969
- const Q = {
970
- title: T,
971
- businessName: a == null ? void 0 : a.name,
972
- logo: a == null ? void 0 : a.thumbnail,
973
- orderNumber: t.seqNumber.toString(),
974
- createdAt: at(t._id),
975
- ref: t.ref || "",
976
- remark: t.remark || "",
977
- buyer: _,
978
- supplier: k,
979
- items: C,
980
- status: t.status,
981
- deliveryOrders: g
982
- }, le = new URL(window.location.href), xe = m && (t.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
983
- le.pathname = le.hostname.includes("portal.feedme") ? `/inventory/${xe}` : `/${xe}`;
984
- const ye = zs.compressToEncodedURIComponent(JSON.stringify(Q));
985
- le.searchParams.append("data", ye), window.open(le.href, "_blank", "noreferrer");
986
- }
987
- const He = {
988
- submitRequest: {
989
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
990
- color: "text-fm-color-typo-primary",
991
- value: U.enum.submitRequest
992
- },
993
- confirmDraft: {
994
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
995
- color: "text-fm-color-typo-primary",
996
- value: U.enum.confirmDraft
997
- },
998
- cancelDraft: {
999
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1000
- color: "text-fm-color-typo-error",
1001
- value: U.enum.cancelDraft
1002
- },
1003
- approveRequest: {
1004
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1005
- color: "text-fm-color-typo-primary",
1006
- value: U.enum.approveRequest
1007
- },
1008
- rejectRequest: {
1009
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1010
- color: "text-fm-color-typo-error",
1011
- value: U.enum.rejectRequest
1012
- },
1013
- processRequest: {
1014
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1015
- color: "text-fm-color-typo-primary",
1016
- value: U.enum.processRequest
1017
- },
1018
- receiveStock: {
1019
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1020
- color: "text-fm-color-typo-primary",
1021
- value: U.enum.receiveStock
1022
- },
1023
- completeReceive: {
1024
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1025
- color: "text-fm-color-typo-primary",
1026
- value: U.enum.completeReceive
1027
- },
1028
- closeRequest: {
1029
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1030
- color: "system-error-300",
1031
- value: U.enum.closeRequest
1032
- },
1033
- approveDraft: {
1034
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1035
- color: "text-fm-color-typo-primary",
1036
- value: U.enum.approveDraft
1037
- },
1038
- rejectDraft: {
1039
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1040
- color: "text-fm-color-typo-error",
1041
- value: U.enum.rejectDraft
1042
- },
1043
- returnStock: {
1044
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1045
- color: "text-fm-color-typo-primary",
1046
- value: U.enum.returnStock
1047
- }
1048
- };
1049
- function fs() {
1050
- const p = Je();
1051
- return {
1052
- ableToMarkReceived(t) {
1053
- if (!t || t.status !== be.enum.RECEIVING || p.useOperatePurchaseOrderV2) return !1;
1054
- const a = Ke().currentLocationDBName;
1055
- return `${t.supplier.internal}_${t.supplier._id}` !== a;
1056
- },
1057
- ableToMarkApproved(t) {
1058
- return !(!t || (t == null ? void 0 : t.status) !== be.enum.REQUESTING);
1059
- },
1060
- ableToCreateFulfillment(t, o) {
1061
- var u, c;
1062
- if (!p.acceptRequireFulfillment || !t || !o || t.status !== be.enum.PROCESSING || !o.processedAt)
1063
- return !1;
1064
- const a = (u = o == null ? void 0 : o.from) == null ? void 0 : u.dbName, m = (c = o == null ? void 0 : o.to) == null ? void 0 : c.dbName;
1065
- return !(a.startsWith("restaurant_") && m.startsWith("restaurant_"));
1066
- }
1067
- };
1068
- }
1069
- function vs() {
1070
- const p = z(() => [
1071
- {
1072
- action: Ht.Action.manage,
1073
- subject: Ht.Subject.Business.inventory_orderDraftApproval
1074
- }
1075
- ]), { hasPermission: t } = or(p);
1076
- return {
1077
- hasOrderDraftPermission: ws(t)
1078
- };
1079
- }
1080
- function ki(p, t, o, a) {
1081
- const m = Ke(), u = ht(), c = yt(), s = fs(), { t: r } = vt(), { hasOrderDraftPermission: d } = vs(), _ = Je(), k = z(
1082
- () => _.enablePrintTemplate ? [Ee[Ae.PrintCustom]] : []
1083
- ), F = z(
1084
- () => _.enablePurchaseOrderEmail ? [Ee[Ae.Email]] : []
1085
- );
1086
- function C(K) {
1087
- const ce = g(K), I = a == null ? void 0 : a.excludeRowActions;
1088
- return I != null && I.length ? ce.filter(
1089
- (w) => !I.includes(w.value)
1090
- ) : ce;
1091
- }
1092
- function g(K) {
1093
- switch (K.status) {
1094
- case "DRAFT":
1095
- return [
1096
- Ee[Ae.Update],
1097
- Ee[Ae.Details],
1098
- K.supplier.internal === "restaurant" || K.supplier.internal === "warehouse" ? He[U.enum.submitRequest] : He[U.enum.confirmDraft],
1099
- He[U.enum.cancelDraft]
1100
- ];
1101
- case "RECEIVING":
1102
- return [
1103
- ...s.ableToMarkReceived(K) ? [He[U.enum.completeReceive]] : [],
1104
- Ee[Ae.Details],
1105
- Ee[Ae.Print],
1106
- ...k.value,
1107
- ...F.value
1108
- ];
1109
- case "PENDING_APPROVAL": {
1110
- const I = [Ee[Ae.Details]];
1111
- return d.value && I.push(
1112
- Ee[Ae.Update],
1113
- He[U.enum.approveDraft],
1114
- He[U.enum.rejectDraft]
1115
- ), I;
1116
- }
1117
- case "REQUESTING":
1118
- return p === "receive/request" ? [
1119
- Ee[Ae.Details],
1120
- Ee[Ae.Print],
1121
- ...k.value
1122
- ] : [
1123
- He[U.enum.approveRequest],
1124
- He[U.enum.rejectRequest],
1125
- Ee[Ae.Details]
1126
- // DefaultRowActions[RowActionEnum.Print]
1127
- ];
1128
- case "PROCESSING":
1129
- return [
1130
- Ee[Ae.Details],
1131
- Ee[Ae.Print],
1132
- ...k.value
1133
- ];
1134
- case "COMPLETE":
1135
- case "CANCEL":
1136
- default:
1137
- return [
1138
- Ee[Ae.Details],
1139
- Ee[Ae.Print],
1140
- ...k.value
1141
- ];
1142
- }
1143
- }
1144
- function M(K) {
1145
- return Object.values(U.enum).includes(K);
1146
- }
1147
- async function T(K, ce, I) {
1148
- var q, W, B, ie, pe, L, O, X, P;
1149
- const w = kt(ce);
1150
- if (K === Ae.Print || K === Ae.PrintCustom) {
1151
- let x = w;
1152
- if (x.items == null && (a != null && a.fetchFullPo)) {
1153
- const n = await a.fetchFullPo(w);
1154
- if (n == null) return;
1155
- x = kt(n);
1156
- }
1157
- const N = (q = a == null ? void 0 : a.resolveLocation) == null ? void 0 : q.call(a, w), se = { ...(I == null ? void 0 : I.toInventoryLocation) ?? N ?? m.currentLocation };
1158
- if (se.type === "restaurant") {
1159
- const n = m.locationRestaurantFromCore(se.doc._id);
1160
- n !== null && (se.doc = n);
1161
- }
1162
- ((W = I == null ? void 0 : I.netSuite) != null && W.refNo || (B = x.netSuite) != null && B.refNo) && (x.ref = [((ie = I == null ? void 0 : I.netSuite) == null ? void 0 : ie.refNo) || ((pe = x.netSuite) == null ? void 0 : pe.refNo)].filter((n) => n).join(" "));
1163
- const Se = I ?? ((L = a == null ? void 0 : a.resolvePurchaseRequest) == null ? void 0 : L.call(a, w)), ke = {
1164
- po: x,
1165
- currentLocation: se,
1166
- business: c.currentBusiness.value,
1167
- fulfilling: p === "approval",
1168
- por: Se
1169
- };
1170
- if (K === Ae.PrintCustom) {
1171
- const n = cs(ke);
1172
- n && (ye.value = n.html, ne.value = n.templateName, ge.value = n.isDefault, xe.value = !0);
1173
- } else
1174
- yr(ke);
1175
- return;
1176
- }
1177
- if (K === Ae.Details) {
1178
- t.promptShowTransferDetails(w, I);
1179
- return;
1180
- }
1181
- if (K === Ae.Update) {
1182
- (O = t.promptUpdateTransferDialog) == null || O.call(t, w);
1183
- return;
1184
- }
1185
- if (K === Ae.Email) {
1186
- (X = t.promptEmailDialog) == null || X.call(t, w);
1187
- return;
1188
- }
1189
- if (M(K)) {
1190
- t.submitAction(ce, K, (P = I == null ? void 0 : I.to) == null ? void 0 : P.dbName);
1191
- return;
1192
- }
1193
- }
1194
- function J() {
1195
- var ce;
1196
- const K = [
1197
- {
1198
- accessorKey: "seqNumber",
1199
- header: () => r("inventory.transfer.table.seqNo"),
1200
- enableSorting: !0,
1201
- size: 80,
1202
- sortUndefined: "last"
1203
- },
1204
- {
1205
- accessorKey: "_id",
1206
- header: () => r("inventory.transfer.table.createdAt"),
1207
- cell(I) {
1208
- return at(`${I.getValue()}`);
1209
- },
1210
- enableSorting: !0
1211
- },
1212
- {
1213
- accessorKey: "supplier.name",
1214
- header: () => r("inventory.transfer.table.transferFrom"),
1215
- enableSorting: !0,
1216
- size: 200
1217
- },
1218
- {
1219
- // Bulk-view summary rows carry itemCount instead of the items array
1220
- id: "noOfItems",
1221
- accessorFn: (I) => {
1222
- var w;
1223
- return I.itemCount ?? ((w = I.items) == null ? void 0 : w.length) ?? 0;
1224
- },
1225
- header: () => r("inventory.transfer.table.noOfItems"),
1226
- cell: (I) => {
1227
- const w = I.row.original.version || "1", q = I.getValue();
1228
- return ee("div", { class: "flex items-center gap-2" }, [
1229
- q,
1230
- w !== "1" ? ee(
1231
- "div",
1232
- { class: "py-3" },
1233
- ee(
1234
- tt,
1235
- ee(
1236
- "div",
1237
- {
1238
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
1239
- },
1240
- `v${w}`
1241
- )
1242
- )
1243
- ) : null
1244
- ]);
1245
- },
1246
- enableSorting: !1,
1247
- meta: {
1248
- width: "10rem"
1249
- }
1250
- },
1251
- {
1252
- accessorKey: "ref",
1253
- header: () => r("inventory.transfer.table.reference"),
1254
- enableSorting: !1,
1255
- size: "auto"
1256
- },
1257
- ...(ce = c.sessionUser.value) != null && ce.role.isAdmin ? [
1258
- {
1259
- id: "statusForAdmin",
1260
- header: () => ee(tt, {}, () => `${r("inventory.transfer.table.status")}`),
1261
- cell(I) {
1262
- return I.row.original.status;
1263
- },
1264
- enableSorting: !0,
1265
- size: 200
1266
- }
1267
- ] : [],
1268
- {
1269
- accessorKey: "status",
1270
- header: () => r("inventory.transfer.table.status"),
1271
- cell(I) {
1272
- const w = I.getValue(), q = I.row.original, { partial: W, over: B } = q.items == null ? { partial: !!q.partialReceived, over: !!q.overReceived } : Ot(pt(q)), ie = wt(w ?? "", W, B);
1273
- let pe = r(`inventory.transfer.status.${ie}`), L = `${w ?? ""}`.toLocaleLowerCase("en-us");
1274
- ie === be.enum.CLOSE && (pe = `${r(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), ie === "PARTIAL_RECEIVED" && L === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (L = be.enum.RECEIVING.toLocaleLowerCase("en-us"));
1275
- let O = null;
1276
- const X = o.value.find((P) => P.ref === I.row.original._id);
1277
- if (X != null && X.milestones && X.milestones.length > 0) {
1278
- const P = X.milestones[X.milestones.length - 1];
1279
- if (P.estimatedTime) {
1280
- const x = new Date(P.estimatedTime), N = x.getDate().toString().padStart(2, "0");
1281
- O = `${x.toLocaleString("en-US", { month: "short" })} ${N}`;
1282
- }
1283
- }
1284
- return ee(
1285
- "div",
1286
- {
1287
- class: "flex"
1288
- },
1289
- [
1290
- ee(
1291
- "div",
1292
- { class: "flex items-center" },
1293
- ee(
1294
- "div",
1295
- {
1296
- class: [
1297
- "fm-status-badge",
1298
- `fm-status-badge-${L}`,
1299
- B && "fm-status-badge-error"
1300
- ].filter(Boolean).join(" ")
1301
- },
1302
- `${pe}`
1303
- )
1304
- ),
1305
- ...O ? [
1306
- ee(
1307
- "div",
1308
- {
1309
- class: "flex items-center gap-1 ml-2"
1310
- },
1311
- [
1312
- ee(dt.FmIcon, {
1313
- name: "local_shipping",
1314
- size: "md",
1315
- color: "neutral-gray-400"
1316
- }),
1317
- ee(
1318
- "span",
1319
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
1320
- O
1321
- )
1322
- ]
1323
- )
1324
- ] : []
1325
- ]
1326
- );
1327
- },
1328
- enableSorting: !0,
1329
- size: 150
1330
- },
1331
- {
1332
- id: "action",
1333
- cell(I) {
1334
- const w = I.row.original, q = C(w);
1335
- return zt(q, (W) => T(W, w));
1336
- },
1337
- enableSorting: !1,
1338
- size: 40,
1339
- meta: {
1340
- cellClass: "",
1341
- headerClass: ""
1342
- }
1343
- }
1344
- ];
1345
- if (u.isEnabled) {
1346
- const I = [
1347
- {
1348
- id: "netsuiteTransferOrder",
1349
- accessorFn: (w) => {
1350
- var q;
1351
- return (q = w.netSuite) != null && q.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1352
- },
1353
- header: () => "NetSuite Order (ID)",
1354
- cell(w) {
1355
- var W;
1356
- const q = w.row.original;
1357
- return (W = q.netSuite) != null && W.id ? `${q.netSuite.refNo} (${q.netSuite.id})` : "N/A";
1358
- },
1359
- enableSorting: !1,
1360
- size: 200,
1361
- meta: {
1362
- cellClass: "",
1363
- headerClass: ""
1364
- }
1365
- },
1366
- {
1367
- id: "netsuiteTransactionNumber",
1368
- accessorFn: (w) => {
1369
- var q, W;
1370
- return ((W = (q = w.netSuite) == null ? void 0 : q.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1371
- },
1372
- header: () => "NetSuite Transaction No.",
1373
- cell(w) {
1374
- var W, B;
1375
- return ((B = (W = w.row.original.netSuite) == null ? void 0 : W.additionalInfo) == null ? void 0 : B.transactionnumber) ?? "N/A";
1376
- },
1377
- enableSorting: !1,
1378
- size: 200,
1379
- meta: {
1380
- cellClass: "",
1381
- headerClass: ""
1382
- }
1383
- }
1384
- ];
1385
- K.splice(K.length - 1, 0, ...I);
1386
- }
1387
- return K;
1388
- }
1389
- function Q() {
1390
- var ce;
1391
- const K = [
1392
- {
1393
- accessorKey: "purchaseOrder.seqNumber",
1394
- header: () => r("inventory.transfer.table.seqNo"),
1395
- enableSorting: !0,
1396
- size: 80,
1397
- sortUndefined: "last"
1398
- },
1399
- {
1400
- accessorKey: "purchaseOrder._id",
1401
- header: () => r("inventory.transfer.table.createdAt"),
1402
- cell(I) {
1403
- return at(`${I.getValue()}`);
1404
- },
1405
- enableSorting: !0
1406
- },
1407
- {
1408
- accessorKey: "to.name",
1409
- header: () => r("inventory.transfer.table.transferTo"),
1410
- enableSorting: !1,
1411
- size: 200
1412
- },
1413
- {
1414
- accessorKey: "purchaseOrder.items.length",
1415
- header: () => r("inventory.transfer.table.noOfItems"),
1416
- enableSorting: !1
1417
- },
1418
- {
1419
- accessorKey: "purchaseOrder.ref",
1420
- header: () => r("inventory.transfer.table.reference"),
1421
- enableSorting: !1,
1422
- size: "auto"
1423
- },
1424
- ...(ce = c.sessionUser.value) != null && ce.role.isAdmin ? [
1425
- {
1426
- id: "statusForAdmin",
1427
- header: () => ee(tt, {}, () => `${r("inventory.transfer.table.status")}`),
1428
- cell(I) {
1429
- return I.row.original.status;
1430
- },
1431
- enableSorting: !0,
1432
- size: 200
1433
- }
1434
- ] : [],
1435
- {
1436
- accessorKey: "purchaseOrder.status",
1437
- header: () => r("inventory.transfer.table.status"),
1438
- cell(I) {
1439
- const w = I.row.original, q = I.getValue();
1440
- if (!w.purchaseOrder)
1441
- return ee(dt.FmChip, {
1442
- label: "N/A",
1443
- compact: !0
1444
- });
1445
- const W = pt(w.purchaseOrder), { partial: B, over: ie } = Ot(W), pe = wt(q ?? "", B, ie);
1446
- let L = r(`inventory.transfer.status.${pe}`), O = `${q ?? ""}`.toLocaleLowerCase("en-us");
1447
- return pe === be.enum.CLOSE && (L = `${r(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), pe === "PARTIAL_RECEIVED" && O === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (O = be.enum.RECEIVING.toLocaleLowerCase("en-us")), w.rejectedAt && (L = r("inventory.transfer.status.REJECT"), O = be.enum.REJECT.toLocaleLowerCase("en-us")), ee(
1448
- "div",
1449
- {
1450
- class: "flex"
1451
- },
1452
- ee(
1453
- "div",
1454
- {
1455
- class: [
1456
- "fm-status-badge",
1457
- `fm-status-badge-${O}`,
1458
- ie && "fm-status-badge-error"
1459
- ].filter(Boolean).join(" ")
1460
- },
1461
- `${L}`
1462
- )
1463
- );
1464
- },
1465
- enableSorting: !0
1466
- },
1467
- {
1468
- id: "action",
1469
- cell(I) {
1470
- const w = I.row.original, W = (w.purchaseOrder ? C(w.purchaseOrder) : []).map((B) => B.value === Ae.Print ? {
1471
- ...B,
1472
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
1473
- } : B);
1474
- return zt(
1475
- W,
1476
- (B) => w.purchaseOrder ? T(B, w.purchaseOrder, w) : void 0
1477
- );
1478
- },
1479
- enableSorting: !1,
1480
- size: 40,
1481
- meta: {
1482
- cellClass: "",
1483
- headerClass: ""
1484
- }
1485
- }
1486
- ];
1487
- if (u.isEnabled) {
1488
- const I = [
1489
- {
1490
- id: "netsuiteTransferOrder",
1491
- accessorFn: (w) => {
1492
- var q;
1493
- return (q = w.netSuite) != null && q.id ? `${w.netSuite.refNo} (${w.netSuite.id})` : "N/A";
1494
- },
1495
- header: () => "NetSuite Order (ID)",
1496
- cell(w) {
1497
- var W;
1498
- const q = w.row.original;
1499
- return (W = q.netSuite) != null && W.id ? `${q.netSuite.refNo} (${q.netSuite.id})` : "N/A";
1500
- },
1501
- enableSorting: !1,
1502
- size: 200,
1503
- meta: {
1504
- cellClass: "",
1505
- headerClass: ""
1506
- }
1507
- },
1508
- {
1509
- id: "netsuiteTransactionNumber",
1510
- accessorFn: (w) => {
1511
- var q, W;
1512
- return ((W = (q = w.netSuite) == null ? void 0 : q.additionalInfo) == null ? void 0 : W.transactionnumber) ?? "N/A";
1513
- },
1514
- header: () => "NetSuite Transaction No.",
1515
- cell(w) {
1516
- var W, B;
1517
- return ((B = (W = w.row.original.netSuite) == null ? void 0 : W.additionalInfo) == null ? void 0 : B.transactionnumber) ?? "N/A";
1518
- },
1519
- enableSorting: !1,
1520
- size: 200,
1521
- meta: {
1522
- cellClass: "",
1523
- headerClass: ""
1524
- }
1525
- }
1526
- ];
1527
- K.splice(K.length - 2, 0, ...I);
1528
- }
1529
- return K;
1530
- }
1531
- const le = z(() => p === "receive/request" ? J() : Q()), xe = Y(!1), ye = Y(""), ne = Y(""), ge = Y(!1);
1532
- return {
1533
- columnDefs: le,
1534
- showCustomPrintDialog: xe,
1535
- customPrintHtml: ye,
1536
- customPrintTemplateName: ne,
1537
- customPrintIsDefault: ge
1538
- };
1539
- }
1540
- const hr = { class: "flex flex-col gap-4 border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, br = { class: "flex items-center justify-between" }, gr = {
1541
- key: 0,
1542
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
1543
- }, _r = { class: "flex justify-between items-start py-1 gap-4" }, xr = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Sr = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, kr = {
1544
- key: 0,
1545
- class: "border-b border-fm-color-stroke-secondary"
1546
- }, Nt = /* @__PURE__ */ Te({
1547
- __name: "PriceAdjustmentEditor",
1548
- props: {
1549
- controller: {},
1550
- state: {}
1551
- },
1552
- setup(p) {
1553
- const t = p, o = z(() => t.state.adjustments ?? []);
1554
- function a(r) {
1555
- return +_e(r.dinero);
1556
- }
1557
- function m() {
1558
- t.controller.addAdjustment();
1559
- }
1560
- function u(r, d) {
1561
- t.controller.updateAdjustment(r, d);
1562
- }
1563
- function c(r, d) {
1564
- t.controller.updateAdjustment(r, null, d);
1565
- }
1566
- function s(r) {
1567
- t.controller.removeAdjustment(r);
1568
- }
1569
- return (r, d) => {
1570
- const _ = te("FmButton"), k = te("FmTextField"), F = te("FmStepperField");
1571
- return l(), f("div", hr, [
1572
- e("div", br, [
1573
- d[0] || (d[0] = e("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, "Price adjustments", -1)),
1574
- D(_, {
1575
- variant: "tertiary",
1576
- label: "Add adjustment",
1577
- "prepend-icon": "add",
1578
- size: "md",
1579
- onClick: m
1580
- })
1581
- ]),
1582
- o.value.length === 0 ? (l(), f("div", gr, " No price adjustments ")) : R("", !0),
1583
- (l(!0), f($e, null, Pe(o.value, (C, g) => (l(), f("div", {
1584
- key: C.id
1585
- }, [
1586
- e("div", _r, [
1587
- e("div", xr, [
1588
- D(k, {
1589
- "model-value": C.name,
1590
- "onUpdate:modelValue": (M) => u(C.id, M),
1591
- label: "Name",
1592
- placeholder: "e.g. Freight, Discount",
1593
- size: "md"
1594
- }, null, 8, ["model-value", "onUpdate:modelValue"])
1595
- ]),
1596
- e("div", Sr, [
1597
- D(F, {
1598
- "model-value": a(C),
1599
- "onUpdate:modelValue": (M) => c(C.id, M),
1600
- label: "Amount (+/-)",
1601
- step: 0.01,
1602
- placeholder: "0.00",
1603
- size: "md",
1604
- "append-text": y(Ce)()
1605
- }, null, 8, ["model-value", "onUpdate:modelValue", "append-text"])
1606
- ]),
1607
- D(_, {
1608
- variant: "tertiary",
1609
- "prepend-icon": "delete",
1610
- size: "md",
1611
- class: "mt-6",
1612
- onClick: (M) => s(C.id)
1613
- }, null, 8, ["onClick"])
1614
- ]),
1615
- g < o.value.length - 1 ? (l(), f("div", kr)) : R("", !0)
1616
- ]))), 128))
1617
- ]);
1618
- };
1619
- }
1620
- });
1621
- function Pt(p) {
1622
- const t = ct(
1623
- Gt({
1624
- currency: p.currency,
1625
- adjustments: p.adjustments ?? []
1626
- })
1627
- ), o = ct(t.value.state());
1628
- function a(c) {
1629
- const s = () => {
1630
- o.value = c.state();
1631
- };
1632
- return c.addListener(s), () => c.removeListener(s);
1633
- }
1634
- let m = a(t.value);
1635
- function u(c) {
1636
- m(), t.value = Gt({
1637
- currency: p.currency,
1638
- adjustments: c ?? []
1639
- }), m = a(t.value), o.value = t.value.state();
1640
- }
1641
- return ts(() => m()), { controller: t, state: o, reset: u };
1642
- }
1643
- const Or = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, wr = { class: "flex flex-col gap-8" }, $r = { class: "flex w-full justify-end gap-16" }, Cr = /* @__PURE__ */ Te({
1644
- __name: "FulfillmentForm",
1645
- props: {
1646
- purchaseOrder: {},
1647
- confirm: { type: Function }
1648
- },
1649
- emits: ["update:show"],
1650
- setup(p, { emit: t }) {
1651
- const o = p, a = $s({
1652
- id: "",
1653
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1654
- items: []
1655
- }), m = Y(), u = t, c = (r) => r != null && r !== "";
1656
- ss(() => {
1657
- o.purchaseOrder && (a.items = o.purchaseOrder.items.map((r) => ({
1658
- id: r.id,
1659
- sku: r.sku,
1660
- measurement: r.measurement,
1661
- amount: r.quantity ?? { amount: 1, precision: 0 }
1662
- })));
1663
- });
1664
- const s = z(() => a.items.length <= 10);
1665
- return (r, d) => {
1666
- const _ = te("FmTable"), k = te("FmButton"), F = te("FmForm");
1667
- return l(), me(F, {
1668
- ref_key: "formRef",
1669
- ref: m,
1670
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1671
- onValidationFailed: console.log,
1672
- onValidationSuccess: d[1] || (d[1] = () => o.confirm(a))
1673
- }, {
1674
- default: ae(() => [
1675
- d[2] || (d[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1676
- e("div", Or, [
1677
- e("div", wr, [
1678
- D(_, {
1679
- "column-defs": [
1680
- {
1681
- header: "Code",
1682
- cell: (C) => {
1683
- const g = o.purchaseOrder.items.find((M) => c(C.row.original.id) ? M.id === C.row.original.id : M.sku._id === C.row.original.sku._id);
1684
- return ee(
1685
- y(dt).FmTooltip,
1686
- {
1687
- content: g.code,
1688
- placement: "top",
1689
- variant: "plain",
1690
- zIndex: 50
1691
- },
1692
- ee(
1693
- "span",
1694
- {
1695
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1696
- },
1697
- g.code
1698
- )
1699
- );
1700
- }
1701
- },
1702
- {
1703
- header: "Name",
1704
- cell: (C) => {
1705
- const g = o.purchaseOrder.items.find((M) => c(C.row.original.id) ? M.id === C.row.original.id : M.sku._id === C.row.original.sku._id);
1706
- return ee(
1707
- y(dt).FmTooltip,
1708
- {
1709
- content: g.name,
1710
- placement: "top",
1711
- variant: "plain",
1712
- zIndex: 50
1713
- },
1714
- ee(
1715
- "span",
1716
- {
1717
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1718
- },
1719
- g.name
1720
- )
1721
- );
1722
- }
1723
- },
1724
- {
1725
- header: "Amount",
1726
- cell: (C) => {
1727
- const g = C.row.original, M = o.purchaseOrder.items.find((J) => c(g.id) ? J.id === g.id : J.sku._id === g.sku._id), T = g.amount ?? {
1728
- amount: 1,
1729
- precision: 0
1730
- };
1731
- return ee(Qs, {
1732
- style: {
1733
- flex: "1 1 0%"
1734
- },
1735
- modelValue: {
1736
- amount: T,
1737
- measurement: g.measurement ?? null
1738
- },
1739
- key: c(g.id) ? g.id : g.sku._id,
1740
- unit: g.sku.unit,
1741
- "onUpdate:modelValue": (J) => {
1742
- if (!J) return;
1743
- const Q = a.items.find((le) => c(g.id) ? le.id === g.id : le.sku._id === g.sku._id);
1744
- Q && (Q.amount = J.amount);
1745
- },
1746
- disableUnit: !0,
1747
- rules: [
1748
- y(Ys)(
1749
- +y(_e)({ amount: 0, precision: 0 })
1750
- ),
1751
- y(Js)(+y(_e)(M.quantity))
1752
- ],
1753
- applyDefaultRules: !0
1754
- });
1755
- }
1756
- }
1757
- ],
1758
- "row-data": a.items,
1759
- "hide-footer": s.value
1760
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1761
- ])
1762
- ]),
1763
- e("div", $r, [
1764
- D(k, {
1765
- class: "px-16",
1766
- label: "Confirm",
1767
- size: "md",
1768
- variant: "primary",
1769
- type: "submit"
1770
- }),
1771
- D(k, {
1772
- class: "px-16",
1773
- label: "Cancel",
1774
- size: "md",
1775
- variant: "secondary",
1776
- onClick: d[0] || (d[0] = () => u("update:show", !1))
1777
- })
1778
- ])
1779
- ]),
1780
- _: 1
1781
- }, 8, ["onValidationFailed"]);
1782
- };
1783
- }
1784
- }), ot = {
1785
- submitRequest: {
1786
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1787
- color: "primary",
1788
- buttonVariant: Ue.Primary
1789
- },
1790
- confirmDraft: {
1791
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1792
- color: "primary",
1793
- buttonVariant: Ue.Primary
1794
- },
1795
- cancelDraft: {
1796
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1797
- color: "system-error-300",
1798
- buttonVariant: Ue.Destructive
1799
- },
1800
- approveDraft: {
1801
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1802
- color: "primary",
1803
- buttonVariant: Ue.Primary
1804
- },
1805
- rejectDraft: {
1806
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1807
- color: "system-error-300",
1808
- buttonVariant: Ue.Destructive
1809
- },
1810
- approveRequest: {
1811
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1812
- color: "primary",
1813
- buttonVariant: Ue.Primary
1814
- },
1815
- processRequest: {
1816
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1817
- color: "primary",
1818
- buttonVariant: Ue.Primary
1819
- },
1820
- receiveStock: {
1821
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1822
- color: "primary",
1823
- buttonVariant: Ue.Primary,
1824
- available: !1
1825
- },
1826
- completeReceive: {
1827
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1828
- color: "primary",
1829
- buttonVariant: Ue.Plain
1830
- },
1831
- rejectRequest: {
1832
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1833
- color: "system-error-300",
1834
- buttonVariant: Ue.Destructive
1835
- },
1836
- closeRequest: {
1837
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1838
- color: "system-error-300",
1839
- buttonVariant: Ue.Destructive,
1840
- available: !1
1841
- },
1842
- returnStock: {
1843
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1844
- color: "primary",
1845
- buttonVariant: Ue.Primary,
1846
- available: !1
1847
- }
1848
- }, Dr = { class: "flex flex-row-reverse" }, Ar = /* @__PURE__ */ Te({
1849
- __name: "NetSuiteSync",
1850
- props: {
1851
- poRequest: {},
1852
- purchaseOrder: {},
1853
- isTransferBetweenOutlets: { type: Boolean },
1854
- scope: {}
1855
- },
1856
- setup(p) {
1857
- const t = p, o = ht(), a = Xe(), m = bt(), u = Y(!1);
1858
- z(() => {
1859
- var _, k, F, C;
1860
- let s = !0;
1861
- o.isEnabled || (s = !1);
1862
- const r = t.purchaseOrder, d = t.poRequest;
1863
- return r && ((_ = r == null ? void 0 : r.supplier) != null && _.internal ? (!d && r.status == be.enum.DRAFT && (s = !1), d && !((k = d == null ? void 0 : d.netSuite) != null && k.id) && (s = !1), t.isTransferBetweenOutlets && (s = !1)) : ((r == null ? void 0 : r.status) !== be.enum.REQUESTING && r.supplier.internal && (s = !1), !d && !((F = r == null ? void 0 : r.netSuite) != null && F.id) && (s = !1), !d && ((C = r == null ? void 0 : r.netSuite) != null && C.id) && (r == null ? void 0 : r.status) == be.enum.REQUESTING && (s = !1))), s;
1864
- });
1865
- async function c() {
1866
- u.value || m.open({
1867
- title: "Sync with NetSuite",
1868
- contentComponent: ee("div", [
1869
- ee("p", "Are you sure you want to sync now?"),
1870
- ee("br"),
1871
- ee(
1872
- "p",
1873
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1874
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1875
- )
1876
- ]),
1877
- primaryActions: {
1878
- text: "Sync",
1879
- close: !0,
1880
- variant: "destructive"
1881
- },
1882
- secondaryActions: { text: "Not now", close: !0 }
1883
- }).onPrimary(async () => {
1884
- var s, r, d, _, k, F, C;
1885
- try {
1886
- u.value = !0;
1887
- const g = ((s = t.purchaseOrder) == null ? void 0 : s._id) || ((r = t.poRequest) == null ? void 0 : r.purchaseOrderId) || "", M = (d = t.poRequest) == null ? void 0 : d.to.dbName;
1888
- await o.syncPurchaseOrder({
1889
- purchaseOrderId: g,
1890
- locationId: t.scope === "approval" ? M : void 0,
1891
- netsuiteId: ((k = (_ = t.purchaseOrder) == null ? void 0 : _.netSuite) == null ? void 0 : k.id) || ((C = (F = t.poRequest) == null ? void 0 : F.netSuite) == null ? void 0 : C.id)
1892
- }), a.open({
1893
- title: "Sync with NetSuite",
1894
- message: "Requested to sync with NetSuite. Please wait a moment.",
1895
- type: "success"
1896
- }), await new Promise((T) => setTimeout(T, 5e3)), u.value = !1;
1897
- } catch (g) {
1898
- console.log("Failed to sync with NetSuite", g), a.open({
1899
- title: "Error",
1900
- message: "Failed to sync with NetSuite",
1901
- type: "error"
1902
- }), u.value = !1;
1903
- }
1904
- });
1905
- }
1906
- return (s, r) => {
1907
- const d = te("FmButton");
1908
- return l(), f("div", Dr, [
1909
- D(d, {
1910
- "prepend-icon": "sync",
1911
- variant: "secondary",
1912
- label: "Sync",
1913
- loading: u.value,
1914
- onClick: c,
1915
- "text-color": "primary",
1916
- "bg-color": "transparent",
1917
- "border-color": "primary"
1918
- }, null, 8, ["loading"])
1919
- ]);
1920
- };
1921
- }
1922
- }), Rr = {
1923
- key: 0,
1924
- class: "flex flex-col gap-8"
1925
- }, Nr = { class: "flex flex-col gap-4" }, Pr = { class: "fm-typo-en-body-lg-600" }, Fr = {
1926
- key: 0,
1927
- class: "flex flex-col gap-4"
1928
- }, Tr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ir = { class: "fm-typo-en-body-lg-600" }, Er = { key: 0 }, qr = { key: 1 }, Vr = {
1929
- key: 1,
1930
- class: "flex flex-col gap-4"
1931
- }, Lr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jr = { class: "fm-typo-en-body-lg-600" }, Ur = { key: 0 }, Mr = { key: 1 }, Br = {
1932
- key: 2,
1933
- class: "flex flex-col gap-4"
1934
- }, zr = { class: "fm-typo-en-body-lg-600" }, Kr = {
1935
- key: 3,
1936
- class: "flex flex-col gap-4"
1937
- }, Hr = { class: "fm-typo-en-body-lg-600" }, Gr = /* @__PURE__ */ Te({
1938
- __name: "NetSuiteInfo",
1939
- props: {
1940
- transferType: {},
1941
- transferToDbName: {},
1942
- poRequest: {},
1943
- purchaseOrder: {},
1944
- isTransferBetweenOutlets: { type: Boolean },
1945
- scope: {}
1946
- },
1947
- setup(p) {
1948
- const t = p, o = ht(), a = Ze(), m = Y(t.poRequest);
1949
- ss(async () => {
1950
- var r;
1951
- if (!t.poRequest && ((r = t.purchaseOrder) != null && r._id)) {
1952
- const d = await a.getLatestPurchaseOrderRequest(t.purchaseOrder._id);
1953
- m.value = d;
1954
- }
1955
- });
1956
- const u = z(
1957
- () => {
1958
- var r, d, _, k, F, C;
1959
- return o.getSubsidiaryFullName(
1960
- ((_ = (d = (r = t.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : d.subsidiary) == null ? void 0 : _.id) || ((C = (F = (k = t.poRequest) == null ? void 0 : k.netSuite) == null ? void 0 : F.subsidiary) == null ? void 0 : C.id)
1961
- ).fullName;
1962
- }
1963
- ), c = z(() => {
1964
- var r, d, _, k, F, C, g, M, T, J, Q, le;
1965
- return (_ = (d = (r = t.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : d.additionalInfo) != null && _.transactionnumber ? (C = (F = (k = t.purchaseOrder) == null ? void 0 : k.netSuite) == null ? void 0 : F.additionalInfo) == null ? void 0 : C.transactionnumber : (T = (M = (g = m.value) == null ? void 0 : g.netSuite) == null ? void 0 : M.additionalInfo) != null && T.transactionnumber ? (le = (Q = (J = m.value) == null ? void 0 : J.netSuite) == null ? void 0 : Q.additionalInfo) == null ? void 0 : le.transactionnumber : null;
1966
- }), s = z(() => {
1967
- var r, d, _, k, F, C;
1968
- return (d = (r = t.purchaseOrder) == null ? void 0 : r.deliveryFullfillment) != null && d.length && ((k = (_ = t.purchaseOrder) == null ? void 0 : _.deliveryFullfillment) == null ? void 0 : k.length) > 0 ? (C = (F = t.purchaseOrder) == null ? void 0 : F.deliveryFullfillment) == null ? void 0 : C.map((g) => {
1969
- var M;
1970
- return (M = g.netSuite) == null ? void 0 : M.refNo;
1971
- }).join(", ") : "N/A";
1972
- });
1973
- return (r, d) => {
1974
- var _, k, F, C, g, M, T, J, Q, le, xe, ye, ne, ge, K, ce;
1975
- return y(o).isEnabled ? (l(), f("div", Rr, [
1976
- e("div", Nr, [
1977
- d[0] || (d[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1978
- e("div", Pr, b(u.value || "N/A"), 1)
1979
- ]),
1980
- !r.isTransferBetweenOutlets && r.scope === y($t).RECEIVE_REQUEST ? (l(), f("div", Fr, [
1981
- e("div", Tr, " NetSuite " + b((k = (_ = r.purchaseOrder) == null ? void 0 : _.netSuite) != null && k.recordType ? y(os)((C = (F = r.purchaseOrder) == null ? void 0 : F.netSuite) == null ? void 0 : C.recordType) : r.transferType === y(nt).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1982
- e("div", Ir, [
1983
- (M = (g = r.purchaseOrder) == null ? void 0 : g.netSuite) != null && M.id ? (l(), f("span", Er, b((J = (T = r.purchaseOrder) == null ? void 0 : T.netSuite) == null ? void 0 : J.refNo) + " (" + b((le = (Q = r.purchaseOrder) == null ? void 0 : Q.netSuite) == null ? void 0 : le.id) + ") ", 1)) : (l(), f("span", qr, "N/A"))
1984
- ])
1985
- ])) : R("", !0),
1986
- !r.isTransferBetweenOutlets && m.value || r.scope === y($t).APPROVAL ? (l(), f("div", Vr, [
1987
- e("div", Lr, " (Request) NetSuite " + b(r.transferType === y(nt).enum.purchase ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1988
- e("div", jr, [
1989
- (ye = (xe = m.value) == null ? void 0 : xe.netSuite) != null && ye.id ? (l(), f("span", Ur, b((ge = (ne = m.value) == null ? void 0 : ne.netSuite) == null ? void 0 : ge.refNo) + " (" + b((ce = (K = m.value) == null ? void 0 : K.netSuite) == null ? void 0 : ce.id) + ") ", 1)) : (l(), f("span", Mr, "N/A"))
1990
- ])
1991
- ])) : R("", !0),
1992
- c.value ? (l(), f("div", Br, [
1993
- d[1] || (d[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1994
- e("div", zr, b(c.value), 1)
1995
- ])) : R("", !0),
1996
- y(o).isEnabled && r.transferType === y(nt).enum.transfer && !r.isTransferBetweenOutlets ? (l(), f("div", Kr, [
1997
- d[2] || (d[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1998
- e("div", Hr, b(s.value), 1)
1999
- ])) : R("", !0)
2000
- ])) : R("", !0);
2001
- };
2002
- }
2003
- }), Wr = { class: "flex flex-row-reverse" }, Qr = /* @__PURE__ */ Te({
2004
- __name: "NetSuiteLog",
2005
- props: {
2006
- netsuiteId: {},
2007
- purchaseOrderId: {}
2008
- },
2009
- setup(p) {
2010
- const t = Xe(), o = Rt();
2011
- async function a(m, u) {
2012
- const c = [];
2013
- if (m && c.push(`body.message:*${m}*`), u) {
2014
- const _ = u.replace(/:/g, "\\:");
2015
- c.push(`${_}`);
2016
- }
2017
- if (c.length === 0) {
2018
- t.open({
2019
- message: "Cannot open logs without valid filters.",
2020
- type: "error"
2021
- });
2022
- return;
2023
- }
2024
- const r = `attributes.pod:netsuite* AND (${c.join(" OR ")})`, { url: d } = await o.getSyncLogs(r);
2025
- t.open(
2026
- {
2027
- message: "Opening NetSuite logs...",
2028
- type: "info"
2029
- },
2030
- 800
2031
- ), await new Promise((_) => setTimeout(_, 800)), window.open(d, "_blank");
2032
- }
2033
- return (m, u) => {
2034
- const c = te("FmButton");
2035
- return l(), f("div", Wr, [
2036
- D(c, {
2037
- "prepend-icon": "history",
2038
- variant: "secondary",
2039
- label: "Logs",
2040
- onClick: u[0] || (u[0] = (s) => a(m.netsuiteId, m.purchaseOrderId)),
2041
- "text-color": "primary",
2042
- "bg-color": "transparent",
2043
- "border-color": "primary"
2044
- })
2045
- ]);
2046
- };
2047
- }
2048
- }), Yr = { class: "flex flex-row-reverse" }, Jr = { key: 0 }, Xr = { key: 1 }, Zr = { class: "mb-6" }, eo = { class: "fm-typo-en-body-md-400" }, to = { key: 0 }, so = { key: 1 }, ro = {
2049
- key: 0,
2050
- class: "flex"
2051
- }, oo = {
2052
- key: 1,
2053
- class: "border-t pt-6"
2054
- }, no = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, ao = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, lo = { class: "w-full" }, io = {
2055
- class: "p-3 fm-typo-en-body-sm-600",
2056
- style: { "min-width": "130px" }
2057
- }, co = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, uo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, mo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, po = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, vo = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, yo = { class: "p-3 fm-typo-en-body-sm-600" }, ho = { key: 2 }, bo = { key: 1 }, go = /* @__PURE__ */ Te({
2058
- __name: "NetSuiteLatestInfo",
2059
- props: {
2060
- netsuiteId: {},
2061
- purchaseOrderId: {}
2062
- },
2063
- setup(p) {
2064
- const t = p, o = Rt(), a = Y(!1), m = Ke(), u = Y(!0), c = Y(!1), s = Y(!1), r = Y(!1), d = Y(null), _ = Y([]);
2065
- async function k() {
2066
- if (!d.value) {
2067
- a.value = !0;
2068
- try {
2069
- u.value = !0;
2070
- const M = await o.getMoreInfo(
2071
- m.currentLocation.dbName,
2072
- t.purchaseOrderId
2073
- );
2074
- d.value = M, c.value = !1;
2075
- } catch {
2076
- c.value = !0;
2077
- } finally {
2078
- u.value = !1;
2079
- }
2080
- await F();
2081
- }
2082
- }
2083
- async function F() {
2084
- if (!(_.value.length > 0))
2085
- try {
2086
- s.value = !0;
2087
- const M = await o.getChangeLogs(t.netsuiteId);
2088
- _.value = M, r.value = !1;
2089
- } catch {
2090
- r.value = !0;
2091
- } finally {
2092
- s.value = !1;
2093
- }
2094
- }
2095
- function C(M) {
2096
- switch (M) {
2097
- case Me.Create:
2098
- return "text-green-600 bg-green-100";
2099
- case Me.Set:
2100
- return "text-blue-600 bg-blue-100";
2101
- case Me.Change:
2102
- return "text-yellow-600 bg-yellow-100";
2103
- case Me.Unset:
2104
- return "text-red-600 bg-red-100";
2105
- default:
2106
- return "text-gray-600 bg-gray-100";
2107
- }
2108
- }
2109
- function g(M) {
2110
- return new Date(M).toLocaleDateString("en-US", {
2111
- year: "numeric",
2112
- month: "short",
2113
- day: "numeric",
2114
- hour: "2-digit",
2115
- minute: "2-digit"
2116
- });
2117
- }
2118
- return (M, T) => {
2119
- const J = te("FmButton"), Q = te("FmLabel"), le = te("FmCircularProgress"), xe = te("FmIcon"), ye = te("FmDialog");
2120
- return l(), f("div", Yr, [
2121
- D(ye, {
2122
- modelValue: a.value,
2123
- "onUpdate:modelValue": T[2] || (T[2] = (ne) => a.value = ne),
2124
- overlay: !0,
2125
- "max-width": 800
2126
- }, {
2127
- "dialog-button": ae(() => [
2128
- D(J, {
2129
- "prepend-icon": "info",
2130
- variant: "secondary",
2131
- label: "Latest Info",
2132
- onClick: T[0] || (T[0] = (ne) => k()),
2133
- "text-color": "primary",
2134
- "bg-color": "transparent",
2135
- "border-color": "primary"
2136
- })
2137
- ]),
2138
- "dialog-header": ae(() => T[3] || (T[3] = [
2139
- e("div", null, "NetSuite latest info", -1)
2140
- ])),
2141
- default: ae(() => [
2142
- u.value ? (l(), f("div", Jr, "Loading...")) : (l(), f("div", Xr, [
2143
- c.value ? (l(), f("p", bo, "Something went wrong.")) : (l(), f($e, { key: 0 }, [
2144
- e("div", Zr, [
2145
- T[4] || (T[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
2146
- (l(!0), f($e, null, Pe(d.value, (ne, ge) => (l(), f("div", {
2147
- key: ge,
2148
- class: "mb-2"
2149
- }, [
2150
- e("div", null, [
2151
- D(Q, {
2152
- label: y(Dt)(ge)
2153
- }, null, 8, ["label"]),
2154
- e("div", eo, [
2155
- Array.isArray(ne) ? (l(), f("span", to, b(ne.length > 0 ? ne.join(", ") : "N/A"), 1)) : (l(), f("span", so, b(ne), 1))
2156
- ])
2157
- ])
2158
- ]))), 128))
2159
- ]),
2160
- s.value ? (l(), f("div", ro, [
2161
- T[5] || (T[5] = e("span", null, "Change Log Loading...", -1)),
2162
- D(le, { size: "md" })
2163
- ])) : R("", !0),
2164
- !s.value && _.value.length > 0 ? (l(), f("div", oo, [
2165
- e("h3", no, [
2166
- D(xe, {
2167
- name: "error",
2168
- color: "#ff9500",
2169
- size: "sm"
2170
- }),
2171
- T[6] || (T[6] = We(" Change Logs "))
2172
- ]),
2173
- e("div", ao, [
2174
- e("table", lo, [
2175
- T[7] || (T[7] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
2176
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
2177
- e("th", {
2178
- class: "text-left p-3 fm-typo-en-body-md-600",
2179
- style: { "min-width": "130px" }
2180
- }, " Date "),
2181
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
2182
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
2183
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
2184
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
2185
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
2186
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
2187
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
2188
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
2189
- ])
2190
- ], -1)),
2191
- e("tbody", null, [
2192
- (l(!0), f($e, null, Pe(_.value, (ne, ge) => (l(), f("tr", {
2193
- key: ge,
2194
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
2195
- }, [
2196
- e("td", io, b(g(ne._dateiso8601)), 1),
2197
- e("td", co, b(ne._rolename), 1),
2198
- e("td", uo, b(ne._employeename), 1),
2199
- e("td", mo, b(ne._contextname), 1),
2200
- e("td", {
2201
- class: ze(`p-3 fm-typo-en-body-sm-600 ${C(Number(ne.type) - 1)}`)
2202
- }, b(y(Me)[Number(ne.type) - 1]), 3),
2203
- e("td", po, b(ne.lineid || ""), 1),
2204
- e("td", fo, b(ne._fieldname), 1),
2205
- e("td", vo, b(ne.oldvalue || ""), 1),
2206
- e("td", yo, b(ne.newvalue || ""), 1)
2207
- ]))), 128))
2208
- ])
2209
- ])
2210
- ])
2211
- ])) : (l(), f("div", ho, T[8] || (T[8] = [
2212
- e("p", null, "No change logs available.", -1)
2213
- ])))
2214
- ], 64))
2215
- ]))
2216
- ]),
2217
- "dialog-footer": ae(() => [
2218
- D(J, {
2219
- class: "ml-auto sm:w-full xs:w-full",
2220
- label: "Close",
2221
- size: "md",
2222
- variant: "primary",
2223
- onClick: T[1] || (T[1] = (ne) => a.value = !1)
2224
- })
2225
- ]),
2226
- _: 1
2227
- }, 8, ["modelValue"])
2228
- ]);
2229
- };
2230
- }
2231
- }), _o = {
2232
- key: 0,
2233
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
2234
- }, xo = { class: "flex gap-8 items-center" }, So = { class: "ml-auto" }, ko = { class: "flex gap-3" }, Oo = /* @__PURE__ */ Te({
2235
- __name: "NetSuitePanel",
2236
- props: {
2237
- poRequest: {},
2238
- purchaseOrder: {},
2239
- transferType: {},
2240
- transferToDbName: {},
2241
- scope: {}
2242
- },
2243
- setup(p) {
2244
- const t = p, o = Zs(), a = z(() => o.isNetSuiteEnabled);
2245
- return (m, u) => {
2246
- var s, r;
2247
- const c = te("FmMenuDivider");
2248
- return a.value ? (l(), f("div", _o, [
2249
- e("div", xo, [
2250
- u[0] || (u[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
2251
- e("div", So, [
2252
- e("div", ko, [
2253
- (r = (s = t.purchaseOrder) == null ? void 0 : s.netSuite) != null && r.id ? (l(), me(tt, { key: 0 }, {
2254
- default: ae(() => {
2255
- var d, _, k;
2256
- return [
2257
- D(go, {
2258
- "netsuite-id": (_ = (d = m.purchaseOrder) == null ? void 0 : d.netSuite) == null ? void 0 : _.id,
2259
- "purchase-order-id": (k = m.purchaseOrder) == null ? void 0 : k._id
2260
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2261
- ];
2262
- }),
2263
- _: 1
2264
- })) : R("", !0),
2265
- D(tt, null, {
2266
- default: ae(() => {
2267
- var d, _, k;
2268
- return [
2269
- D(Qr, {
2270
- "netsuite-id": (_ = (d = m.purchaseOrder) == null ? void 0 : d.netSuite) == null ? void 0 : _.id,
2271
- "purchase-order-id": (k = m.purchaseOrder) == null ? void 0 : k._id
2272
- }, null, 8, ["netsuite-id", "purchase-order-id"])
2273
- ];
2274
- }),
2275
- _: 1
2276
- }),
2277
- D(Ar, {
2278
- "po-request": m.poRequest,
2279
- "purchase-order": m.purchaseOrder,
2280
- "is-transfer-between-outlets": !a.value,
2281
- scope: m.scope
2282
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
2283
- ])
2284
- ])
2285
- ]),
2286
- D(c),
2287
- D(Gr, {
2288
- "po-request": m.poRequest,
2289
- "purchase-order": m.purchaseOrder,
2290
- "transfer-type": m.transferType,
2291
- "transfer-to-db-name": m.transferToDbName,
2292
- "is-transfer-between-outlets": !a.value,
2293
- scope: m.scope
2294
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
2295
- ])) : R("", !0);
2296
- };
2297
- }
2298
- }), wo = ["open"], $o = { class: "fm-typo-en-body-sm-600 cursor-pointer select-none" }, Zt = /* @__PURE__ */ Te({
2299
- __name: "FmAdminCollapsiblePanel",
2300
- props: {
2301
- title: { default: "Admin" },
2302
- open: { type: Boolean, default: !1 },
2303
- selectable: { type: Boolean, default: !0 },
2304
- class: { default: void 0 },
2305
- contentClass: { default: void 0 }
2306
- },
2307
- setup(p) {
2308
- const t = p;
2309
- return (o, a) => (l(), me(tt, {
2310
- selectable: t.selectable,
2311
- class: ze(t.class)
2312
- }, {
2313
- default: ae(() => [
2314
- e("details", {
2315
- open: t.open,
2316
- class: "w-full"
2317
- }, [
2318
- e("summary", $o, b(t.title), 1),
2319
- e("div", {
2320
- class: ze(["mt-4 flex flex-col gap-2", t.contentClass])
2321
- }, [
2322
- Cs(o.$slots, "default")
2323
- ], 2)
2324
- ], 8, wo)
2325
- ]),
2326
- _: 3
2327
- }, 8, ["selectable", "class"]));
2328
- }
2329
- });
2330
- function ys(p) {
2331
- if (!(p != null && p.itemsAtSubmission)) return [];
2332
- const t = p.version === Ve.enum[2], o = new Set(p.itemsAtSubmission.map((a) => t ? a.id : a.sku._id));
2333
- return p.items.filter((a) => {
2334
- const m = t ? a.id : a.sku._id;
2335
- return !o.has(m);
2336
- });
2337
- }
2338
- function hs(p, t) {
2339
- var u;
2340
- if (!p || t.length === 0) return {};
2341
- const o = p.version === Ve.enum[2], a = new Set(t.map((c) => o ? c.id : c.sku._id)), m = {};
2342
- for (const c of p.deliveryOrder ?? [])
2343
- for (const s of c.received ?? []) {
2344
- const r = o ? s.id : s.sku._id;
2345
- r && a.has(r) && (m[r] = (m[r] ?? 0) + (((u = s.amount) == null ? void 0 : u.amount) ?? 0));
2346
- }
2347
- return t.reduce(
2348
- (c, s) => {
2349
- var F, C;
2350
- const r = (o ? s.id : s.sku._id) ?? "", d = ((F = s.quantity) == null ? void 0 : F.amount) ?? 0, _ = m[r] ?? 0, k = ((C = s.quantity) == null ? void 0 : C.precision) ?? 0;
2351
- return c[r] = {
2352
- key: r,
2353
- total: { amount: d, precision: k },
2354
- received: { amount: _, precision: k },
2355
- remaining: { amount: d - _, precision: k }
2356
- }, c;
2357
- },
2358
- {}
2359
- );
2360
- }
2361
- const Co = { class: "flex flex-col gap-3" }, Do = { class: "flex flex-col gap-4" }, Ao = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Ro = { class: "flex flex-col gap-4" }, No = { class: "flex justify-between items-start py-1 gap-4" }, Po = { class: "flex flex-col flex-1 min-w-0" }, Fo = { class: "fm-typo-en-body-lg-600 truncate" }, To = { class: "fm-typo-en-body-md-400 truncate" }, Io = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Eo = {
2362
- key: 0,
2363
- class: "flex items-center gap-2"
2364
- }, qo = {
2365
- key: 0,
2366
- class: "border-b border-fm-color-stroke-secondary"
2367
- }, Vo = { class: "flex flex-col gap-4" }, Lo = { class: "flex items-center justify-between" }, jo = {
2368
- key: 0,
2369
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2370
- }, Uo = { class: "flex justify-between items-start py-1 gap-4" }, Mo = { class: "flex-1 min-w-0 flex flex-col gap-2" }, Bo = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, zo = {
2371
- key: 0,
2372
- class: "flex items-center gap-2"
2373
- }, Ko = {
2374
- key: 0,
2375
- class: "border-b border-fm-color-stroke-secondary"
2376
- }, Ho = { class: "flex flex-col gap-4" }, Go = { class: "flex flex-col gap-4" }, Wo = { class: "flex flex-col gap-4" }, Qo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Yo = {
2377
- key: 1,
2378
- class: "flex flex-col gap-4"
2379
- }, Jo = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, it = "Will be ignored on save (zero or negative quantity)", Xo = /* @__PURE__ */ Te({
2380
- __name: "EditForm",
2381
- props: {
2382
- purchaseOrder: {},
2383
- deliveryOrder: {},
2384
- receivedInfoMap: {}
2385
- },
2386
- emits: ["submitted"],
2387
- setup(p, { emit: t }) {
2388
- const { t: o } = rr(), a = Je(), m = Xe(), u = Y(!1), c = Ct(), s = p, r = t, d = as("deliveryOrder"), _ = Ze(), {
2389
- controller: k,
2390
- state: F,
2391
- reset: C
2392
- } = Pt({
2393
- currency: Ce(),
2394
- adjustments: s.deliveryOrder.priceAdjustments
2395
- }), g = z(
2396
- () => {
2397
- var P;
2398
- return ((P = s.purchaseOrder.deliveryFullfillment) == null ? void 0 : P.findIndex(
2399
- (x) => s.deliveryOrder.fullfillmentId && x.id === s.deliveryOrder.fullfillmentId
2400
- )) ?? -1;
2401
- }
2402
- ), M = a.enablePurchaseOrderReceiveWithCustomCost, T = a.enablePortalDeliveryOrderWrite, J = Y({}), Q = z(
2403
- () => (s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items).length
2404
- ), le = z(() => ys(s.purchaseOrder)), xe = z(
2405
- () => hs(s.purchaseOrder, le.value)
2406
- ), ye = z(
2407
- () => s.purchaseOrder.items.map(
2408
- (P, x) => z({
2409
- get: () => {
2410
- var V;
2411
- const N = (V = d.received[x]) == null ? void 0 : V.amount;
2412
- return N ? +_e(N) : 0;
2413
- },
2414
- set: (N) => {
2415
- d.received[x].amount = Qe(N, 2);
2416
- }
2417
- })
2418
- )
2419
- ), ne = z(
2420
- () => s.purchaseOrder.items.map(
2421
- (P, x) => z({
2422
- get: () => {
2423
- var V;
2424
- const N = (V = d.received[x]) == null ? void 0 : V.cost;
2425
- return N ? +_e(N) : 0;
2426
- },
2427
- set: (N) => {
2428
- d.received[x].cost = {
2429
- currency: Ce(),
2430
- ...Qe(N, 4)
2431
- };
2432
- }
2433
- })
2434
- )
2435
- );
2436
- function ge(P) {
2437
- var N;
2438
- const x = !J.value[P];
2439
- if (J.value[P] = x, x) {
2440
- const V = (N = d.received[P]) == null ? void 0 : N.cost;
2441
- d.received[P].cost = V ? { ...V, precision: 4 } : { currency: Ce(), amount: 0, precision: 4 };
2442
- } else
2443
- delete d.received[P].cost;
2444
- }
2445
- const K = Y([]), ce = z(
2446
- () => c.skus.filter((P) => !P.isInactive).map((P) => ({ label: `${P.name} (${P.code})`, value: P._id }))
2447
- );
2448
- function I() {
2449
- K.value.push({ skuId: null, costEnabled: !1 }), d.received.push({
2450
- sku: null,
2451
- amount: Fe.fromNumber(0),
2452
- measurement: null
2453
- });
2454
- }
2455
- function w(P) {
2456
- K.value.splice(P, 1), d.received.splice(Q.value + P, 1);
2457
- }
2458
- function q(P, x) {
2459
- K.value[P].skuId = x;
2460
- const N = x ? c.skuById[x] : null;
2461
- d.received[Q.value + P].sku = N;
2462
- }
2463
- function W(P, x) {
2464
- var Se, ke;
2465
- const N = (Se = s.receivedInfoMap) == null ? void 0 : Se[x.sku._id], V = N ? `${o("inventory.transfer.receiveRequest.details.received")} ${Fe.toFormatString({ value: N.received })} / ${mt(x.quantity, x.sku.unit, x.measurement)}` : void 0;
2466
- return (((ke = ye.value[P]) == null ? void 0 : ke.value) ?? 0) > 0 ? V : V ? `${V} · ${it}` : it;
2467
- }
2468
- function B(P, x) {
2469
- var Se;
2470
- const V = (((Se = ie.value[x]) == null ? void 0 : Se.value) ?? 0) <= 0;
2471
- let se;
2472
- if (P.skuId && xe.value[P.skuId]) {
2473
- const ke = xe.value[P.skuId], n = Fe.toFormatString({ value: ke.received });
2474
- se = `${o("inventory.transfer.receiveRequest.details.received")} ${n}`;
2475
- }
2476
- return V ? se ? `${se} · ${it}` : it : se;
2477
- }
2478
- const ie = z(
2479
- () => K.value.map((P, x) => {
2480
- const N = Q.value + x;
2481
- return z({
2482
- get: () => {
2483
- var se;
2484
- const V = (se = d.received[N]) == null ? void 0 : se.amount;
2485
- return V ? +_e(V) : 0;
2486
- },
2487
- set: (V) => {
2488
- d.received[N].amount = Qe(V, 2);
2489
- }
2490
- });
2491
- })
2492
- ), pe = z(
2493
- () => K.value.map((P, x) => {
2494
- const N = Q.value + x;
2495
- return z({
2496
- get: () => {
2497
- var se;
2498
- const V = (se = d.received[N]) == null ? void 0 : se.cost;
2499
- return V ? +_e(V) : 0;
2500
- },
2501
- set: (V) => {
2502
- d.received[N].cost = {
2503
- currency: Ce(),
2504
- ...Qe(V, 4)
2505
- };
2506
- }
2507
- });
2508
- })
2509
- );
2510
- function L(P) {
2511
- const x = K.value[P], N = Q.value + P;
2512
- x.costEnabled = !x.costEnabled, x.costEnabled ? d.received[N].cost = { currency: Ce(), amount: 0, precision: 4 } : delete d.received[N].cost;
2513
- }
2514
- Ye(
2515
- () => u.value,
2516
- (P) => {
2517
- var n, i, S;
2518
- if (!P) {
2519
- K.value = [], J.value = {};
2520
- return;
2521
- }
2522
- C(s.deliveryOrder.priceAdjustments);
2523
- const x = s.purchaseOrder.itemsAtSubmission ?? s.purchaseOrder.items, N = new Set(x.map(($) => $.sku._id)), V = {}, se = [];
2524
- for (const $ of s.deliveryOrder.received ?? []) {
2525
- const j = (n = $.sku) == null ? void 0 : n._id;
2526
- j && (N.has(j) ? V[j] = $ : se.push($));
2527
- }
2528
- d.received = x.map(($) => {
2529
- const j = V[$.sku._id];
2530
- return j ? { ...j } : {
2531
- sku: $.sku,
2532
- amount: Fe.fromNumber(0),
2533
- measurement: $.measurement ?? null
2534
- };
2535
- });
2536
- const Se = {};
2537
- for (let $ = 0; $ < x.length; $++)
2538
- (i = V[x[$].sku._id]) != null && i.cost && (Se[$] = !0);
2539
- J.value = Se, K.value = [];
2540
- const ke = le.value;
2541
- for (const $ of se) {
2542
- const j = ke.find((H) => {
2543
- var re;
2544
- return H.sku._id === ((re = $.sku) == null ? void 0 : re._id);
2545
- });
2546
- K.value.push({
2547
- skuId: ((S = $.sku) == null ? void 0 : S._id) ?? null,
2548
- costEnabled: !!$.cost,
2549
- locked: !0,
2550
- quantityLocked: !0,
2551
- historyItem: j
2552
- }), d.received.push({ ...$ });
2553
- }
2554
- if (ke.length) {
2555
- const $ = new Set(se.map((j) => {
2556
- var H;
2557
- return (H = j.sku) == null ? void 0 : H._id;
2558
- }));
2559
- for (const j of ke)
2560
- $.has(j.sku._id) || (K.value.push({
2561
- skuId: j.sku._id,
2562
- costEnabled: !1,
2563
- locked: !0,
2564
- historyItem: j
2565
- }), d.received.push({
2566
- sku: j.sku,
2567
- amount: Fe.fromNumber(0),
2568
- measurement: j.measurement ?? null
2569
- }));
2570
- }
2571
- }
2572
- );
2573
- const O = Y(!1);
2574
- function X() {
2575
- O.value = !0, _.updateDeliveryOrder({
2576
- deliveryOrder: {
2577
- ...s.deliveryOrder,
2578
- ...d,
2579
- priceAdjustments: k.value.state().adjustments
2580
- },
2581
- purchaseOrderId: s.purchaseOrder._id,
2582
- purchaseOrderRev: s.purchaseOrder._rev
2583
- }).then(() => {
2584
- m.open(
2585
- {
2586
- title: "Success",
2587
- message: `PO# ${s.purchaseOrder.seqNumber} Changes have been saved`,
2588
- type: "success"
2589
- },
2590
- 1e4
2591
- ), u.value = !1, r("submitted");
2592
- }).finally(() => {
2593
- O.value = !1;
2594
- });
2595
- }
2596
- return (P, x) => {
2597
- const N = te("FmButton"), V = te("FmStepperField"), se = te("FmSwitch"), Se = te("FmSelect"), ke = te("FmTextField"), n = te("FmDialog");
2598
- return l(), me(n, {
2599
- modelValue: u.value,
2600
- "onUpdate:modelValue": x[1] || (x[1] = (i) => u.value = i),
2601
- overlay: !0,
2602
- "min-width": 800
2603
- }, {
2604
- "dialog-button": ae(() => [
2605
- y(T) ? (l(), me(N, {
2606
- key: 0,
2607
- variant: "plain",
2608
- label: "Edit",
2609
- size: "md",
2610
- "prepend-icon": "edit"
2611
- })) : R("", !0)
2612
- ]),
2613
- "dialog-header": ae(() => [
2614
- e("div", null, "Received on " + b(y(et)(s.deliveryOrder.createdAt)), 1)
2615
- ]),
2616
- "dialog-footer": ae(() => [
2617
- D(N, {
2618
- class: "ml-auto",
2619
- label: "Apply changes",
2620
- size: "md",
2621
- variant: "destructive",
2622
- disabled: O.value,
2623
- loading: O.value,
2624
- onClick: X
2625
- }, null, 8, ["disabled", "loading"])
2626
- ]),
2627
- default: ae(() => [
2628
- e("div", Co, [
2629
- e("div", Do, [
2630
- x[2] || (x[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
2631
- e("div", Ao, b(s.deliveryOrder.adjustment ? y(et)(new Date(y(ut)(s.deliveryOrder.adjustment))) : "-"), 1)
2632
- ]),
2633
- e("div", Ro, [
2634
- x[4] || (x[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2635
- (l(!0), f($e, null, Pe(s.purchaseOrder.items, (i, S) => {
2636
- var $;
2637
- return l(), f("div", { key: S }, [
2638
- e("div", No, [
2639
- e("div", Po, [
2640
- e("span", Fo, b(i.sku.name), 1),
2641
- e("span", To, b(i.sku.code), 1)
2642
- ]),
2643
- e("div", Io, [
2644
- D(V, {
2645
- label: "Receive Quantity",
2646
- modelValue: ye.value[S].value,
2647
- "onUpdate:modelValue": (j) => ye.value[S].value = j,
2648
- "append-text": (($ = i.measurement) == null ? void 0 : $.abbrev) ?? i.sku.unit.abbrev,
2649
- "helper-text": W(S, i)
2650
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
2651
- y(M) ? (l(), f("div", Eo, [
2652
- D(se, {
2653
- "model-value": J.value[S],
2654
- "onUpdate:modelValue": (j) => ge(S),
2655
- size: "sm"
2656
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2657
- x[3] || (x[3] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2658
- ])) : R("", !0),
2659
- y(M) && J.value[S] ? (l(), me(V, {
2660
- key: 1,
2661
- modelValue: ne.value[S].value,
2662
- "onUpdate:modelValue": (j) => ne.value[S].value = j,
2663
- label: "Total Cost",
2664
- step: 1e-4,
2665
- min: 0,
2666
- placeholder: "0.0000",
2667
- size: "sm",
2668
- "append-text": y(Ce)()
2669
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : R("", !0)
2670
- ])
2671
- ]),
2672
- S < s.purchaseOrder.items.length - 1 ? (l(), f("div", qo)) : R("", !0)
2673
- ]);
2674
- }), 128))
2675
- ]),
2676
- e("div", Vo, [
2677
- e("div", Lo, [
2678
- x[5] || (x[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
2679
- D(N, {
2680
- variant: "tertiary",
2681
- label: "Add item",
2682
- "prepend-icon": "add",
2683
- size: "md",
2684
- onClick: I
2685
- })
2686
- ]),
2687
- K.value.length === 0 ? (l(), f("div", jo, " No extra items added ")) : R("", !0),
2688
- (l(!0), f($e, null, Pe(K.value, (i, S) => {
2689
- var $, j;
2690
- return l(), f("div", { key: S }, [
2691
- e("div", Uo, [
2692
- e("div", Mo, [
2693
- D(Se, {
2694
- "model-value": i.skuId,
2695
- "onUpdate:modelValue": (H) => q(S, H),
2696
- label: "Ingredient",
2697
- items: ce.value,
2698
- searchable: "",
2699
- searchTarget: "label",
2700
- placeholder: "Select ingredient",
2701
- disabled: i.locked
2702
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
2703
- ]),
2704
- e("div", Bo, [
2705
- D(V, {
2706
- label: "Receive Quantity",
2707
- modelValue: ie.value[S].value,
2708
- "onUpdate:modelValue": (H) => ie.value[S].value = H,
2709
- "append-text": i.skuId ? ((j = ($ = y(c).skuById[i.skuId]) == null ? void 0 : $.unit) == null ? void 0 : j.abbrev) ?? "" : "",
2710
- "helper-text": B(i, S),
2711
- disabled: i.quantityLocked || !i.skuId
2712
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text", "disabled"]),
2713
- y(M) ? (l(), f("div", zo, [
2714
- D(se, {
2715
- "model-value": i.costEnabled,
2716
- "onUpdate:modelValue": (H) => L(S),
2717
- size: "sm"
2718
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2719
- x[6] || (x[6] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2720
- ])) : R("", !0),
2721
- y(M) && i.costEnabled ? (l(), me(V, {
2722
- key: 1,
2723
- modelValue: pe.value[S].value,
2724
- "onUpdate:modelValue": (H) => pe.value[S].value = H,
2725
- label: "Total Cost",
2726
- step: 1e-4,
2727
- min: 0,
2728
- placeholder: "0.0000",
2729
- size: "sm",
2730
- "append-text": y(Ce)()
2731
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : R("", !0)
2732
- ]),
2733
- i.locked ? R("", !0) : (l(), me(N, {
2734
- key: 0,
2735
- variant: "tertiary",
2736
- "prepend-icon": "delete",
2737
- size: "md",
2738
- class: "mt-6",
2739
- onClick: (H) => w(S)
2740
- }, null, 8, ["onClick"]))
2741
- ]),
2742
- S < K.value.length - 1 ? (l(), f("div", Ko)) : R("", !0)
2743
- ]);
2744
- }), 128))
2745
- ]),
2746
- e("div", Ho, [
2747
- x[7] || (x[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2748
- e("div", Go, [
2749
- D(ke, {
2750
- modelValue: y(d).deliveryOrderNumber,
2751
- "onUpdate:modelValue": x[0] || (x[0] = (i) => y(d).deliveryOrderNumber = i),
2752
- size: "md",
2753
- placeholder: s.deliveryOrder.deliveryOrderNumber
2754
- }, null, 8, ["modelValue", "placeholder"])
2755
- ])
2756
- ]),
2757
- e("div", Wo, [
2758
- x[8] || (x[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2759
- e("div", Qo, b(s.deliveryOrder.remark || "N/A"), 1)
2760
- ]),
2761
- y(a).enablePurchaseOrderPriceAdjustment ? (l(), me(Nt, {
2762
- key: 0,
2763
- controller: y(k),
2764
- state: y(F)
2765
- }, null, 8, ["controller", "state"])) : R("", !0),
2766
- g.value >= 0 ? (l(), f("div", Yo, [
2767
- x[9] || (x[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Fulfilment's sequence", -1)),
2768
- e("div", Jo, b(g.value + 1), 1)
2769
- ])) : R("", !0)
2770
- ])
2771
- ]),
2772
- _: 1
2773
- }, 8, ["modelValue"]);
2774
- };
2775
- }
2776
- }), Zo = { class: "flex flex-col gap-3" }, en = { class: "flex flex-col gap-4" }, tn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, sn = {
2777
- key: 0,
2778
- class: "flex flex-col gap-4"
2779
- }, rn = { class: "flex items-center justify-between" }, on = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, nn = {
2780
- key: 0,
2781
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2782
- }, an = { class: "flex gap-4" }, ln = { class: "flex-1" }, cn = { class: "flex-1" }, un = {
2783
- key: 0,
2784
- class: "flex items-center text-fm-color-system-error-300"
2785
- }, dn = { class: "fm-typo-en-body-md-400" }, mn = { class: "flex flex-col gap-4" }, pn = { class: "flex justify-between items-start py-1 gap-4" }, fn = { class: "flex flex-col flex-1 min-w-0" }, vn = { class: "fm-typo-en-body-lg-600 truncate" }, yn = { class: "fm-typo-en-body-md-400 truncate" }, hn = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, bn = {
2786
- key: 0,
2787
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2788
- }, gn = {
2789
- key: 1,
2790
- class: "flex items-center gap-2"
2791
- }, _n = {
2792
- key: 0,
2793
- class: "border-b border-fm-color-stroke-secondary"
2794
- }, xn = { class: "flex flex-col gap-4" }, Sn = { class: "flex items-center justify-between" }, kn = {
2795
- key: 0,
2796
- class: "fm-typo-en-body-md-400 text-fm-color-typo-tertiary"
2797
- }, On = { class: "flex justify-between items-start py-1 gap-4" }, wn = { class: "flex-1 min-w-0 flex flex-col gap-2" }, $n = { class: "flex flex-col gap-2 items-end w-52 shrink-0" }, Cn = {
2798
- key: 0,
2799
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-300 self-end text-right"
2800
- }, Dn = {
2801
- key: 1,
2802
- class: "flex items-center gap-2"
2803
- }, An = {
2804
- key: 0,
2805
- class: "border-b border-fm-color-stroke-secondary"
2806
- }, Rn = { class: "flex flex-col gap-4" }, Nn = { class: "flex flex-col gap-4" }, Pn = { class: "flex flex-col gap-4" }, Fn = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, es = "Will be ignored on save (zero or negative quantity)", Tn = /* @__PURE__ */ Te({
2807
- __name: "CreateForm",
2808
- props: {
2809
- purchaseOrder: {},
2810
- receivedInfoMap: {},
2811
- receivedMap: {}
2812
- },
2813
- emits: ["submitted"],
2814
- setup(p, { emit: t }) {
2815
- var fe, ue, Oe;
2816
- const { t: o } = vt(), a = Y(!1), m = yt(), u = p, c = t, s = as("", {
2817
- default: {
2818
- deliveryOrderNumber: "",
2819
- remark: "",
2820
- received: (u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items).map((h) => ({
2821
- sku: h.sku,
2822
- amount: Fe.fromNumber(0),
2823
- measurement: h.measurement
2824
- })),
2825
- createdBy: {
2826
- id: ((fe = m.sessionUser.value) == null ? void 0 : fe.id) || "",
2827
- name: ((ue = m.sessionUser.value) == null ? void 0 : ue.displayName) || ""
2828
- },
2829
- createdAt: ""
2830
- }
2831
- }), r = Ze(), d = bt(), _ = Je(), k = Ct(), {
2832
- controller: F,
2833
- state: C,
2834
- reset: g
2835
- } = Pt({ currency: Ce() }), M = ((Oe = u.purchaseOrder) == null ? void 0 : Oe.supplier.internal) != null, T = M && _.enablePOSTransferRequireFulfillment, J = _.enablePortalDeliveryOrderWrite && (u.purchaseOrder.status === be.Enum.RECEIVING || u.purchaseOrder.status === be.Enum.COMPLETE) && (M ? !T : !0), Q = _.enablePurchaseOrderReceiveWithCustomCost, le = _.enableBackdateReceive, xe = Y({}), ye = z(
2836
- () => u.purchaseOrder.itemsAtSubmission ?? u.purchaseOrder.items
2837
- ), ne = z(() => ys(u.purchaseOrder)), ge = z(
2838
- () => hs(u.purchaseOrder, ne.value)
2839
- ), K = z(
2840
- () => {
2841
- var h;
2842
- return (((h = u.purchaseOrder) == null ? void 0 : h.version) ?? Ve.enum[1]) === Ve.enum[2];
2843
- }
2844
- );
2845
- function ce(h) {
2846
- return (K.value ? h.id : h.sku._id) ?? null;
2847
- }
2848
- const I = Xe(), w = z({
2849
- get() {
2850
- if (!s.createdAt) return "";
2851
- const h = new Date(s.createdAt), v = h.getFullYear(), A = String(h.getMonth() + 1).padStart(2, "0"), Z = String(h.getDate()).padStart(2, "0");
2852
- return `${v}-${A}-${Z}`;
2853
- },
2854
- set(h) {
2855
- if (h) {
2856
- const v = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [A, Z, oe] = h.split("-");
2857
- v.setFullYear(parseInt(A)), v.setMonth(parseInt(Z) - 1), v.setDate(parseInt(oe)), s.createdAt = v.toISOString();
2858
- }
2859
- }
2860
- }), q = z({
2861
- get() {
2862
- if (!s.createdAt) return "";
2863
- const h = new Date(s.createdAt), v = String(h.getHours()).padStart(2, "0"), A = String(h.getMinutes()).padStart(2, "0");
2864
- return `${v}:${A}`;
2865
- },
2866
- set(h) {
2867
- if (h) {
2868
- const v = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [A, Z] = h.split(":");
2869
- v.setHours(parseInt(A)), v.setMinutes(parseInt(Z)), s.createdAt = v.toISOString();
2870
- }
2871
- }
2872
- }), W = z(() => {
2873
- const h = ut(u.purchaseOrder._id);
2874
- if (!h) return "";
2875
- const v = new Date(h), A = v.getFullYear(), Z = String(v.getMonth() + 1).padStart(2, "0"), oe = String(v.getDate()).padStart(2, "0");
2876
- return `${A}-${Z}-${oe}`;
2877
- }), B = z(() => {
2878
- const h = ut(u.purchaseOrder._id);
2879
- return h ? new Date(h) : null;
2880
- }), ie = z(() => {
2881
- if (!w.value || !q.value || !B.value) return null;
2882
- if (/* @__PURE__ */ new Date(`${w.value}T${q.value}:00`) < B.value) {
2883
- const v = W.value, A = B.value.getHours(), Z = B.value.getMinutes(), oe = A >= 12 ? "PM" : "AM", Re = A % 12 || 12, G = `${String(Re).padStart(2, "0")}:${String(Z).padStart(2, "0")} ${oe}`;
2884
- return `Delivery date & time cannot be earlier than order creation (${v} ${G})`;
2885
- }
2886
- return null;
2887
- }), pe = z(() => ie.value || N.value.some((v) => !v.skuId) ? !1 : s.received.some((v) => {
2888
- const A = v.amount;
2889
- return A ? +_e(A) > 0 : !1;
2890
- }));
2891
- function L(h) {
2892
- var A;
2893
- const v = (A = u.receivedInfoMap[h.sku._id]) == null ? void 0 : A.received;
2894
- return `${o("inventory.transfer.receiveRequest.details.received")} ${Fe.toFormatString({ value: v })} / ${mt(h.quantity, h.sku.unit, h.measurement)}`;
2895
- }
2896
- function O() {
2897
- s.createdAt = "";
2898
- }
2899
- const X = z(() => ye.value.map((h, v) => z({
2900
- get: () => {
2901
- var Z;
2902
- const A = (Z = s.received[v]) == null ? void 0 : Z.amount;
2903
- return A ? +_e(A) : 0;
2904
- },
2905
- set: (A) => {
2906
- s.received[v].amount = Qe(A, 2);
2907
- }
2908
- })));
2909
- function P(h) {
2910
- const v = !xe.value[h];
2911
- if (xe.value[h] = v, v) {
2912
- const A = ye.value[h];
2913
- A.totalCost ? s.received[h].cost = {
2914
- currency: A.totalCost.currency,
2915
- amount: A.totalCost.amount,
2916
- precision: 4
2917
- // Standardize to 4 decimals
2918
- } : s.received[h].cost = {
2919
- currency: Ce(),
2920
- amount: 0,
2921
- precision: 4
2922
- };
2923
- } else
2924
- delete s.received[h].cost;
2925
- }
2926
- const x = z(() => ye.value.map((h, v) => z({
2927
- get: () => {
2928
- var Z;
2929
- const A = (Z = s.received[v]) == null ? void 0 : Z.cost;
2930
- return A ? +_e(A) : 0;
2931
- },
2932
- set: (A) => {
2933
- s.received[v].cost = {
2934
- currency: Ce(),
2935
- ...Qe(A, 4)
2936
- };
2937
- }
2938
- }))), N = Y([]), V = z(
2939
- () => k.skus.filter((h) => !h.isInactive).map((h) => ({ label: `${h.name} (${h.code})`, value: h._id }))
2940
- ), se = z(() => ye.value.length);
2941
- function Se() {
2942
- N.value.push({ skuId: null, stableKey: null, costEnabled: !1 }), s.received.push({
2943
- sku: null,
2944
- amount: Fe.fromNumber(0),
2945
- measurement: null
2946
- });
2947
- }
2948
- function ke(h) {
2949
- N.value.splice(h, 1), s.received.splice(se.value + h, 1);
2950
- }
2951
- function n(h, v) {
2952
- N.value[h].skuId = v;
2953
- const A = v ? k.skuById[v] : null;
2954
- s.received[se.value + h].sku = A;
2955
- }
2956
- function i(h) {
2957
- const v = h.stableKey;
2958
- if (v && ge.value[v]) {
2959
- const A = ge.value[v], Z = Fe.toFormatString({ value: A.received });
2960
- return `${o("inventory.transfer.receiveRequest.details.received")} ${Z}`;
2961
- }
2962
- }
2963
- const S = z(
2964
- () => N.value.map((h, v) => {
2965
- const A = se.value + v;
2966
- return z({
2967
- get: () => {
2968
- var oe;
2969
- const Z = (oe = s.received[A]) == null ? void 0 : oe.amount;
2970
- return Z ? +_e(Z) : 0;
2971
- },
2972
- set: (Z) => {
2973
- s.received[A].amount = Qe(Z, 2);
2974
- }
2975
- });
2976
- })
2977
- ), $ = z(
2978
- () => N.value.map((h, v) => {
2979
- const A = se.value + v;
2980
- return z({
2981
- get: () => {
2982
- var oe;
2983
- const Z = (oe = s.received[A]) == null ? void 0 : oe.cost;
2984
- return Z ? +_e(Z) : 0;
2985
- },
2986
- set: (Z) => {
2987
- s.received[A].cost = {
2988
- currency: Ce(),
2989
- ...Qe(Z, 4)
2990
- };
2991
- }
2992
- });
2993
- })
2994
- );
2995
- function j(h) {
2996
- const v = N.value[h], A = se.value + h;
2997
- v.costEnabled = !v.costEnabled, v.costEnabled ? s.received[A].cost = { currency: Ce(), amount: 0, precision: 4 } : delete s.received[A].cost;
2998
- }
2999
- function H() {
3000
- d.open({
3001
- title: "Confirm Create Delivery Order",
3002
- message: `Are you sure you want to create delivery order for PO# ${u.purchaseOrder.seqNumber}?`,
3003
- primaryActions: {
3004
- text: "Create",
3005
- close: !0,
3006
- variant: "primary"
3007
- },
3008
- secondaryActions: {
3009
- text: "Cancel",
3010
- close: !0
3011
- }
3012
- }).onPrimary(() => E());
3013
- }
3014
- const re = Y(!1);
3015
- function E() {
3016
- re.value = !0, r.createDeliveryOrder({
3017
- deliveryOrder: {
3018
- ...s,
3019
- priceAdjustments: F.value.state().adjustments
3020
- },
3021
- purchaseOrderId: u.purchaseOrder._id,
3022
- purchaseOrderRev: u.purchaseOrder._rev,
3023
- currency: Ce()
3024
- }).then(() => {
3025
- I.open(
3026
- {
3027
- title: "Success",
3028
- message: `New delivery order created for PO# ${u.purchaseOrder.seqNumber}`,
3029
- type: "success"
3030
- },
3031
- 1e4
3032
- ), a.value = !1, c("submitted");
3033
- }).finally(() => {
3034
- re.value = !1;
3035
- });
3036
- }
3037
- return Ye(
3038
- () => a.value,
3039
- (h) => {
3040
- var Z;
3041
- if (!h) {
3042
- N.value = [], g([]), s.received = ye.value.map((oe) => ({
3043
- sku: oe.sku,
3044
- amount: Fe.fromNumber(0),
3045
- measurement: oe.measurement
3046
- }));
3047
- return;
3048
- }
3049
- const v = ye.value;
3050
- for (let oe = 0; oe < v.length; oe++) {
3051
- const Re = v[oe], he = (((Z = u.purchaseOrder) == null ? void 0 : Z.version) ?? Ve.enum[1]) === Ve.enum[2] ? Re.id : Re.sku._id, we = u.receivedMap[he], Ne = +_e(Re.quantity), Ie = we ? +_e(we.received) : 0;
3052
- X.value[oe].value = Math.max(0, Ne - Ie);
3053
- }
3054
- const A = ne.value;
3055
- if (A.length) {
3056
- for (const oe of A) {
3057
- const Re = ce(oe);
3058
- N.value.push({
3059
- skuId: oe.sku._id,
3060
- stableKey: Re,
3061
- costEnabled: !1,
3062
- historyItem: oe
3063
- }), s.received.push({
3064
- // Propagate the stable id so V2 submissions align with the existing PO line.
3065
- ...K.value && oe.id ? { id: oe.id } : {},
3066
- sku: oe.sku,
3067
- amount: Fe.fromNumber(0),
3068
- measurement: oe.measurement ?? null
3069
- });
3070
- }
3071
- for (let oe = 0; oe < A.length; oe++) {
3072
- const Re = ce(A[oe]), G = Re ? ge.value[Re] : void 0;
3073
- if (G) {
3074
- const he = Math.pow(10, G.remaining.precision ?? 2);
3075
- S.value[oe].value = Math.max(0, G.remaining.amount / he);
3076
- }
3077
- }
3078
- }
3079
- }
3080
- ), (h, v) => {
3081
- const A = te("FmButton"), Z = te("FmDatePicker"), oe = te("FmTimePicker"), Re = te("FmIcon"), G = te("FmStepperField"), he = te("FmSwitch"), we = te("FmSelect"), Ne = te("FmTextField"), Ie = te("FmDialog");
3082
- return l(), me(Ie, {
3083
- modelValue: a.value,
3084
- "onUpdate:modelValue": v[4] || (v[4] = (De) => a.value = De),
3085
- overlay: !0,
3086
- "min-width": 800
3087
- }, {
3088
- "dialog-button": ae(() => [
3089
- y(J) ? (l(), me(A, {
3090
- key: 0,
3091
- variant: "primary",
3092
- label: "Create",
3093
- size: "md",
3094
- "prepend-icon": "add",
3095
- class: "w-full"
3096
- })) : R("", !0)
3097
- ]),
3098
- "dialog-header": ae(() => [
3099
- e("div", null, "Order #" + b(u.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
3100
- ]),
3101
- "dialog-footer": ae(() => [
3102
- D(A, {
3103
- class: "ml-auto",
3104
- label: "Create",
3105
- size: "md",
3106
- variant: "destructive",
3107
- disabled: !pe.value || re.value,
3108
- loading: re.value,
3109
- onClick: H
3110
- }, null, 8, ["disabled", "loading"])
3111
- ]),
3112
- default: ae(() => {
3113
- var De;
3114
- return [
3115
- e("div", Zo, [
3116
- e("div", en, [
3117
- v[5] || (v[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
3118
- e("div", tn, b((De = y(m).sessionUser.value) == null ? void 0 : De.displayName), 1)
3119
- ]),
3120
- y(le) ? (l(), f("div", sn, [
3121
- e("div", rn, [
3122
- e("div", on, [
3123
- v[6] || (v[6] = We(" Delivery Date & Time ")),
3124
- !w.value && !q.value ? (l(), f("div", nn, " Leave blank to use current date & time ")) : R("", !0)
3125
- ]),
3126
- w.value || q.value ? (l(), me(A, {
3127
- key: 0,
3128
- variant: "tertiary",
3129
- label: "Clear",
3130
- "prepend-icon": "close",
3131
- onClick: O
3132
- })) : R("", !0)
3133
- ]),
3134
- e("div", an, [
3135
- e("div", ln, [
3136
- D(Z, {
3137
- modelValue: w.value,
3138
- "onUpdate:modelValue": v[0] || (v[0] = (ve) => w.value = ve)
3139
- }, null, 8, ["modelValue"])
3140
- ]),
3141
- e("div", cn, [
3142
- D(oe, {
3143
- modelValue: q.value,
3144
- "onUpdate:modelValue": v[1] || (v[1] = (ve) => q.value = ve)
3145
- }, null, 8, ["modelValue"])
3146
- ])
3147
- ]),
3148
- ie.value ? (l(), f("div", un, [
3149
- D(Re, {
3150
- name: "error",
3151
- class: "inline-block mr-1",
3152
- size: "sm"
3153
- }),
3154
- e("div", dn, b(ie.value), 1)
3155
- ])) : R("", !0)
3156
- ])) : R("", !0),
3157
- e("div", mn, [
3158
- v[8] || (v[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
3159
- (l(!0), f($e, null, Pe(ye.value, (ve, de) => {
3160
- var Le;
3161
- return l(), f("div", { key: de }, [
3162
- e("div", pn, [
3163
- e("div", fn, [
3164
- e("span", vn, b(ve.sku.name), 1),
3165
- e("span", yn, b(ve.sku.code), 1)
3166
- ]),
3167
- e("div", hn, [
3168
- D(G, {
3169
- label: "Receive Quantity",
3170
- modelValue: X.value[de].value,
3171
- "onUpdate:modelValue": (qe) => X.value[de].value = qe,
3172
- "helper-text": L(ve),
3173
- "append-text": ((Le = ve.measurement) == null ? void 0 : Le.abbrev) ?? ve.sku.unit.abbrev
3174
- }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
3175
- X.value[de].value <= 0 ? (l(), f("div", bn, b(es))) : R("", !0),
3176
- y(Q) ? (l(), f("div", gn, [
3177
- D(he, {
3178
- "model-value": xe.value[de],
3179
- "onUpdate:modelValue": (qe) => P(de),
3180
- size: "sm"
3181
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3182
- v[7] || (v[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3183
- ])) : R("", !0),
3184
- y(Q) && xe.value[de] ? (l(), me(G, {
3185
- key: 2,
3186
- modelValue: x.value[de].value,
3187
- "onUpdate:modelValue": (qe) => x.value[de].value = qe,
3188
- label: "Total Cost",
3189
- step: 1e-4,
3190
- min: 0,
3191
- placeholder: "0.0000",
3192
- size: "sm",
3193
- "append-text": y(Ce)()
3194
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : R("", !0)
3195
- ])
3196
- ]),
3197
- de < ye.value.length - 1 ? (l(), f("div", _n)) : R("", !0)
3198
- ]);
3199
- }), 128))
3200
- ]),
3201
- e("div", xn, [
3202
- e("div", Sn, [
3203
- v[9] || (v[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Extra items", -1)),
3204
- D(A, {
3205
- variant: "tertiary",
3206
- label: "Add item",
3207
- "prepend-icon": "add",
3208
- size: "md",
3209
- onClick: Se
3210
- })
3211
- ]),
3212
- N.value.length === 0 ? (l(), f("div", kn, " No extra items added ")) : R("", !0),
3213
- (l(!0), f($e, null, Pe(N.value, (ve, de) => {
3214
- var Le, qe;
3215
- return l(), f("div", { key: de }, [
3216
- e("div", On, [
3217
- e("div", wn, [
3218
- D(we, {
3219
- "model-value": ve.skuId,
3220
- "onUpdate:modelValue": (je) => n(de, je),
3221
- label: "Ingredient",
3222
- items: V.value,
3223
- searchable: "",
3224
- searchTarget: "label",
3225
- placeholder: "Select ingredient",
3226
- disabled: !!ve.historyItem
3227
- }, null, 8, ["model-value", "onUpdate:modelValue", "items", "disabled"])
3228
- ]),
3229
- e("div", $n, [
3230
- D(G, {
3231
- label: "Receive Quantity",
3232
- modelValue: S.value[de].value,
3233
- "onUpdate:modelValue": (je) => S.value[de].value = je,
3234
- "append-text": ve.skuId ? ((qe = (Le = y(k).skuById[ve.skuId]) == null ? void 0 : Le.unit) == null ? void 0 : qe.abbrev) ?? "" : "",
3235
- "helper-text": i(ve)
3236
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text", "helper-text"]),
3237
- S.value[de].value <= 0 ? (l(), f("div", Cn, b(es))) : R("", !0),
3238
- y(Q) ? (l(), f("div", Dn, [
3239
- D(he, {
3240
- "model-value": ve.costEnabled,
3241
- "onUpdate:modelValue": (je) => j(de),
3242
- size: "sm"
3243
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
3244
- v[10] || (v[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
3245
- ])) : R("", !0),
3246
- y(Q) && ve.costEnabled ? (l(), me(G, {
3247
- key: 2,
3248
- modelValue: $.value[de].value,
3249
- "onUpdate:modelValue": (je) => $.value[de].value = je,
3250
- label: "Total Cost",
3251
- step: 1e-4,
3252
- min: 0,
3253
- placeholder: "0.0000",
3254
- size: "sm",
3255
- "append-text": y(Ce)()
3256
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : R("", !0)
3257
- ]),
3258
- ve.historyItem ? R("", !0) : (l(), me(A, {
3259
- key: 0,
3260
- variant: "tertiary",
3261
- "prepend-icon": "delete",
3262
- size: "md",
3263
- class: "mt-6",
3264
- onClick: (je) => ke(de)
3265
- }, null, 8, ["onClick"]))
3266
- ]),
3267
- de < N.value.length - 1 ? (l(), f("div", An)) : R("", !0)
3268
- ]);
3269
- }), 128))
3270
- ]),
3271
- e("div", Rn, [
3272
- v[11] || (v[11] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
3273
- e("div", Nn, [
3274
- D(Ne, {
3275
- modelValue: y(s).deliveryOrderNumber,
3276
- "onUpdate:modelValue": v[2] || (v[2] = (ve) => y(s).deliveryOrderNumber = ve),
3277
- size: "md"
3278
- }, null, 8, ["modelValue"])
3279
- ])
3280
- ]),
3281
- e("div", Pn, [
3282
- v[12] || (v[12] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
3283
- e("div", Fn, [
3284
- D(Ne, {
3285
- modelValue: y(s).remark,
3286
- "onUpdate:modelValue": v[3] || (v[3] = (ve) => y(s).remark = ve),
3287
- size: "md"
3288
- }, null, 8, ["modelValue"])
3289
- ])
3290
- ]),
3291
- y(_).enablePurchaseOrderPriceAdjustment ? (l(), me(Nt, {
3292
- key: 1,
3293
- controller: y(F),
3294
- state: y(C)
3295
- }, null, 8, ["controller", "state"])) : R("", !0)
3296
- ])
3297
- ];
3298
- }),
3299
- _: 1
3300
- }, 8, ["modelValue"]);
3301
- };
3302
- }
3303
- }), In = {
3304
- key: 0,
3305
- class: "flex flex-col gap-1"
3306
- }, En = { class: "truncate" }, qn = { class: "shrink-0" }, Vn = /* @__PURE__ */ Te({
3307
- __name: "PriceAdjustmentList",
3308
- props: {
3309
- adjustments: {}
3310
- },
3311
- setup(p) {
3312
- const t = p, o = z(() => t.adjustments ?? []);
3313
- function a(m) {
3314
- const u = m.amount < 0 ? "-" : "+", c = _e({ ...m, amount: Math.abs(m.amount) });
3315
- return `${u}${m.currency} ${c}`;
3316
- }
3317
- return (m, u) => o.value.length ? (l(), f("div", In, [
3318
- (l(!0), f($e, null, Pe(o.value, (c) => (l(), f("div", {
3319
- key: c.id,
3320
- class: "flex justify-between gap-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
3321
- }, [
3322
- e("span", En, b(c.name), 1),
3323
- e("span", qn, b(a(c.dinero)), 1)
3324
- ]))), 128))
3325
- ])) : R("", !0);
3326
- }
3327
- }), Ln = { class: "flex flex-col gap-3" }, jn = /* @__PURE__ */ Te({
3328
- __name: "PriceAdjustmentEditForm",
3329
- props: {
3330
- purchaseOrder: {}
3331
- },
3332
- emits: ["submitted"],
3333
- setup(p, { emit: t }) {
3334
- const o = p, a = t, m = Ze(), u = Xe(), c = Y(!1), s = Y(!1), { controller: r, state: d, reset: _ } = Pt({
3335
- currency: Ce(),
3336
- adjustments: o.purchaseOrder.priceAdjustments
3337
- });
3338
- Ye(
3339
- () => c.value,
3340
- (F) => {
3341
- F && _(o.purchaseOrder.priceAdjustments);
3342
- }
3343
- );
3344
- function k() {
3345
- s.value = !0, m.updatePurchaseOrder({
3346
- ...o.purchaseOrder,
3347
- priceAdjustments: r.value.state().adjustments
3348
- }).then(() => {
3349
- u.open(
3350
- {
3351
- title: "Success",
3352
- message: `PO# ${o.purchaseOrder.seqNumber} price adjustments saved`,
3353
- type: "success"
3354
- },
3355
- 1e4
3356
- ), c.value = !1, a("submitted");
3357
- }).finally(() => {
3358
- s.value = !1;
3359
- });
3360
- }
3361
- return (F, C) => {
3362
- const g = te("FmButton"), M = te("FmDialog");
3363
- return l(), me(M, {
3364
- modelValue: c.value,
3365
- "onUpdate:modelValue": C[0] || (C[0] = (T) => c.value = T),
3366
- overlay: !0,
3367
- "min-width": 600
3368
- }, {
3369
- "dialog-button": ae(() => [
3370
- D(g, {
3371
- variant: "plain",
3372
- label: "Edit price adjustments",
3373
- size: "md",
3374
- "prepend-icon": "edit"
3375
- })
3376
- ]),
3377
- "dialog-header": ae(() => [
3378
- e("div", null, "Price adjustments — PO# " + b(o.purchaseOrder.seqNumber), 1)
3379
- ]),
3380
- "dialog-footer": ae(() => [
3381
- D(g, {
3382
- class: "ml-auto",
3383
- label: "Apply changes",
3384
- size: "md",
3385
- variant: "destructive",
3386
- disabled: s.value,
3387
- loading: s.value,
3388
- onClick: k
3389
- }, null, 8, ["disabled", "loading"])
3390
- ]),
3391
- default: ae(() => [
3392
- e("div", Ln, [
3393
- D(Nt, {
3394
- controller: y(r),
3395
- state: y(d)
3396
- }, null, 8, ["controller", "state"])
3397
- ])
3398
- ]),
3399
- _: 1
3400
- }, 8, ["modelValue"]);
3401
- };
3402
- }
3403
- }), Un = { class: "flex flex-row-reverse" }, Mn = {
3404
- key: 0,
3405
- class: "flex"
3406
- }, Bn = {
3407
- key: 1,
3408
- class: "border-t pt-6"
3409
- }, zn = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Kn = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Hn = { class: "w-full" }, Gn = {
3410
- class: "p-3 fm-typo-en-body-sm-600",
3411
- style: { "min-width": "130px" }
3412
- }, Wn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Yn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Jn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zn = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ea = { class: "p-3 fm-typo-en-body-sm-600" }, ta = { key: 2 }, sa = /* @__PURE__ */ Te({
3413
- __name: "NetSuiteTransactionChangeLog",
3414
- props: {
3415
- netsuiteId: {}
3416
- },
3417
- setup(p) {
3418
- const t = p, o = Rt(), a = Y(!1), m = Y(!1), u = Y(!1), c = Y([]);
3419
- async function s() {
3420
- if (!(c.value.length > 0))
3421
- try {
3422
- m.value = !0;
3423
- const _ = await o.getChangeLogs(t.netsuiteId);
3424
- c.value = _, u.value = !1;
3425
- } catch {
3426
- u.value = !0;
3427
- } finally {
3428
- m.value = !1;
3429
- }
3430
- }
3431
- function r(_) {
3432
- switch (_) {
3433
- case Me.Create:
3434
- return "text-green-600 bg-green-100";
3435
- case Me.Set:
3436
- return "text-blue-600 bg-blue-100";
3437
- case Me.Change:
3438
- return "text-yellow-600 bg-yellow-100";
3439
- case Me.Unset:
3440
- return "text-red-600 bg-red-100";
3441
- default:
3442
- return "text-gray-600 bg-gray-100";
3443
- }
3444
- }
3445
- function d(_) {
3446
- return new Date(_).toLocaleDateString("en-US", {
3447
- year: "numeric",
3448
- month: "short",
3449
- day: "numeric",
3450
- hour: "2-digit",
3451
- minute: "2-digit"
3452
- });
3453
- }
3454
- return (_, k) => {
3455
- const F = te("FmButton"), C = te("FmCircularProgress"), g = te("FmIcon"), M = te("FmDialog");
3456
- return l(), f("div", Un, [
3457
- D(M, {
3458
- modelValue: a.value,
3459
- "onUpdate:modelValue": k[2] || (k[2] = (T) => a.value = T),
3460
- overlay: !0,
3461
- "max-width": 800
3462
- }, {
3463
- "dialog-button": ae(() => [
3464
- D(F, {
3465
- "prepend-icon": "info",
3466
- variant: "secondary",
3467
- label: "NetSuite",
3468
- onClick: k[0] || (k[0] = (T) => s()),
3469
- "text-color": "primary",
3470
- "bg-color": "transparent",
3471
- "border-color": "primary"
3472
- })
3473
- ]),
3474
- "dialog-header": ae(() => k[3] || (k[3] = [
3475
- e("div", null, "NetSuite info", -1)
3476
- ])),
3477
- default: ae(() => [
3478
- m.value ? (l(), f("div", Mn, [
3479
- k[4] || (k[4] = e("span", null, "Change Log Loading...", -1)),
3480
- D(C, { size: "md" })
3481
- ])) : R("", !0),
3482
- !m.value && c.value.length > 0 ? (l(), f("div", Bn, [
3483
- e("h3", zn, [
3484
- D(g, {
3485
- name: "error",
3486
- color: "#ff9500",
3487
- size: "sm"
3488
- }),
3489
- k[5] || (k[5] = We(" Change Logs "))
3490
- ]),
3491
- e("div", Kn, [
3492
- e("table", Hn, [
3493
- k[6] || (k[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
3494
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
3495
- e("th", {
3496
- class: "text-left p-3 fm-typo-en-body-md-600",
3497
- style: { "min-width": "130px" }
3498
- }, " Date "),
3499
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
3500
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
3501
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
3502
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
3503
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
3504
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
3505
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
3506
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
3507
- ])
3508
- ], -1)),
3509
- e("tbody", null, [
3510
- (l(!0), f($e, null, Pe(c.value, (T, J) => (l(), f("tr", {
3511
- key: J,
3512
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
3513
- }, [
3514
- e("td", Gn, b(d(T._dateiso8601)), 1),
3515
- e("td", Wn, b(T._rolename), 1),
3516
- e("td", Qn, b(T._employeename), 1),
3517
- e("td", Yn, b(T._contextname), 1),
3518
- e("td", {
3519
- class: ze(`p-3 fm-typo-en-body-sm-600 ${r(Number(T.type) - 1)}`)
3520
- }, b(y(Me)[Number(T.type) - 1]), 3),
3521
- e("td", Jn, b(T.lineid || ""), 1),
3522
- e("td", Xn, b(T._fieldname), 1),
3523
- e("td", Zn, b(T.oldvalue || ""), 1),
3524
- e("td", ea, b(T.newvalue || ""), 1)
3525
- ]))), 128))
3526
- ])
3527
- ])
3528
- ])
3529
- ])) : (l(), f("div", ta, k[7] || (k[7] = [
3530
- e("p", null, "No change logs available.", -1)
3531
- ])))
3532
- ]),
3533
- "dialog-footer": ae(() => [
3534
- D(F, {
3535
- class: "ml-auto sm:w-full xs:w-full",
3536
- label: "Close",
3537
- size: "md",
3538
- variant: "primary",
3539
- onClick: k[1] || (k[1] = (T) => a.value = !1)
3540
- })
3541
- ]),
3542
- _: 1
3543
- }, 8, ["modelValue"])
3544
- ]);
3545
- };
3546
- }
3547
- }), ra = { class: "flex flex-col w-full gap-3" }, oa = { class: "flex" }, na = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, aa = { class: "flex flex-col gap-16 w-full h-full" }, la = { class: "flex justify-between" }, ia = { class: "fm-typo-en-body-lg-600" }, ca = { class: "flex gap-2" }, ua = {
3548
- key: 0,
3549
- class: "flex items-center gap-1"
3550
- }, da = { class: "fm-typo-en-body-md-400" }, ma = { class: "flex flex-col gap-8" }, pa = {
3551
- key: 0,
3552
- class: "flex items-start justify-between gap-6"
3553
- }, fa = { class: "text-xs font-mono text-right break-all" }, va = {
3554
- key: 1,
3555
- class: "flex items-start justify-between gap-6"
3556
- }, ya = { class: "fm-typo-en-body-sm-600" }, ha = {
3557
- key: 2,
3558
- class: "flex items-start justify-between gap-6"
3559
- }, ba = { class: "text-xs font-mono text-right break-all" }, ga = {
3560
- key: 3,
3561
- class: "flex items-start justify-between gap-6"
3562
- }, _a = { class: "text-xs font-mono text-right break-all" }, xa = { class: "flex flex-col gap-4" }, Sa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ka = { class: "flex gap-1" }, Oa = { class: "fm-typo-en-body-lg-600" }, wa = {
3563
- key: 0,
3564
- class: "flex flex-col gap-4"
3565
- }, $a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ca = { class: "fm-typo-en-body-lg-600" }, Da = { class: "flex flex-col gap-4" }, Aa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ra = { class: "fm-typo-en-body-lg-600" }, Na = {
3566
- key: 1,
3567
- class: "flex flex-col gap-4"
3568
- }, Pa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "fm-typo-en-body-lg-600" }, Ta = {
3569
- key: 2,
3570
- class: "flex flex-col gap-4"
3571
- }, Ia = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ea = { class: "fm-typo-en-body-lg-600" }, qa = {
3572
- key: 3,
3573
- class: "flex flex-col gap-4"
3574
- }, Va = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, La = { class: "fm-typo-en-body-lg-600" }, ja = {
3575
- key: 4,
3576
- class: "flex flex-col gap-4"
3577
- }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ma = { class: "fm-typo-en-body-lg-600" }, Ba = {
3578
- key: 5,
3579
- class: "flex flex-col gap-4"
3580
- }, za = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ka = { class: "fm-typo-en-body-lg-600" }, Ha = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ga = { class: "flex flex-col gap-8" }, Wa = { class: "flex gap-8 items-center" }, Qa = { class: "flex-1 fm-typo-en-body-lg-600" }, Ya = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ja = { class: "flex w-full gap-4" }, Xa = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Za = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, el = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, tl = ["innerHTML"], sl = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, rl = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, ol = {
3581
- key: 0,
3582
- class: "flex items-center gap-4"
3583
- }, nl = { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, al = {
3584
- key: 0,
3585
- class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
3586
- }, ll = { class: "py-8" }, il = { class: "flex justify-end gap-4 items-center" }, cl = { class: "fm-typo-en-body-lg-600" }, ul = {
3587
- key: 0,
3588
- class: "flex justify-end"
3589
- }, dl = {
3590
- key: 1,
3591
- class: "flex-1 xs:w-screen xs:max-w-full"
3592
- }, ml = {
3593
- key: 0,
3594
- class: "flex flex-col items-center gap-8 h-full"
3595
- }, pl = ["src"], fl = { class: "fm-typo-en-body-lg-600" }, vl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, yl = {
3596
- key: 1,
3597
- class: "px-4 flex flex-col"
3598
- }, hl = { class: "flex gap-12 content-stretch" }, bl = {
3599
- class: "flex flex-col w-40",
3600
- name: "circles"
3601
- }, gl = { class: "flex-1 flex flex-col items-center" }, _l = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, xl = { class: "flex-1 flex flex-col items-center" }, Sl = { class: "flex w-full items-center gap-4" }, kl = {
3602
- class: "py-12 flex flex-col gap-4",
3603
- name: "received-at header"
3604
- }, Ol = { class: "fm-typo-en-body-lg-400" }, wl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, $l = { class: "ml-auto flex gap-1" }, Cl = { class: "flex gap-12 content-stretch" }, Dl = {
3605
- class: "flex flex-col w-40",
3606
- name: "circles"
3607
- }, Al = { class: "flex-1 flex flex-col items-center" }, Rl = {
3608
- class: "py-12 flex flex-col gap-4 flex-1",
3609
- name: "delivery details"
3610
- }, Nl = { class: "flex flex-col gap-8" }, Pl = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Fl = { class: "flex flex-col gap-4" }, Tl = {
3611
- key: 2,
3612
- class: "flex-1 xs:w-screen xs:max-w-full"
3613
- }, Il = {
3614
- key: 0,
3615
- class: "flex flex-col items-center gap-8 h-full"
3616
- }, El = ["src"], ql = { class: "fm-typo-en-body-lg-600" }, Vl = {
3617
- key: 1,
3618
- class: "px-4 flex flex-col gap-12"
3619
- }, Ll = { class: "flex flex-col gap-4" }, jl = { class: "flex justify-between gap-8" }, Ul = { class: "fm-typo-en-body-lg-600" }, Ml = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary whitespace-nowrap" }, Bl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zl = {
3620
- key: 0,
3621
- class: "fm-typo-en-body-md-400"
3622
- }, Kl = { class: "flex gap-8 xs:flex-col" }, Oi = /* @__PURE__ */ Te({
3623
- __name: "TransferDetails",
3624
- props: {
3625
- poRequest: {},
3626
- purchaseOrder: {},
3627
- transferTo: {},
3628
- transferToDbName: {},
3629
- show: { type: Boolean },
3630
- canResubmit: { type: Boolean },
3631
- canApprove: { type: Boolean },
3632
- scope: {},
3633
- receivedMap: {},
3634
- shipments: {}
3635
- },
3636
- emits: ["update:show", "submitted"],
3637
- setup(p, { emit: t }) {
3638
- const o = p, a = t, m = bt(), u = Xe(), c = Je(), s = Ke(), r = yt(), { hasOrderDraftPermission: d } = vs(), _ = ps();
3639
- function k(n) {
3640
- const i = n.isCustomCost, S = n.totalCost;
3641
- return i != null ? i === !0 : S != null;
3642
- }
3643
- Ye(
3644
- () => o.purchaseOrder,
3645
- (n) => {
3646
- _.init(n);
3647
- },
3648
- { immediate: !0 }
3649
- );
3650
- const F = z(
3651
- () => {
3652
- var n, i;
3653
- return {
3654
- id: ((n = r.sessionUser.value) == null ? void 0 : n.id) ?? "",
3655
- name: ((i = r.sessionUser.value) == null ? void 0 : i.displayName) ?? ""
3656
- };
3657
- }
3658
- ), C = fs(), { t: g } = vt(), M = z(
3659
- () => {
3660
- var n, i, S, $;
3661
- return ((i = (n = o.purchaseOrder) == null ? void 0 : n.supplier) == null ? void 0 : i.internal) === "restaurant" || (($ = (S = o.purchaseOrder) == null ? void 0 : S.supplier) == null ? void 0 : $.internal) === "warehouse" ? nt.enum.transfer : nt.enum.purchase;
3662
- }
3663
- ), T = z(() => {
3664
- var S;
3665
- const n = (S = o.shipments) == null ? void 0 : S.find(($) => {
3666
- var j;
3667
- return $.ref === ((j = o.purchaseOrder) == null ? void 0 : j._id);
3668
- });
3669
- let i = null;
3670
- if (n != null && n.milestones && n.milestones.length > 0) {
3671
- const $ = n.milestones[n.milestones.length - 1];
3672
- if ($.estimatedTime) {
3673
- const j = new Date($.estimatedTime), H = j.getDate().toString().padStart(2, "0");
3674
- i = `${j.toLocaleString("en-US", { month: "short" })} ${H}`;
3675
- }
3676
- }
3677
- return i;
3678
- }), J = Y(!1), Q = Y(""), le = Y(!0), xe = Ze(), ye = Xs(xe.getWorkflowConfig), ne = ms(), ge = [
3679
- U.enum.receiveStock,
3680
- U.enum.processRequest,
3681
- U.enum.closeRequest
3682
- ], K = z(() => {
3683
- if (!o.purchaseOrder)
3684
- return [];
3685
- const n = ye.result.value;
3686
- if (n.state === Qt.loading)
3687
- return [];
3688
- const i = {
3689
- user: F.value,
3690
- executedAt: s.locations.computeFirst(
3691
- (re) => {
3692
- var E;
3693
- return re.dbName === ((E = s._currentLocation) == null ? void 0 : E.dbName) ? re : null;
3694
- }
3695
- ),
3696
- purchaseOrderRequest: o.poRequest,
3697
- purchaseOrder: o.purchaseOrder
3698
- }, S = c.useOperatePurchaseOrderV2, $ = c.poWorkflowAllowToMarkCompleted, j = [...ge];
3699
- S && !$ && j.push(U.enum.completeReceive);
3700
- let H = [];
3701
- try {
3702
- n.state === Qt.error ? (console.error("Error fetching workflow config:", n.error), H = gt.getAvailableActions({
3703
- ...i,
3704
- orderConfig: gt.getDefaultConfig()
3705
- }).actions.filter((re) => !j.includes(re))) : H = gt.getAvailableActions({
3706
- ...i,
3707
- orderConfig: n.data
3708
- }).actions.filter((re) => !j.includes(re));
3709
- } catch (re) {
3710
- console.error("Error getting available actions:", re);
3711
- }
3712
- return o.scope === "approval" && (H = H.filter((re) => re !== U.enum.completeReceive)), d.value || (H = H.filter(
3713
- (re) => re !== U.enum.approveDraft && re !== U.enum.rejectDraft
3714
- )), H;
3715
- }), ce = Ks(o, "show"), I = z(() => [
3716
- {
3717
- label: g("inventory.transfer.receiveRequest.details.overview"),
3718
- value: "overview"
3719
- },
3720
- {
3721
- label: g("inventory.transfer.receiveRequest.details.deliveryHistory"),
3722
- value: "deliveryHistory"
3723
- },
3724
- {
3725
- label: g("inventory.transfer.receiveRequest.details.actionLogs"),
3726
- value: "actionLogs"
3727
- }
3728
- ]), w = Y(I.value[0]);
3729
- Ye(
3730
- () => o.show,
3731
- (n) => {
3732
- n && (w.value = I.value[0]);
3733
- }
3734
- );
3735
- function q(n) {
3736
- return n.map((i) => ({
3737
- ...i,
3738
- amount: {
3739
- ...i.amount,
3740
- amount: -Math.abs(i.amount.amount)
3741
- }
3742
- }));
3743
- }
3744
- async function W(n, i, S, $, j) {
3745
- return new Promise((H, re) => {
3746
- const E = {
3747
- closeButton: !1,
3748
- title: $.title,
3749
- message: $.message,
3750
- primaryActions: $.primaryActions,
3751
- secondaryActions: { text: "No", close: !1 }
3752
- };
3753
- let fe = i.rejectReason ?? "";
3754
- S === U.enum.rejectDraft && (E.contentComponent = ds, E.contentComponentProps = {
3755
- message: $.message,
3756
- onChange: (ue) => {
3757
- fe = ue ?? "";
3758
- }
3759
- }), m.open(E).onPrimary(async () => {
3760
- var Oe, h, v, A;
3761
- const ue = [];
3762
- S === U.enum.confirmDraft || S === U.enum.submitRequest ? ue.push({
3763
- action: "confirmDraft",
3764
- payload: _.controller.value.toConfirmDraftData(Ce())
3765
- }) : S === U.enum.approveRequest ? (ue.push({
3766
- action: "approveRequest",
3767
- payload: null
3768
- }), i.fulfillment && ue.push({
3769
- action: "processRequest",
3770
- payload: {
3771
- fulfillmentId: "",
3772
- deliveryOrderNumber: "",
3773
- deliveryRemark: null,
3774
- items: q(i.fulfillment.items),
3775
- createdBy: F.value
3776
- }
3777
- })) : S === U.enum.processRequest ? i.fulfillment && ue.push({
3778
- action: "processRequest",
3779
- payload: {
3780
- fulfillmentId: "",
3781
- deliveryOrderNumber: "",
3782
- deliveryRemark: null,
3783
- items: q(i.fulfillment.items),
3784
- createdBy: F.value
3785
- }
3786
- }) : S === U.enum.rejectRequest ? ue.push({
3787
- action: "rejectRequest",
3788
- payload: null
3789
- }) : S === U.enum.closeRequest ? ue.push({
3790
- action: "closeRequest",
3791
- payload: null
3792
- }) : S === U.enum.rejectDraft && ue.push({
3793
- action: "rejectDraft",
3794
- payload: {
3795
- rejectReason: fe ?? ""
3796
- }
3797
- });
3798
- try {
3799
- await ne({
3800
- operate: {
3801
- operation: S,
3802
- doc: n,
3803
- options: i
3804
- },
3805
- operateV2: {
3806
- _id: ((Oe = o.purchaseOrder) == null ? void 0 : Oe._id) ?? "",
3807
- _rev: ((h = o.purchaseOrder) == null ? void 0 : h._rev) ?? "",
3808
- action: S === U.enum.submitRequest ? U.enum.confirmDraft : S,
3809
- payloads: ue
3810
- // add payload if action is receiveStock or processRequest
3811
- },
3812
- transferTo: (A = (v = o.poRequest) == null ? void 0 : v.to) == null ? void 0 : A.dbName
3813
- }).delayed(1e3), H("submitted");
3814
- } catch (Z) {
3815
- re(Z);
3816
- }
3817
- }).onSecondary(() => {
3818
- H("cancelled");
3819
- for (let ue = 0; ue < j + 2; ue++)
3820
- m.close();
3821
- }).onClose(() => {
3822
- });
3823
- });
3824
- }
3825
- async function B(n) {
3826
- var j, H, re, E;
3827
- if (n === U.enum.receiveStock)
3828
- return;
3829
- const i = us[n];
3830
- if (!i) {
3831
- u.open({
3832
- title: "Something went wrong",
3833
- message: `Cannot process order: ${Dt(n)}`,
3834
- type: "error"
3835
- });
3836
- return;
3837
- }
3838
- const { successMessage: S, ...$ } = i;
3839
- if (o.purchaseOrder) {
3840
- Q.value = `${n}`, J.value = !0, le.value = !1;
3841
- const fe = {};
3842
- let ue = 0;
3843
- if ((n === U.enum.confirmDraft || // auto receive for warehouse to warehouse
3844
- n === U.enum.completeReceive) && c.autoReceiveWarehouse)
3845
- fe.autoReceive = !0;
3846
- else if ((n === U.enum.approveRequest || n === U.enum.processRequest) && c.acceptRequireFulfillment) {
3847
- const Oe = (H = (j = o.poRequest) == null ? void 0 : j.from) == null ? void 0 : H.dbName, h = (E = (re = o.poRequest) == null ? void 0 : re.to) == null ? void 0 : E.dbName;
3848
- if (Oe && h && (Oe.startsWith("warehouse_") || h.startsWith("warehouse_"))) {
3849
- const v = await new Promise((A, Z) => {
3850
- m.open({
3851
- closeButton: !1,
3852
- title: "Confirm transfer amount",
3853
- dialogComponent: Cr,
3854
- dialogComponentProps: {
3855
- purchaseOrder: o.purchaseOrder,
3856
- confirm: A,
3857
- "onUpdate:show": (oe) => {
3858
- oe || (Q.value = "", J.value = !1, le.value = !0, ue++, m.close()), Z("cancelled");
3859
- }
3860
- }
3861
- });
3862
- });
3863
- fe.fulfillment = v;
3864
- }
3865
- }
3866
- try {
3867
- await W(
3868
- o.purchaseOrder,
3869
- fe,
3870
- n,
3871
- i,
3872
- ue
3873
- ) === "submitted" && (u.open({
3874
- title: "Success",
3875
- message: S,
3876
- type: "success"
3877
- }), a("update:show", !1), a("submitted"));
3878
- } catch (Oe) {
3879
- u.open({
3880
- title: "Something went wrong",
3881
- message: Oe instanceof Error ? Oe.message : "Please try again.",
3882
- type: "error"
3883
- }), console.error("Error when submitting PO operation", n, o.purchaseOrder, Oe);
3884
- } finally {
3885
- Q.value = "", J.value = !1, le.value = !0;
3886
- }
3887
- }
3888
- }
3889
- const ie = z(() => {
3890
- var n, i;
3891
- return ((n = o.purchaseOrder) == null ? void 0 : n.status) === be.enum.RECEIVING || ((i = o.purchaseOrder) == null ? void 0 : i.status) === be.enum.COMPLETE;
3892
- }), pe = z(() => o.purchaseOrder ? pt(o.purchaseOrder) : {}), L = z(() => {
3893
- const n = o.purchaseOrder;
3894
- if (!n) return { status: "", statusClass: "" };
3895
- const { partial: i, over: S } = Ot(pe.value), $ = wt(n.status, i, S);
3896
- let j = g(`inventory.transfer.status.${$}`), H = `${n.status}`.toLocaleLowerCase("en-us");
3897
- return $ === be.enum.CLOSE && (j = `${g(`inventory.transfer.status.${be.enum.COMPLETE}`)}`), $ === "PARTIAL_RECEIVED" && H === be.enum.PROCESSING.toLocaleLowerCase("en-us") && (H = be.enum.RECEIVING.toLocaleLowerCase("en-us")), {
3898
- status: j,
3899
- statusClass: `fm-status-badge fm-status-badge-${H}`
3900
- };
3901
- }), O = z(() => {
3902
- var H, re;
3903
- const n = ((H = o.purchaseOrder) == null ? void 0 : H.deliveryOrder) ?? [], i = ((re = o.purchaseOrder) == null ? void 0 : re.deliveryFullfillment) ?? [], S = [
3904
- ...n.map((E) => ({
3905
- createdAt: E.createdAt,
3906
- type: "grn",
3907
- doc: E
3908
- })),
3909
- ...i.map((E) => ({
3910
- createdAt: E.createdAt,
3911
- type: "fulfillment",
3912
- doc: E
3913
- }))
3914
- ];
3915
- S.reverse().sort((E, fe) => E.createdAt.localeCompare(fe.createdAt));
3916
- function $(E) {
3917
- var Oe, h, v, A, Z, oe, Re, G, he, we, Ne, Ie;
3918
- const fe = i.findIndex((De) => De.id === E.fullfillmentId), ue = [
3919
- (h = (Oe = i[fe]) == null ? void 0 : Oe.netSuite) != null && h.id ? {
3920
- label: "Fulfillment's ref no. (Netsuite)",
3921
- values: [
3922
- `${((A = (v = i[fe]) == null ? void 0 : v.netSuite) == null ? void 0 : A.refNo) ?? "N/A"} (${((oe = (Z = i[fe]) == null ? void 0 : Z.netSuite) == null ? void 0 : oe.id) ?? "-"})`
3923
- ]
3924
- } : null,
3925
- (Re = E == null ? void 0 : E.netSuite) != null && Re.id ? {
3926
- label: "Netsuite ref no.",
3927
- values: [`${((G = E == null ? void 0 : E.netSuite) == null ? void 0 : G.refNo) ?? "N/A"} (${((he = E == null ? void 0 : E.netSuite) == null ? void 0 : he.id) ?? "-"})`]
3928
- } : null,
3929
- (we = E == null ? void 0 : E.netSuite) != null && we.recordType ? {
3930
- label: "Netsuite Type",
3931
- values: [os((Ne = E == null ? void 0 : E.netSuite) == null ? void 0 : Ne.recordType)]
3932
- } : null
3933
- ];
3934
- return {
3935
- header: "Received",
3936
- deliveryOrder: E,
3937
- date: et(new Date(E.createdAt)),
3938
- info: [
3939
- {
3940
- label: "Adjustment date",
3941
- values: [
3942
- E.adjustment ? et(new Date(ut(E.adjustment))) : "-"
3943
- ]
3944
- },
3945
- {
3946
- label: "Received by",
3947
- values: [(Ie = E.createdBy) == null ? void 0 : Ie.name]
3948
- },
3949
- {
3950
- label: "Received items",
3951
- values: E.received.map((De) => {
3952
- var ve;
3953
- return ee("div", [
3954
- ee(
3955
- "div",
3956
- {
3957
- class: "flex gap-4"
3958
- },
3959
- [
3960
- ee(
3961
- "div",
3962
- {
3963
- class: "flex flex-col"
3964
- },
3965
- [
3966
- ee(
3967
- "span",
3968
- {
3969
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
3970
- },
3971
- `${De.sku.name}`
3972
- ),
3973
- ee(
3974
- "span",
3975
- {
3976
- class: "fm-typo-en-body-md-400"
3977
- },
3978
- `${De.sku.code} `
3979
- )
3980
- ]
3981
- ),
3982
- ee(
3983
- "div",
3984
- {
3985
- class: "ml-auto flex flex-col"
3986
- },
3987
- [
3988
- ee(
3989
- "div",
3990
- {
3991
- class: "ml-auto flex gap-1"
3992
- },
3993
- [
3994
- ee(
3995
- "span",
3996
- {
3997
- class: "fm-typo-en-body-lg-600 self-end"
3998
- },
3999
- _e(De.amount, !1)
4000
- ),
4001
- ee(
4002
- "span",
4003
- {
4004
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4005
- },
4006
- ((ve = De.measurement) == null ? void 0 : ve.abbrev) ?? De.sku.unit.abbrev
4007
- )
4008
- ]
4009
- ),
4010
- ee(
4011
- "div",
4012
- {
4013
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4014
- },
4015
- `${De.cost ? `(${lt(De.cost)})` : ""}`
4016
- )
4017
- ]
4018
- )
4019
- ]
4020
- )
4021
- ]);
4022
- })
4023
- },
4024
- {
4025
- label: "Delivery order no.",
4026
- values: [E.deliveryOrderNumber || "N/A"]
4027
- },
4028
- {
4029
- label: "Remark",
4030
- values: [E.remark || "N/A"]
4031
- },
4032
- fe > -1 ? {
4033
- label: "Fulfilment's sequence",
4034
- values: [`${fe + 1}`]
4035
- } : null,
4036
- ...ue
4037
- ].filter((De) => !!De)
4038
- };
4039
- }
4040
- function j(E) {
4041
- var ue, Oe, h;
4042
- const fe = i.findIndex((v) => v.id === E.id);
4043
- return {
4044
- header: "Fulfillment",
4045
- date: et(new Date(E.createdAt)),
4046
- info: [
4047
- {
4048
- label: "Sequence",
4049
- values: [String(fe + 1)]
4050
- },
4051
- {
4052
- label: "Receiveable items",
4053
- values: E.items.map((v) => {
4054
- var A;
4055
- return ee("div", [
4056
- ee(
4057
- "div",
4058
- {
4059
- class: "flex gap-4"
4060
- },
4061
- [
4062
- ee(
4063
- "div",
4064
- {
4065
- class: "flex flex-col"
4066
- },
4067
- [
4068
- ee(
4069
- "span",
4070
- {
4071
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
4072
- },
4073
- `${v.sku.name}`
4074
- ),
4075
- ee(
4076
- "span",
4077
- {
4078
- class: "fm-typo-en-body-md-400"
4079
- },
4080
- `${v.sku.code} `
4081
- )
4082
- ]
4083
- ),
4084
- ee(
4085
- "div",
4086
- {
4087
- class: "ml-auto flex flex-col"
4088
- },
4089
- [
4090
- ee(
4091
- "div",
4092
- {
4093
- class: "ml-auto flex gap-1"
4094
- },
4095
- [
4096
- ee(
4097
- "span",
4098
- {
4099
- class: "fm-typo-en-body-lg-600 self-end"
4100
- },
4101
- _e(v.amount, !1)
4102
- ),
4103
- ee(
4104
- "span",
4105
- {
4106
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
4107
- },
4108
- ((A = v.measurement) == null ? void 0 : A.abbrev) ?? v.sku.unit.abbrev
4109
- )
4110
- ]
4111
- ),
4112
- ee(
4113
- "div",
4114
- {
4115
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
4116
- },
4117
- `${v.cost ? `(${lt(v.cost)})` : ""}`
4118
- )
4119
- ]
4120
- )
4121
- ]
4122
- )
4123
- ]);
4124
- })
4125
- },
4126
- (ue = E.netSuite) != null && ue.refNo ? {
4127
- label: "Netsuite Ref no. (ID)",
4128
- values: [`${(Oe = E.netSuite) == null ? void 0 : Oe.refNo} (${((h = E.netSuite) == null ? void 0 : h.id) ?? "-"})`]
4129
- } : null
4130
- ].filter((v) => !!v)
4131
- };
4132
- }
4133
- return S.map(
4134
- (E) => E.type === "grn" ? $(E.doc) : j(E.doc)
4135
- );
4136
- });
4137
- function X(n) {
4138
- var H;
4139
- const S = (((H = o.purchaseOrder) == null ? void 0 : H.version) ?? Ve.enum[1]) === Ve.enum[2] ? n.id : n.sku._id, $ = o.receivedMap[S], j = x(n);
4140
- return $ ? `<span class="${j} fm-typo-en-body-lg-600">${Fe.toFormatString({ value: $.received })}</span>/${mt(n.quantity, n.sku.unit, n.measurement)}` : `<span class="fm-typo-en-body-lg-600">-</span>/${mt(n.quantity, n.sku.unit, n.measurement)}`;
4141
- }
4142
- function P(n) {
4143
- const i = o.purchaseOrder;
4144
- if (!(i != null && i.itemsAtSubmission)) return !1;
4145
- const S = i.version === Ve.enum[2], $ = S ? n.id : n.sku._id;
4146
- return $ == null ? !1 : !i.itemsAtSubmission.some((j) => (S ? j.id : j.sku._id) === $);
4147
- }
4148
- function x(n) {
4149
- var fe;
4150
- const S = (((fe = o.purchaseOrder) == null ? void 0 : fe.version) ?? Ve.enum[1]) === Ve.enum[2] ? n.id : n.sku._id, $ = o.receivedMap[S], { isPartialReceive: j, isNoReceive: H, isOverReceive: re, isFullReceive: E } = vr($);
4151
- return H ? "text-fm-color-typo-tertiary" : j ? "text-fm-color-system-warning-300" : re ? "text-fm-color-system-error-300" : E ? "text-fm-color-system-success-300" : "";
4152
- }
4153
- const N = z(() => {
4154
- var n, i, S;
4155
- return (n = o.purchaseOrder) != null && n.itemsAtSubmission ? ((i = o.purchaseOrder) == null ? void 0 : i.version) === Ve.enum[2] ? o.purchaseOrder.items.reduce(($, j) => {
4156
- var re, E;
4157
- const H = (E = (re = o.purchaseOrder) == null ? void 0 : re.itemsAtSubmission) == null ? void 0 : E.find(
4158
- (fe) => fe.id === j.id
4159
- );
4160
- return H && H.quantity !== j.quantity && $.set(j.sku.code, {
4161
- originalAmount: Number(Fe.toFormatString({ value: H.quantity })),
4162
- newAmount: Number(Fe.toFormatString({ value: j.quantity }))
4163
- }), $;
4164
- }, /* @__PURE__ */ new Map()) : (S = o.purchaseOrder) == null ? void 0 : S.items.reduce(($, j) => {
4165
- var fe, ue;
4166
- const H = (ue = (fe = o.purchaseOrder) == null ? void 0 : fe.itemsAtSubmission) == null ? void 0 : ue.find(
4167
- (Oe) => Oe.sku._id === j.sku._id
4168
- ), re = H ? Number(Fe.toFormatString({ value: H.quantity })) : 0, E = Number(Fe.toFormatString({ value: j.quantity }));
4169
- return H && re !== E && $.set(j.sku.code, {
4170
- originalAmount: re,
4171
- newAmount: E
4172
- }), $;
4173
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
4174
- }), V = (n) => {
4175
- var S, $;
4176
- const i = N.value;
4177
- return ((S = o.purchaseOrder) == null ? void 0 : S.version) === Ve.enum[2] ? i.has(n.id) : i.has(($ = n.sku) == null ? void 0 : $.code);
4178
- }, se = (n) => {
4179
- var S, $;
4180
- const i = N.value;
4181
- return ((S = o.purchaseOrder) == null ? void 0 : S.version) === Ve.enum[2] ? i.get(n.id) : i.get(($ = n.sku) == null ? void 0 : $.code);
4182
- }, Se = z(() => {
4183
- const n = o.purchaseOrder;
4184
- if (!n) return "";
4185
- const i = n.actionChangelogs ?? [], S = i.length ? i[i.length - 1] : null;
4186
- if (S && S.action === "rejectDraft") {
4187
- const $ = S.remarks ?? "";
4188
- return $ && $.toString().trim() !== "" ? $.toString() : "-";
4189
- }
4190
- return "";
4191
- }), ke = z(() => {
4192
- const n = o.purchaseOrder;
4193
- return n ? [...n.actionChangelogs ?? []].reverse() : [];
4194
- });
4195
- return (n, i) => {
4196
- const S = te("FmButton"), $ = te("FmButtonGroup"), j = te("FmChip"), H = te("FmIcon"), re = te("FmMenuDivider"), E = te("FmCard"), fe = te("FmTooltip"), ue = te("FmSpacer"), Oe = te("FmSideSheet");
4197
- return l(), me(Oe, {
4198
- modelValue: y(ce),
4199
- "onUpdate:modelValue": i[9] || (i[9] = (h) => Ds(ce) ? ce.value = h : null),
4200
- "dismiss-away": le.value,
4201
- "max-width": 600,
4202
- "close-button": !1
4203
- }, {
4204
- "side-sheet-header": ae(() => {
4205
- var h, v;
4206
- return [
4207
- e("div", ra, [
4208
- e("div", oa, [
4209
- e("div", na, b(y(g)("inventory.transfer.receiveRequest.details.title") + ((h = n.purchaseOrder) != null && h.seqNumber ? ` #${(v = n.purchaseOrder) == null ? void 0 : v.seqNumber}` : "")), 1),
4210
- D(S, {
4211
- class: "ml-auto -m-2",
4212
- variant: "tertiary",
4213
- "prepend-icon": "close",
4214
- onClick: i[0] || (i[0] = (A) => a("update:show", !1))
4215
- })
4216
- ]),
4217
- D($, {
4218
- items: I.value,
4219
- modelValue: w.value,
4220
- "onUpdate:modelValue": i[1] || (i[1] = (A) => w.value = A)
4221
- }, null, 8, ["items", "modelValue"]),
4222
- n.purchaseOrder && w.value.value === "deliveryHistory" ? (l(), me(Tn, {
4223
- key: 0,
4224
- "purchase-order": n.purchaseOrder,
4225
- "received-info-map": pe.value,
4226
- "received-map": n.receivedMap,
4227
- onSubmitted: i[2] || (i[2] = () => {
4228
- a("update:show", !1), a("submitted");
4229
- })
4230
- }, null, 8, ["purchase-order", "received-info-map", "received-map"])) : R("", !0)
4231
- ])
4232
- ];
4233
- }),
4234
- default: ae(() => {
4235
- var h, v, A, Z, oe, Re;
4236
- return [
4237
- e("div", aa, [
4238
- w.value.value === "overview" ? (l(), f($e, { key: 0 }, [
4239
- e("div", null, [
4240
- D(E, {
4241
- variant: "outlined",
4242
- class: "flex flex-col gap-8 px-12 py-16"
4243
- }, {
4244
- default: ae(() => {
4245
- var G, he, we, Ne, Ie, De, ve, de, Le, qe;
4246
- return [
4247
- e("div", la, [
4248
- e("div", ia, b(y(g)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
4249
- e("div", ca, [
4250
- D(j, {
4251
- label: L.value.status,
4252
- class: ze(L.value.statusClass),
4253
- compact: ""
4254
- }, null, 8, ["label", "class"]),
4255
- T.value ? (l(), f("div", ua, [
4256
- D(H, {
4257
- name: "local_shipping",
4258
- color: "#666666"
4259
- }),
4260
- e("span", da, b(T.value), 1)
4261
- ])) : R("", !0)
4262
- ])
4263
- ]),
4264
- D(re),
4265
- e("div", ma, [
4266
- D(Zt, { title: "Debug Info" }, {
4267
- default: ae(() => {
4268
- var je, Ft, Tt, It, Et, qt, Vt, Lt, jt, Ut, Mt, Bt;
4269
- return [
4270
- (je = n.purchaseOrder) != null && je._id ? (l(), f("div", pa, [
4271
- i[10] || (i[10] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order ID ", -1)),
4272
- e("span", fa, b((Ft = n.purchaseOrder) == null ? void 0 : Ft._id), 1)
4273
- ])) : R("", !0),
4274
- (Tt = n.purchaseOrder) != null && Tt.status ? (l(), f("div", va, [
4275
- i[11] || (i[11] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Purchase Order Status ", -1)),
4276
- e("span", ya, b((It = n.purchaseOrder) == null ? void 0 : It.status), 1)
4277
- ])) : R("", !0),
4278
- (qt = (Et = n.purchaseOrder) == null ? void 0 : Et.supplier) != null && qt._id ? (l(), f("div", ha, [
4279
- i[12] || (i[12] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Source Location ID ", -1)),
4280
- e("span", ba, b(((Lt = (Vt = n.purchaseOrder) == null ? void 0 : Vt.supplier) == null ? void 0 : Lt.internal) != null ? `${(Ut = (jt = n.purchaseOrder) == null ? void 0 : jt.supplier) == null ? void 0 : Ut.internal}_` : "") + b((Bt = (Mt = n.purchaseOrder) == null ? void 0 : Mt.supplier) == null ? void 0 : Bt._id), 1)
4281
- ])) : R("", !0),
4282
- n.transferToDbName ? (l(), f("div", ga, [
4283
- i[13] || (i[13] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Destination Location ID ", -1)),
4284
- e("span", _a, b(n.transferToDbName), 1)
4285
- ])) : R("", !0)
4286
- ];
4287
- }),
4288
- _: 1
4289
- }),
4290
- e("div", xa, [
4291
- e("div", Sa, [
4292
- e("div", ka, b(y(g)("inventory.transfer.receiveRequest.details.createdAt")), 1)
4293
- ]),
4294
- e("div", Oa, b(y(at)(((G = n.purchaseOrder) == null ? void 0 : G._id) ?? "")), 1)
4295
- ]),
4296
- (he = n.purchaseOrder) != null && he.effectiveAt ? (l(), f("div", wa, [
4297
- e("div", $a, b(y(g)("inventory.transfer.receiveRequest.details.date")), 1),
4298
- e("div", Ca, b(y(At)(new Date((we = n.purchaseOrder) == null ? void 0 : we.effectiveAt))), 1)
4299
- ])) : R("", !0),
4300
- e("div", Da, [
4301
- e("div", Aa, b(y(g)("inventory.transfer.receiveRequest.details.type.title")), 1),
4302
- e("div", Ra, b(y(g)(
4303
- `inventory.transfer.receiveRequest.details.type.${M.value.toLocaleLowerCase("en-US")}`
4304
- )), 1)
4305
- ]),
4306
- (Ie = (Ne = n.purchaseOrder) == null ? void 0 : Ne.supplier) != null && Ie.name ? (l(), f("div", Na, [
4307
- e("div", Pa, b(y(g)("inventory.transfer.receiveRequest.details.from")), 1),
4308
- e("div", Fa, b((ve = (De = n.purchaseOrder) == null ? void 0 : De.supplier) == null ? void 0 : ve.name), 1)
4309
- ])) : R("", !0),
4310
- n.transferTo ? (l(), f("div", Ta, [
4311
- e("div", Ia, b(y(g)("inventory.transfer.receiveRequest.details.to")), 1),
4312
- e("div", Ea, b(n.transferTo), 1)
4313
- ])) : R("", !0),
4314
- (de = n.purchaseOrder) != null && de.ref ? (l(), f("div", qa, [
4315
- e("div", Va, b(y(g)("inventory.transfer.receiveRequest.details.reference")), 1),
4316
- e("div", La, b(n.purchaseOrder.ref), 1)
4317
- ])) : R("", !0),
4318
- (Le = n.purchaseOrder) != null && Le.remark ? (l(), f("div", ja, [
4319
- e("div", Ua, b(y(g)("inventory.transfer.receiveRequest.details.remark")), 1),
4320
- e("div", Ma, b(n.purchaseOrder.remark), 1)
4321
- ])) : R("", !0),
4322
- ((qe = n.purchaseOrder) == null ? void 0 : qe.status) === y(be).enum.DRAFT && Se.value ? (l(), f("div", Ba, [
4323
- e("div", za, b(y(g)("inventory.transfer.receiveRequest.details.rejectionReason")), 1),
4324
- e("div", Ka, b(Se.value !== "" ? Se.value : "-"), 1)
4325
- ])) : R("", !0)
4326
- ])
4327
- ];
4328
- }),
4329
- _: 1
4330
- })
4331
- ]),
4332
- D(Oo, {
4333
- "po-request": n.poRequest,
4334
- purchaseOrder: n.purchaseOrder,
4335
- transferType: M.value,
4336
- transferToDbName: n.transferToDbName,
4337
- scope: n.scope
4338
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
4339
- e("div", Ha, [
4340
- e("div", Ga, [
4341
- e("div", Wa, [
4342
- e("span", Qa, [
4343
- We(b(ie.value ? y(g)("inventory.transfer.receiveRequest.details.receivedItems") : y(g)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
4344
- (v = (h = n.purchaseOrder) == null ? void 0 : h.netSuite) != null && v.missingItems && ((Z = (A = n.purchaseOrder) == null ? void 0 : A.netSuite) == null ? void 0 : Z.missingItems.length) > 0 ? (l(), me(fe, {
4345
- key: 0,
4346
- variant: "rich",
4347
- placement: "top",
4348
- "z-index": 51
4349
- }, {
4350
- content: ae(() => {
4351
- var G, he;
4352
- return [
4353
- e("div", Ya, [
4354
- (l(!0), f($e, null, Pe((he = (G = n.purchaseOrder) == null ? void 0 : G.netSuite) == null ? void 0 : he.missingItems, (we, Ne) => (l(), f("div", {
4355
- class: "flex justify-center align-middle",
4356
- key: Ne
4357
- }, [
4358
- D(H, {
4359
- name: "arrow_right",
4360
- size: "sm"
4361
- }),
4362
- We(" " + b(`(${we.netSuiteId}) ${we.name}: ${we.reason}`), 1)
4363
- ]))), 128))
4364
- ])
4365
- ];
4366
- }),
4367
- default: ae(() => [
4368
- D(H, {
4369
- name: "error",
4370
- color: "#ff2c2c",
4371
- size: "sm"
4372
- })
4373
- ]),
4374
- _: 1
4375
- })) : R("", !0)
4376
- ])
4377
- ]),
4378
- D(re),
4379
- (l(!0), f($e, null, Pe(((oe = n.purchaseOrder) == null ? void 0 : oe.items) ?? [], (G, he) => {
4380
- var we;
4381
- return l(), f("div", {
4382
- key: he,
4383
- class: "flex flex-col"
4384
- }, [
4385
- e("div", Ja, [
4386
- e("div", Xa, [
4387
- We(b(G.name) + " ", 1),
4388
- P(G) ? (l(), me(fe, {
4389
- key: 0,
4390
- variant: "rich",
4391
- placement: "top",
4392
- "z-index": 51
4393
- }, {
4394
- content: ae(() => i[14] || (i[14] = [
4395
- e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Extra item (added during delivery) ", -1)
4396
- ])),
4397
- default: ae(() => [
4398
- D(H, {
4399
- name: "add_circle",
4400
- color: "#6b7280",
4401
- size: "sm"
4402
- })
4403
- ]),
4404
- _: 1
4405
- })) : R("", !0),
4406
- V(G) ? (l(), me(fe, {
4407
- key: 1,
4408
- variant: "rich",
4409
- placement: "top",
4410
- "z-index": 51
4411
- }, {
4412
- content: ae(() => {
4413
- var Ne, Ie;
4414
- return [
4415
- e("div", Za, [
4416
- i[15] || (i[15] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
4417
- e("div", null, "Original Amount: " + b((Ne = se(G)) == null ? void 0 : Ne.originalAmount), 1),
4418
- e("div", null, " New Amount: " + b((Ie = se(G)) == null ? void 0 : Ie.newAmount), 1)
4419
- ])
4420
- ];
4421
- }),
4422
- default: ae(() => [
4423
- D(H, {
4424
- name: "error",
4425
- color: "#ff9500",
4426
- size: "sm"
4427
- })
4428
- ]),
4429
- _: 2
4430
- }, 1024)) : R("", !0)
4431
- ]),
4432
- e("div", el, [
4433
- e("span", {
4434
- innerHTML: X(G)
4435
- }, null, 8, tl)
4436
- ])
4437
- ]),
4438
- e("div", sl, [
4439
- e("div", rl, b(G.code), 1),
4440
- y(c).enableTotalCost ? (l(), f("div", ol, [
4441
- e("span", nl, b(y(lt)(
4442
- (we = G.totalCost) != null && we.amount ? G.totalCost : y(_).controller.value.getItemCost(G, y(Ce)()).cost
4443
- )), 1),
4444
- k(G) ? R("", !0) : (l(), f("span", al, [
4445
- i[16] || (i[16] = e("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1)),
4446
- We(" " + b(y(g)("inventory.transfer.form.items.autoCalculated")), 1)
4447
- ]))
4448
- ])) : R("", !0)
4449
- ])
4450
- ]);
4451
- }), 128)),
4452
- +y(_e)(y(_).controller.value.getTotalCosts()) ? (l(), f($e, { key: 0 }, [
4453
- e("div", ll, [
4454
- D(re)
4455
- ]),
4456
- e("div", il, [
4457
- i[17] || (i[17] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
4458
- e("div", cl, b(y(Ce)()) + " " + b(y(lt)({
4459
- ...y(_).controller.value.getTotalCosts(),
4460
- currency: y(Ce)()
4461
- }).replace(/[^0-9.,]/g, "")), 1)
4462
- ])
4463
- ], 64)) : R("", !0),
4464
- y(c).enablePurchaseOrderPriceAdjustment ? (l(), f($e, { key: 1 }, [
4465
- D(Vn, {
4466
- adjustments: (Re = n.purchaseOrder) == null ? void 0 : Re.priceAdjustments
4467
- }, null, 8, ["adjustments"]),
4468
- n.purchaseOrder ? (l(), f("div", ul, [
4469
- D(jn, {
4470
- "purchase-order": n.purchaseOrder,
4471
- onSubmitted: i[3] || (i[3] = () => {
4472
- a("update:show", !1), a("submitted");
4473
- })
4474
- }, null, 8, ["purchase-order"])
4475
- ])) : R("", !0)
4476
- ], 64)) : R("", !0)
4477
- ])
4478
- ])
4479
- ], 64)) : w.value.value === "deliveryHistory" ? (l(), f("div", dl, [
4480
- O.value.length ? (l(), f("div", yl, [
4481
- (l(!0), f($e, null, Pe(O.value, (G, he) => {
4482
- var we, Ne, Ie, De, ve;
4483
- return l(), f($e, { key: he }, [
4484
- e("div", hl, [
4485
- e("div", bl, [
4486
- e("div", gl, [
4487
- e("div", {
4488
- class: ze([
4489
- {
4490
- "bg-fm-color-primary": he !== 0,
4491
- "bg-white": he === 0
4492
- },
4493
- "w-[2px] h-full"
4494
- ])
4495
- }, null, 2)
4496
- ]),
4497
- e("div", _l, [
4498
- G.header === "Received" ? (l(), me(H, {
4499
- key: 0,
4500
- name: "local_shipping",
4501
- outline: "",
4502
- color: "#ffffff"
4503
- })) : R("", !0)
4504
- ]),
4505
- e("div", xl, [
4506
- e("div", {
4507
- class: ze([
4508
- {
4509
- "bg-fm-color-primary": he < O.value.length - 1,
4510
- "bg-white": he >= O.value.length - 1
4511
- },
4512
- "w-[2px] h-full"
4513
- ])
4514
- }, null, 2)
4515
- ])
4516
- ]),
4517
- e("div", Sl, [
4518
- e("div", kl, [
4519
- e("div", Ol, b(G.header), 1),
4520
- e("div", wl, b(G.date), 1)
4521
- ]),
4522
- e("div", $l, [
4523
- G.header === "Received" && G.deliveryOrder && n.purchaseOrder ? (l(), me(Xo, {
4524
- key: 0,
4525
- deliveryOrder: G.deliveryOrder,
4526
- purchaseOrder: n.purchaseOrder,
4527
- "received-info-map": pe.value,
4528
- onSubmitted: i[4] || (i[4] = () => {
4529
- a("update:show", !1), a("submitted");
4530
- })
4531
- }, null, 8, ["deliveryOrder", "purchaseOrder", "received-info-map"])) : R("", !0),
4532
- (Ne = (we = G.deliveryOrder) == null ? void 0 : we.netSuite) != null && Ne.id ? (l(), me(Zt, {
4533
- key: 1,
4534
- title: "Admin",
4535
- class: "min-w-[140px]"
4536
- }, {
4537
- default: ae(() => {
4538
- var de, Le;
4539
- return [
4540
- D(sa, {
4541
- "netsuite-id": (Le = (de = G.deliveryOrder) == null ? void 0 : de.netSuite) == null ? void 0 : Le.id
4542
- }, null, 8, ["netsuite-id"])
4543
- ];
4544
- }),
4545
- _: 2
4546
- }, 1024)) : R("", !0),
4547
- n.purchaseOrder && ((Ie = G.deliveryOrder) != null && Ie.id) ? (l(), me(Ws, {
4548
- key: 2,
4549
- "purchase-order-id": (De = n.purchaseOrder) == null ? void 0 : De._id,
4550
- "delivery-order-id": (ve = G.deliveryOrder) == null ? void 0 : ve.id
4551
- }, null, 8, ["purchase-order-id", "delivery-order-id"])) : R("", !0)
4552
- ])
4553
- ])
4554
- ]),
4555
- e("div", Cl, [
4556
- e("div", Dl, [
4557
- e("div", Al, [
4558
- e("div", {
4559
- class: ze([
4560
- {
4561
- "bg-fm-color-primary": he < O.value.length - 1,
4562
- "bg-white": he >= O.value.length - 1
4563
- },
4564
- "w-[2px] h-full"
4565
- ])
4566
- }, null, 2)
4567
- ])
4568
- ]),
4569
- e("div", Rl, [
4570
- D(E, {
4571
- variant: "outlined",
4572
- class: "py-12 px-16"
4573
- }, {
4574
- default: ae(() => [
4575
- e("div", Nl, [
4576
- (l(!0), f($e, null, Pe(G.info, (de, Le) => (l(), f("div", {
4577
- key: Le,
4578
- class: "flex flex-col gap-4"
4579
- }, [
4580
- e("div", Pl, b(de == null ? void 0 : de.label), 1),
4581
- e("div", Fl, [
4582
- (l(!0), f($e, null, Pe(de == null ? void 0 : de.values, (qe, je) => (l(), f("div", {
4583
- key: je,
4584
- class: "fm-typo-en-body-lg-600"
4585
- }, [
4586
- typeof qe == "string" ? (l(), f($e, { key: 0 }, [
4587
- We(b(qe), 1)
4588
- ], 64)) : (l(), me(As(qe), { key: 1 }))
4589
- ]))), 128))
4590
- ])
4591
- ]))), 128))
4592
- ])
4593
- ]),
4594
- _: 2
4595
- }, 1024)
4596
- ])
4597
- ])
4598
- ], 64);
4599
- }), 128))
4600
- ])) : (l(), f("div", ml, [
4601
- D(ue),
4602
- e("div", null, [
4603
- e("img", {
4604
- src: y(Wt),
4605
- alt: "List is empty"
4606
- }, null, 8, pl)
4607
- ]),
4608
- e("div", fl, b(y(g)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
4609
- e("div", vl, b(y(g)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
4610
- D(ue),
4611
- D(ue)
4612
- ]))
4613
- ])) : w.value.value === "actionLogs" ? (l(), f("div", Tl, [
4614
- ke.value.length ? (l(), f("div", Vl, [
4615
- (l(!0), f($e, null, Pe(ke.value, (G, he) => (l(), me(E, {
4616
- key: he,
4617
- variant: "outlined",
4618
- class: "py-12 px-16"
4619
- }, {
4620
- default: ae(() => {
4621
- var we;
4622
- return [
4623
- e("div", Ll, [
4624
- e("div", jl, [
4625
- e("div", Ul, b(y(ot)[G.action] ? y(g)(y(ot)[G.action].translationKey) : G.action), 1),
4626
- e("div", Ml, b(y(et)(G.changedAt)), 1)
4627
- ]),
4628
- e("div", Bl, b((we = G.changedBy) == null ? void 0 : we.name), 1),
4629
- G.remarks ? (l(), f("div", zl, b(G.remarks), 1)) : R("", !0)
4630
- ])
4631
- ];
4632
- }),
4633
- _: 2
4634
- }, 1024))), 128))
4635
- ])) : (l(), f("div", Il, [
4636
- D(ue),
4637
- e("div", null, [
4638
- e("img", {
4639
- src: y(Wt),
4640
- alt: "List is empty"
4641
- }, null, 8, El)
4642
- ]),
4643
- e("div", ql, b(y(g)("inventory.transfer.receiveRequest.details.noActionLogs")), 1),
4644
- D(ue),
4645
- D(ue)
4646
- ]))
4647
- ])) : R("", !0)
4648
- ])
4649
- ];
4650
- }),
4651
- "side-sheet-footer": ae(() => [
4652
- e("div", Kl, [
4653
- (l(!0), f($e, null, Pe(K.value, (h) => (l(), f($e, null, [
4654
- y(ot)[h].available != !1 ? (l(), me(S, {
4655
- key: h,
4656
- label: y(g)(y(ot)[h].translationKey),
4657
- onClick: (v) => B(h),
4658
- loading: Q.value === h,
4659
- disabled: Q.value !== h && J.value,
4660
- variant: y(ot)[h].buttonVariant
4661
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : R("", !0)
4662
- ], 64))), 256)),
4663
- y(C).ableToMarkReceived(n.purchaseOrder) && !K.value.includes("completeReceive") ? (l(), me(S, {
4664
- key: 0,
4665
- label: y(g)("inventory.transfer.receiveRequest.actions.completeReceive"),
4666
- onClick: i[5] || (i[5] = (h) => B("completeReceive")),
4667
- loading: Q.value === "completeReceive",
4668
- disabled: Q.value !== "completeReceive" && J.value
4669
- }, null, 8, ["label", "loading", "disabled"])) : R("", !0),
4670
- y(C).ableToMarkApproved(n.purchaseOrder) && n.canApprove && !K.value.includes("approveRequest") ? (l(), me(S, {
4671
- key: 1,
4672
- label: y(g)("inventory.transfer.approval.actions.approveRequest"),
4673
- onClick: i[6] || (i[6] = (h) => B("approveRequest")),
4674
- loading: Q.value === "approveRequest",
4675
- disabled: Q.value !== "approveRequest" && J.value
4676
- }, null, 8, ["label", "loading", "disabled"])) : R("", !0),
4677
- y(C).ableToCreateFulfillment(n.purchaseOrder, n.poRequest) && o.scope === "approval" ? (l(), me(S, {
4678
- key: 2,
4679
- label: y(g)("inventory.transfer.receiveRequest.actions.processRequest"),
4680
- onClick: i[7] || (i[7] = (h) => B("processRequest")),
4681
- loading: Q.value === "processRequest",
4682
- disabled: Q.value !== "processRequest" && J.value
4683
- }, null, 8, ["label", "loading", "disabled"])) : R("", !0),
4684
- D(S, {
4685
- label: y(g)("common.close"),
4686
- variant: "tertiary",
4687
- onClick: i[8] || (i[8] = (h) => a("update:show", !1))
4688
- }, null, 8, ["label"])
4689
- ])
4690
- ]),
4691
- _: 1
4692
- }, 8, ["modelValue", "dismiss-away"]);
4693
- };
4694
- }
4695
- });
4696
- export {
4697
- $t as P,
4698
- Oi as _,
4699
- ki as a,
4700
- xi as b,
4701
- dr as c,
4702
- cs as d,
4703
- us as e,
4704
- ds as f,
4705
- ls as g,
4706
- ps as h,
4707
- pt as i,
4708
- ms as j,
4709
- Pt as k,
4710
- Nt as l,
4711
- Si as u
4712
- };