@feedmepos/mf-inventory-portal 1.7.13 → 1.7.15-dev.0

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