@feedmepos/mf-inventory-portal 1.2.61-dev.1 → 1.2.61

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 (126) hide show
  1. package/dist/{App-Dj4TFhg1.js → App-BqScGtJx.js} +78 -82
  2. package/dist/{ApprovalView-Cpbfph-H.js → ApprovalView-BFdlYIot.js} +5 -5
  3. package/dist/{BindingsDialog-CUbU9tih.js → BindingsDialog-Dvmrms77.js} +5 -5
  4. package/dist/{BindingsPicker-CMlAGOJT.js → BindingsPicker-fPVSXv-h.js} +3 -3
  5. package/dist/{BindingsTable-DvOE5QM2.js → BindingsTable-CnUa8VOi.js} +5 -5
  6. package/dist/{ClosingDraftView-DKv-ehO_.js → ClosingDraftView-10BcpWkm.js} +216 -217
  7. package/dist/{ClosingHistoryView-DIl78iH9.js → ClosingHistoryView-zLh0HCIb.js} +36 -36
  8. package/dist/{ClosingTemplateView-DPDh_geQ.js → ClosingTemplateView-BFupX87V.js} +14 -14
  9. package/dist/{DeliveryOrderPrintPreview-Bi3xgagw.js → DeliveryOrderPrintPreview-BLBqmOjw.js} +7 -7
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B_5_SxUn.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DN8ziFA_.js} +20 -20
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B3Kl8YBw.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DJT_7Uus.js} +2 -2
  12. package/dist/{FmMultiselectDialog-1IUxEPwt.js → FmMultiselectDialog-B5paZk6T.js} +16 -16
  13. package/dist/{FmMultiselectDialog-BSOTemHV.js → FmMultiselectDialog-DmnYEmN1.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BMK8Az4J.js → FmUnitInput.vue_vue_type_script_setup_true_lang-MW749j29.js} +22 -23
  15. package/dist/{ImportView-CkitDDEU.js → ImportView-BsI1_unJ.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DZUQavPo.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D8hvH-4n.js} +1 -1
  17. package/dist/{IngredientGroupView-ogDZwQFL.js → IngredientGroupView-BALVTSwF.js} +5 -5
  18. package/dist/{IngredientsView-B5AWPQhS.js → IngredientsView-C-sauieO.js} +24 -25
  19. package/dist/{IntegrationView-DIx6B_wR.js → IntegrationView-GG2E4Yrl.js} +17 -18
  20. package/dist/{InventoryBindingForm-CAs2PaKF.js → InventoryBindingForm-DCSBFj6b.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-D62U_Ewm.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-4_i25unG.js} +16 -17
  22. package/dist/{InventoryBindingSummary-DNWMJUDR.js → InventoryBindingSummary-6dFJPewB.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-flGJ-4xe.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CU9mgYbv.js} +5 -5
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CwcKHn69.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DC1HpuMm.js} +2 -2
  25. package/dist/{PublishView-IYCGQZF7.js → PublishView-DO7k1AeP.js} +8 -8
  26. package/dist/{PurchaseOrderPrintPreview-CQ-J1uJn.js → PurchaseOrderPrintPreview-C3VqOLCi.js} +11 -11
  27. package/dist/ReceiveRequestView-CpgLQtbw.js +2806 -0
  28. package/dist/RecipeView-C2D7FdzN.js +646 -0
  29. package/dist/{StockView-F7oGArF7.js → StockView-CtC3ldc6.js} +105 -106
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-j6pS_g4o.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cj6cVmd0.js} +1 -1
  31. package/dist/{SupplierView-DaDXVRF6.js → SupplierView-DKFtc22j.js} +19 -20
  32. package/dist/{SurchargeView-CBkF-szL.js → SurchargeView-B-EYMp6w.js} +6 -6
  33. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BDxbVt07.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CDeeFvnm.js} +2 -2
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DnoutmMc.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CH3hjFS8.js} +1 -1
  35. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-rAyYuhku.js +3493 -0
  36. package/dist/{TransferTemplateView-BlyMl_7M.js → TransferTemplateView-FeC34QoJ.js} +21 -22
  37. package/dist/{UnitView-JRqgYWbI.js → UnitView-BoJisnXd.js} +10 -11
  38. package/dist/{WarehouseView-Cb5Dj6f4.js → WarehouseView-s-xF6xJ0.js} +5 -5
  39. package/dist/{WastageTemplateView-DoyXkHM6.js → WastageTemplateView-BQBlHZLh.js} +14 -14
  40. package/dist/api/inventory.d.ts +36 -126
  41. package/dist/api/netsuite.d.ts +1 -8
  42. package/dist/{app-DMbbrEyL.js → app-_4kRbuQl.js} +7147 -8148
  43. package/dist/app.d.ts +0 -228
  44. package/dist/app.js +1 -1
  45. package/dist/{closing-template-B68c4BCg.js → closing-template-BBWYKm_X.js} +1 -1
  46. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -37
  47. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +0 -14
  48. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -16
  49. package/dist/{date2-WSrIZrGN.js → date2-Cd93SZu4.js} +1 -1
  50. package/dist/{dayjs.min-BEzS3oNC.js → dayjs.min-DeHn_Fz-.js} +16 -16
  51. package/dist/{defineDeepModel-B7GuNHyt.js → defineDeepModel-DUOLQh1E.js} +1 -1
  52. package/dist/{duplicate-template-BTdZ25aR.js → duplicate-template-BgpMF-fd.js} +1 -1
  53. package/dist/{feature-DJFFmYSS.js → feature-DqGkM6Yx.js} +1439 -1334
  54. package/dist/{format-time-from-id-BEqcrmTR.js → format-time-from-id-BkH4swoc.js} +1 -1
  55. package/dist/{format-unit-display-DIqyPFuN.js → format-unit-display-rkrD3WLD.js} +15 -16
  56. package/dist/{import-export.helper-Dnvx2Wa0.js → import-export.helper-C8Q4AMQx.js} +15 -16
  57. package/dist/{index-dh2P5FKl.js → index-B0WTs-3a.js} +1412 -1471
  58. package/dist/{index-J3wFLjDN.js → index-B3m_9m2a.js} +3 -3
  59. package/dist/{index-BNBtrozQ.js → index-O5M93j6z.js} +1 -1
  60. package/dist/{lodash-DoqYeksT.js → lodash-Dj6GdEkm.js} +1 -1
  61. package/dist/{netsuite-C87QvoFY.js → netsuite-DpQxb3vH.js} +60 -60
  62. package/dist/{purchase-order-template-CbRmEHxi.js → purchase-order-template-DKuo07gT.js} +1 -1
  63. package/dist/router/name.d.ts +0 -1
  64. package/dist/rules-D6o4zK8x.js +327 -0
  65. package/dist/{stock-DrdiXQFX.js → stock-D7HQf4-H.js} +1 -1
  66. package/dist/stock-DLFjfcAv.js +75 -0
  67. package/dist/stores/feature.d.ts +0 -2
  68. package/dist/stores/integration/netsuite.d.ts +1 -8
  69. package/dist/stores/inventory.d.ts +30 -119
  70. package/dist/{supplier-DWophRmk.js → supplier-B3kE2tbF.js} +2 -2
  71. package/dist/{surcharge-Ds9TtpDs.js → surcharge-Cc9vownX.js} +1 -1
  72. package/dist/tsconfig.app.tsbuildinfo +1 -1
  73. package/dist/{use-ingredient-select-dialog-CPugamev.js → use-ingredient-select-dialog-MnUTm-3P.js} +2 -2
  74. package/dist/{use-inventory-binding-dialog-Vj7T-h-w.js → use-inventory-binding-dialog-_J9LNiGo.js} +2 -2
  75. package/dist/{use-template-enabled-locations-2-DfKY5avH.js → use-template-enabled-locations-2-B9gbuIPM.js} +2 -2
  76. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -64
  77. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +24 -192
  78. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -8
  79. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +12 -96
  80. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +12 -96
  81. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +18 -18
  82. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +0 -14
  83. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +4 -32
  84. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -28
  85. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -8
  86. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +2 -16
  87. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +5 -33
  88. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -16
  89. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +4 -32
  90. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -8
  91. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +6 -41
  92. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +36 -246
  93. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -287
  94. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +0 -16
  95. package/dist/views/stock/components/StockRecordCard.vue.d.ts +0 -1
  96. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -16
  97. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +2 -16
  98. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +2 -16
  99. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -16
  100. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -8
  101. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +3 -24
  102. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +12 -96
  103. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +12 -96
  104. package/dist/{vue-i18n-Td4-wYd2.js → vue-i18n-BvsTy4Fg.js} +535 -535
  105. package/dist/{xlsx-DFL__z5b.js → xlsx-BvjocXXw.js} +398 -398
  106. package/dist/{xlsx.util-Bi7Vb-wa.js → xlsx.util-D65Nsat4.js} +1 -1
  107. package/package.json +3 -3
  108. package/dist/ReceiveRequestView-NOIHVxoI.js +0 -2916
  109. package/dist/RecipeView-KZV269Yw.js +0 -1558
  110. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B_u8kuNh.js +0 -3354
  111. package/dist/UnitCostHistoryView-B6mco57v.js +0 -651
  112. package/dist/api/unit-cost-history.d.ts +0 -28
  113. package/dist/number-nN9jCKom.js +0 -232
  114. package/dist/rules-Dbz4JyZU.js +0 -98
  115. package/dist/stock-ChSl_QOD.js +0 -75
  116. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -169
  117. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingAlternative.vue.d.ts +0 -43
  118. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingRule.vue.d.ts +0 -25
  119. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +0 -125
  120. package/dist/views/ingredients/components/inventory-binding/v2/components/InventorySkuBindingV2Field.vue.d.ts +0 -129
  121. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-alternative-table.d.ts +0 -30
  122. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +0 -4
  123. package/dist/views/unit-cost-history/UnitCostHistoryView.vue.d.ts +0 -2
  124. package/dist/views/unit-cost-history/components/UnitCostDetailsSideSheet.vue.d.ts +0 -19
  125. package/dist/views/unit-cost-history/components/UnitCostRecalculationDialog.vue.d.ts +0 -11
  126. package/dist/views/unit-cost-history/composables/use-unit-cost-history.d.ts +0 -65
