@feedmepos/mf-inventory-portal 1.7.0-dev.3 → 1.7.0-dev.5

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