@@ -1,2916 +0,0 @@
1
- import { computed as q, h as Y, defineComponent as le, openBlock as x, createElementBlock as P, Fragment as re, renderList as fe, createElementVNode as o, toDisplayString as I, unref as e, resolveComponent as O, createVNode as m, withCtx as A, createCommentVNode as K, ref as U, createBlock as se, watch as be, normalizeClass as W, normalizeStyle as kt, onMounted as Ze, createTextVNode as Ce, toRaw as qt, shallowRef as pt, onUnmounted as Ut, triggerRef as Nt, reactive as Bt, mergeProps as Xe, isRef as he, createSlots as zt, Teleport as Lt, normalizeProps as jt, guardReactiveProps as Ht } from "vue";
2
- import { t as de, s as pe, f as Ct, O as Qt, D as Yt, u as Ne, a as Be, P as ft, Q as Kt, T as Xt, U as Zt, V as Wt, v as Jt, y as wt, m as Me } from "./app-DMbbrEyL.js";
3
- import { i as vt, _ as Gt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B3Kl8YBw.js";
4
- import { u as es, P as Ye, a as ts, _ as ss, g as os } from "./TransferDetails.vue_vue_type_script_setup_true_lang-B_u8kuNh.js";
5
- import { a as xe, d as we, c as as } from "./number-nN9jCKom.js";
6
- import { _ as St, u as rs, i as ns, e as ls } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-CwcKHn69.js";
7
- import { d as yt } from "./dayjs.min-BEzS3oNC.js";
8
- import { u as is } from "./useTabStorage-BkIVScW_.js";
9
- import { u as us, _ as ds } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
10
- import { useBreakpoints as We, components as me, FmButtonVariant as cs, useSnackbar as Se, useDialog as ms, useProxiedModel as Ft } from "@feedmepos/ui-library";
11
- import { F as De } from "./form-mode.enum-BKiNVH6A.js";
12
- import { R as Te, A as Ue, M as ps, c as bt, B as fs } from "./rules-Dbz4JyZU.js";
13
- import { _ as vs, a as ys, b as bs, F as gs } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-BMK8Az4J.js";
14
- import { F as qe, u as ze, c as _s, P as hs } from "./feature-DJFFmYSS.js";
15
- import { u as Pe } from "./netsuite-C87QvoFY.js";
16
- import { useI18n as ge } from "@feedmepos/mf-common";
17
- import { u as $t } from "./surcharge-Ds9TtpDs.js";
18
- import { a as xs } from "./FmMultiselectDialog-1IUxEPwt.js";
19
- import { F as ce, _ as It } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
20
- import { u as Je } from "./supplier-DWophRmk.js";
21
- import { d as Ge, e as ks, g as Cs, b as ws } from "./date2-WSrIZrGN.js";
22
- import { u as Ss, _ as Fs } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B_5_SxUn.js";
23
- import { _ as $s } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
24
- import { a as Dt } from "./format-unit-display-DIqyPFuN.js";
25
- import { u as et } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BDxbVt07.js";
26
- import { u as Is } from "./vue-i18n-Td4-wYd2.js";
27
- import { s as Ds, r as Ts } from "./xlsx.util-Bi7Vb-wa.js";
28
- import { F as Ps } from "./FmDroppableField-J0xUsOTV.js";
29
- import { d as Vs } from "./defineDeepModel-B7GuNHyt.js";
30
- import { P as Rs, J as Os } from "./app-DiX-EfV6.js";
31
- var te = /* @__PURE__ */ ((f) => (f.Code = "Code", f.Name = "Name", f.TemplateName = "TemplateName", f.Amount = "Amount", f.Cost = "Cost", f.TotalCost = "TotalCost", f.Delete = "Delete", f))(te || {});
32
- const As = () => Y(
33
- St,
34
- {
35
- zIndex: 50,
36
- class: "whitespace-nowrap"
37
- },
38
- `Total (${Ct()})`
39
- );
40
- function Es(f) {
41
- const { t: b } = ge(), { breakpoints: d } = We(), u = ze(), _ = Pe();
42
- function n(i) {
43
- const t = f.formController.getAllPurchaseOrderItems().find((s) => s.item.sku._id === i);
44
- return (t == null ? void 0 : t.isCustomCost) ?? !1;
45
- }
46
- function g(i) {
47
- var s, a, r, C, $, c, v;
48
- return !!(((a = (s = i.defaultCost) == null ? void 0 : s.costPerUnit) == null ? void 0 : a.amount) ?? ((v = (c = ($ = (C = (r = f.supplier) == null ? void 0 : r.supplyItems) == null ? void 0 : C.find((T) => T.skuId === i._id)) == null ? void 0 : $.defaultCost) == null ? void 0 : c.costPerUnit) == null ? void 0 : v.amount));
49
- }
50
- function h(i) {
51
- if (!n(i.sku._id) && g(i.sku)) {
52
- const { cost: t, supplierOverrideCost: s } = qe.calculateDefaultCost({
53
- item: i.sku,
54
- amount: i.quantity,
55
- measurement: i.measurement,
56
- overrides: {
57
- supplier: f.supplier
58
- },
59
- defaultCurrency: pe()
60
- });
61
- return { cost: t, supplierOverrideCost: s };
62
- } else
63
- return {
64
- cost: i.totalCost ?? { amount: 0, precision: 0, currency: pe() }
65
- };
66
- }
67
- const F = [
68
- {
69
- id: "Code",
70
- header: () => b("inventory.transfer.form.items.table.Code"),
71
- accessorKey: "code",
72
- size: 200,
73
- cell(i) {
74
- const t = i.row.original;
75
- return _.isEnabled ? Y(
76
- me.FmTooltip,
77
- {
78
- content: t.code,
79
- placement: "top",
80
- variant: "plain",
81
- zIndex: 50
82
- },
83
- Y(
84
- "span",
85
- {
86
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
87
- },
88
- t.code
89
- )
90
- ) : Y(me.FmTextField, {
91
- modelValue: t.code,
92
- "onUpdate:modelValue": (s) => {
93
- f.updateItem({
94
- ...t,
95
- code: s
96
- });
97
- },
98
- key: t.sku._id,
99
- rules: [Te()],
100
- labelMark: "required"
101
- });
102
- },
103
- enableSorting: !1
104
- },
105
- {
106
- id: "Name",
107
- header: () => b("inventory.transfer.form.items.table.Name"),
108
- minSize: 300,
109
- cell(i) {
110
- const t = i.row.original;
111
- return _.isEnabled ? Y(
112
- me.FmTooltip,
113
- {
114
- content: t.name,
115
- placement: "top",
116
- variant: "plain",
117
- zIndex: 50
118
- },
119
- Y(
120
- "span",
121
- {
122
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
123
- },
124
- t.name
125
- )
126
- ) : Y(me.FmTextField, {
127
- modelValue: t.name,
128
- "onUpdate:modelValue": (s) => {
129
- f.updateItem({
130
- ...t,
131
- name: s
132
- });
133
- },
134
- key: t.sku._id,
135
- rules: [Te()],
136
- labelMark: "required"
137
- });
138
- },
139
- enableSorting: !1
140
- },
141
- {
142
- id: "TemplateName",
143
- header: () => b("inventory.transfer.form.items.table.Name"),
144
- minSize: 300,
145
- enableSorting: !1,
146
- cell(i) {
147
- const t = i.row.original, s = t.code, a = t.name;
148
- return Y(
149
- me.FmTooltip,
150
- { zIndex: 50 },
151
- {
152
- default() {
153
- return Y("div", { class: "flex flex-col w-full" }, [
154
- Y(
155
- "div",
156
- { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
157
- a
158
- ),
159
- Y(
160
- "div",
161
- {
162
- class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
163
- },
164
- s
165
- )
166
- ]);
167
- },
168
- content() {
169
- return a;
170
- }
171
- }
172
- );
173
- }
174
- },
175
- {
176
- id: "Amount",
177
- header: () => b("inventory.transfer.form.items.table.Amount"),
178
- minSize: 200,
179
- cell(i) {
180
- var C, $, c, v, T;
181
- const t = i.row.original, s = (C = f.forecastAmounts) == null ? void 0 : C.find((E) => E.skuId === t.sku._id), a = s ? s.helperState === "error" ? `Predicted: ${s.amount} (out of range)` : `Predicted: ${s.amount}` : void 0, r = (v = (c = ($ = f.template) == null ? void 0 : $.purchaseOrder) == null ? void 0 : c.items) == null ? void 0 : v.find(
182
- (E) => E.sku._id === t.sku._id
183
- );
184
- return Y(vs, {
185
- style: {
186
- flex: "1 1 0%"
187
- },
188
- modelValue: {
189
- amount: t.quantity ?? { amount: 1, precision: 0 },
190
- measurement: t.measurement ?? null
191
- },
192
- key: t.sku._id,
193
- unit: t.sku.unit,
194
- helperText: a,
195
- helperState: s == null ? void 0 : s.helperState,
196
- "onUpdate:modelValue": (E) => {
197
- if (!E) return;
198
- const Z = {
199
- ...t,
200
- quantity: E.amount,
201
- measurement: E.measurement
202
- };
203
- f.updateItem(Z);
204
- },
205
- stepper: r == null ? void 0 : r.quantityStep,
206
- disableUnit: !!r,
207
- disabled: f.disabled,
208
- rules: [
209
- ys(
210
- +xe(
211
- ((T = t.quantity) == null ? void 0 : T.amount) === 0 ? { amount: 0, precision: 0 } : (r == null ? void 0 : r.minimumQuantity) ?? { amount: 0, precision: 0 }
212
- )
213
- ),
214
- bs(
215
- r != null && r.maximumQuantity ? +xe(r == null ? void 0 : r.maximumQuantity) : 1 / 0
216
- ),
217
- ...r != null && r.quantityStep ? [gs(r.quantityStep)] : []
218
- ],
219
- applyDefaultRules: !0
220
- });
221
- },
222
- enableSorting: !1
223
- },
224
- {
225
- id: "Cost",
226
- header: As,
227
- size: 180,
228
- cell(i) {
229
- const t = i.row.original, s = g(t.sku), a = d.value.xs || d.value.sm;
230
- if (!n(t.sku._id) && s) {
231
- const { cost: r, supplierOverrideCost: C } = h(t);
232
- return Y(
233
- "div",
234
- {
235
- class: [
236
- "flex gap-4 fm-typo-en-body-md-400 items-center",
237
- f.disabled ? "text-fm-color-typo-disabled" : ""
238
- ],
239
- key: t.sku._id
240
- },
241
- [
242
- u.enablePurchaseOrderCostEdit ? Y(me.FmButton, {
243
- prependIcon: "edit",
244
- variant: cs.Tertiary,
245
- disabled: f.disabled,
246
- onClick() {
247
- f.updateItem(
248
- {
249
- ...t,
250
- totalCost: r
251
- },
252
- !0
253
- );
254
- }
255
- }) : null,
256
- Y(
257
- "div",
258
- {
259
- class: "flex flex-col"
260
- },
261
- [
262
- Y(
263
- "span",
264
- a ? we(r) : xe(r)
265
- ),
266
- Y(
267
- "span",
268
- {
269
- class: [
270
- "fm-typo-en-body-sm-400",
271
- f.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
272
- ]
273
- },
274
- b("inventory.transfer.form.items.autoCalculated")
275
- ),
276
- C ? Y(
277
- "span",
278
- {
279
- class: [
280
- "fm-typo-en-body-sm-400",
281
- f.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
282
- ]
283
- },
284
- [
285
- we(C.costPerUnit),
286
- "/",
287
- C.measurement ? Y(
288
- "span",
289
- { class: "text-blue-500 font-semibold" },
290
- C.measurement.abbrev
291
- ) : Y("span", { class: "text-green-500 font-bold" }, t.sku.unit.abbrev)
292
- // base unit style
293
- ]
294
- ) : null
295
- ]
296
- )
297
- ]
298
- );
299
- }
300
- return Y(
301
- me.FmTextField,
302
- {
303
- disabled: f.disabled || !u.enablePurchaseOrderCostEdit,
304
- modelValue: xe(t.totalCost ?? { amount: 0, precision: 0 }),
305
- key: t.sku._id,
306
- "onUpdate:modelValue": (r) => {
307
- u.enablePurchaseOrderCostEdit && f.updateItem(
308
- {
309
- ...t,
310
- totalCost: {
311
- ...as(+r),
312
- currency: pe()
313
- }
314
- },
315
- !0
316
- );
317
- },
318
- rules: [Ue(0), ps(2)]
319
- },
320
- {
321
- prepend() {
322
- return a ? Y(
323
- "div",
324
- {
325
- class: [
326
- "text-fm-typo-en-body-lg-400",
327
- f.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
328
- ]
329
- },
330
- Ct()
331
- ) : null;
332
- },
333
- append() {
334
- return !s || !u.enablePurchaseOrderCostEdit ? null : Y(me.FmButton, {
335
- prependIcon: "close",
336
- variant: "tertiary",
337
- disabled: f.disabled,
338
- onClick() {
339
- const { cost: r } = qe.calculateDefaultCost({
340
- item: t.sku,
341
- amount: t.quantity,
342
- measurement: t.measurement,
343
- overrides: {
344
- supplier: f.supplier
345
- },
346
- defaultCurrency: pe()
347
- });
348
- f.updateItem(
349
- {
350
- ...t,
351
- // NOTE: different from PO template, if a default cost is reenabled,
352
- // the total cost will automatically assigned
353
- totalCost: r
354
- },
355
- !1
356
- );
357
- }
358
- });
359
- }
360
- }
361
- );
362
- },
363
- enableSorting: !1
364
- },
365
- {
366
- id: "Delete",
367
- header: "",
368
- cell(i) {
369
- const t = i.row.original;
370
- return Y("div", { class: "flex justify-end" }, [
371
- Y(me.FmButton, {
372
- key: t.sku._id,
373
- class: "delete-button",
374
- type: "button",
375
- icon: "delete",
376
- variant: "tertiary",
377
- size: "md",
378
- disabled: f.disabled,
379
- onClick: () => {
380
- f.deleteItem(t);
381
- }
382
- })
383
- ]);
384
- },
385
- enableSorting: !1,
386
- size: 40,
387
- meta: {
388
- cellClass: "",
389
- headerClass: ""
390
- }
391
- }
392
- ], k = q(() => u.enableTotalCost && f.transferType === de.enum.purchase ? F : F.filter(
393
- (i) => i.id !== "Cost"
394
- /* Cost */
395
- )), y = q(() => ({
396
- ...f.items.reduce((t, s) => {
397
- const { cost: a } = h(s);
398
- return qe.add([t, a]);
399
- }, qe.reset()),
400
- currency: f.items[0] ? h(f.items[0]).cost.currency : pe()
401
- }));
402
- return {
403
- columnDefs: k,
404
- totalCost: y
405
- };
406
- }
407
- const Ms = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, qs = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Us = { class: "w-[450px] xs:w-full flex" }, Ns = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Bs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Tt = /* @__PURE__ */ le({
408
- __name: "SupplierPriceHistory",
409
- props: {
410
- prices: {}
411
- },
412
- setup(f) {
413
- const b = Je();
414
- function d(u) {
415
- return b.suppliers.find((_) => _._id === u);
416
- }
417
- return (u, _) => (x(), P("div", Ms, [
418
- (x(!0), P(re, null, fe(Object.keys(u.prices), (n) => {
419
- var g;
420
- return x(), P("div", {
421
- key: n,
422
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
423
- }, [
424
- o("div", qs, I((g = d(n)) == null ? void 0 : g.name), 1),
425
- o("div", Us, [
426
- (x(!0), P(re, null, fe(u.prices[n].slice(0, 3), (h) => {
427
- var F;
428
- return x(), P("div", {
429
- key: h.date,
430
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
431
- }, [
432
- o("div", Ns, [
433
- o("span", null, I(h.totalCost ? e(we)(h.totalCost) : "No data"), 1),
434
- _[0] || (_[0] = o("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
435
- o("span", null, I(e(xe)(h.totalUnit, !1)), 1),
436
- o("span", null, I(((F = h.measurement) == null ? void 0 : F.abbrev) ?? h.unit.abbrev), 1)
437
- ]),
438
- o("div", Bs, [
439
- o("span", null, "(#" + I(h.seqNumber) + ")", 1),
440
- _[1] || (_[1] = o("span", null, I(" "), -1)),
441
- o("span", null, I(e(Ge)(new Date(h.date))), 1)
442
- ])
443
- ]);
444
- }), 128))
445
- ])
446
- ]);
447
- }), 128))
448
- ]));
449
- }
450
- }), zs = { class: "flex flex-col gap-8 py-16" }, Ls = { class: "flex items-center" }, js = { class: "flex-1 flex gap-1 items-center" }, Hs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Qs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ys = { class: "flex gap-8 w-full" }, Ks = { class: "flex-1 flex flex-col gap-4" }, Xs = { class: "flex-1 flex flex-col gap-4" }, Zs = { class: "flex gap-8 w-full" }, Ws = { class: "flex-1 flex flex-col gap-4" }, Js = {
451
- key: 0,
452
- class: "flex-1 flex flex-col gap-4"
453
- }, Gs = /* @__PURE__ */ le({
454
- __name: "TransferItem",
455
- props: {
456
- cellByColId: {},
457
- comparePriceBySku: {},
458
- showComparePrice: { type: Boolean },
459
- row: {}
460
- },
461
- setup(f) {
462
- const { t: b } = ge();
463
- return (d, u) => {
464
- var g, h, F, k, y, i, t, s, a, r, C, $, c, v, T, E, Z, z, X, N, B, V, D, M, L, J, oe;
465
- const _ = O("FmLabel"), n = O("FmSpacer");
466
- return x(), P("div", zs, [
467
- o("div", Ls, [
468
- o("div", js, [
469
- o("span", Hs, " (" + I(d.row.original.sku.code) + ") ", 1),
470
- o("span", Qs, I(d.row.original.sku.name), 1)
471
- ]),
472
- o("div", null, [
473
- m(e(ce), {
474
- render: (F = (h = (g = d.cellByColId.Delete) == null ? void 0 : g.column) == null ? void 0 : h.columnDef) == null ? void 0 : F.cell,
475
- props: (y = (k = d.cellByColId.Delete) == null ? void 0 : k.getContext) == null ? void 0 : y.call(k)
476
- }, null, 8, ["render", "props"])
477
- ])
478
- ]),
479
- o("div", Ys, [
480
- o("div", Ks, [
481
- m(_, {
482
- label: e(b)(`inventory.transfer.form.items.table.${e(te).Code}`)
483
- }, null, 8, ["label"]),
484
- m(e(ce), {
485
- render: (s = (t = (i = d.cellByColId[e(te).Code]) == null ? void 0 : i.column) == null ? void 0 : t.columnDef) == null ? void 0 : s.cell,
486
- props: (r = (a = d.cellByColId[e(te).Code]) == null ? void 0 : a.getContext) == null ? void 0 : r.call(a)
487
- }, null, 8, ["render", "props"]),
488
- u[0] || (u[0] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
489
- ]),
490
- o("div", Xs, [
491
- m(_, {
492
- label: e(b)(`inventory.transfer.form.items.table.${e(te).Name}`)
493
- }, null, 8, ["label"]),
494
- m(e(ce), {
495
- render: (c = ($ = (C = d.cellByColId[e(te).Name]) == null ? void 0 : C.column) == null ? void 0 : $.columnDef) == null ? void 0 : c.cell,
496
- props: (T = (v = d.cellByColId[e(te).Name]) == null ? void 0 : v.getContext) == null ? void 0 : T.call(v)
497
- }, null, 8, ["render", "props"]),
498
- u[1] || (u[1] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
499
- ])
500
- ]),
501
- o("div", Zs, [
502
- o("div", Ws, [
503
- m(_, {
504
- label: e(b)(`inventory.transfer.form.items.table.${e(te).Amount}`)
505
- }, null, 8, ["label"]),
506
- m(e(ce), {
507
- render: (z = (Z = (E = d.cellByColId[e(te).Amount]) == null ? void 0 : E.column) == null ? void 0 : Z.columnDef) == null ? void 0 : z.cell,
508
- props: (N = (X = d.cellByColId[e(te).Amount]) == null ? void 0 : X.getContext) == null ? void 0 : N.call(X)
509
- }, null, 8, ["render", "props"]),
510
- u[2] || (u[2] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
511
- ]),
512
- d.cellByColId[e(te).Cost] ? (x(), P("div", Js, [
513
- m(St, { "z-index": 50 }, {
514
- default: A(() => [
515
- m(_, {
516
- label: e(b)(`inventory.transfer.form.items.table.${e(te).Cost}2`)
517
- }, null, 8, ["label"])
518
- ]),
519
- _: 1
520
- }),
521
- m(e(ce), {
522
- render: (D = (V = (B = d.cellByColId[e(te).Cost]) == null ? void 0 : B.column) == null ? void 0 : V.columnDef) == null ? void 0 : D.cell,
523
- props: (L = (M = d.cellByColId[e(te).Cost]) == null ? void 0 : M.getContext) == null ? void 0 : L.call(M)
524
- }, null, 8, ["render", "props"]),
525
- u[3] || (u[3] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
526
- ])) : K("", !0)
527
- ]),
528
- d.showComparePrice && Object.keys(d.comparePriceBySku[(J = d.row.original.sku) == null ? void 0 : J._id] ?? {}).length > 0 ? (x(), P(re, { key: 0 }, [
529
- m(n, { class: "h-8" }),
530
- m(Tt, {
531
- prices: d.comparePriceBySku[(oe = d.row.original.sku) == null ? void 0 : oe._id]
532
- }, null, 8, ["prices"])
533
- ], 64)) : K("", !0)
534
- ]);
535
- };
536
- }
537
- });
538
- function eo(f) {
539
- const b = q({
540
- get() {
541
- const n = f.getEffectiveAt();
542
- return n ? new Date(n) : null;
543
- },
544
- set(n) {
545
- f.setEffectiveAt((n == null ? void 0 : n.toISOString()) ?? null);
546
- }
547
- }), d = q({
548
- get() {
549
- return !!b.value;
550
- },
551
- set(n) {
552
- n ? b.value = /* @__PURE__ */ new Date() : b.value = null;
553
- }
554
- }), u = q({
555
- get() {
556
- return b.value === null ? "" : Ge(b.value);
557
- },
558
- set(n) {
559
- n ? b.value = /* @__PURE__ */ new Date(`${n} ${_.value}`) : b.value = null;
560
- }
561
- }), _ = q({
562
- get() {
563
- return b.value === null ? "" : ks(b.value);
564
- },
565
- set(n) {
566
- n ? b.value = /* @__PURE__ */ new Date(`${u.value} ${n}`) : b.value = null;
567
- }
568
- });
569
- return {
570
- backdatePo: b,
571
- backdateSwitch: d,
572
- backdateModel: u,
573
- backdateTimeModel: _
574
- };
575
- }
576
- const to = {
577
- width: "24",
578
- height: "24",
579
- viewBox: "0 0 24 24",
580
- fill: "none",
581
- xmlns: "http://www.w3.org/2000/svg"
582
- }, so = ["fill"], oo = ["fill"], ao = ["stroke"], ro = ["stroke"], no = /* @__PURE__ */ le({
583
- __name: "SparkIcon",
584
- props: {
585
- size: {
586
- type: Number,
587
- default: 24
588
- },
589
- color: {
590
- type: String,
591
- default: "#c7c7cc"
592
- }
593
- },
594
- setup(f) {
595
- return (b, d) => (x(), P("svg", to, [
596
- o("path", {
597
- d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
598
- fill: f.color
599
- }, null, 8, so),
600
- o("path", {
601
- d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
602
- fill: f.color
603
- }, null, 8, oo),
604
- o("path", {
605
- d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
606
- stroke: f.color,
607
- "stroke-width": "1.5",
608
- "stroke-linecap": "round",
609
- "stroke-linejoin": "round"
610
- }, null, 8, ao),
611
- o("path", {
612
- d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
613
- stroke: f.color,
614
- "stroke-width": "1.5",
615
- "stroke-linecap": "round",
616
- "stroke-linejoin": "round"
617
- }, null, 8, ro)
618
- ]));
619
- }
620
- }), lo = { class: "flex gap-8 items-center" }, io = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, uo = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, co = { class: "flex items-center w-full" }, mo = { class: "flex-1" }, po = { class: "fm-typo-en-title-sm-800" }, fo = { class: "flex items-start gap-8" }, vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, yo = { class: "flex gap-1" }, bo = /* @__PURE__ */ le({
621
- __name: "ForecastStock",
622
- props: {
623
- templateId: {},
624
- disabled: { type: Boolean },
625
- poItems: {},
626
- templateItems: {}
627
- },
628
- emits: ["update:poItems", "update:forecastAmounts", "update:predictionId"],
629
- setup(f, { emit: b }) {
630
- const d = f, u = b, _ = U(!1), n = U(7), g = rs(), h = Se(), { t: F } = ge();
631
- function k(s, a, r) {
632
- return a != null && s < a && (s = a), r != null && s > r && (s = r), s;
633
- }
634
- function y(s) {
635
- if (!((s == null ? void 0 : s.amount) == null || (s == null ? void 0 : s.precision) == null))
636
- return s.amount / Math.pow(10, s.precision);
637
- }
638
- function i({
639
- sku: s,
640
- code: a,
641
- name: r,
642
- baseAmount: C,
643
- measurement: $,
644
- min: c,
645
- max: v
646
- }) {
647
- if ($) {
648
- const T = $.conversion.amount;
649
- let E = Math.ceil(C / T);
650
- return E = k(E, c, v), {
651
- sku: s,
652
- code: a,
653
- name: r,
654
- quantity: { amount: E, precision: 0 },
655
- measurement: $
656
- };
657
- } else {
658
- const T = Math.ceil(k(C, c, v));
659
- return {
660
- sku: s,
661
- code: a,
662
- name: r,
663
- quantity: { amount: T, precision: 0 },
664
- measurement: null
665
- };
666
- }
667
- }
668
- async function t() {
669
- const s = bt(0)(n.value);
670
- if (typeof s == "string") {
671
- h.open({
672
- message: s,
673
- type: "error"
674
- });
675
- return;
676
- }
677
- _.value = !1, await g.readPurchaseOrder(n.value, d.templateId);
678
- const a = g.purchaseOrderForecast.skus;
679
- if (a.length === 0) {
680
- h.open({
681
- message: F("inventory.transfer.form.items.forecastStock.notAvailable"),
682
- type: "info"
683
- }), u("update:predictionId", g.purchaseOrderForecast.prediction_id);
684
- return;
685
- }
686
- const r = d.templateItems.reduce(($, c) => {
687
- var Z;
688
- const v = (Z = d.poItems) == null ? void 0 : Z.find((z) => z.sku._id === c.sku._id), T = a.find((z) => z.id === c.sku._id);
689
- if (!T)
690
- return v && $.push(v), $;
691
- if (!d.templateId && T.amount <= 0) return $;
692
- const E = T.amount ?? y(v == null ? void 0 : v.quantity) ?? 0;
693
- return $.push(
694
- i({
695
- sku: c.sku,
696
- code: c.code,
697
- name: c.name,
698
- baseAmount: E,
699
- measurement: c.measurement || null,
700
- min: y(c.minimumQuantity),
701
- max: y(c.maximumQuantity)
702
- })
703
- ), $;
704
- }, []), C = a.map(($) => {
705
- const c = d.templateItems.find((X) => X.sku._id === $.id);
706
- let v = $.amount, T = 0;
707
- if (c != null && c.measurement) {
708
- const X = y(c.measurement.conversion) ?? 1;
709
- v = Math.ceil($.amount / X);
710
- } else
711
- v = Math.ceil($.amount);
712
- const E = y(c == null ? void 0 : c.minimumQuantity) ?? 0, Z = y(c == null ? void 0 : c.maximumQuantity) ?? 1 / 0, z = v < E || v > Z ? "error" : "success";
713
- return { skuId: $.id, amount: v, precision: T, helperState: z };
714
- });
715
- u("update:poItems", r), u("update:forecastAmounts", C), u("update:predictionId", g.purchaseOrderForecast.prediction_id);
716
- }
717
- return (s, a) => {
718
- const r = O("FmButton"), C = O("FmIcon"), $ = O("FmStepperField"), c = O("FmPopover");
719
- return x(), se(c, {
720
- disabled: s.disabled,
721
- class: "flex",
722
- "show-popover": _.value,
723
- onPopoverChanged: a[3] || (a[3] = (v) => _.value = v)
724
- }, {
725
- "popover-button": A(() => [
726
- m(r, {
727
- label: "unused",
728
- variant: "secondary",
729
- "text-color": s.disabled ? "disabled" : "primary",
730
- "bg-color": "transparent",
731
- "border-color": s.disabled ? "disabled" : "primary",
732
- disabled: s.disabled
733
- }, {
734
- default: A(() => [
735
- o("div", lo, [
736
- m(no, {
737
- size: 24,
738
- color: s.disabled ? "#c7c7cc" : "#ff7823"
739
- }, null, 8, ["color"]),
740
- o("div", io, I(e(F)("inventory.transfer.form.items.forecastStock.title")), 1)
741
- ])
742
- ]),
743
- _: 1
744
- }, 8, ["text-color", "border-color", "disabled"])
745
- ]),
746
- default: A(() => [
747
- o("div", uo, [
748
- o("div", co, [
749
- o("div", mo, [
750
- m($s, { "z-index": 99 }, {
751
- default: A(() => [
752
- o("p", po, I(e(F)("inventory.transfer.form.items.forecastStock.title")), 1)
753
- ]),
754
- _: 1
755
- })
756
- ]),
757
- m(r, {
758
- icon: "close",
759
- size: "md",
760
- variant: "tertiary",
761
- onClick: a[0] || (a[0] = (v) => _.value = !1)
762
- })
763
- ]),
764
- m($, {
765
- modelValue: n.value,
766
- "onUpdate:modelValue": a[1] || (a[1] = (v) => n.value = v),
767
- label: e(F)("inventory.transfer.form.items.forecastStock.days"),
768
- rules: [e(bt)(0)]
769
- }, {
770
- "helper-text": A(() => [
771
- o("div", fo, [
772
- m(C, {
773
- name: "warning",
774
- size: "sm",
775
- class: "text-fm-color-system-warning-300"
776
- }),
777
- o("div", vo, I(e(F)("inventory.transfer.form.items.forecastStock.replace")), 1)
778
- ])
779
- ]),
780
- _: 1
781
- }, 8, ["modelValue", "label", "rules"]),
782
- o("div", yo, [
783
- a[4] || (a[4] = o("div", { class: "grow" }, null, -1)),
784
- m(r, {
785
- label: e(F)("common.cancel"),
786
- variant: "tertiary",
787
- onClick: a[2] || (a[2] = (v) => _.value = !1)
788
- }, null, 8, ["label"]),
789
- m(r, {
790
- label: e(F)("inventory.transfer.form.items.forecastStock.generate"),
791
- onClick: t
792
- }, null, 8, ["label"])
793
- ])
794
- ])
795
- ]),
796
- _: 1
797
- }, 8, ["disabled", "show-popover"]);
798
- };
799
- }
800
- });
801
- function go() {
802
- const f = Se(), b = et(), d = U(!1);
803
- be(d, (g) => {
804
- g && (_.value = !0, u().finally(() => {
805
- _.value = !1;
806
- }));
807
- });
808
- async function u() {
809
- try {
810
- const { startDate: g, endDate: h } = Cs(6), y = (await b.getPurchaseOrders({ start: g, end: h })).filter(
811
- (i) => {
812
- var t, s;
813
- return i.status === Qt.enum.COMPLETE && ((t = i.supplier) == null ? void 0 : t.internal) !== "warehouse" && ((s = i.supplier) == null ? void 0 : s.internal) !== "restaurant";
814
- }
815
- ).reduce((i, t) => {
816
- const s = new Date(Yt(t._id)), a = t.supplier._id;
817
- for (const r of t.items) {
818
- if (!r.totalCost) continue;
819
- const C = i[r.sku._id] ?? {}, $ = C[a] ?? [];
820
- $.push({
821
- date: s.toISOString(),
822
- totalUnit: r.quantity,
823
- totalCost: r.totalCost,
824
- unit: r.sku.unit,
825
- measurement: r.measurement,
826
- seqNumber: t.seqNumber
827
- }), C[a] = $, i[r.sku._id] = C;
828
- }
829
- return i;
830
- }, {});
831
- n.value = y;
832
- } catch {
833
- f.open({
834
- title: "Something went wrong",
835
- message: "Cannot retrieve supplier purchase history. Please try again."
836
- }), d.value = !1;
837
- }
838
- }
839
- const _ = U(!1), n = U({});
840
- return {
841
- comparePricesToggle: d,
842
- comparePriceFetching: _,
843
- comparePriceBySku: n
844
- };
845
- }
846
- const _o = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, ho = { key: 0 }, xo = ["colspan"], ko = /* @__PURE__ */ le({
847
- __name: "TransferItemTable",
848
- props: {
849
- templateItem: {},
850
- row: {},
851
- comparePriceBySku: {},
852
- showComparePrice: { type: Boolean },
853
- disabled: { type: Boolean }
854
- },
855
- emits: ["update:item"],
856
- setup(f) {
857
- function b(d) {
858
- return d.column.columnDef.meta;
859
- }
860
- return (d, u) => {
861
- var _, n;
862
- return x(), P(re, null, [
863
- o("tr", {
864
- class: W(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
865
- "bg-fm-color-neutral-gray-100": d.row.getIsSelected()
866
- }])
867
- }, [
868
- (x(!0), P(re, null, fe(d.row.getVisibleCells(), (g) => {
869
- var h, F, k, y;
870
- return x(), P("td", {
871
- key: g.id,
872
- class: W(["h-[56px] text-fm-color-typo-primary", ((h = b(g)) == null ? void 0 : h.cellClass) ?? "px-16"]),
873
- style: kt({
874
- width: (F = b(g)) == null ? void 0 : F.width,
875
- maxWidth: (k = b(g)) == null ? void 0 : k.maxWidth,
876
- textAlign: ((y = b(g)) == null ? void 0 : y.textAlign) ?? "left"
877
- })
878
- }, [
879
- o("span", _o, [
880
- m(e(ce), {
881
- render: g.column.columnDef.cell,
882
- props: g.getContext()
883
- }, null, 8, ["render", "props"])
884
- ])
885
- ], 6);
886
- }), 128))
887
- ], 2),
888
- d.showComparePrice && Object.keys(d.comparePriceBySku[(_ = d.row.original.sku) == null ? void 0 : _._id] ?? {}).length > 0 ? (x(), P("tr", ho, [
889
- o("td", {
890
- colspan: d.row.getVisibleCells().length
891
- }, [
892
- m(Tt, {
893
- prices: d.comparePriceBySku[(n = d.row.original.sku) == null ? void 0 : n._id]
894
- }, null, 8, ["prices"])
895
- ], 8, xo)
896
- ])) : K("", !0)
897
- ], 64);
898
- };
899
- }
900
- }), Co = {
901
- key: 0,
902
- class: "flex flex-col gap-8"
903
- }, wo = { class: "flex flex-col gap-4" }, So = { class: "flex items-center gap-4" }, Fo = {
904
- key: 0,
905
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
906
- }, $o = /* @__PURE__ */ le({
907
- __name: "NetSuiteField",
908
- props: {
909
- required: { type: Boolean },
910
- disabled: { type: Boolean },
911
- subsidiaryOptional: { type: Boolean },
912
- supplier: {},
913
- setting: {},
914
- items: {},
915
- onChange: { type: Function }
916
- },
917
- emits: ["netsuite:ready"],
918
- setup(f, { emit: b }) {
919
- const d = Pe(), u = f, _ = b, { t: n } = Is(), g = U(!1), h = U();
920
- function F() {
921
- var s, a, r, C;
922
- if (!u.supplier) return;
923
- u.supplier.internal ? h.value = d.getNetSuiteLocation(
924
- `${u.supplier.internal}_${u.supplier._id}`
925
- ) : h.value = d.getNetSuiteVendor(u.supplier._id);
926
- const i = u.supplier.internal ? d.getLocationSubsidiary((s = h.value) == null ? void 0 : s.netSuiteId).id : (a = h.value) == null ? void 0 : a.subsidiaryId, t = u.supplier.internal ? (r = d.currentLocationSubsidiary()) == null ? void 0 : r.id : (C = d.currentVendorSubsidiary(u.supplier._id)) == null ? void 0 : C.id;
927
- g.value = !(!d.isEnabled || i && d.isEnabled && i == t);
928
- }
929
- be(
930
- () => u.supplier,
931
- () => {
932
- u.subsidiaryOptional && F();
933
- },
934
- { deep: !0 }
935
- ), Ze(() => {
936
- let i = {
937
- id: "",
938
- subsidiary: { id: "", name: "" },
939
- errors: []
940
- };
941
- if (d.isReady) {
942
- if (!d.isEnabled || !u.required) {
943
- _("netsuite:ready", i);
944
- return;
945
- }
946
- try {
947
- const t = d.currentLocationSubsidiary();
948
- u.setting ? i = {
949
- ...u.setting,
950
- subsidiary: {
951
- id: t.id || "",
952
- name: t.name
953
- }
954
- } : i = {
955
- ...i,
956
- subsidiary: {
957
- id: t.id || "",
958
- name: t.name
959
- }
960
- };
961
- const s = d.getAvailableItems(t.id), a = u.items.filter((r) => {
962
- if (r.measurement != null) {
963
- const C = d.getAvailableMeasurements(
964
- r.sku._id,
965
- t.id
966
- );
967
- return s.includes(r.sku._id) && C.includes(r.measurement.id);
968
- }
969
- return s.includes(r.sku._id);
970
- }).map((r) => r.sku._id);
971
- u.onChange(
972
- u.items.filter((r) => a.includes(r.sku._id)),
973
- i
974
- );
975
- } finally {
976
- F(), g.value ? u.subsidiaryOptional && _("netsuite:ready", i) : _("netsuite:ready", i);
977
- }
978
- }
979
- });
980
- const k = q(
981
- () => u.supplier.internal ? d.currentLocationSubsidiary() : d.currentVendorSubsidiary(u.supplier._id)
982
- ), y = q(() => {
983
- var i, t;
984
- return h.value == null ? `Cannot find the NetSuite location for "${u.supplier.name}"` : `The subsidiary of the request
985
- location is ${(t = d.getLocationSubsidiary((i = h.value) == null ? void 0 : i.netSuiteId)) == null ? void 0 : t.fullName}`;
986
- });
987
- return (i, t) => {
988
- const s = O("FmLabel"), a = O("FmIcon"), r = O("FmField"), C = O("FmTooltip");
989
- return e(d).isEnabled && u.required ? (x(), P("div", Co, [
990
- m(s, {
991
- label: `NetSuite ${e(n)("inventory.transfer.form.netsuite.subsidiary")}`
992
- }, null, 8, ["label"]),
993
- o("div", wo, [
994
- m(C, {
995
- "z-index": 51,
996
- placement: "left",
997
- disabled: i.disabled
998
- }, {
999
- content: A(() => t[0] || (t[0] = [
1000
- Ce("This field is locked and based on the location of the request.")
1001
- ])),
1002
- default: A(() => [
1003
- m(r, null, {
1004
- default: A(() => {
1005
- var $;
1006
- return [
1007
- o("div", So, [
1008
- m(a, {
1009
- name: "lock_outline",
1010
- size: "sm",
1011
- color: i.disabled ? "neutral-gray-200" : "neutral-gray-400"
1012
- }, null, 8, ["color"]),
1013
- o("div", {
1014
- class: W([i.disabled ? "text-fm-color-typo-disabled" : ""])
1015
- }, I(($ = k.value) == null ? void 0 : $.fullName), 3)
1016
- ])
1017
- ];
1018
- }),
1019
- _: 1
1020
- })
1021
- ]),
1022
- _: 1
1023
- }, 8, ["disabled"]),
1024
- g.value ? (x(), P("div", Fo, I(y.value), 1)) : K("", !0)
1025
- ])
1026
- ])) : K("", !0);
1027
- };
1028
- }
1029
- });
1030
- function ye(f) {
1031
- const b = qt(f);
1032
- if (Array.isArray(b))
1033
- return b.map(ye);
1034
- if (b !== null && typeof b == "object") {
1035
- const d = {};
1036
- for (const u in b)
1037
- Object.prototype.hasOwnProperty.call(b, u) && (d[u] = ye(b[u]));
1038
- return d;
1039
- }
1040
- return b;
1041
- }
1042
- const Ke = {
1043
- set: "set",
1044
- add: "add",
1045
- delete: "delete"
1046
- };
1047
- function gt(f) {
1048
- return {
1049
- dbName: f.dbName,
1050
- type: f.type,
1051
- name: f.name,
1052
- acceptRequest: f.acceptRequest ?? !1,
1053
- doc: f.doc
1054
- };
1055
- }
1056
- function _t(f, b, d, u, _) {
1057
- const n = ye(f.suppliers ?? []), g = ye(b.allLocations ?? []).map(gt), h = b._currentLocation ? gt(ye(b._currentLocation)) : null, F = d.inventory ? [ye(d.inventory)] : [], k = u.state.setting ? ye(u.state.setting) : null, y = ye(_.surcharges ?? []);
1058
- return {
1059
- suppliers: n,
1060
- locations: g,
1061
- currentLocation: h,
1062
- inventoryDoc: F,
1063
- netSuiteSetting: k,
1064
- surcharges: y
1065
- };
1066
- }
1067
- function Io() {
1068
- const f = Je(), b = Ne(), d = Be(), u = Pe(), _ = $t(), n = _t(
1069
- f,
1070
- b,
1071
- d,
1072
- u,
1073
- _
1074
- ), g = pt(_s({ env: n }));
1075
- g.value.setUsePartialUpdates(!0);
1076
- const h = pt(g.value.state()), F = (t) => {
1077
- h.value = t;
1078
- };
1079
- g.value.addListener(F);
1080
- const k = (t, s, a) => {
1081
- switch (t) {
1082
- case Ke.set:
1083
- ft(h.value, s, a);
1084
- break;
1085
- case Ke.add:
1086
- Xt(h.value, s, a);
1087
- break;
1088
- case Ke.delete:
1089
- Kt(h.value, s);
1090
- break;
1091
- default:
1092
- console.warn(`Unknown partial update operation: ${t}, falling back to 'set'`), ft(h.value, s, a);
1093
- }
1094
- s !== "remark" && s !== "ref" && Nt(h);
1095
- };
1096
- g.value.addPartialListener(k);
1097
- function y() {
1098
- const t = _t(
1099
- f,
1100
- b,
1101
- d,
1102
- u,
1103
- _
1104
- );
1105
- g.value.updateFullEnv(t), h.value = g.value.state();
1106
- }
1107
- be(
1108
- [
1109
- () => f.suppliers,
1110
- () => b.allLocations,
1111
- () => b._currentLocation,
1112
- () => d.inventory,
1113
- () => u.state.setting,
1114
- () => _.surcharges
1115
- ],
1116
- () => {
1117
- y();
1118
- },
1119
- { deep: !0 }
1120
- ), Ut(() => {
1121
- g.value.removeListener(F), g.value.removePartialListener(k);
1122
- });
1123
- function i(t) {
1124
- var s;
1125
- if (t != null && t._id) {
1126
- g.value.loadPurchaseOrder(t);
1127
- return;
1128
- }
1129
- if (!ze().mustUsePoTemplate) {
1130
- g.value.init();
1131
- return;
1132
- }
1133
- t != null && t.template && ((s = t.templateDoc) != null && s.purchaseOrder) ? (t.items = t.templateDoc.purchaseOrder.items, g.value.initFromTemplate(t)) : g.value.initOutletToOutlet();
1134
- }
1135
- return {
1136
- controller: g,
1137
- state: h,
1138
- init: i
1139
- };
1140
- }
1141
- const Do = { class: "flex flex-col gap-4" }, To = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, Po = { class: "flex flex-col gap-16" }, Vo = { class: "flex flex-col gap-24" }, Ro = { class: "flex flex-col gap-8" }, Oo = { class: "flex flex-col gap-4" }, Ao = { class: "flex items-center gap-4" }, Eo = { class: "flex flex-col gap-8" }, Mo = { class: "flex flex-col gap-4" }, qo = { class: "flex items-center gap-4" }, Uo = {
1142
- key: 3,
1143
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1144
- }, No = {
1145
- key: 0,
1146
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1147
- }, Bo = { class: "flex-1" }, zo = { class: "flex-1" }, Lo = {
1148
- key: 1,
1149
- class: "flex items-center gap-4"
1150
- }, jo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Ho = { class: "flex flex-col gap-16" }, Qo = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Yo = { class: "flex gap-8" }, Ko = { key: 0 }, Xo = {
1151
- key: 0,
1152
- class: "flex justify-end p-16 border-t border-fm-color-neutral-gray-300"
1153
- }, Zo = { class: "flex items-center gap-16" }, Wo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, Jo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Go = {
1154
- key: 1,
1155
- class: "flex flex-col gap-16"
1156
- }, ea = { class: "flex items-center gap-8" }, ta = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, sa = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-8" }, oa = { class: "flex flex-col gap-8 border border-fm-color-neutral-gray-300 fm-corner-radius-md overflow-hidden" }, aa = { class: "flex flex-col gap-4 flex-1" }, ra = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, na = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, la = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary whitespace-nowrap ml-16" }, ia = /* @__PURE__ */ le({
1157
- __name: "TransferFormWithController",
1158
- props: {
1159
- modelValue: {},
1160
- request: {},
1161
- disabled: { type: Boolean },
1162
- suppliers: {},
1163
- skus: {},
1164
- lastClosingDate: {}
1165
- },
1166
- emits: ["validation-success", "form:ready"],
1167
- setup(f, { expose: b, emit: d }) {
1168
- const u = f, _ = d, { t: n } = ge(), g = Ne(), h = Be(), F = $t(), k = ze(), y = Dt(), { breakpoints: i } = We(), t = q(() => i.value.xs || i.value.sm), s = Io();
1169
- s.init(u.modelValue);
1170
- const { controller: a, state: r } = s, C = Bt({
1171
- value: !1
1172
- }), $ = U(!1), c = U(0), v = U([]), T = U(void 0), E = q(
1173
- () => {
1174
- var l;
1175
- return ((l = u.modelValue) == null ? void 0 : l.templateDoc) ?? y.templates.find((p) => {
1176
- var j;
1177
- return p._id === ((j = u.modelValue) == null ? void 0 : j.template);
1178
- });
1179
- }
1180
- ), Z = q(() => r.value.status === "DRAFT" || !r.value.rev), z = q(
1181
- () => {
1182
- var l;
1183
- return ((l = r.value.items) == null ? void 0 : l.map((p) => p.item)) || [];
1184
- }
1185
- );
1186
- Ze(async () => {
1187
- await F.browse(), $.value = !0;
1188
- }), be([$, C], ([l, p], [j, H]) => {
1189
- p.value && H.value && _("form:ready");
1190
- });
1191
- const X = q(
1192
- () => g.currentLocation.type === Zt.restaurant
1193
- ), N = ms(), B = Ss(
1194
- () => r.value,
1195
- (l) => {
1196
- a.value.selectSupplier(l.supplier._id);
1197
- },
1198
- !0,
1199
- !k.businessSupplierOnly
1200
- ), V = q({
1201
- get() {
1202
- var l;
1203
- return typeof ((l = r.value.supplier) == null ? void 0 : l.internal) == "string" ? de.enum.transfer : de.enum.purchase;
1204
- },
1205
- set(l) {
1206
- a.value.selectType(l);
1207
- }
1208
- }), D = q(() => {
1209
- let l = B.transferLocationOptions.value;
1210
- return k.mustUsePoTemplate && !r.value.template && (l = l.filter((p) => {
1211
- var j;
1212
- return (j = p.sublabel) == null ? void 0 : j.startsWith("restaurant");
1213
- })), l;
1214
- }), M = q({
1215
- get() {
1216
- var l;
1217
- return (l = r.value.supplier) == null ? void 0 : l._id;
1218
- },
1219
- set(l) {
1220
- B.transferLocationModel.value = l;
1221
- }
1222
- }), L = q({
1223
- get() {
1224
- return r.value.remark ?? "";
1225
- },
1226
- set(l) {
1227
- a.value.addRemark(l ?? "");
1228
- }
1229
- }), J = q({
1230
- get() {
1231
- return r.value.ref ?? "";
1232
- },
1233
- set(l) {
1234
- a.value.addReference(l ?? "");
1235
- }
1236
- }), { backdatePo: oe, backdateSwitch: w, backdateModel: S, backdateTimeModel: Q } = eo({
1237
- getEffectiveAt() {
1238
- return r.value.effectiveAt;
1239
- },
1240
- setEffectiveAt(l) {
1241
- a.value.setEffectiveAt(l);
1242
- }
1243
- }), { comparePricesToggle: ne, comparePriceFetching: ie, comparePriceBySku: ee } = go(), _e = U();
1244
- b({
1245
- validateInputs: () => {
1246
- var l, p;
1247
- (p = (l = _e.value) == null ? void 0 : l.validateInputs) == null || p.call(l);
1248
- },
1249
- resetInputsValidation: () => {
1250
- var l, p;
1251
- (p = (l = _e.value) == null ? void 0 : l.resetInputsValidation) == null || p.call(l);
1252
- },
1253
- resetInputs: () => {
1254
- var l, p;
1255
- (p = (l = _e.value) == null ? void 0 : l.resetInputs) == null || p.call(l);
1256
- },
1257
- getFormData: () => {
1258
- a.value.prepareForSubmit();
1259
- const p = !!(r.value.id && r.value.rev) ? a.value.toUpdateData() : a.value.toCreateData();
1260
- return T.value ? { ...p, predictionId: T.value } : p;
1261
- }
1262
- });
1263
- const ve = q(() => ({
1264
- updateItem: (l, p) => {
1265
- const j = Wt.parse(l), H = a.value.toFdtoPOItem(j), ae = a.value.getSkuInfo(l.sku), ue = {
1266
- ...H,
1267
- isCustomCost: p ?? ae.isCustomCost
1268
- };
1269
- a.value.updateSkuInfo(ue);
1270
- },
1271
- deleteItem: (l) => {
1272
- a.value.removeSku(l.sku);
1273
- }
1274
- })), Ve = Es({
1275
- formController: a.value,
1276
- updateItem: (l, p) => ve.value.updateItem(l, p),
1277
- deleteItem: (l) => ve.value.deleteItem(l),
1278
- get supplier() {
1279
- return r.value.supplier;
1280
- },
1281
- get items() {
1282
- return z.value;
1283
- },
1284
- get transferType() {
1285
- return V.value;
1286
- },
1287
- get template() {
1288
- return E.value;
1289
- },
1290
- get disabled() {
1291
- return u.disabled;
1292
- },
1293
- get forecastAmounts() {
1294
- return v.value;
1295
- }
1296
- }), Re = q(() => Ve.columnDefs.value);
1297
- function Oe() {
1298
- const l = a.value.getSkuOptions(), p = z.value.map((H) => H.sku._id), j = [
1299
- {
1300
- type: "string",
1301
- key: "tags",
1302
- entity: "item",
1303
- values: ["Inactive", "Active"]
1304
- }
1305
- ];
1306
- N.open({
1307
- title: n("inventory.transfer.form.items.selectItem"),
1308
- closeButton: !0,
1309
- contentComponent: xs,
1310
- contentComponentProps: {
1311
- modelValue: p,
1312
- items: l,
1313
- virtualScroll: !0,
1314
- filterAttributes: j
1315
- },
1316
- primaryActions: {
1317
- text: n("common.confirm"),
1318
- close: !0
1319
- },
1320
- secondaryActions: {
1321
- text: n("common.close"),
1322
- close: !0,
1323
- variant: "tertiary"
1324
- }
1325
- }).onPrimary((H) => {
1326
- a.value.applySelectedSku(new Set(H));
1327
- });
1328
- }
1329
- function Le(l) {
1330
- return l;
1331
- }
1332
- const ke = q(() => {
1333
- var l;
1334
- return E.value ? ((l = E.value) == null ? void 0 : l.purchaseOrder.items) || [] : h.skus.map((p) => ({
1335
- quantity: {
1336
- amount: 0,
1337
- precision: 0
1338
- },
1339
- name: p.name,
1340
- code: p.code,
1341
- sku: p,
1342
- quantityStep: {
1343
- amount: 0,
1344
- precision: 0
1345
- },
1346
- measurement: p.trackingMeasurement ? p.unit.measurements.find((j) => j.id === p.trackingMeasurement) : null
1347
- }));
1348
- }), Fe = q(() => {
1349
- const l = [];
1350
- return (!k.mustUsePoTemplate || k.mustUsePoTemplate && r.value.template) && l.push({
1351
- label: n("inventory.transfer.form.type.purchase"),
1352
- value: de.enum.purchase
1353
- }), l.push({
1354
- label: n("inventory.transfer.form.type.transfer"),
1355
- value: de.enum.transfer
1356
- }), l;
1357
- }), $e = q(
1358
- () => {
1359
- var l;
1360
- return ((l = r.value.items) == null ? void 0 : l.every((p) => p.item.quantity.amount <= 0)) ?? !0;
1361
- }
1362
- );
1363
- function Ae(l) {
1364
- if (!l) return "";
1365
- const p = [];
1366
- if (l.$and && Array.isArray(l.$and))
1367
- for (const j of l.$and) {
1368
- if (j.supplierId && j.supplierId.$eq) {
1369
- const H = D.value.find((ae) => ae.value === j.supplierId.$eq);
1370
- H && p.push(`Supplier: ${H.label}`);
1371
- }
1372
- if (j.totalCost) {
1373
- const H = j.totalCost;
1374
- let ae = "", ue = 0;
1375
- if (H.$lt !== void 0 ? (ae = "<", ue = H.$lt) : H.$lte !== void 0 ? (ae = "≤", ue = H.$lte) : H.$gt !== void 0 ? (ae = ">", ue = H.$gt) : H.$gte !== void 0 ? (ae = "≥", ue = H.$gte) : H.$eq !== void 0 && (ae = "=", ue = H.$eq), ae) {
1376
- const Ee = pe();
1377
- p.push(`Total cost ${ae} ${Ee} ${ue.toFixed(2)}`);
1378
- }
1379
- }
1380
- }
1381
- return p.length > 0 ? p.join(" and ") : "Always applied";
1382
- }
1383
- return (l, p) => {
1384
- var ot, at;
1385
- const j = O("FmChip"), H = O("FmLabel"), ae = O("FmIcon"), ue = O("FmField"), Ee = O("FmTooltip"), tt = O("FmSelect"), Pt = O("FmTextField"), Vt = O("FmTextarea"), st = O("FmSwitch"), Rt = O("FmDatePicker"), Ot = O("FmTimePicker"), je = O("FmFormGroup"), At = O("FmButton"), Et = O("FmTable"), Mt = O("FmForm");
1386
- return x(), P("div", Do, [
1387
- o("div", To, [
1388
- (ot = u.modelValue) != null && ot.template ? (x(), se(j, {
1389
- key: 0,
1390
- variant: l.disabled ? "warning" : void 0,
1391
- label: `${e(n)("inventory.transfer.template.title")}: ${((at = E.value) == null ? void 0 : at.name) ?? e(n)("inventory.transfer.form.loading")}`,
1392
- icon: "summarize",
1393
- compact: ""
1394
- }, null, 8, ["variant", "label"])) : K("", !0),
1395
- m(j, {
1396
- label: e(g).currentLocation.name,
1397
- icon: "storefront",
1398
- compact: ""
1399
- }, null, 8, ["label"]),
1400
- l.lastClosingDate ? (x(), se(j, {
1401
- key: 1,
1402
- label: `${e(n)("inventory.transfer.form.lastClosing")}: ${e(Ge)(l.lastClosingDate)} ${e(ws)(l.lastClosingDate)}`,
1403
- icon: "calendar_month",
1404
- compact: ""
1405
- }, null, 8, ["label"])) : K("", !0)
1406
- ]),
1407
- m(Mt, {
1408
- ref_key: "formRef",
1409
- ref: _e,
1410
- class: "flex flex-col gap-32",
1411
- disabled: l.disabled,
1412
- onValidationFailed: console.log,
1413
- onValidationSuccess: p[15] || (p[15] = (He) => _("validation-success"))
1414
- }, {
1415
- default: A(() => {
1416
- var He, rt, nt, lt, it, ut, dt;
1417
- return [
1418
- o("div", Po, [
1419
- o("div", Vo, [
1420
- (He = u.modelValue) != null && He.template ? (x(), P(re, { key: 0 }, [
1421
- o("div", Ro, [
1422
- m(H, {
1423
- label: e(n)("inventory.transfer.form.type.title")
1424
- }, null, 8, ["label"]),
1425
- o("div", Oo, [
1426
- m(Ee, {
1427
- "z-index": 51,
1428
- placement: "left",
1429
- disabled: l.disabled
1430
- }, {
1431
- content: A(() => p[16] || (p[16] = [
1432
- Ce("This field is locked from template.")
1433
- ])),
1434
- default: A(() => [
1435
- m(ue, null, {
1436
- default: A(() => [
1437
- o("div", Ao, [
1438
- m(ae, {
1439
- name: "lock_outline",
1440
- size: "sm",
1441
- color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1442
- }, null, 8, ["color"]),
1443
- o("div", {
1444
- class: W({ "text-fm-color-typo-disabled": l.disabled })
1445
- }, I(e(n)(`inventory.transfer.form.type.${V.value.toLocaleLowerCase("en-us")}`)), 3)
1446
- ])
1447
- ]),
1448
- _: 1
1449
- })
1450
- ]),
1451
- _: 1
1452
- }, 8, ["disabled"]),
1453
- o("div", {
1454
- class: W([
1455
- "fm-typo-en-body-sm-400",
1456
- l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1457
- ])
1458
- }, null, 2)
1459
- ])
1460
- ]),
1461
- o("div", Eo, [
1462
- m(H, {
1463
- label: V.value === e(de).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom")
1464
- }, null, 8, ["label"]),
1465
- o("div", Mo, [
1466
- m(Ee, {
1467
- "z-index": 51,
1468
- placement: "left",
1469
- disabled: l.disabled
1470
- }, {
1471
- content: A(() => p[17] || (p[17] = [
1472
- Ce("This field is locked from template.")
1473
- ])),
1474
- default: A(() => [
1475
- m(ue, null, {
1476
- default: A(() => {
1477
- var R;
1478
- return [
1479
- o("div", qo, [
1480
- m(ae, {
1481
- name: "lock_outline",
1482
- size: "sm",
1483
- color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1484
- }, null, 8, ["color"]),
1485
- o("div", {
1486
- class: W({ "text-fm-color-typo-disabled": l.disabled })
1487
- }, I((R = D.value.find((G) => G.value === M.value)) == null ? void 0 : R.label), 3)
1488
- ])
1489
- ];
1490
- }),
1491
- _: 1
1492
- })
1493
- ]),
1494
- _: 1
1495
- }, 8, ["disabled"])
1496
- ])
1497
- ])
1498
- ], 64)) : (x(), P(re, { key: 1 }, [
1499
- m(tt, {
1500
- label: e(n)("inventory.transfer.form.type.title"),
1501
- "label-mark": "required",
1502
- modelValue: V.value,
1503
- "onUpdate:modelValue": p[0] || (p[0] = (R) => V.value = R),
1504
- items: Fe.value,
1505
- rules: [e(Ue)(1)(Fe.value)]
1506
- }, {
1507
- default: A(() => [
1508
- o("span", {
1509
- class: W([
1510
- "line-clamp-1 fm-typo-en-body-lg-400",
1511
- l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1512
- ])
1513
- }, I(e(Jt)(V.value)), 3)
1514
- ]),
1515
- _: 1
1516
- }, 8, ["label", "modelValue", "items", "rules"]),
1517
- m(tt, {
1518
- label: V.value === e(de).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
1519
- "label-mark": "required",
1520
- modelValue: M.value,
1521
- "onUpdate:modelValue": p[1] || (p[1] = (R) => M.value = R),
1522
- items: D.value,
1523
- rules: [e(Ue)(1)(D.value)]
1524
- }, {
1525
- "menu-wrapper": A((R) => {
1526
- var G, Ie;
1527
- return [
1528
- m(Fs, Xe(R, {
1529
- items: D.value,
1530
- "model-value": (Ie = (G = l.modelValue) == null ? void 0 : G.supplier) == null ? void 0 : Ie._id
1531
- }), null, 16, ["items", "model-value"])
1532
- ];
1533
- }),
1534
- default: A(() => {
1535
- var R;
1536
- return [
1537
- o("span", {
1538
- class: W([
1539
- "line-clamp-1 fm-typo-en-body-lg-400",
1540
- l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1541
- ])
1542
- }, I((R = D.value.find((G) => G.value === M.value)) == null ? void 0 : R.label), 3)
1543
- ];
1544
- }),
1545
- _: 1
1546
- }, 8, ["label", "modelValue", "items", "rules"])
1547
- ], 64)),
1548
- m(Pt, {
1549
- label: e(n)("inventory.transfer.form.reference"),
1550
- "label-mark": "optional",
1551
- modelValue: J.value,
1552
- "onUpdate:modelValue": p[2] || (p[2] = (R) => J.value = R)
1553
- }, null, 8, ["label", "modelValue"]),
1554
- m(Vt, {
1555
- label: e(n)("inventory.transfer.form.remark"),
1556
- "label-mark": "optional",
1557
- "max-length": 240,
1558
- modelValue: L.value,
1559
- "onUpdate:modelValue": p[3] || (p[3] = (R) => L.value = R),
1560
- class: W([l.disabled ? "text-fm-color-typo-disabled " : ""])
1561
- }, null, 8, ["label", "modelValue", "class"]),
1562
- $.value ? (x(), se($o, {
1563
- key: 2,
1564
- required: e(r).template != null || e(r).netSuite != null,
1565
- subsidiaryOptional: e(r).template == null,
1566
- disabled: l.disabled,
1567
- supplier: e(r).supplier,
1568
- setting: e(r).netSuite,
1569
- items: z.value,
1570
- onChange: (R, G) => {
1571
- e(a).setNetSuiteSetting(G);
1572
- },
1573
- "onNetsuite:ready": p[4] || (p[4] = (R) => {
1574
- C.value = !0;
1575
- })
1576
- }, null, 8, ["required", "subsidiaryOptional", "disabled", "supplier", "setting", "items", "onChange"])) : K("", !0),
1577
- e(k).enableBackdatePo ? (x(), P("div", Uo, [
1578
- o("div", {
1579
- class: W([
1580
- "flex",
1581
- {
1582
- "flex-col": t.value
1583
- }
1584
- ])
1585
- }, [
1586
- m(st, {
1587
- modelValue: e(w),
1588
- "onUpdate:modelValue": p[5] || (p[5] = (R) => he(w) ? w.value = R : null),
1589
- label: e(n)("inventory.transfer.form.backdate.title"),
1590
- sublabel: e(n)("inventory.transfer.form.backdate.subtitle"),
1591
- "label-placement": "right",
1592
- disabled: X.value && !l.lastClosingDate || l.disabled
1593
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1594
- o("div", {
1595
- class: W({ hidden: t.value, "w-16": !t.value })
1596
- }, null, 2),
1597
- e(w) ? (x(), P("div", No, [
1598
- o("div", Bo, [
1599
- m(Rt, {
1600
- modelValue: e(S),
1601
- "onUpdate:modelValue": p[6] || (p[6] = (R) => he(S) ? S.value = R : null)
1602
- }, null, 8, ["modelValue"])
1603
- ]),
1604
- o("div", zo, [
1605
- m(Ot, {
1606
- modelValue: e(Q),
1607
- "onUpdate:modelValue": p[7] || (p[7] = (R) => he(Q) ? Q.value = R : null)
1608
- }, null, 8, ["modelValue"])
1609
- ])
1610
- ])) : K("", !0)
1611
- ], 2),
1612
- e(oe) ? (x(), se(je, {
1613
- key: 0,
1614
- modelValue: e(oe),
1615
- "onUpdate:modelValue": p[8] || (p[8] = (R) => he(oe) ? oe.value = R : null),
1616
- rules: [e(fs)(new Date(l.lastClosingDate), /* @__PURE__ */ new Date())]
1617
- }, null, 8, ["modelValue", "rules"])) : K("", !0),
1618
- X.value && !l.lastClosingDate ? (x(), P("div", Lo, [
1619
- m(ae, {
1620
- name: "error",
1621
- size: "sm",
1622
- class: "text-fm-color-typo-warning"
1623
- }),
1624
- o("span", jo, I(e(n)("inventory.transfer.form.backdate.error")), 1)
1625
- ])) : K("", !0)
1626
- ])) : K("", !0)
1627
- ])
1628
- ]),
1629
- o("div", Ho, [
1630
- m(je, {
1631
- "model-value": z.value,
1632
- rules: [e(Ue)(1)]
1633
- }, null, 8, ["model-value", "rules"]),
1634
- o("div", {
1635
- class: W([
1636
- "flex gap-16",
1637
- {
1638
- "flex-col items-start": t.value,
1639
- "items-center": !t.value
1640
- }
1641
- ])
1642
- }, [
1643
- o("div", Qo, I(e(n)("inventory.transfer.form.items.title")), 1),
1644
- o("div", Yo, [
1645
- m(At, {
1646
- disabled: l.disabled,
1647
- label: e(n)("inventory.transfer.form.items.addItem"),
1648
- "prepend-icon": "add",
1649
- variant: "secondary",
1650
- "text-color": "primary",
1651
- "bg-color": "transparent",
1652
- "border-color": "primary",
1653
- onClick: p[9] || (p[9] = (R) => Oe()),
1654
- size: "md"
1655
- }, null, 8, ["disabled", "label"]),
1656
- m(bo, {
1657
- "template-id": e(r).template || void 0,
1658
- "template-items": ke.value,
1659
- "po-items": z.value,
1660
- "onUpdate:forecastAmounts": p[10] || (p[10] = (R) => {
1661
- v.value = R;
1662
- }),
1663
- "onUpdate:poItems": p[11] || (p[11] = (R) => {
1664
- e(a).updateItems(R), c.value++;
1665
- }),
1666
- "onUpdate:predictionId": p[12] || (p[12] = (R) => {
1667
- T.value = R;
1668
- })
1669
- }, null, 8, ["template-id", "template-items", "po-items"])
1670
- ])
1671
- ], 2),
1672
- V.value === e(de).enum.purchase && Z.value && e(k).enableTotalCost && z.value.length ? (x(), P("div", Ko, [
1673
- m(st, {
1674
- label: e(ie) ? e(n)("inventory.transfer.form.items.fetchingData") : e(n)("inventory.transfer.form.items.comparePriceHistory"),
1675
- "prepend-icon": "compare_arrows",
1676
- "label-placement": "right",
1677
- "model-value": e(ne),
1678
- "onUpdate:modelValue": p[13] || (p[13] = (R) => he(ne) ? ne.value = R : null),
1679
- disabled: e(ie) || l.disabled
1680
- }, null, 8, ["label", "model-value", "disabled"])
1681
- ])) : K("", !0),
1682
- m(je, {
1683
- "model-value": $e.value,
1684
- rules: [() => $e.value ? "Must have at least one non-zero item" : !0]
1685
- }, null, 8, ["model-value", "rules"]),
1686
- (x(), se(Et, {
1687
- "column-defs": Re.value,
1688
- "column-visibility": {
1689
- [e(te).Code]: !(((rt = l.modelValue) == null ? void 0 : rt.template) ?? ((nt = l.modelValue) == null ? void 0 : nt.templateDoc)),
1690
- [e(te).Name]: !(((lt = l.modelValue) == null ? void 0 : lt.template) ?? ((it = l.modelValue) == null ? void 0 : it.templateDoc)),
1691
- [e(te).TemplateName]: !!(((ut = l.modelValue) == null ? void 0 : ut.template) ?? ((dt = l.modelValue) == null ? void 0 : dt.templateDoc))
1692
- },
1693
- "row-data": z.value,
1694
- key: c.value,
1695
- "hide-footer": "",
1696
- "page-size": z.value.length
1697
- }, {
1698
- "table-row": A((R) => {
1699
- var G, Ie, ct, mt;
1700
- return [
1701
- m(ko, {
1702
- "compare-price-by-sku": e(ee),
1703
- "show-compare-price": V.value === e(de).enum.purchase && e(ne),
1704
- row: R,
1705
- "template-item": (mt = (ct = (Ie = (G = l.modelValue) == null ? void 0 : G.templateDoc) == null ? void 0 : Ie.purchaseOrder) == null ? void 0 : ct.items) == null ? void 0 : mt.find(
1706
- (Qe) => Qe.sku._id === R.original.sku._id
1707
- ),
1708
- "onUpdate:item": p[14] || (p[14] = (Qe) => ve.value.updateItem(Qe)),
1709
- disabled: l.disabled
1710
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1711
- ];
1712
- }),
1713
- "list-row": A((R) => [
1714
- (x(), se(It, {
1715
- row: R,
1716
- key: z.value.map((G) => G.sku._id).join(".")
1717
- }, {
1718
- default: A((G) => [
1719
- m(Gs, {
1720
- "compare-price-by-sku": e(ee),
1721
- "show-compare-price": V.value === e(de).enum.purchase && e(ne),
1722
- row: R,
1723
- "cell-by-col-id": G
1724
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1725
- ]),
1726
- _: 2
1727
- }, 1032, ["row"]))
1728
- ]),
1729
- _: 1
1730
- }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1731
- ]),
1732
- e(k).enableTotalCost ? (x(), P("div", Xo, [
1733
- o("div", Zo, [
1734
- o("div", Wo, I(e(n)("inventory.transfer.form.surcharges.totalCost")), 1),
1735
- o("div", Jo, I(e(pe)()) + " " + I(e(we)({
1736
- ...e(a).getTotalCosts(),
1737
- currency: e(pe)()
1738
- }).replace(/[^0-9.,]/g, "")), 1)
1739
- ])
1740
- ])) : K("", !0),
1741
- e(a).getMatchedSurcharges().length > 0 ? (x(), P("div", Go, [
1742
- o("div", ea, [
1743
- o("div", ta, I(e(n)("inventory.transfer.form.surcharges.title")), 1),
1744
- m(j, {
1745
- label: e(n)("inventory.transfer.form.surcharges.autoApplied"),
1746
- icon: "auto_awesome",
1747
- variant: "info",
1748
- compact: ""
1749
- }, null, 8, ["label"])
1750
- ]),
1751
- o("div", sa, I(e(n)("inventory.transfer.form.surcharges.appliedBased")), 1),
1752
- o("div", oa, [
1753
- (x(!0), P(re, null, fe(e(a).getMatchedSurcharges(), (R, G) => (x(), P("div", {
1754
- key: G,
1755
- class: W([
1756
- "p-16 flex items-center justify-between",
1757
- G !== e(a).getMatchedSurcharges().length - 1 ? "border-b border-fm-color-neutral-gray-300" : ""
1758
- ])
1759
- }, [
1760
- o("div", aa, [
1761
- o("div", ra, I(R.item.name), 1),
1762
- o("div", na, I(e(n)("inventory.transfer.form.surcharges.appliedBased")) + ": " + I(Ae(R.surcharge.rule)), 1)
1763
- ]),
1764
- o("div", la, I(e(pe)()) + " " + I(e(we)(R.item.totalCost).replace(/[^0-9.,]/g, "")), 1)
1765
- ], 2))), 128))
1766
- ])
1767
- ])) : K("", !0)
1768
- ];
1769
- }),
1770
- _: 1
1771
- }, 8, ["disabled", "onValidationFailed"])
1772
- ]);
1773
- };
1774
- }
1775
- }), ua = { class: "flex items-center" }, da = { class: "fm-typo-en-title-md-800" }, ca = { class: "flex gap-4" }, ma = { class: "fm-typo-en-title-md-600" }, pa = { class: "flex flex-col gap-16" }, fa = { class: "fm-typo-en-body-md-400" }, va = { class: "max-h-[300px] overflow-y-auto" }, ya = { class: "list-disc pl-16" }, ba = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ga = { class: "flex w-full gap-8 justify-end" }, _a = /* @__PURE__ */ le({
1776
- __name: "TransferDialog",
1777
- props: {
1778
- mode: {},
1779
- modelValue: {},
1780
- templateId: {},
1781
- show: { type: Boolean },
1782
- lastClosingDate: {}
1783
- },
1784
- emits: ["update:show", "submitted"],
1785
- setup(f, { expose: b, emit: d }) {
1786
- var oe;
1787
- const u = f, _ = d, n = et(), g = Dt(), h = Se(), F = Je(), k = Be(), y = Ne(), { t: i } = ge(), t = U(!1), s = U(!1), a = U(!1), r = U(!1), C = q(() => {
1788
- var w;
1789
- return ((w = T.value.items) == null ? void 0 : w.filter((S) => S.quantity.amount === 0)) ?? [];
1790
- });
1791
- async function $(w) {
1792
- if (w) {
1793
- s.value = !1;
1794
- try {
1795
- await F.readSuppliers(), s.value = !0;
1796
- } catch {
1797
- h.open({
1798
- title: i("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1799
- message: i("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1800
- type: "error"
1801
- });
1802
- }
1803
- }
1804
- }
1805
- y.watchLocation($);
1806
- function c() {
1807
- return {
1808
- remark: void 0,
1809
- ref: void 0,
1810
- stockSnapshotId: void 0,
1811
- effectiveAt: void 0,
1812
- items: [],
1813
- supplier: {
1814
- _rev: void 0,
1815
- email: void 0,
1816
- internal: void 0,
1817
- contactName: void 0,
1818
- phoneNumber: void 0,
1819
- registrationNumber: void 0,
1820
- supplyItems: void 0,
1821
- _id: "",
1822
- name: "",
1823
- address: {
1824
- line2: void 0,
1825
- line1: "",
1826
- state: "",
1827
- city: "",
1828
- postcode: "",
1829
- country: ""
1830
- }
1831
- },
1832
- status: "DRAFT",
1833
- _id: "",
1834
- seqNumber: 0,
1835
- deliveryOrder: [],
1836
- template: u.templateId,
1837
- templateDoc: g.templates.find((S) => S._id === u.templateId)
1838
- };
1839
- }
1840
- const v = Ft(u, "show"), T = U(u.modelValue ?? c()), E = U(((oe = u.modelValue) == null ? void 0 : oe._id) ?? `${Math.random()}`);
1841
- be(
1842
- () => u.show,
1843
- (w) => {
1844
- var S;
1845
- w && (a.value = !1, T.value = u.modelValue ?? c(), E.value = ((S = u.modelValue) == null ? void 0 : S._id) ?? `${Math.random()}`);
1846
- }
1847
- );
1848
- const Z = q(() => !s.value || !a.value), z = q(() => {
1849
- switch (u.mode) {
1850
- case De.READ:
1851
- return "View transfer";
1852
- case De.CREATE:
1853
- return i("inventory.transfer.receiveRequest.create.title");
1854
- case De.UPDATE:
1855
- return i("inventory.transfer.receiveRequest.update.title");
1856
- }
1857
- return "";
1858
- }), X = U();
1859
- b({
1860
- validateInputs: () => {
1861
- var w, S;
1862
- (S = (w = X.value) == null ? void 0 : w.validateInputs) == null || S.call(w);
1863
- },
1864
- resetInputsValidation: () => {
1865
- var w, S;
1866
- (S = (w = X.value) == null ? void 0 : w.resetInputsValidation) == null || S.call(w);
1867
- },
1868
- resetInputs: () => {
1869
- var w, S;
1870
- (S = (w = X.value) == null ? void 0 : w.resetInputs) == null || S.call(w);
1871
- }
1872
- });
1873
- async function N() {
1874
- const w = T.value;
1875
- if (t.value = !0, w.items = w.items.filter((S) => S.quantity.amount > 0), !w.items.length) {
1876
- h.open({
1877
- title: "Cannot create order",
1878
- message: "There are no items with non-zero amount in your request.",
1879
- type: "error"
1880
- });
1881
- return;
1882
- }
1883
- (w.supplier.internal === "warehouse" || w.supplier.internal === "restaurant") && (w.items = w.items.map(({ totalCost: S, ...Q }) => Q));
1884
- try {
1885
- await n.createPurchaseOrder(w), await new Promise((S) => setTimeout(S, 1e3)), h.open({
1886
- title: i("inventory.transfer.receiveRequest.create.success"),
1887
- message: i("inventory.transfer.receiveRequest.create.successMessage"),
1888
- type: "success"
1889
- }), _("update:show", !1), _("submitted");
1890
- } catch (S) {
1891
- h.open({
1892
- title: i("inventory.transfer.receiveRequest.create.error.title"),
1893
- message: i("inventory.transfer.receiveRequest.create.error.message"),
1894
- type: "error"
1895
- }), console.error("Error in creating purchase order", S);
1896
- } finally {
1897
- t.value = !1;
1898
- }
1899
- }
1900
- async function B() {
1901
- const w = T.value;
1902
- if (t.value = !0, w.items = w.items.filter((S) => S.quantity.amount > 0), !w.items.length) {
1903
- h.open({
1904
- title: "Cannot create order",
1905
- message: "There are no items with non-zero amount in your request.",
1906
- type: "error"
1907
- });
1908
- return;
1909
- }
1910
- (w.supplier.internal === "warehouse" || w.supplier.internal === "restaurant") && (w.items = w.items.map(({ totalCost: S, ...Q }) => Q));
1911
- try {
1912
- await n.updatePurchaseOrder(w), await new Promise((S) => setTimeout(S, 1e3)), h.open({
1913
- title: i("inventory.transfer.receiveRequest.update.success"),
1914
- message: i("inventory.transfer.receiveRequest.update.successMessage"),
1915
- type: "success"
1916
- }), _("update:show", !1), _("submitted");
1917
- } catch (S) {
1918
- h.open({
1919
- title: i("inventory.transfer.receiveRequest.update.error.title"),
1920
- message: i("inventory.transfer.receiveRequest.update.error.message"),
1921
- type: "error"
1922
- }), console.error("Error in updating purchase order", S);
1923
- } finally {
1924
- t.value = !1;
1925
- }
1926
- }
1927
- function V() {
1928
- switch (u.mode) {
1929
- case De.CREATE:
1930
- return N();
1931
- case De.UPDATE:
1932
- return B();
1933
- }
1934
- }
1935
- function D() {
1936
- var w;
1937
- T.value.items = ((w = T.value.items) == null ? void 0 : w.filter((S) => S.quantity.amount > 0)) ?? [], r.value = !1, L();
1938
- }
1939
- function M() {
1940
- X.value.getFormData && (T.value = {
1941
- ...T.value,
1942
- ...X.value.getFormData()
1943
- });
1944
- }
1945
- function L() {
1946
- var Q, ne;
1947
- const w = hs.validatePurchaseOrderItems({
1948
- skusById: k.skuById ?? {},
1949
- items: T.value.items ?? []
1950
- }), S = Object.values(w).flat();
1951
- if (S.length > 0) {
1952
- const ie = S[0];
1953
- h.open({
1954
- title: `[Row ${ie.index + 1}] "${ie.poItem.sku.name}"`,
1955
- message: `${ie.message}`,
1956
- type: "error"
1957
- });
1958
- return;
1959
- }
1960
- (ne = (Q = X.value) == null ? void 0 : Q.validateInputs) == null || ne.call(Q);
1961
- }
1962
- function J() {
1963
- if (M(), C.value.length > 0) {
1964
- r.value = !0;
1965
- return;
1966
- }
1967
- L();
1968
- }
1969
- return (w, S) => {
1970
- const Q = O("FmButton"), ne = O("FmSideSheet"), ie = O("FmDialog");
1971
- return x(), P(re, null, [
1972
- m(ne, {
1973
- modelValue: e(v),
1974
- "onUpdate:modelValue": S[3] || (S[3] = (ee) => he(v) ? v.value = ee : null),
1975
- "dismiss-away": "",
1976
- "close-button": "",
1977
- "max-width": 900
1978
- }, {
1979
- "side-sheet-header": A(() => [
1980
- o("div", ua, [
1981
- o("div", da, I(z.value), 1)
1982
- ])
1983
- ]),
1984
- default: A(() => [
1985
- (x(), se(ia, {
1986
- class: "w-full",
1987
- ref_key: "formRef",
1988
- ref: X,
1989
- "onForm:ready": S[0] || (S[0] = () => a.value = !0),
1990
- onValidationSuccess: V,
1991
- modelValue: T.value,
1992
- "onUpdate:modelValue": S[1] || (S[1] = (ee) => T.value = ee),
1993
- disabled: t.value || Z.value,
1994
- suppliers: e(F).suppliers,
1995
- skus: e(k).skus,
1996
- key: E.value,
1997
- "last-closing-date": w.lastClosingDate
1998
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1999
- ]),
2000
- "side-sheet-footer": A(() => [
2001
- o("div", ca, [
2002
- m(Q, {
2003
- loading: t.value,
2004
- disabled: Z.value,
2005
- label: e(i)("common.save"),
2006
- onClick: J
2007
- }, null, 8, ["loading", "disabled", "label"]),
2008
- m(Q, {
2009
- disabled: Z.value,
2010
- variant: "tertiary",
2011
- label: e(i)("common.close"),
2012
- onClick: S[2] || (S[2] = (ee) => _("update:show", !1))
2013
- }, null, 8, ["disabled", "label"])
2014
- ])
2015
- ]),
2016
- _: 1
2017
- }, 8, ["modelValue"]),
2018
- m(ie, {
2019
- modelValue: r.value,
2020
- "onUpdate:modelValue": S[5] || (S[5] = (ee) => r.value = ee),
2021
- overlay: !0
2022
- }, {
2023
- "dialog-header": A(() => [
2024
- o("div", ma, I(e(i)("inventory.transfer.template.zeroQuantity.title")), 1)
2025
- ]),
2026
- "dialog-footer": A(() => [
2027
- o("div", ga, [
2028
- m(Q, {
2029
- label: e(i)("common.cancel"),
2030
- variant: "tertiary",
2031
- onClick: S[4] || (S[4] = (ee) => r.value = !1)
2032
- }, null, 8, ["label"]),
2033
- m(Q, {
2034
- label: e(i)("inventory.transfer.template.zeroQuantity.removeAll"),
2035
- variant: "primary",
2036
- "prepend-icon": "delete",
2037
- onClick: D
2038
- }, null, 8, ["label"])
2039
- ])
2040
- ]),
2041
- default: A(() => [
2042
- o("div", pa, [
2043
- o("div", fa, I(e(i)("inventory.transfer.template.zeroQuantity.message", { count: C.value.length })), 1),
2044
- o("div", va, [
2045
- o("ul", ya, [
2046
- (x(!0), P(re, null, fe(C.value, (ee) => (x(), P("li", {
2047
- key: ee.sku._id,
2048
- class: "fm-typo-en-body-md-400"
2049
- }, I(ee.sku.name) + " (" + I(ee.sku.code) + ") ", 1))), 128))
2050
- ])
2051
- ]),
2052
- o("div", ba, I(e(i)("inventory.transfer.template.zeroQuantity.prompt")), 1)
2053
- ])
2054
- ]),
2055
- _: 1
2056
- }, 8, ["modelValue"])
2057
- ], 64);
2058
- };
2059
- }
2060
- });
2061
- function ha(f) {
2062
- const [b, d, u, ..._] = Ds(f), n = u.map((k) => k.toLowerCase().trim().replace(/ /g, "_")), h = ["item_name", "transfer_quantity(uom)", "uom", "scanned_code"].filter((k) => !n.includes(k));
2063
- if (h.length)
2064
- throw new Error(
2065
- `Missing headers (${h.join()}). Excel file does not come from the template.`
2066
- );
2067
- return _.map((k, y) => {
2068
- const i = {};
2069
- for (const t in n) {
2070
- const s = n[t];
2071
- Object.assign(i, { [s]: k[t] });
2072
- }
2073
- return {
2074
- index: y,
2075
- data: i
2076
- };
2077
- });
2078
- }
2079
- function xa(f) {
2080
- const b = f.SheetNames;
2081
- try {
2082
- return b.reduce(
2083
- (u, _) => {
2084
- const n = new Array(), g = f.Sheets[_], h = Be(), F = ha(g), k = [];
2085
- for (const { index: i, data: t } of F) {
2086
- t.scanned_code === "" && n.push(`Row ${i + 1}: Scanned code is empty`), t.item_name === "" && n.push(`Row ${i + 1}: Item name is empty`), t.uom === "" && n.push(`Row ${i + 1}: UOM is empty`), t["transfer_quantity(uom)"] === "" && n.push(`Row ${i + 1}: Transfer quantity is empty`);
2087
- const s = h.skus.find((C) => C.code === t.scanned_code);
2088
- if (!s) {
2089
- n.push(`Row ${i + 1}: SKU not found`);
2090
- continue;
2091
- }
2092
- const a = s.unit.abbrev === t.uom;
2093
- let r = null;
2094
- if (!a) {
2095
- const C = s.unit.measurements.find(($) => $.abbrev === t.uom);
2096
- if (!C) {
2097
- n.push(`Row ${i + 1}: Measurement not found`);
2098
- continue;
2099
- }
2100
- r = C;
2101
- }
2102
- k.push({
2103
- sku: s,
2104
- code: t.scanned_code,
2105
- name: t.item_name,
2106
- quantity: wt.fromNumber(Number(t["transfer_quantity(uom)"])),
2107
- measurement: r
2108
- });
2109
- }
2110
- const y = {
2111
- type: "create",
2112
- poItems: k,
2113
- excelSheetName: _,
2114
- errors: n
2115
- };
2116
- return u.importCreateResult.push(y), u;
2117
- },
2118
- {
2119
- invalidExcel: !1,
2120
- importCreateResult: new Array()
2121
- }
2122
- );
2123
- } catch (d) {
2124
- return {
2125
- invalidExcel: !0,
2126
- invalidExcelMessage: (d == null ? void 0 : d.message) ?? "Invalid excel",
2127
- importCreateResult: []
2128
- };
2129
- }
2130
- }
2131
- const ka = { class: "flex flex-col flex-1" }, Ca = { class: "flex flex-col" }, wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Sa = {
2132
- key: 0,
2133
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
2134
- }, Fa = { key: 0 }, $a = {
2135
- class: /* @__PURE__ */ W(["fm-typo-en-body-lg-600"])
2136
- }, Ia = { class: "flex-1" }, Da = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, Ta = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, Pa = { class: "text-fm-color-typo-primary" }, Va = { class: "ml-auto" }, Ra = { key: 0 }, Oa = /* @__PURE__ */ le({
2137
- __name: "XilnexResult",
2138
- props: {
2139
- type: {},
2140
- name: {},
2141
- items: {},
2142
- errors: {}
2143
- },
2144
- setup(f) {
2145
- const b = f, { t: d } = ge(), u = U(!1), _ = () => {
2146
- b.errors.length && (u.value = !u.value);
2147
- };
2148
- return (n, g) => {
2149
- var k;
2150
- const h = O("FmIcon"), F = O("FmTooltip");
2151
- return x(), P("div", ka, [
2152
- o("div", {
2153
- onClick: _,
2154
- class: W({
2155
- "cursor-pointer": n.errors.length
2156
- })
2157
- }, [
2158
- o("div", Ca, [
2159
- o("div", wa, [
2160
- o("div", {
2161
- class: W({
2162
- "text-fm-color-system-error-300": n.errors.length
2163
- })
2164
- }, [
2165
- Ce(I(n.name) + " ", 1),
2166
- n.type === "create" ? (x(), P("span", Sa, "(" + I(e(d)("inventory.closing.template.import.new")) + ")", 1)) : K("", !0)
2167
- ], 2),
2168
- n.errors.length ? (x(), P("div", Fa, [
2169
- m(h, {
2170
- name: "error",
2171
- size: "sm",
2172
- color: "system-error-300"
2173
- })
2174
- ])) : K("", !0)
2175
- ]),
2176
- g[0] || (g[0] = o("hr", { class: "my-2" }, null, -1)),
2177
- o("div", $a, [
2178
- (k = n.items) != null && k.length ? (x(!0), P(re, { key: 0 }, fe(n.items, (y, i) => (x(), P("div", {
2179
- key: i,
2180
- class: "flex gap-4 mt-2 items-center"
2181
- }, [
2182
- o("div", Ia, [
2183
- m(F, {
2184
- content: y.code,
2185
- placement: "top",
2186
- "z-index": 51
2187
- }, {
2188
- default: A(() => [
2189
- o("span", Da, I(y.code), 1)
2190
- ]),
2191
- _: 2
2192
- }, 1032, ["content"]),
2193
- m(F, {
2194
- content: y.name,
2195
- placement: "top",
2196
- "z-index": 51
2197
- }, {
2198
- default: A(() => [
2199
- o("span", Ta, I(y.name), 1)
2200
- ]),
2201
- _: 2
2202
- }, 1032, ["content"])
2203
- ]),
2204
- o("div", null, [
2205
- o("span", Pa, I(e(wt).toFormatString({
2206
- value: y.quantity
2207
- })), 1),
2208
- Ce(" " + I(y.measurement ? y.measurement.abbrev : y.sku.unit.abbrev), 1)
2209
- ])
2210
- ]))), 128)) : K("", !0)
2211
- ])
2212
- ]),
2213
- o("div", Va, [
2214
- n.errors.length ? (x(), se(h, {
2215
- key: 0,
2216
- name: u.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2217
- size: "md"
2218
- }, null, 8, ["name"])) : K("", !0)
2219
- ])
2220
- ], 2),
2221
- u.value ? (x(), P("div", {
2222
- key: 0,
2223
- class: W(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
2224
- "text-fm-color-typo-secondary": !n.errors.length,
2225
- "text-fm-color-system-error-300": n.errors.length
2226
- }])
2227
- }, [
2228
- n.errors.length ? (x(), P("div", Ra, [
2229
- o("ol", null, [
2230
- (x(!0), P(re, null, fe(n.errors, (y, i) => (x(), P("li", { key: i }, I(y), 1))), 128))
2231
- ])
2232
- ])) : K("", !0)
2233
- ], 2)) : K("", !0)
2234
- ]);
2235
- };
2236
- }
2237
- }), Aa = { class: "flex flex-col gap-24" }, Ea = {
2238
- key: 0,
2239
- class: "flex items-center gap-8"
2240
- }, Ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qa = { class: "flex flex-col gap-8" }, Ua = { class: "line-clamp-2 text-ellipsis break-all" }, Na = {
2241
- key: 2,
2242
- class: "shrink-0"
2243
- }, Ba = {
2244
- key: 0,
2245
- class: "flex flex-col"
2246
- }, za = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, La = {
2247
- key: 0,
2248
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
2249
- }, ja = { class: "fm-typo-en-body-lg-600" }, ht = "Transfer note", Ha = /* @__PURE__ */ le({
2250
- __name: "XilnexImportForm",
2251
- setup(f, { expose: b }) {
2252
- const d = U(null), u = Se(), _ = U(!1), n = U(!1), g = Vs(), h = U(!1), F = Pe();
2253
- U([]);
2254
- const k = q({
2255
- get() {
2256
- var c;
2257
- return ((c = g.supplier) == null ? void 0 : c.name) ?? "";
2258
- },
2259
- set(c) {
2260
- c && (g.supplier = {
2261
- name: c,
2262
- registrationNumber: "",
2263
- _id: "xilnex",
2264
- internal: "restaurant",
2265
- address: {
2266
- line1: "",
2267
- line2: "",
2268
- city: "",
2269
- state: "",
2270
- country: "",
2271
- postcode: ""
2272
- }
2273
- });
2274
- }
2275
- });
2276
- Ze(async () => {
2277
- const c = await F.getNetSuiteLocations();
2278
- console.log(c), h.value = !0;
2279
- });
2280
- const y = q({
2281
- get() {
2282
- return "";
2283
- },
2284
- set(c) {
2285
- if (c) {
2286
- const v = g.effectiveAt ? new Date(g.effectiveAt) : /* @__PURE__ */ new Date(), [T, E, Z] = c.split("-");
2287
- v.setFullYear(parseInt(T)), v.setMonth(parseInt(E) - 1), v.setDate(parseInt(Z)), g.effectiveAt = v.toISOString();
2288
- }
2289
- }
2290
- }), i = q({
2291
- get() {
2292
- return null;
2293
- },
2294
- set(c) {
2295
- if (c) {
2296
- const v = g.effectiveAt ? new Date(g.effectiveAt) : /* @__PURE__ */ new Date(), [T, E] = c.split(":");
2297
- v.setMinutes(parseInt(T)), v.setSeconds(parseInt(E)), g.effectiveAt = v.toISOString();
2298
- }
2299
- }
2300
- }), t = U(new Array()), s = U([]), a = q(
2301
- () => !!t.value.length || s.value.some((c) => c.errors.length)
2302
- ), r = U();
2303
- b({
2304
- validateInputs: () => {
2305
- var c, v;
2306
- (v = (c = r.value) == null ? void 0 : c.validateInputs) == null || v.call(c);
2307
- },
2308
- resetInputsValidation: () => {
2309
- var c, v;
2310
- (v = (c = r.value) == null ? void 0 : c.resetInputsValidation) == null || v.call(c);
2311
- },
2312
- resetInputs: () => {
2313
- var c, v;
2314
- (v = (c = r.value) == null ? void 0 : c.resetInputs) == null || v.call(c);
2315
- }
2316
- });
2317
- const { t: C } = ge();
2318
- async function $(c) {
2319
- t.value = [], s.value = [];
2320
- try {
2321
- _.value = !0;
2322
- const [v] = await Promise.all([
2323
- Ts(c),
2324
- // fake buffer
2325
- new Promise((E) => setTimeout(E, 1e3))
2326
- ]), T = xa(v);
2327
- if (T.invalidExcel) {
2328
- t.value.push(
2329
- T.invalidExcelMessage ?? C("inventory.ingredient.import.fileError.invalidExcel")
2330
- );
2331
- return;
2332
- }
2333
- if (s.value = T.importCreateResult, !s.value.length) {
2334
- t.value.push(C("inventory.ingredient.import.fileError.noData"));
2335
- return;
2336
- }
2337
- g.items = s.value.map((E) => E.poItems).flat();
2338
- } catch (v) {
2339
- u.open({
2340
- title: C("inventory.ingredient.import.fileError.unableToRead"),
2341
- message: v == null ? void 0 : v.message,
2342
- type: "error"
2343
- }), console.error("Error in reading file", v);
2344
- } finally {
2345
- t.value.length && u.open({
2346
- title: C("inventory.ingredient.import.fileError.invalidExcel"),
2347
- type: "error"
2348
- }), _.value = !1;
2349
- }
2350
- }
2351
- return be(d, (c) => {
2352
- c && $(c);
2353
- }), (c, v) => {
2354
- const T = O("FmSelect"), E = O("FmDatePicker"), Z = O("FmTimePicker"), z = O("FmCircularProgress"), X = O("FmLabel"), N = O("FmIcon"), B = O("FmButton"), V = O("FmForm");
2355
- return x(), se(V, {
2356
- ref_key: "formRef",
2357
- ref: r
2358
- }, {
2359
- default: A(() => [
2360
- o("div", Aa, [
2361
- m(T, {
2362
- modelValue: k.value,
2363
- "onUpdate:modelValue": v[0] || (v[0] = (D) => k.value = D),
2364
- label: "Transfer from",
2365
- searchable: "",
2366
- searchTarget: "label",
2367
- items: [
2368
- { label: "Object", value: null },
2369
- { label: "Array", value: ["array", "1"] },
2370
- { label: "Number", value: 3 },
2371
- { label: "String", value: "4" },
2372
- { label: "1", value: "5" },
2373
- { label: "2", value: "6" }
2374
- ],
2375
- "helper-text": "Helper",
2376
- rules: [e(Te)()]
2377
- }, null, 8, ["modelValue", "rules"]),
2378
- m(E, {
2379
- modelValue: y.value,
2380
- "onUpdate:modelValue": v[1] || (v[1] = (D) => y.value = D),
2381
- label: "Transfer date",
2382
- rules: [e(Te)()]
2383
- }, null, 8, ["modelValue", "rules"]),
2384
- m(Z, {
2385
- modelValue: i.value,
2386
- "onUpdate:modelValue": v[2] || (v[2] = (D) => i.value = D),
2387
- label: "Transfer time",
2388
- rules: [e(Te)()]
2389
- }, null, 8, ["modelValue", "rules"]),
2390
- n.value ? (x(), P("div", Ea, [
2391
- o("div", null, [
2392
- m(z, {
2393
- size: "md",
2394
- color: "neutral-gray-200"
2395
- })
2396
- ]),
2397
- o("div", Ma, I(e(C)("inventory.formField.loading")), 1)
2398
- ])) : (x(), P(re, { key: 1 }, [
2399
- m(Ps, {
2400
- "max-file-size": 5,
2401
- class: W({
2402
- "w-full": !0,
2403
- "h-[200px]": !d.value
2404
- }),
2405
- accept: ".xlsx,.xls",
2406
- label: ht,
2407
- onFileUpload: v[3] || (v[3] = (D) => d.value = D),
2408
- "button-label": e(C)("inventory.ingredient.import.selectFile")
2409
- }, zt({ _: 2 }, [
2410
- d.value ? {
2411
- name: "default",
2412
- fn: A(({ openFileDialog: D }) => [
2413
- m(X, null, {
2414
- default: A(() => [
2415
- Ce(I(ht))
2416
- ]),
2417
- _: 1
2418
- }),
2419
- o("div", qa, [
2420
- o("div", {
2421
- class: W([
2422
- "fm-corner-radius-md p-16 flex items-center gap-16",
2423
- {
2424
- "border border-fm-color-neutral-gray-100": _.value,
2425
- "border border-fm-color-neutral-gray-200": !_.value && !a.value,
2426
- "border border-fm-color-system-error-200": a.value
2427
- }
2428
- ])
2429
- }, [
2430
- _.value ? (x(), se(z, {
2431
- key: 0,
2432
- size: "md",
2433
- color: "neutral-gray-200"
2434
- })) : (x(), se(N, {
2435
- key: 1,
2436
- name: a.value ? "error" : "attach_file",
2437
- outline: "",
2438
- color: a.value ? "system-error-300" : void 0
2439
- }, null, 8, ["name", "color"])),
2440
- o("div", {
2441
- class: W([
2442
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2443
- {
2444
- "text-fm-color-typo-disabled": _.value,
2445
- "text-fm-color-typo-primary": !_.value
2446
- }
2447
- ])
2448
- }, [
2449
- o("div", Ua, I(d.value.name), 1)
2450
- ], 2),
2451
- _.value ? K("", !0) : (x(), P("div", Na, [
2452
- m(B, {
2453
- label: e(C)("inventory.ingredient.import.replaceFile"),
2454
- variant: a.value ? "destructive" : "secondary",
2455
- "prepend-icon": a.value ? void 0 : "autorenew",
2456
- onClick: D
2457
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2458
- ]))
2459
- ], 2),
2460
- t.value.length ? (x(), P("div", Ba, [
2461
- (x(!0), P(re, null, fe(t.value, (M, L) => (x(), P("div", {
2462
- key: L,
2463
- class: "flex gap-8 items-center"
2464
- }, [
2465
- m(N, {
2466
- name: "error",
2467
- size: "sm",
2468
- color: "system-error-300"
2469
- }),
2470
- o("div", za, I(M), 1)
2471
- ]))), 128))
2472
- ])) : K("", !0)
2473
- ])
2474
- ]),
2475
- key: "0"
2476
- } : void 0
2477
- ]), 1032, ["class", "button-label"]),
2478
- d.value ? (x(), P("div", La, [
2479
- o("div", ja, I(e(C)("inventory.ingredient.import.summary")), 1),
2480
- (x(!0), P(re, null, fe(s.value, (D, M) => (x(), se(Oa, {
2481
- key: M,
2482
- name: `Transfer Note ${M + 1}`,
2483
- items: D.poItems,
2484
- errors: D.errors,
2485
- type: "create"
2486
- }, null, 8, ["name", "items", "errors"]))), 128))
2487
- ])) : K("", !0)
2488
- ], 64))
2489
- ])
2490
- ]),
2491
- _: 1
2492
- }, 512);
2493
- };
2494
- }
2495
- }), Qa = { class: "w-[480px]" }, Ya = /* @__PURE__ */ le({
2496
- __name: "XilnexImportDialog",
2497
- props: {
2498
- show: { type: Boolean }
2499
- },
2500
- emits: ["update:show", "submitted"],
2501
- setup(f, { expose: b, emit: d }) {
2502
- const u = d, n = Ft(f, "show"), g = Se(), h = et(), F = U(!1), k = U(), y = U();
2503
- b({
2504
- validateInputs: () => {
2505
- var s, a;
2506
- (a = (s = k.value) == null ? void 0 : s.validateInputs) == null || a.call(s);
2507
- },
2508
- resetInputsValidation: () => {
2509
- var s, a;
2510
- (a = (s = k.value) == null ? void 0 : s.resetInputsValidation) == null || a.call(s);
2511
- },
2512
- resetInputs: () => {
2513
- var s, a;
2514
- (a = (s = k.value) == null ? void 0 : s.resetInputs) == null || a.call(s);
2515
- }
2516
- });
2517
- function i() {
2518
- var s, a;
2519
- (a = (s = k.value) == null ? void 0 : s.validateInputs) == null || a.call(s);
2520
- }
2521
- async function t() {
2522
- var a, r, C, $, c;
2523
- if (!((r = (a = y.value) == null ? void 0 : a.supplier) != null && r.name)) {
2524
- g.open({
2525
- title: "Upload failed",
2526
- message: "Location is required",
2527
- type: "error"
2528
- });
2529
- return;
2530
- }
2531
- if (!((C = y.value) != null && C.items) || ((c = ($ = y.value) == null ? void 0 : $.items) == null ? void 0 : c.length) === 0) {
2532
- g.open({
2533
- title: "Upload failed",
2534
- message: "No data to upload",
2535
- type: "error"
2536
- });
2537
- return;
2538
- }
2539
- const s = y.value.effectiveAt ? new Date(y.value.effectiveAt) : null;
2540
- if (!s) {
2541
- g.open({
2542
- title: "Invalid date",
2543
- message: "Transfer date is required",
2544
- type: "error"
2545
- });
2546
- return;
2547
- }
2548
- if (s.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2549
- g.open({
2550
- title: "Invalid date",
2551
- message: "Transfer date cannot be in the future",
2552
- type: "error"
2553
- });
2554
- return;
2555
- }
2556
- F.value = !0;
2557
- try {
2558
- await h.importFromXilnex(y.value), u("update:show", !1);
2559
- } catch (v) {
2560
- await new Promise((T) => setTimeout(T, 1e3)), g.open({
2561
- title: "Upload failed",
2562
- message: v == null ? void 0 : v.message,
2563
- type: "error"
2564
- });
2565
- } finally {
2566
- F.value = !1;
2567
- }
2568
- }
2569
- return (s, a) => {
2570
- const r = O("FmSpacer"), C = O("FmButton"), $ = O("FmDialog");
2571
- return x(), se($, {
2572
- modelValue: e(n),
2573
- "onUpdate:modelValue": a[2] || (a[2] = (c) => he(n) ? n.value = c : null),
2574
- overlay: !0,
2575
- "close-button": !1
2576
- }, {
2577
- "dialog-header": A(() => a[3] || (a[3] = [
2578
- o("div", null, "Xilnex transfer order", -1)
2579
- ])),
2580
- "dialog-footer": A(() => [
2581
- m(r, { class: "sm:hidden xs:hidden" }),
2582
- m(C, {
2583
- disabled: F.value,
2584
- class: "sm:w-full xs:w-full",
2585
- label: "Cancel",
2586
- size: "md",
2587
- variant: "tertiary",
2588
- onClick: a[1] || (a[1] = (c) => u("update:show", !1))
2589
- }, null, 8, ["disabled"]),
2590
- m(C, {
2591
- disabled: F.value,
2592
- loading: F.value,
2593
- class: "sm:w-full xs:w-full",
2594
- label: "Upload",
2595
- size: "md",
2596
- variant: "primary",
2597
- onClick: i
2598
- }, null, 8, ["disabled", "loading"])
2599
- ]),
2600
- default: A(() => [
2601
- o("div", Qa, [
2602
- m(Ha, {
2603
- ref_key: "formRef",
2604
- ref: k,
2605
- onValidationSuccess: t,
2606
- modelValue: y.value,
2607
- "onUpdate:modelValue": a[0] || (a[0] = (c) => y.value = c)
2608
- }, null, 8, ["modelValue"])
2609
- ])
2610
- ]),
2611
- _: 1
2612
- }, 8, ["modelValue"]);
2613
- };
2614
- }
2615
- }), Ka = { class: "flex flex-col py-8" }, Xa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Za = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Wa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Ja = {
2616
- key: 0,
2617
- class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2618
- }, Ga = { class: "pt-8" }, xt = "ReceiveRequestViewSearchCriteria", Tr = /* @__PURE__ */ le({
2619
- __name: "ReceiveRequestView",
2620
- setup(f) {
2621
- const { t: b } = ge(), d = Se();
2622
- Me.object({
2623
- name: Me.string().optional().nullable(),
2624
- startDate: Me.string().optional().nullable(),
2625
- endDate: Me.string().optional().nullable()
2626
- });
2627
- const u = q(
2628
- () => !t._currentLocation || y.loading.value
2629
- ), _ = is(), n = ze(), g = Pe();
2630
- function h() {
2631
- const N = {
2632
- name: "",
2633
- ...vt()
2634
- }, B = _.getItem(xt);
2635
- if (!B)
2636
- return N;
2637
- try {
2638
- return JSON.parse(B);
2639
- } catch {
2640
- return N;
2641
- }
2642
- }
2643
- function F() {
2644
- _.setItem(xt, JSON.stringify(k.value));
2645
- }
2646
- const k = U(h()), y = es(
2647
- Ye.RECEIVE_REQUEST,
2648
- k.value
2649
- ), { columnDefs: i } = ts(
2650
- Ye.RECEIVE_REQUEST,
2651
- y,
2652
- y.shipments
2653
- ), t = Ne();
2654
- async function s() {
2655
- const N = `inventory-record_${yt(k.value.startDate).format("DD-MM-YYYY_HH-mm")}-${yt(k.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, B = y.purchaseOrders.value.flatMap(
2656
- (D) => D.items.map((M) => {
2657
- var Q;
2658
- const L = new Date(ns(D._id) ?? ""), J = D.effectiveAt ? new Date(D.effectiveAt) : void 0, oe = xe(
2659
- os(M.sku, D.deliveryOrder || [])
2660
- ), w = xe(M.quantity), S = ((Q = M == null ? void 0 : M.measurement) == null ? void 0 : Q.abbrev) || M.sku.unit.abbrev;
2661
- return {
2662
- "SKU code": M.code,
2663
- "SKU name": M.name,
2664
- "PO #": D.seqNumber,
2665
- "Effective at": J,
2666
- Date: L,
2667
- Status: D.status,
2668
- Reference: D.ref ?? "",
2669
- "Received quantity": oe,
2670
- "Ordered quantity": w,
2671
- Unit: S,
2672
- "Total cost": M.totalCost ? we(M.totalCost) : null
2673
- };
2674
- })
2675
- ), V = [
2676
- "SKU code",
2677
- "SKU name",
2678
- "PO #",
2679
- "Date",
2680
- "Status",
2681
- "Reference",
2682
- "Received quantity",
2683
- "Ordered quantity",
2684
- "Unit"
2685
- ];
2686
- n.enableBackdatePo && V.insert("Effective at", 4), n.enableTotalCost && V.push("Total cost"), await ls(
2687
- [
2688
- {
2689
- name: "purchases",
2690
- data: B,
2691
- columns: V
2692
- }
2693
- ],
2694
- N
2695
- ), d.open({
2696
- title: b("inventory.transfer.receiveRequest.export.success"),
2697
- message: b("inventory.transfer.receiveRequest.export.message", [N]),
2698
- type: "success"
2699
- });
2700
- }
2701
- const a = U(vt()), r = U("");
2702
- be([() => a.value], ([N]) => {
2703
- !N.startDate || !N.endDate || (k.value.startDate = N.startDate, k.value.endDate = N.endDate, y.updateDateRange(
2704
- k.value.startDate,
2705
- k.value.endDate
2706
- ), F());
2707
- }), be([() => r.value], () => {
2708
- F();
2709
- });
2710
- function C(N) {
2711
- if (N === "create") {
2712
- if (u.value) {
2713
- d.open({
2714
- title: "Loading data...",
2715
- message: "Please wait.",
2716
- type: "info"
2717
- });
2718
- return;
2719
- }
2720
- return y.promptCreateTransferDialog();
2721
- }
2722
- if (N === "upload" && n.enableXilnexTransferNote)
2723
- return y.promptUploadTransferDialog();
2724
- if (N === "refresh")
2725
- return y.fetchData();
2726
- if (N === "export")
2727
- return s();
2728
- }
2729
- const { breakpoints: $ } = We(), c = q(() => $.value.xs || $.value.sm), v = q(() => c.value ? 10 : 20), T = us(), E = q(() => [
2730
- {
2731
- label: b("inventory.transfer.receiveRequest.actions.create"),
2732
- value: "create",
2733
- isPrimary: !0,
2734
- prependIcon: "add"
2735
- },
2736
- ...n.enableXilnexTransferNote ? [
2737
- {
2738
- label: b("inventory.common.upload"),
2739
- value: "upload"
2740
- }
2741
- ] : [],
2742
- {
2743
- label: b("inventory.common.refresh"),
2744
- value: "refresh"
2745
- },
2746
- {
2747
- label: b("inventory.common.export"),
2748
- value: "export"
2749
- }
2750
- ]), Z = q(() => {
2751
- const N = [
2752
- {
2753
- type: "string",
2754
- key: "status",
2755
- entity: "purchaseOrder",
2756
- values: Array.from(
2757
- new Set(y.purchaseOrders.value.map((V) => V.status))
2758
- )
2759
- }
2760
- ], B = [
2761
- {
2762
- type: "string",
2763
- key: "netsuiteTransactionNumber",
2764
- entity: "purchaseOrder",
2765
- values: y.purchaseOrders.value.map((V) => {
2766
- var D, M;
2767
- return (M = (D = V.netSuite) == null ? void 0 : D.additionalInfo) == null ? void 0 : M.transactionnumber;
2768
- }).filter((V) => V != null)
2769
- },
2770
- {
2771
- type: "string",
2772
- key: "netsuiteOrderNo",
2773
- entity: "purchaseOrder",
2774
- values: y.purchaseOrders.value.map((V) => {
2775
- var D;
2776
- return (D = V.netSuite) == null ? void 0 : D.refNo;
2777
- }).filter((V) => V != null)
2778
- },
2779
- {
2780
- type: "string",
2781
- key: "netsuiteOrderId",
2782
- entity: "purchaseOrder",
2783
- values: y.purchaseOrders.value.map((V) => {
2784
- var D;
2785
- return (D = V.netSuite) == null ? void 0 : D.id;
2786
- }).filter((V) => V != null)
2787
- }
2788
- ];
2789
- return [...N, ...g.isEnabled ? B : []];
2790
- }), z = U(null), X = q(() => {
2791
- if (!z.value)
2792
- return y.purchaseOrders.value;
2793
- const N = Rs.build(z.value);
2794
- return y.purchaseOrders.value.filter((B) => {
2795
- var V, D, M, L;
2796
- return Os(
2797
- {
2798
- netsuiteTransactionNumber: (D = (V = B.netSuite) == null ? void 0 : V.additionalInfo) == null ? void 0 : D.transactionnumber,
2799
- netsuiteOrderNo: (M = B.netSuite) == null ? void 0 : M.refNo,
2800
- netsuiteOrderId: (L = B.netSuite) == null ? void 0 : L.id,
2801
- status: B.status
2802
- },
2803
- N
2804
- );
2805
- });
2806
- });
2807
- return (N, B) => {
2808
- const V = O("FmTable");
2809
- return x(), se(ds, {
2810
- title: e(b)("inventory.transfer.receiveRequest.title2"),
2811
- actions: E.value,
2812
- "onClick:action": C
2813
- }, {
2814
- default: A(() => {
2815
- var D, M;
2816
- return [
2817
- o("div", {
2818
- class: W([
2819
- "flex flex-col gap-8 max-h-full",
2820
- {
2821
- "p-0": c.value,
2822
- "px-24 ": !c.value
2823
- }
2824
- ])
2825
- }, [
2826
- m(Gt, {
2827
- "date-range-query": "",
2828
- "date-range": a.value,
2829
- "onUpdate:dateRange": B[0] || (B[0] = (L) => a.value = L),
2830
- searchable: "",
2831
- "change-location": "",
2832
- search: r.value,
2833
- "onUpdate:search": B[1] || (B[1] = (L) => r.value = L),
2834
- filterable: "",
2835
- "filter-attributes": Z.value,
2836
- filter: z.value,
2837
- "onUpdate:filter": B[2] || (B[2] = (L) => z.value = L)
2838
- }, null, 8, ["date-range", "search", "filter-attributes", "filter"]),
2839
- (x(), se(V, {
2840
- style: kt(e(T).tableHeight),
2841
- "column-defs": e(i),
2842
- "row-data": X.value,
2843
- "search-value": r.value,
2844
- loading: u.value,
2845
- onRowClick: B[3] || (B[3] = (L) => e(y).promptShowTransferDetails(L.original)),
2846
- key: (D = e(t)._currentLocation) == null ? void 0 : D.dbName,
2847
- "page-size": v.value
2848
- }, {
2849
- "list-row": A((L) => [
2850
- m(It, {
2851
- row: L,
2852
- onRowClick: e(y).promptShowTransferDetails
2853
- }, {
2854
- default: A((J) => {
2855
- var oe, w, S, Q, ne, ie, ee, _e, ve, Ve, Re, Oe, Le, ke, Fe, $e, Ae, l, p, j;
2856
- return [
2857
- o("div", Ka, [
2858
- o("div", Xa, [
2859
- m(e(ce), {
2860
- render: (S = (w = (oe = J._id) == null ? void 0 : oe.column) == null ? void 0 : w.columnDef) == null ? void 0 : S.cell,
2861
- props: (ne = (Q = J._id) == null ? void 0 : Q.getContext) == null ? void 0 : ne.call(Q)
2862
- }, null, 8, ["render", "props"])
2863
- ]),
2864
- o("div", Za, [
2865
- m(e(ce), {
2866
- render: (_e = (ee = (ie = J.supplier_name) == null ? void 0 : ie.column) == null ? void 0 : ee.columnDef) == null ? void 0 : _e.cell,
2867
- props: (Ve = (ve = J.supplier_name) == null ? void 0 : ve.getContext) == null ? void 0 : Ve.call(ve)
2868
- }, null, 8, ["render", "props"])
2869
- ]),
2870
- o("div", Wa, I(L.original.items.map((H) => `${H.name}`).join(", ")), 1),
2871
- L.original.ref ? (x(), P("div", Ja, [
2872
- m(e(ce), {
2873
- render: (Le = (Oe = (Re = J.ref) == null ? void 0 : Re.column) == null ? void 0 : Oe.columnDef) == null ? void 0 : Le.cell,
2874
- props: (Fe = (ke = J.ref) == null ? void 0 : ke.getContext) == null ? void 0 : Fe.call(ke)
2875
- }, null, 8, ["render", "props"])
2876
- ])) : K("", !0),
2877
- o("div", Ga, [
2878
- m(e(ce), {
2879
- render: (l = (Ae = ($e = J.status) == null ? void 0 : $e.column) == null ? void 0 : Ae.columnDef) == null ? void 0 : l.cell,
2880
- props: (j = (p = J.status) == null ? void 0 : p.getContext) == null ? void 0 : j.call(p)
2881
- }, null, 8, ["render", "props"])
2882
- ])
2883
- ])
2884
- ];
2885
- }),
2886
- _: 2
2887
- }, 1032, ["row", "onRowClick"])
2888
- ]),
2889
- _: 1
2890
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2891
- ], 2),
2892
- (x(), se(Lt, { to: "body" }, [
2893
- m(_a, Xe(e(y).transferDialogProps.value, {
2894
- onSubmitted: e(y).fetchData
2895
- }), null, 16, ["onSubmitted"]),
2896
- m(ss, Xe({
2897
- scope: e(Ye).RECEIVE_REQUEST
2898
- }, {
2899
- ...e(y).transferDetailsProps.value,
2900
- receivedMap: ((M = e(y).transferDetailsProps.value) == null ? void 0 : M.receivedMap) ?? {},
2901
- shipments: e(y).shipments.value ?? []
2902
- }, {
2903
- onSubmitted: e(y).fetchData
2904
- }), null, 16, ["scope", "onSubmitted"]),
2905
- m(Ya, jt(Ht(e(y).xilnexImportDialogProps.value)), null, 16)
2906
- ]))
2907
- ];
2908
- }),
2909
- _: 1
2910
- }, 8, ["title", "actions"]);
2911
- };
2912
- }
2913
- });
2914
- export {
2915
- Tr as default
2916
- };