@feedmepos/mf-inventory-portal 0.0.25-dev.2 → 0.0.25-dev.21

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 (115) hide show
  1. package/dist/App-D6WBVERc.js +278 -0
  2. package/dist/ApprovalView-BIBoagE8.js +146 -0
  3. package/dist/{BindingsDialog-qeGh3ND8.js → BindingsDialog-DHRRkK1Z.js} +6 -6
  4. package/dist/{BindingsPicker-SfiA8fmD.js → BindingsPicker-DohvMDDF.js} +3 -3
  5. package/dist/{BindingsTable-BjW-eJr6.js → BindingsTable-C_JwU9ei.js} +6 -6
  6. package/dist/ClosingDraftView-BBebhUj-.js +1308 -0
  7. package/dist/ClosingTemplateView-CXRN19-D.js +1859 -0
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js +34 -0
  9. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BJufUQNE.js +215 -0
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-5rldKjyh.js → FmUnitInput.vue_vue_type_script_setup_true_lang-C5Xk19jY.js} +52 -52
  11. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-7HNI82u-.js +51 -0
  12. package/dist/{IngredientGroupView-CGyyFyvj.js → IngredientGroupView-l2bAc1Kj.js} +1 -1
  13. package/dist/{IngredientsView-BLKk-VxQ.js → IngredientsView-zDXt7KEx.js} +394 -382
  14. package/dist/{IntegrationView-C6gwvZ9b.js → IntegrationView-BYnlAPrP.js} +660 -623
  15. package/dist/{InventoryBindingForm-BB3ZN3Lx.js → InventoryBindingForm-BuweG4Vl.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-PT7Quw7j.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DgxN0U4N.js} +99 -99
  17. package/dist/{InventoryBindingSummary-yr0oie3c.js → InventoryBindingSummary-BpEo0JsK.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjJGUE9a.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CcjzkzCt.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-O1mYRa5W.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Ej20iSHA.js} +15 -15
  20. package/dist/PublishView-DCZ0zIaP.js +222 -0
  21. package/dist/{PurchaseOrderPrintPreview-Q_9-KVNj.js → PurchaseOrderPrintPreview-Cag7UEvz.js} +1 -1
  22. package/dist/ReceiveRequestView-ChIJGA98.js +2319 -0
  23. package/dist/{RecipeView-DBfugmRY.js → RecipeView-bBshe0eF.js} +32 -31
  24. package/dist/{index-CgspzSQi.js → StockView-D6-oKpAC.js} +3577 -1764
  25. package/dist/{SupplierView-BQViPyfj.js → SupplierView-dyIcGp9Q.js} +12 -11
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C_7wbQow.js +1771 -0
  27. package/dist/TransferTemplateView-D2rxV0k_.js +1660 -0
  28. package/dist/{UnitView-CrbFeWaB.js → UnitView-DVS5Az5c.js} +14 -14
  29. package/dist/{WarehouseView-Dy5GljxY.js → WarehouseView-CR03TpnA.js} +332 -314
  30. package/dist/api/closing-draft.d.ts +1 -0
  31. package/dist/api/inventory.d.ts +9 -6
  32. package/dist/api/purchase-order.d.ts +2 -1
  33. package/dist/{app-D0O4wr2X.js → app-oV9ISfFL.js} +28343 -28141
  34. package/dist/app.js +1 -1
  35. package/dist/components/FmAutocompleteTextField.vue.d.ts +31 -0
  36. package/dist/components/FmCustomAttribute.vue.d.ts +3 -8
  37. package/dist/components/FmLockableField.vue.d.ts +3 -0
  38. package/dist/components/FmMultiselectDialog.d.ts +46 -0
  39. package/dist/components/FmMultiselectDialog.vue.d.ts +20 -3
  40. package/dist/components/FmMultiselectDialogProps.d.ts +2 -0
  41. package/dist/components/MountListener.vue.d.ts +15 -0
  42. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -1
  43. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -1
  44. package/dist/{decimal-CPGmj9BT.js → decimal-C7zgfr5G.js} +1 -1
  45. package/dist/feature-CDQQ-mV9.js +1003 -0
  46. package/dist/{format-unit-display-CMM6DZJj.js → format-unit-display-CVBzrNQ4.js} +334 -327
  47. package/dist/helper/fuzzy.d.ts +10 -0
  48. package/dist/index-0VS4cuk3.js +35546 -0
  49. package/dist/{stock-9nTT4Amy.js → stock-BIP_NIK_.js} +3 -3
  50. package/dist/stores/feature.d.ts +4 -7
  51. package/dist/stores/integration/netsuite.d.ts +5 -0
  52. package/dist/stores/inventory.d.ts +135 -8
  53. package/dist/stores/location.d.ts +100 -0
  54. package/dist/stores/warehouse.d.ts +1 -0
  55. package/dist/style.css +1 -1
  56. package/dist/{supplier-CH4EwBZM.js → supplier-DUQ2VSMg.js} +1 -1
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/use-ingredient-select-dialog-VkU5_Aaj.js +51 -0
  59. package/dist/{use-inventory-binding-dialog-Dli3xtq4.js → use-inventory-binding-dialog-BXp0z3v_.js} +1 -1
  60. package/dist/views/adjustment-template/wastage-template/actions.d.ts +24 -0
  61. package/dist/views/adjustment-template/wastage-template/table.d.ts +24 -0
  62. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -4
  63. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  64. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +48 -24
  65. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  66. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  67. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +36 -12
  68. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -12
  69. package/dist/views/dev/components/AutocompleteTextField.vue.d.ts +2 -0
  70. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +3 -3
  71. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  72. package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +16 -0
  73. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  74. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +2 -0
  75. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +1387 -0
  76. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +5 -1
  77. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +3 -0
  78. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -2
  79. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +48 -2
  80. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +490 -2
  81. package/dist/views/receive-request/components/transfer-form/components/TransferSubItemTable.vue.d.ts +72 -0
  82. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +25 -2
  83. package/dist/views/receive-request/components/transfer-form/helpers/calculate-sub-item-total.helper.d.ts +4 -0
  84. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +693 -35
  85. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +684 -35
  86. package/dist/views/receive-request/helper/po-to-po-template.util.d.ts +1 -0
  87. package/dist/views/receive-request/helper/print-po.d.ts +9 -2
  88. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  89. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +270 -2
  90. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +286 -0
  91. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItem.vue.d.ts +74 -0
  92. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItemTable.vue.d.ts +92 -0
  93. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +8 -0
  94. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +1 -0
  95. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +36 -2
  96. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +456 -12
  97. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +456 -12
  98. package/dist/views/transfer-template/helpers/location-to-po-supplier.util.d.ts +75 -0
  99. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -0
  100. package/dist/{vue-i18n-BcYt8MNZ.js → vue-i18n-CCd5_SRR.js} +212 -212
  101. package/package.json +3 -3
  102. package/dist/App-oKNdl2la.js +0 -276
  103. package/dist/ApprovalView-hDGkcBDy.js +0 -138
  104. package/dist/ClosingDraftView-CEeeL7W4.js +0 -1225
  105. package/dist/ClosingTemplateView-CkS9e0MV.js +0 -1819
  106. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-CIBSvY0s.js +0 -142
  107. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dg_7ELeT.js +0 -286
  108. package/dist/PublishView-ByXdmuJL.js +0 -192
  109. package/dist/ReceiveRequestView-CApg7LGM.js +0 -1876
  110. package/dist/StockView-D6o_oUlz.js +0 -1817
  111. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D2skLe2M.js +0 -1327
  112. package/dist/TransferTemplateView-DVesObTd.js +0 -1284
  113. package/dist/components/FmCustomAttribute2.vue.d.ts +0 -18
  114. package/dist/index-P5iEcRw3.js +0 -29202
  115. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -2628
@@ -1,1876 +0,0 @@
1
- import { reactive as at, onMounted as Be, h as L, computed as q, defineComponent as pe, openBlock as S, createElementBlock as M, Fragment as ke, renderList as Ue, createElementVNode as o, toDisplayString as U, unref as e, resolveComponent as P, createVNode as d, withCtx as D, createCommentVNode as G, ref as N, createBlock as J, watch as _e, normalizeClass as W, normalizeStyle as ot, createTextVNode as Ee, nextTick as ct, mergeProps as Oe, isRef as Se, Teleport as mt } from "vue";
2
- import { b as Ne, $ as pt, m as Ge, j as ye, P as ft, a1 as ze, L as vt, ao as yt, A as Re, M as bt, n as lt, c as Ae, a8 as Le, G as ie, ap as gt, a as He, aq as _t, ar as kt, as as ht, H as Ct, u as je, at as xt, a0 as St, V as wt, au as Ft, E as nt, J as Dt, e as De, av as Ve, a2 as Je, z as $t, _ as Tt, B as Pt, O as We } from "./app-D0O4wr2X.js";
3
- import { u as rt, a as It, b as Vt, _ as Rt, g as At } from "./TransferDetails.vue_vue_type_script_setup_true_lang-D2skLe2M.js";
4
- import { _ as it, u as qt, i as Mt, e as Ut } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-O1mYRa5W.js";
5
- import { u as Et } from "./useTabStorage-BkIVScW_.js";
6
- import { useBreakpoints as Ye, components as ve, FmButtonVariant as Ot, useSnackbar as qe, useDialog as Bt, useProxiedModel as Nt } from "@feedmepos/ui-library";
7
- import { P as j, u as ut } from "./format-unit-display-CMM6DZJj.js";
8
- import { _ as zt, F as Lt, a as Xe, b as Ht } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-5rldKjyh.js";
9
- import { c as re, u as jt, _ as Yt } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dg_7ELeT.js";
10
- import { useI18n as he } from "@feedmepos/mf-common";
11
- import { u as Ke } from "./supplier-CH4EwBZM.js";
12
- import { _ as Kt } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- import { u as Qt } from "./vue-i18n-BcYt8MNZ.js";
14
- import "./array-hChJVZLE.js";
15
- var Y = /* @__PURE__ */ ((m) => (m.Code = "Code", m.Name = "Name", m.Amount = "Amount", m.Cost = "Cost", m.TotalCost = "TotalCost", m.Delete = "Delete", m))(Y || {});
16
- const et = () => {
17
- const { t: m } = he();
18
- return L(
19
- it,
20
- {
21
- zIndex: 50,
22
- class: "whitespace-nowrap"
23
- },
24
- m("inventory.transfer.form.items.table.Cost", [lt()])
25
- );
26
- };
27
- function Zt(m) {
28
- const { t: y } = he(), n = at({}), { breakpoints: i } = Ye(), b = Ae(), t = Ne();
29
- Be(() => {
30
- for (const u of m.items) {
31
- if (!u.totalCost)
32
- continue;
33
- const a = re(u.sku, u.quantity, u.measurement, {
34
- supplier: m.supplier
35
- }), l = u.totalCost ?? pt.reset();
36
- a ? n[u.sku._id] = a.amount !== l.amount || a.precision !== l.precision : n[u.sku._id] = !0;
37
- }
38
- });
39
- function f(u) {
40
- var l, v, k, h, _, x, F;
41
- return !!(((v = (l = u.defaultCost) == null ? void 0 : l.costPerUnit) == null ? void 0 : v.amount) ?? ((F = (x = (_ = (h = (k = m.supplier) == null ? void 0 : k.supplyItems) == null ? void 0 : h.find((V) => V.skuId === u._id)) == null ? void 0 : _.defaultCost) == null ? void 0 : x.costPerUnit) == null ? void 0 : F.amount));
42
- }
43
- const g = [
44
- {
45
- id: "Code",
46
- header: () => y("inventory.transfer.form.items.table.Code"),
47
- accessorKey: "code",
48
- size: 96,
49
- cell(u) {
50
- const a = u.row.original;
51
- return t.isEnabled ? L(
52
- ve.FmTooltip,
53
- {
54
- content: a.code,
55
- placement: "top",
56
- variant: "plain",
57
- zIndex: 50
58
- },
59
- L(
60
- "span",
61
- {
62
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
63
- },
64
- a.code
65
- )
66
- ) : L(ve.FmTextField, {
67
- modelValue: a.code,
68
- "onUpdate:modelValue": (l) => {
69
- m.updateItem({
70
- ...a,
71
- code: l
72
- });
73
- },
74
- key: a.sku._id,
75
- rules: [Ge()],
76
- labelMark: "required"
77
- });
78
- },
79
- enableSorting: !1
80
- },
81
- {
82
- id: "Name",
83
- header: () => y("inventory.transfer.form.items.table.Name"),
84
- minSize: 300,
85
- cell(u) {
86
- const a = u.row.original;
87
- return t.isEnabled ? L(
88
- ve.FmTooltip,
89
- {
90
- content: a.name,
91
- placement: "top",
92
- variant: "plain",
93
- zIndex: 50
94
- },
95
- L(
96
- "span",
97
- {
98
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
99
- },
100
- a.name
101
- )
102
- ) : L(ve.FmTextField, {
103
- modelValue: a.name,
104
- "onUpdate:modelValue": (l) => {
105
- m.updateItem({
106
- ...a,
107
- name: l
108
- });
109
- },
110
- key: a.sku._id,
111
- rules: [Ge()],
112
- labelMark: "required"
113
- });
114
- },
115
- enableSorting: !1
116
- },
117
- {
118
- id: "Amount",
119
- header: () => y("inventory.transfer.form.items.table.Amount"),
120
- minSize: 200,
121
- cell(u) {
122
- var v, k, h;
123
- const a = u.row.original, l = (h = (k = (v = m.template) == null ? void 0 : v.purchaseOrder) == null ? void 0 : k.items) == null ? void 0 : h.find(
124
- (_) => _.sku._id === a.sku._id
125
- );
126
- return L(zt, {
127
- style: {
128
- flex: "1 1 0%"
129
- },
130
- modelValue: {
131
- amount: a.quantity ?? { amount: 1, precision: 0 },
132
- measurement: a.measurement ?? null
133
- },
134
- key: a.sku._id,
135
- unit: a.sku.unit,
136
- "onUpdate:modelValue": (_) => {
137
- const x = {
138
- ...a,
139
- quantity: _.amount,
140
- measurement: _.measurement
141
- };
142
- b.enableTotalCost && (x.totalCost = re(a.sku, a.quantity, a.measurement, {
143
- supplier: m.supplier,
144
- // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
145
- // will return the auto calculated default cost instead of the manual total cost
146
- manualTotalCost: n[a.sku._id] ? x.totalCost : void 0
147
- })), m.updateItem(x);
148
- },
149
- stepper: l == null ? void 0 : l.quantityStep,
150
- disableUnit: !!l,
151
- disabled: m.disabled,
152
- rules: [
153
- Lt(
154
- +ye(
155
- (l == null ? void 0 : l.minimumQuantity) ?? {
156
- amount: 1,
157
- precision: ft(a.sku.unit, a.measurement)
158
- }
159
- )
160
- ),
161
- l != null && l.maximumQuantity ? Xe(
162
- +ye(l == null ? void 0 : l.maximumQuantity)
163
- ) : Xe(1 / 0),
164
- ...l != null && l.quantityStep ? [Ht(l.quantityStep)] : []
165
- ],
166
- applyDefaultRules: !0
167
- });
168
- },
169
- enableSorting: !1
170
- },
171
- b.mustUseDefaultCost ? {
172
- id: "TotalCost",
173
- header: et,
174
- size: 180,
175
- accessorFn: (u) => {
176
- const a = re(u.sku, u.quantity, u.measurement, {
177
- supplier: m.supplier
178
- });
179
- return ye(a);
180
- }
181
- } : {
182
- id: "Cost",
183
- header: et,
184
- size: 180,
185
- cell(u) {
186
- const a = u.row.original, l = f(a.sku), v = i.value.xs || i.value.sm;
187
- return !n[a.sku._id] && l ? L(
188
- "div",
189
- {
190
- class: [
191
- "flex gap-4 fm-typo-en-body-md-400 items-center",
192
- m.disabled ? "text-fm-color-typo-disabled" : ""
193
- ],
194
- key: a.sku._id
195
- },
196
- [
197
- L(ve.FmButton, {
198
- prependIcon: "edit",
199
- variant: Ot.Tertiary,
200
- disabled: m.disabled,
201
- onClick() {
202
- m.updateItem({
203
- ...a,
204
- totalCost: re(a.sku, a.quantity, a.measurement, {
205
- supplier: m.supplier
206
- })
207
- }), n[a.sku._id] = !0;
208
- }
209
- }),
210
- L(
211
- "div",
212
- {
213
- class: "flex flex-col"
214
- },
215
- [
216
- L(
217
- "span",
218
- v ? ze(
219
- re(a.sku, a.quantity, a.measurement, {
220
- supplier: m.supplier
221
- })
222
- ) : ye(
223
- re(a.sku, a.quantity, a.measurement, {
224
- supplier: m.supplier
225
- })
226
- )
227
- ),
228
- L(
229
- "span",
230
- {
231
- class: [
232
- "fm-typo-en-body-sm-400",
233
- m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
234
- ]
235
- },
236
- y("inventory.transfer.form.items.autoCalculated")
237
- )
238
- ]
239
- )
240
- ]
241
- ) : L(
242
- ve.FmTextField,
243
- {
244
- modelValue: ye(a.totalCost ?? { amount: 0, precision: 0 }),
245
- key: a.sku._id,
246
- "onUpdate:modelValue": (k) => {
247
- m.updateItem({
248
- ...a,
249
- totalCost: {
250
- ...vt(+k),
251
- currency: yt()
252
- }
253
- });
254
- },
255
- rules: [Re(0), bt(2)]
256
- },
257
- {
258
- prepend() {
259
- return v ? L(
260
- "div",
261
- {
262
- class: [
263
- "text-fm-typo-en-body-lg-400",
264
- m.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
265
- ]
266
- },
267
- lt()
268
- ) : null;
269
- },
270
- append() {
271
- return l ? L(ve.FmButton, {
272
- prependIcon: "close",
273
- variant: "tertiary",
274
- disabled: m.disabled,
275
- onClick() {
276
- m.updateItem({
277
- ...a,
278
- // NOTE: different from PO template, if a default cost is reenabled,
279
- // the total cost will automatically assigned
280
- totalCost: re(a.sku, a.quantity, a.measurement, {
281
- supplier: m.supplier
282
- })
283
- }), n[a.sku._id] = !1;
284
- }
285
- }) : null;
286
- }
287
- }
288
- );
289
- },
290
- enableSorting: !1
291
- },
292
- {
293
- id: "Delete",
294
- header: "",
295
- cell(u) {
296
- const a = u.row.original;
297
- return L(ve.FmButton, {
298
- key: a.sku._id,
299
- class: "delete-button",
300
- type: "button",
301
- icon: "delete",
302
- variant: "tertiary",
303
- size: "md",
304
- disabled: m.disabled,
305
- onClick: () => {
306
- m.deleteItem(a);
307
- }
308
- });
309
- },
310
- enableSorting: !1,
311
- size: 40,
312
- meta: {
313
- cellClass: "",
314
- headerClass: ""
315
- }
316
- }
317
- ];
318
- return {
319
- columnDefs: q(() => b.enableTotalCost && (b.mustUseDefaultCost || m.transferType === j.PURCHASE) ? g : g.filter(
320
- (u) => u.id !== "Cost"
321
- /* Cost */
322
- ))
323
- };
324
- }
325
- const Gt = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Jt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Wt = { class: "w-[450px] xs:w-full flex" }, Xt = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, es = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, dt = /* @__PURE__ */ pe({
326
- __name: "SupplierPriceHistory",
327
- props: {
328
- prices: {}
329
- },
330
- setup(m) {
331
- const y = Ke();
332
- function n(i) {
333
- return y.suppliers.find((b) => b._id === i);
334
- }
335
- return (i, b) => (S(), M("div", Gt, [
336
- (S(!0), M(ke, null, Ue(Object.keys(i.prices), (t) => {
337
- var f;
338
- return S(), M("div", {
339
- key: t,
340
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
341
- }, [
342
- o("div", Jt, U((f = n(t)) == null ? void 0 : f.name), 1),
343
- o("div", Wt, [
344
- (S(!0), M(ke, null, Ue(i.prices[t].slice(0, 3), (g) => {
345
- var w;
346
- return S(), M("div", {
347
- key: g.date,
348
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
349
- }, [
350
- o("div", Xt, [
351
- o("span", null, U(g.totalCost ? e(ze)(g.totalCost) : "No data"), 1),
352
- b[0] || (b[0] = o("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
353
- o("span", null, U(e(ye)(g.totalUnit, !1)), 1),
354
- o("span", null, U(((w = g.measurement) == null ? void 0 : w.abbrev) ?? g.unit.abbrev), 1)
355
- ]),
356
- o("div", es, [
357
- o("span", null, "(#" + U(g.seqNumber) + ")", 1),
358
- b[1] || (b[1] = o("span", null, U(" "), -1)),
359
- o("span", null, U(e(Le)(new Date(g.date))), 1)
360
- ])
361
- ]);
362
- }), 128))
363
- ])
364
- ]);
365
- }), 128))
366
- ]));
367
- }
368
- }), ts = { class: "flex flex-col gap-8 py-16" }, ss = { class: "flex items-center" }, as = { class: "flex-1 flex gap-1 items-center" }, os = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ls = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ns = { class: "flex gap-8 w-full" }, rs = { class: "flex-1 flex flex-col gap-4" }, is = { class: "flex-1 flex flex-col gap-4" }, us = { class: "flex gap-8 w-full" }, ds = { class: "flex-1 flex flex-col gap-4" }, cs = {
369
- key: 0,
370
- class: "flex-1 flex flex-col gap-4"
371
- }, ms = /* @__PURE__ */ pe({
372
- __name: "TransferItem",
373
- props: {
374
- cellByColId: {},
375
- comparePriceBySku: {},
376
- showComparePrice: { type: Boolean },
377
- row: {}
378
- },
379
- setup(m) {
380
- const { t: y } = he();
381
- return (n, i) => {
382
- var f, g, w, u, a, l, v, k, h, _, x, F, V, z, ue, T, $, O, R, I, B, K, Q, p, c, H, oe;
383
- const b = P("FmLabel"), t = P("FmSpacer");
384
- return S(), M("div", ts, [
385
- o("div", ss, [
386
- o("div", as, [
387
- o("span", os, " (" + U(n.row.original.sku.code) + ") ", 1),
388
- o("span", ls, U(n.row.original.sku.name), 1)
389
- ]),
390
- o("div", null, [
391
- d(e(ie), {
392
- render: (w = (g = (f = n.cellByColId.Delete) == null ? void 0 : f.column) == null ? void 0 : g.columnDef) == null ? void 0 : w.cell,
393
- props: (a = (u = n.cellByColId.Delete) == null ? void 0 : u.getContext) == null ? void 0 : a.call(u)
394
- }, null, 8, ["render", "props"])
395
- ])
396
- ]),
397
- o("div", ns, [
398
- o("div", rs, [
399
- d(b, {
400
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Code}`)
401
- }, null, 8, ["label"]),
402
- d(e(ie), {
403
- render: (k = (v = (l = n.cellByColId[e(Y).Code]) == null ? void 0 : l.column) == null ? void 0 : v.columnDef) == null ? void 0 : k.cell,
404
- props: (_ = (h = n.cellByColId[e(Y).Code]) == null ? void 0 : h.getContext) == null ? void 0 : _.call(h)
405
- }, null, 8, ["render", "props"]),
406
- i[0] || (i[0] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
407
- ]),
408
- o("div", is, [
409
- d(b, {
410
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Name}`)
411
- }, null, 8, ["label"]),
412
- d(e(ie), {
413
- render: (V = (F = (x = n.cellByColId[e(Y).Name]) == null ? void 0 : x.column) == null ? void 0 : F.columnDef) == null ? void 0 : V.cell,
414
- props: (ue = (z = n.cellByColId[e(Y).Name]) == null ? void 0 : z.getContext) == null ? void 0 : ue.call(z)
415
- }, null, 8, ["render", "props"]),
416
- i[1] || (i[1] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
417
- ])
418
- ]),
419
- o("div", us, [
420
- o("div", ds, [
421
- d(b, {
422
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Amount}`)
423
- }, null, 8, ["label"]),
424
- d(e(ie), {
425
- render: (O = ($ = (T = n.cellByColId[e(Y).Amount]) == null ? void 0 : T.column) == null ? void 0 : $.columnDef) == null ? void 0 : O.cell,
426
- props: (I = (R = n.cellByColId[e(Y).Amount]) == null ? void 0 : R.getContext) == null ? void 0 : I.call(R)
427
- }, null, 8, ["render", "props"]),
428
- i[2] || (i[2] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
429
- ]),
430
- n.cellByColId[e(Y).Cost] ? (S(), M("div", cs, [
431
- d(it, { "z-index": 50 }, {
432
- default: D(() => [
433
- d(b, {
434
- label: e(y)(`inventory.transfer.form.items.table.${e(Y).Cost}2`)
435
- }, null, 8, ["label"])
436
- ]),
437
- _: 1
438
- }),
439
- d(e(ie), {
440
- render: (Q = (K = (B = n.cellByColId[e(Y).Cost]) == null ? void 0 : B.column) == null ? void 0 : K.columnDef) == null ? void 0 : Q.cell,
441
- props: (c = (p = n.cellByColId[e(Y).Cost]) == null ? void 0 : p.getContext) == null ? void 0 : c.call(p)
442
- }, null, 8, ["render", "props"]),
443
- i[3] || (i[3] = o("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
444
- ])) : G("", !0)
445
- ]),
446
- n.showComparePrice && Object.keys(n.comparePriceBySku[(H = n.row.original.sku) == null ? void 0 : H._id] ?? {}).length > 0 ? (S(), M(ke, { key: 0 }, [
447
- d(t, { class: "h-8" }),
448
- d(dt, {
449
- prices: n.comparePriceBySku[(oe = n.row.original.sku) == null ? void 0 : oe._id]
450
- }, null, 8, ["prices"])
451
- ], 64)) : G("", !0)
452
- ]);
453
- };
454
- }
455
- });
456
- function ps(m) {
457
- const y = q({
458
- get() {
459
- const t = m.getEffectiveAt();
460
- return t ? new Date(t) : null;
461
- },
462
- set(t) {
463
- m.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
464
- }
465
- }), n = q({
466
- get() {
467
- return !!y.value;
468
- },
469
- set(t) {
470
- t ? y.value = /* @__PURE__ */ new Date() : y.value = null;
471
- }
472
- }), i = q({
473
- get() {
474
- return y.value === null ? "" : Le(y.value);
475
- },
476
- set(t) {
477
- t ? y.value = /* @__PURE__ */ new Date(`${t} ${b.value}`) : y.value = null;
478
- }
479
- }), b = q({
480
- get() {
481
- return y.value === null ? "" : gt(y.value);
482
- },
483
- set(t) {
484
- t ? y.value = /* @__PURE__ */ new Date(`${i.value} ${t}`) : y.value = null;
485
- }
486
- });
487
- return {
488
- backdatePo: y,
489
- backdateSwitch: n,
490
- backdateModel: i,
491
- backdateTimeModel: b
492
- };
493
- }
494
- const fs = {
495
- width: "24",
496
- height: "24",
497
- viewBox: "0 0 24 24",
498
- fill: "none",
499
- xmlns: "http://www.w3.org/2000/svg"
500
- }, vs = ["fill"], ys = ["fill"], bs = ["stroke"], gs = ["stroke"], _s = /* @__PURE__ */ pe({
501
- __name: "SparkIcon",
502
- props: {
503
- size: {
504
- type: Number,
505
- default: 24
506
- },
507
- color: {
508
- type: String,
509
- default: "#c7c7cc"
510
- }
511
- },
512
- setup(m) {
513
- return (y, n) => (S(), M("svg", fs, [
514
- o("path", {
515
- 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",
516
- fill: m.color
517
- }, null, 8, vs),
518
- o("path", {
519
- 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",
520
- fill: m.color
521
- }, null, 8, ys),
522
- o("path", {
523
- 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",
524
- stroke: m.color,
525
- "stroke-width": "1.5",
526
- "stroke-linecap": "round",
527
- "stroke-linejoin": "round"
528
- }, null, 8, bs),
529
- o("path", {
530
- 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",
531
- stroke: m.color,
532
- "stroke-width": "1.5",
533
- "stroke-linecap": "round",
534
- "stroke-linejoin": "round"
535
- }, null, 8, gs)
536
- ]));
537
- }
538
- }), ks = { class: "flex gap-8 items-center" }, hs = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Cs = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, xs = { class: "flex items-center w-full" }, Ss = { class: "flex-1" }, ws = { class: "fm-typo-en-title-sm-800" }, Fs = { class: "flex items-start gap-8" }, Ds = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, $s = { class: "flex gap-1" }, tt = /* @__PURE__ */ pe({
539
- __name: "ForecastStock",
540
- props: {
541
- disabled: { type: Boolean }
542
- },
543
- emits: ["update:poItems"],
544
- setup(m, { emit: y }) {
545
- const n = y, i = N(!1), b = N(7), t = qt(), f = qe(), g = He(), { t: w } = he();
546
- async function u() {
547
- if (b.value < 1)
548
- return;
549
- i.value = !1, await t.readPurchaseOrder(b.value);
550
- const a = [];
551
- if (t.purchaseOrderForecast.skus.length <= 0) {
552
- f.open({
553
- message: w("inventory.transfer.form.items.forecastStock.notAvailable"),
554
- type: "info"
555
- });
556
- return;
557
- }
558
- const l = t.purchaseOrderForecast.skus.reduce((v, k) => {
559
- const h = g.skus.find((F) => F._id === k.id);
560
- if (v.find((F) => F.sku._id === k.id) || !h)
561
- return v;
562
- const x = {
563
- sku: h,
564
- code: h.code,
565
- name: h.name,
566
- quantity: {
567
- amount: k.amount,
568
- precision: 0
569
- }
570
- };
571
- return v.push(x), v;
572
- }, a);
573
- n("update:poItems", l);
574
- }
575
- return (a, l) => {
576
- const v = P("FmButton"), k = P("FmIcon"), h = P("FmStepperField"), _ = P("FmPopover");
577
- return S(), J(_, {
578
- disabled: a.disabled,
579
- class: "flex",
580
- "show-popover": i.value,
581
- onPopoverChanged: l[3] || (l[3] = (x) => i.value = x)
582
- }, {
583
- "popover-button": D(() => [
584
- d(v, {
585
- label: "unused",
586
- variant: "secondary",
587
- "text-color": a.disabled ? "disabled" : "primary",
588
- "bg-color": "transparent",
589
- "border-color": a.disabled ? "disabled" : "primary",
590
- disabled: a.disabled
591
- }, {
592
- default: D(() => [
593
- o("div", ks, [
594
- d(_s, {
595
- size: 24,
596
- color: a.disabled ? "#c7c7cc" : "#ff7823"
597
- }, null, 8, ["color"]),
598
- o("div", hs, U(e(w)("inventory.transfer.form.items.forecastStock.title")), 1)
599
- ])
600
- ]),
601
- _: 1
602
- }, 8, ["text-color", "border-color", "disabled"])
603
- ]),
604
- default: D(() => [
605
- o("div", Cs, [
606
- o("div", xs, [
607
- o("div", Ss, [
608
- d(Kt, { "z-index": 99 }, {
609
- default: D(() => [
610
- o("p", ws, U(e(w)("inventory.transfer.form.items.forecastStock.title")), 1)
611
- ]),
612
- _: 1
613
- })
614
- ]),
615
- d(v, {
616
- icon: "close",
617
- size: "md",
618
- variant: "tertiary",
619
- onClick: l[0] || (l[0] = (x) => i.value = !1)
620
- })
621
- ]),
622
- d(h, {
623
- modelValue: b.value,
624
- "onUpdate:modelValue": l[1] || (l[1] = (x) => b.value = x),
625
- label: e(w)("inventory.transfer.form.items.forecastStock.days"),
626
- rules: [e(Re)(1)]
627
- }, {
628
- "helper-text": D(() => [
629
- o("div", Fs, [
630
- d(k, {
631
- name: "warning",
632
- size: "sm",
633
- class: "text-fm-color-system-warning-300"
634
- }),
635
- o("div", Ds, U(e(w)("inventory.transfer.form.items.forecastStock.replace")), 1)
636
- ])
637
- ]),
638
- _: 1
639
- }, 8, ["modelValue", "label", "rules"]),
640
- o("div", $s, [
641
- l[4] || (l[4] = o("div", { class: "grow" }, null, -1)),
642
- d(v, {
643
- label: e(w)("common.cancel"),
644
- variant: "tertiary",
645
- onClick: l[2] || (l[2] = (x) => i.value = !1)
646
- }, null, 8, ["label"]),
647
- d(v, {
648
- label: e(w)("inventory.transfer.form.items.forecastStock.generate"),
649
- onClick: u
650
- }, null, 8, ["label"])
651
- ])
652
- ])
653
- ]),
654
- _: 1
655
- }, 8, ["disabled", "show-popover"]);
656
- };
657
- }
658
- });
659
- function Ts() {
660
- const m = qe(), y = rt(), n = N(!1);
661
- _e(n, (f) => {
662
- f && (b.value = !0, i().finally(() => {
663
- b.value = !1;
664
- }));
665
- });
666
- async function i() {
667
- try {
668
- const { startDate: f, endDate: g } = _t(6), a = (await y.getPurchaseOrders({ start: f, end: g })).filter(
669
- (l) => {
670
- var v, k;
671
- return l.status === kt.enum.COMPLETE && ((v = l.supplier) == null ? void 0 : v.internal) !== "warehouse" && ((k = l.supplier) == null ? void 0 : k.internal) !== "restaurant";
672
- }
673
- ).reduce((l, v) => {
674
- const k = new Date(ht(v._id)), h = v.supplier._id;
675
- for (const _ of v.items) {
676
- if (!_.totalCost) continue;
677
- const x = l[_.sku._id] ?? {}, F = x[h] ?? [];
678
- F.push({
679
- date: k.toISOString(),
680
- totalUnit: _.quantity,
681
- totalCost: _.totalCost,
682
- unit: _.sku.unit,
683
- measurement: _.measurement,
684
- seqNumber: v.seqNumber
685
- }), x[h] = F, l[_.sku._id] = x;
686
- }
687
- return l;
688
- }, {});
689
- t.value = a;
690
- } catch {
691
- m.open({
692
- title: "Something went wrong",
693
- message: "Cannot retrieve supplier purchase history. Please try again."
694
- }), n.value = !1;
695
- }
696
- }
697
- const b = N(!1), t = N({});
698
- return {
699
- comparePricesToggle: n,
700
- comparePriceFetching: b,
701
- comparePriceBySku: t
702
- };
703
- }
704
- const Ps = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, Is = { key: 0 }, Vs = ["colspan"], Rs = /* @__PURE__ */ pe({
705
- __name: "TransferItemTable",
706
- props: {
707
- row: {},
708
- comparePriceBySku: {},
709
- showComparePrice: { type: Boolean }
710
- },
711
- setup(m) {
712
- function y(n) {
713
- return n.column.columnDef.meta;
714
- }
715
- return (n, i) => {
716
- var b, t;
717
- return S(), M(ke, null, [
718
- o("tr", {
719
- class: W(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
720
- "bg-fm-color-neutral-gray-100": n.row.getIsSelected()
721
- }])
722
- }, [
723
- (S(!0), M(ke, null, Ue(n.row.getVisibleCells(), (f) => {
724
- var g, w, u, a;
725
- return S(), M("td", {
726
- key: f.id,
727
- class: W([
728
- "h-[52px] px-16 text-fm-color-typo-primary",
729
- ((g = y(f)) == null ? void 0 : g.cellClass) ?? "px-16"
730
- ]),
731
- style: ot({
732
- width: (w = y(f)) == null ? void 0 : w.width,
733
- maxWidth: (u = y(f)) == null ? void 0 : u.maxWidth,
734
- textAlign: ((a = y(f)) == null ? void 0 : a.textAlign) ?? "left"
735
- })
736
- }, [
737
- o("span", Ps, [
738
- d(e(ie), {
739
- render: f.column.columnDef.cell,
740
- props: f.getContext()
741
- }, null, 8, ["render", "props"])
742
- ])
743
- ], 6);
744
- }), 128))
745
- ], 2),
746
- n.showComparePrice && Object.keys(n.comparePriceBySku[(b = n.row.original.sku) == null ? void 0 : b._id] ?? {}).length > 0 ? (S(), M("tr", Is, [
747
- o("td", {
748
- colspan: n.row.getVisibleCells().length
749
- }, [
750
- d(dt, {
751
- prices: n.comparePriceBySku[(t = n.row.original.sku) == null ? void 0 : t._id]
752
- }, null, 8, ["prices"])
753
- ], 8, Vs)
754
- ])) : G("", !0)
755
- ], 64);
756
- };
757
- }
758
- }), As = {
759
- key: 0,
760
- class: "flex flex-col gap-8"
761
- }, qs = { class: "flex flex-col gap-4" }, Ms = { class: "flex items-center gap-4" }, Us = {
762
- key: 0,
763
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
764
- }, Es = /* @__PURE__ */ pe({
765
- __name: "NetSuiteField",
766
- props: {
767
- required: { type: Boolean },
768
- disabled: { type: Boolean },
769
- supplier: {},
770
- setting: {},
771
- items: {},
772
- onChange: { type: Function }
773
- },
774
- emits: ["netsuite:ready"],
775
- setup(m, { emit: y }) {
776
- const n = Ne(), i = m, b = y, { t } = Qt(), f = N(!1), g = N();
777
- Be(() => {
778
- var l, v, k, h;
779
- let a = {
780
- id: "",
781
- subsidiary: { id: "", name: "" },
782
- errors: []
783
- };
784
- if (!n.isEnabled || !i.required) {
785
- b("netsuite:ready", a);
786
- return;
787
- }
788
- try {
789
- const _ = n.currentLocationSubsidiary();
790
- i.setting ? a = {
791
- ...i.setting,
792
- subsidiary: {
793
- id: _.id || "",
794
- name: _.name
795
- }
796
- } : a = {
797
- ...a,
798
- subsidiary: {
799
- id: _.id || "",
800
- name: _.name
801
- }
802
- };
803
- const x = n.getAvailableItems(_.id), F = i.items.filter((V) => {
804
- if (V.measurement != null) {
805
- const z = n.getAvailableMeasurements(
806
- V.sku._id,
807
- _.id
808
- );
809
- return x.includes(V.sku._id) && z.includes(V.measurement.id);
810
- }
811
- return x.includes(V.sku._id);
812
- }).map((V) => V.sku._id);
813
- i.onChange(
814
- i.items.filter((V) => F.includes(V.sku._id)),
815
- a
816
- );
817
- } finally {
818
- i.supplier.internal ? g.value = n.getNetSuiteLocation(
819
- `${i.supplier.internal}_${i.supplier._id}`
820
- ) : g.value = n.getNetSuiteVendor(i.supplier._id);
821
- const _ = i.supplier.internal ? n.getLocationSubsidiary((l = g.value) == null ? void 0 : l.netSuiteId).id : (v = g.value) == null ? void 0 : v.subsidiaryId, x = i.supplier.internal ? (k = n.currentLocationSubsidiary()) == null ? void 0 : k.id : (h = n.currentVendorSubsidiary(i.supplier._id)) == null ? void 0 : h.id;
822
- !n.isEnabled || _ && n.isEnabled && _ == x ? b("netsuite:ready", a) : f.value = !0;
823
- }
824
- });
825
- const w = q(
826
- () => i.supplier.internal ? n.currentLocationSubsidiary() : n.currentVendorSubsidiary(i.supplier._id)
827
- ), u = q(() => {
828
- var a, l;
829
- return g.value == null ? `Cannot find the NetSuite location for "${i.supplier.name}"` : `The subsidiary of the request
830
- location is ${(l = n.getLocationSubsidiary((a = g.value) == null ? void 0 : a.netSuiteId)) == null ? void 0 : l.fullName}`;
831
- });
832
- return (a, l) => {
833
- const v = P("FmLabel"), k = P("FmIcon"), h = P("FmField"), _ = P("FmTooltip");
834
- return e(n).isEnabled && i.required ? (S(), M("div", As, [
835
- d(v, {
836
- label: `NetSuite ${e(t)("inventory.transfer.form.netsuite.subsidiary")}`
837
- }, null, 8, ["label"]),
838
- o("div", qs, [
839
- d(_, {
840
- "z-index": 51,
841
- placement: "left",
842
- disabled: a.disabled
843
- }, {
844
- content: D(() => l[0] || (l[0] = [
845
- Ee("This field is locked and based on the location of the request.")
846
- ])),
847
- default: D(() => [
848
- d(h, null, {
849
- default: D(() => {
850
- var x;
851
- return [
852
- o("div", Ms, [
853
- d(k, {
854
- name: "lock_outline",
855
- size: "sm",
856
- color: a.disabled ? "neutral-gray-200" : "neutral-gray-400"
857
- }, null, 8, ["color"]),
858
- o("div", {
859
- class: W([a.disabled ? "text-fm-color-typo-disabled" : ""])
860
- }, U((x = w.value) == null ? void 0 : x.fullName), 3)
861
- ])
862
- ];
863
- }),
864
- _: 1
865
- })
866
- ]),
867
- _: 1
868
- }, 8, ["disabled"]),
869
- f.value ? (S(), M("div", Us, U(u.value), 1)) : G("", !0)
870
- ])
871
- ])) : G("", !0);
872
- };
873
- }
874
- }), Os = { class: "flex flex-col gap-4" }, Bs = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, Ns = { class: "flex flex-col gap-16" }, zs = { class: "flex flex-col gap-24" }, Ls = { class: "flex flex-col gap-8" }, Hs = { class: "flex flex-col gap-4" }, js = { class: "flex items-center gap-4" }, Ys = { class: "flex flex-col gap-8" }, Ks = { class: "flex flex-col gap-4" }, Qs = { class: "flex items-center gap-4" }, Zs = {
875
- key: 3,
876
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
877
- }, Gs = {
878
- key: 0,
879
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
880
- }, Js = { class: "flex-1" }, Ws = { class: "flex-1" }, Xs = {
881
- key: 1,
882
- class: "flex items-center gap-4"
883
- }, ea = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, ta = { class: "flex flex-col gap-16" }, sa = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, aa = { class: "flex gap-8" }, oa = { key: 0 }, la = /* @__PURE__ */ pe({
884
- __name: "TransferForm2",
885
- props: {
886
- modelValue: {},
887
- request: {},
888
- disabled: { type: Boolean },
889
- suppliers: {},
890
- skus: {},
891
- lastClosingDate: {}
892
- },
893
- emits: ["validation-success", "form:ready"],
894
- setup(m, { expose: y, emit: n }) {
895
- const i = m, b = n, t = Ct(), { t: f } = he(), g = je(), w = He(), u = Ne(), a = Ke(), l = Ae(), v = ut(), { breakpoints: k } = Ye(), h = q(() => k.value.xs || k.value.sm), _ = at({
896
- value: !1
897
- }), x = N(!1), F = q(
898
- () => {
899
- var s;
900
- return ((s = i.modelValue) == null ? void 0 : s.templateDoc) ?? v.templates.find((r) => r._id === t.template);
901
- }
902
- ), V = q(() => t.status === "DRAFT" || !t._rev);
903
- _e(F, (s) => {
904
- s && V.value && (t.supplier = (s == null ? void 0 : s.purchaseOrder.supplier) ?? t.supplier);
905
- }), Be(() => {
906
- var s;
907
- try {
908
- if (!t.template) return;
909
- if (!t.items.length) {
910
- let r = [];
911
- (s = F.value) != null && s.purchaseOrder.items && (r = F.value.purchaseOrder.items.filter((E) => {
912
- var Z;
913
- return ((Z = E.quantity) == null ? void 0 : Z.amount) != 0;
914
- })), t.items = r;
915
- }
916
- } finally {
917
- x.value = !0;
918
- }
919
- }), _e([x, _], ([s, r], [E, Z]) => {
920
- r.value && Z.value && b("form:ready");
921
- });
922
- const z = q(
923
- () => g.currentLocation.type === xt.restaurant
924
- );
925
- g.watchLocation(async () => {
926
- location && (t.supplier || (t.supplier = a.suppliers.find((s) => s) ?? t.supplier));
927
- });
928
- const ue = Bt(), T = jt(
929
- () => t,
930
- (s) => {
931
- Object.assign(t, s);
932
- },
933
- !0,
934
- !0
935
- ), $ = q({
936
- get() {
937
- var s;
938
- return typeof ((s = t == null ? void 0 : t.supplier) == null ? void 0 : s.internal) == "string" ? j.TRANSFER : j.PURCHASE;
939
- },
940
- set(s) {
941
- var E;
942
- const r = typeof ((E = t == null ? void 0 : t.supplier) == null ? void 0 : E.internal) == "string" ? j.TRANSFER : j.PURCHASE;
943
- s !== r && (t.supplier = s === j.PURCHASE ? T.locationOptionsTypePurchase.value[0] : T.locationOptionsTypeTransfer.value[0]);
944
- }
945
- });
946
- _e(
947
- () => {
948
- var s;
949
- return (s = i.modelValue) == null ? void 0 : s.template;
950
- },
951
- (s) => {
952
- l.mustUsePoTemplate && !s && ct(() => {
953
- var r, E;
954
- t.supplier = ((E = (r = T.locationOptionsTypeTransfer.value) == null ? void 0 : r.filter(
955
- (Z) => Z.internal === "restaurant"
956
- )) == null ? void 0 : E[0]) ?? t.supplier;
957
- });
958
- },
959
- { immediate: !0 }
960
- );
961
- const O = q(() => {
962
- let s = T.transferLocationOptions.value;
963
- return l.mustUsePoTemplate && !t.template && (s = s.filter((r) => {
964
- var E;
965
- return (E = r.sublabel) == null ? void 0 : E.startsWith("restaurant");
966
- })), s;
967
- }), R = q({
968
- get() {
969
- return t.supplier._id;
970
- },
971
- set(s) {
972
- T.transferLocationModel.value = s;
973
- }
974
- }), I = q({
975
- get() {
976
- return t.remark ?? void 0;
977
- },
978
- set(s) {
979
- t.remark = s;
980
- }
981
- }), { backdatePo: B, backdateSwitch: K, backdateModel: Q, backdateTimeModel: p } = ps({
982
- getEffectiveAt() {
983
- return t.effectiveAt;
984
- },
985
- setEffectiveAt(s) {
986
- t.effectiveAt = s;
987
- }
988
- }), { comparePricesToggle: c, comparePriceFetching: H, comparePriceBySku: oe } = Ts(), X = N();
989
- y({
990
- validateInputs: () => {
991
- var s, r;
992
- (r = (s = X.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
993
- },
994
- resetInputsValidation: () => {
995
- var s, r;
996
- (r = (s = X.value) == null ? void 0 : s.resetInputsValidation) == null || r.call(s);
997
- },
998
- resetInputs: () => {
999
- var s, r;
1000
- (r = (s = X.value) == null ? void 0 : s.resetInputs) == null || r.call(s);
1001
- }
1002
- });
1003
- const $e = Zt({
1004
- updateItem: (s) => {
1005
- t.items = t.items.map((r) => r.sku._id !== s.sku._id ? r : s);
1006
- },
1007
- deleteItem: (s) => {
1008
- t.items = t.items.filter((r) => r.sku._id !== s.sku._id);
1009
- },
1010
- get supplier() {
1011
- return t.supplier;
1012
- },
1013
- get items() {
1014
- return t.items;
1015
- },
1016
- get transferType() {
1017
- return $.value;
1018
- },
1019
- get template() {
1020
- return F.value;
1021
- },
1022
- get disabled() {
1023
- return i.disabled;
1024
- }
1025
- }), Ce = q(() => {
1026
- let s = $e.columnDefs.value;
1027
- return u.isEnabled && $.value === j.TRANSFER && (s = s.filter((r) => r.id !== Y.TotalCost)), s;
1028
- });
1029
- function Te() {
1030
- var ae, fe, xe, Ie, we;
1031
- const s = new Set((xe = (fe = (ae = F.value) == null ? void 0 : ae.purchaseOrder) == null ? void 0 : fe.items) == null ? void 0 : xe.map((A) => A.sku._id)), r = u.isEnabled ? u.getAvailableItems((we = (Ie = t.netSuite) == null ? void 0 : Ie.subsidiary) == null ? void 0 : we.id) : [], E = s.size ? w.skus.filter((A) => s.has(A._id)) : w.skus, Z = u.isEnabled ? E.filter((A) => {
1032
- var le, te, ce, ne;
1033
- const ee = (te = (le = F.value) == null ? void 0 : le.purchaseOrder) == null ? void 0 : te.items.find(
1034
- (me) => me.sku._id === A._id
1035
- );
1036
- if (ee != null && ee.measurement != null) {
1037
- const me = u.getAvailableMeasurements(
1038
- ee.sku._id,
1039
- (ne = (ce = t.netSuite) == null ? void 0 : ce.subsidiary) == null ? void 0 : ne.id
1040
- );
1041
- return r.includes(ee.sku._id) && me.includes(ee.measurement.id);
1042
- }
1043
- return r.includes(A._id);
1044
- }).map((A) => A._id) : E.map((A) => A._id), de = E.map(
1045
- (A) => ({
1046
- label: A.name,
1047
- sublabel: A.code,
1048
- value: A,
1049
- disabled: !Z.includes(A._id)
1050
- })
1051
- ), be = de.filter((A) => {
1052
- var ee;
1053
- return (ee = t.items) == null ? void 0 : ee.find((le) => le.sku._id === A.value._id);
1054
- }).map((A) => A.value);
1055
- ue.open({
1056
- title: f("inventory.transfer.form.items.selectItem"),
1057
- closeButton: !0,
1058
- contentComponent: Dt,
1059
- contentComponentProps: {
1060
- modelValue: be,
1061
- items: de,
1062
- virtualScroll: !0
1063
- },
1064
- primaryActions: {
1065
- text: f("common.confirm"),
1066
- close: !0
1067
- },
1068
- secondaryActions: {
1069
- text: f("common.close"),
1070
- close: !0,
1071
- variant: "tertiary"
1072
- }
1073
- }).onPrimary((A) => {
1074
- const ee = t.items ?? [], le = A.map((te) => {
1075
- var me, Fe;
1076
- const ce = ee.find((ge) => ge.sku._id === te._id);
1077
- if (ce)
1078
- return ce;
1079
- const ne = ((Fe = (me = F.value) == null ? void 0 : me.purchaseOrder.items) == null ? void 0 : Fe.find(
1080
- (ge) => ge.sku._id === te._id
1081
- )) ?? {
1082
- sku: te,
1083
- code: te.code,
1084
- name: te.name,
1085
- quantity: {
1086
- amount: 1,
1087
- precision: 0
1088
- }
1089
- };
1090
- return $.value == j.PURCHASE && (ne.totalCost = re(
1091
- ne.sku,
1092
- ne.quantity,
1093
- ne.measurement,
1094
- {
1095
- supplier: t.supplier
1096
- }
1097
- )), ne;
1098
- });
1099
- le.sort((te, ce) => te.sku.code.localeCompare(ce.sku.code)), t.items = le;
1100
- });
1101
- }
1102
- function Me(s) {
1103
- return s;
1104
- }
1105
- const Pe = q(() => {
1106
- const s = [];
1107
- return (!l.mustUsePoTemplate || l.mustUsePoTemplate && t.template) && s.push({
1108
- label: f("inventory.transfer.form.type.purchase"),
1109
- value: j.PURCHASE
1110
- }), s.push({
1111
- label: f("inventory.transfer.form.type.transfer"),
1112
- value: j.TRANSFER
1113
- }), s;
1114
- });
1115
- return (s, r) => {
1116
- var me, Fe;
1117
- const E = P("FmChip"), Z = P("FmLabel"), de = P("FmIcon"), be = P("FmField"), ae = P("FmTooltip"), fe = P("FmSelect"), xe = P("FmTextField"), Ie = P("FmTextarea"), we = P("FmSwitch"), A = P("FmDatePicker"), ee = P("FmTimePicker"), le = P("FmFormGroup"), te = P("FmButton"), ce = P("FmTable"), ne = P("FmForm");
1118
- return S(), M("div", Os, [
1119
- o("div", Bs, [
1120
- (me = i.modelValue) != null && me.template ? (S(), J(E, {
1121
- key: 0,
1122
- variant: s.disabled ? "warning" : void 0,
1123
- label: `${e(f)("inventory.transfer.template.title")}: ${((Fe = F.value) == null ? void 0 : Fe.name) ?? e(f)("inventory.transfer.form.loading")}`,
1124
- icon: "summarize",
1125
- compact: ""
1126
- }, null, 8, ["variant", "label"])) : G("", !0),
1127
- d(E, {
1128
- label: e(g).currentLocation.name,
1129
- icon: "storefront",
1130
- compact: ""
1131
- }, null, 8, ["label"]),
1132
- s.lastClosingDate ? (S(), J(E, {
1133
- key: 1,
1134
- label: `${e(f)("inventory.transfer.form.lastClosing")}: ${e(Le)(s.lastClosingDate)} ${e(St)(s.lastClosingDate)}`,
1135
- icon: "calendar_month",
1136
- compact: ""
1137
- }, null, 8, ["label"])) : G("", !0)
1138
- ]),
1139
- d(ne, {
1140
- ref_key: "formRef",
1141
- ref: X,
1142
- class: "flex flex-col gap-32",
1143
- disabled: s.disabled,
1144
- onValidationFailed: console.log,
1145
- onValidationSuccess: r[13] || (r[13] = (ge) => b("validation-success"))
1146
- }, {
1147
- default: D(() => {
1148
- var ge, Qe;
1149
- return [
1150
- o("div", Ns, [
1151
- o("div", zs, [
1152
- (ge = i.modelValue) != null && ge.template ? (S(), M(ke, { key: 0 }, [
1153
- o("div", Ls, [
1154
- d(Z, {
1155
- label: e(f)("inventory.transfer.form.type.title")
1156
- }, null, 8, ["label"]),
1157
- o("div", Hs, [
1158
- d(ae, {
1159
- "z-index": 51,
1160
- placement: "left",
1161
- disabled: s.disabled
1162
- }, {
1163
- content: D(() => r[14] || (r[14] = [
1164
- Ee("This field is locked from template.")
1165
- ])),
1166
- default: D(() => [
1167
- d(be, null, {
1168
- default: D(() => [
1169
- o("div", js, [
1170
- d(de, {
1171
- name: "lock_outline",
1172
- size: "sm",
1173
- color: s.disabled ? "neutral-gray-200" : "neutral-gray-400"
1174
- }, null, 8, ["color"]),
1175
- o("div", {
1176
- class: W({ "text-fm-color-typo-disabled": s.disabled })
1177
- }, U(e(f)(`inventory.transfer.form.type.${$.value.toLocaleLowerCase("en-us")}`)), 3)
1178
- ])
1179
- ]),
1180
- _: 1
1181
- })
1182
- ]),
1183
- _: 1
1184
- }, 8, ["disabled"]),
1185
- o("div", {
1186
- class: W([
1187
- "fm-typo-en-body-sm-400",
1188
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1189
- ])
1190
- }, null, 2)
1191
- ])
1192
- ]),
1193
- o("div", Ys, [
1194
- d(Z, {
1195
- label: $.value === e(j).PURCHASE ? e(f)("inventory.transfer.form.purchaseFrom") : e(f)("inventory.transfer.form.transferFrom")
1196
- }, null, 8, ["label"]),
1197
- o("div", Ks, [
1198
- d(ae, {
1199
- "z-index": 51,
1200
- placement: "left",
1201
- disabled: s.disabled
1202
- }, {
1203
- content: D(() => r[15] || (r[15] = [
1204
- Ee("This field is locked from template.")
1205
- ])),
1206
- default: D(() => [
1207
- d(be, null, {
1208
- default: D(() => {
1209
- var C;
1210
- return [
1211
- o("div", Qs, [
1212
- d(de, {
1213
- name: "lock_outline",
1214
- size: "sm",
1215
- color: s.disabled ? "neutral-gray-200" : "neutral-gray-400"
1216
- }, null, 8, ["color"]),
1217
- o("div", {
1218
- class: W({ "text-fm-color-typo-disabled": s.disabled })
1219
- }, U((C = O.value.find((se) => se.value === R.value)) == null ? void 0 : C.label), 3)
1220
- ])
1221
- ];
1222
- }),
1223
- _: 1
1224
- })
1225
- ]),
1226
- _: 1
1227
- }, 8, ["disabled"])
1228
- ])
1229
- ])
1230
- ], 64)) : (S(), M(ke, { key: 1 }, [
1231
- d(fe, {
1232
- label: e(f)("inventory.transfer.form.type.title"),
1233
- "label-mark": "required",
1234
- modelValue: $.value,
1235
- "onUpdate:modelValue": r[0] || (r[0] = (C) => $.value = C),
1236
- items: Pe.value,
1237
- rules: [e(Re)(1)(O.value)]
1238
- }, {
1239
- default: D(() => [
1240
- o("span", {
1241
- class: W([
1242
- "line-clamp-1 fm-typo-en-body-lg-400",
1243
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1244
- ])
1245
- }, U(e(wt)($.value)), 3)
1246
- ]),
1247
- _: 1
1248
- }, 8, ["label", "modelValue", "items", "rules"]),
1249
- d(fe, {
1250
- label: $.value === e(j).PURCHASE ? e(f)("inventory.transfer.form.purchaseFrom") : e(f)("inventory.transfer.form.transferFrom"),
1251
- "label-mark": "required",
1252
- modelValue: R.value,
1253
- "onUpdate:modelValue": r[1] || (r[1] = (C) => R.value = C),
1254
- items: O.value
1255
- }, {
1256
- "menu-wrapper": D((C) => {
1257
- var se, Ze;
1258
- return [
1259
- d(Yt, Oe(C, {
1260
- items: O.value,
1261
- "model-value": (Ze = (se = s.modelValue) == null ? void 0 : se.supplier) == null ? void 0 : Ze._id
1262
- }), null, 16, ["items", "model-value"])
1263
- ];
1264
- }),
1265
- default: D(() => {
1266
- var C;
1267
- return [
1268
- o("span", {
1269
- class: W([
1270
- "line-clamp-1 fm-typo-en-body-lg-400",
1271
- s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1272
- ])
1273
- }, U((C = O.value.find((se) => se.value === R.value)) == null ? void 0 : C.label), 3)
1274
- ];
1275
- }),
1276
- _: 1
1277
- }, 8, ["label", "modelValue", "items"])
1278
- ], 64)),
1279
- d(xe, {
1280
- label: e(f)("inventory.transfer.form.reference"),
1281
- "label-mark": "optional",
1282
- modelValue: e(t).ref,
1283
- "onUpdate:modelValue": r[2] || (r[2] = (C) => e(t).ref = C)
1284
- }, null, 8, ["label", "modelValue"]),
1285
- d(Ie, {
1286
- label: e(f)("inventory.transfer.form.remark"),
1287
- "label-mark": "optional",
1288
- "max-length": 240,
1289
- modelValue: I.value,
1290
- "onUpdate:modelValue": r[3] || (r[3] = (C) => I.value = C),
1291
- class: W([s.disabled ? "text-fm-color-typo-disabled " : ""])
1292
- }, null, 8, ["label", "modelValue", "class"]),
1293
- x.value ? (S(), J(Es, {
1294
- key: 2,
1295
- required: e(t).template != null,
1296
- disabled: s.disabled,
1297
- supplier: e(t).supplier,
1298
- setting: e(t).netSuite,
1299
- items: e(t).items,
1300
- onChange: (C, se) => {
1301
- e(t).items = C, e(t).netSuite = se;
1302
- },
1303
- "onNetsuite:ready": r[4] || (r[4] = (C) => {
1304
- _.value = !0;
1305
- })
1306
- }, null, 8, ["required", "disabled", "supplier", "setting", "items", "onChange"])) : G("", !0),
1307
- e(l).enableBackdatePo ? (S(), M("div", Zs, [
1308
- o("div", {
1309
- class: W([
1310
- "flex",
1311
- {
1312
- "flex-col": h.value
1313
- }
1314
- ])
1315
- }, [
1316
- d(we, {
1317
- modelValue: e(K),
1318
- "onUpdate:modelValue": r[5] || (r[5] = (C) => Se(K) ? K.value = C : null),
1319
- label: e(f)("inventory.transfer.form.backdate.title"),
1320
- sublabel: e(f)("inventory.transfer.form.backdate.subtitle"),
1321
- "label-placement": "right",
1322
- disabled: z.value && !s.lastClosingDate || s.disabled
1323
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1324
- o("div", {
1325
- class: W({ hidden: h.value, "w-16": !h.value })
1326
- }, null, 2),
1327
- e(K) ? (S(), M("div", Gs, [
1328
- o("div", Js, [
1329
- d(A, {
1330
- modelValue: e(Q),
1331
- "onUpdate:modelValue": r[6] || (r[6] = (C) => Se(Q) ? Q.value = C : null)
1332
- }, null, 8, ["modelValue"])
1333
- ]),
1334
- o("div", Ws, [
1335
- d(ee, {
1336
- modelValue: e(p),
1337
- "onUpdate:modelValue": r[7] || (r[7] = (C) => Se(p) ? p.value = C : null)
1338
- }, null, 8, ["modelValue"])
1339
- ])
1340
- ])) : G("", !0)
1341
- ], 2),
1342
- e(B) ? (S(), J(le, {
1343
- key: 0,
1344
- modelValue: e(B),
1345
- "onUpdate:modelValue": r[8] || (r[8] = (C) => Se(B) ? B.value = C : null),
1346
- rules: [e(Ft)(new Date(s.lastClosingDate), /* @__PURE__ */ new Date())]
1347
- }, null, 8, ["modelValue", "rules"])) : G("", !0),
1348
- z.value && !s.lastClosingDate ? (S(), M("div", Xs, [
1349
- d(de, {
1350
- name: "error",
1351
- size: "sm",
1352
- class: "text-fm-color-typo-warning"
1353
- }),
1354
- o("span", ea, U(e(f)("inventory.transfer.form.backdate.error")), 1)
1355
- ])) : G("", !0)
1356
- ])) : G("", !0)
1357
- ])
1358
- ]),
1359
- o("div", ta, [
1360
- d(le, {
1361
- "model-value": e(t).items,
1362
- rules: [e(Re)(1)]
1363
- }, null, 8, ["model-value", "rules"]),
1364
- o("div", {
1365
- class: W([
1366
- "flex gap-16",
1367
- {
1368
- "flex-col items-start": h.value,
1369
- "items-center": !h.value
1370
- }
1371
- ])
1372
- }, [
1373
- o("div", sa, U(e(f)("inventory.transfer.form.items.title")), 1),
1374
- o("div", aa, [
1375
- d(te, {
1376
- disabled: s.disabled,
1377
- label: e(f)("inventory.transfer.form.items.addItem"),
1378
- "prepend-icon": "add",
1379
- variant: "secondary",
1380
- "text-color": "primary",
1381
- "bg-color": "transparent",
1382
- "border-color": "primary",
1383
- onClick: r[9] || (r[9] = (C) => Te()),
1384
- size: "md"
1385
- }, null, 8, ["disabled", "label"]),
1386
- e(t).template ? (S(), J(ae, {
1387
- key: 0,
1388
- "z-index": 50
1389
- }, {
1390
- content: D(() => [
1391
- o("div", null, U(e(f)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1392
- ]),
1393
- default: D(() => [
1394
- d(tt, {
1395
- "onUpdate:poItems": r[10] || (r[10] = (C) => e(t).items = C),
1396
- disabled: ""
1397
- })
1398
- ]),
1399
- _: 1
1400
- })) : (S(), J(tt, {
1401
- key: 1,
1402
- "onUpdate:poItems": r[11] || (r[11] = (C) => e(t).items = C),
1403
- disabled: s.disabled || !!e(t).template
1404
- }, null, 8, ["disabled"]))
1405
- ])
1406
- ], 2),
1407
- $.value === e(j).PURCHASE && V.value && e(l).enableTotalCost && ((Qe = s.modelValue) != null && Qe.items.length) ? (S(), M("div", oa, [
1408
- d(we, {
1409
- label: e(H) ? e(f)("inventory.transfer.form.items.fetchingData") : e(f)("inventory.transfer.form.items.comparePriceHistory"),
1410
- "prepend-icon": "compare_arrows",
1411
- "label-placement": "right",
1412
- "model-value": e(c),
1413
- "onUpdate:modelValue": r[12] || (r[12] = (C) => Se(c) ? c.value = C : null),
1414
- disabled: e(H) || s.disabled
1415
- }, null, 8, ["label", "model-value", "disabled"])
1416
- ])) : G("", !0),
1417
- (S(), J(ce, {
1418
- "column-defs": Ce.value,
1419
- "row-data": e(t).items,
1420
- key: e(t).items.map((C) => C.sku._id).join("."),
1421
- "hide-footer": "",
1422
- "page-size": e(t).items.length
1423
- }, {
1424
- "table-row": D((C) => [
1425
- d(Rs, {
1426
- "compare-price-by-sku": e(oe),
1427
- "show-compare-price": $.value === e(j).PURCHASE && e(c),
1428
- row: C
1429
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1430
- ]),
1431
- "list-row": D((C) => [
1432
- (S(), J(nt, {
1433
- row: C,
1434
- key: e(t).items.map((se) => se.sku._id).join(".")
1435
- }, {
1436
- default: D((se) => [
1437
- d(ms, {
1438
- "compare-price-by-sku": e(oe),
1439
- "show-compare-price": $.value === e(j).PURCHASE && e(c),
1440
- row: C,
1441
- "cell-by-col-id": se
1442
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1443
- ]),
1444
- _: 2
1445
- }, 1032, ["row"]))
1446
- ]),
1447
- _: 1
1448
- }, 8, ["column-defs", "row-data", "page-size"]))
1449
- ])
1450
- ];
1451
- }),
1452
- _: 1
1453
- }, 8, ["disabled", "onValidationFailed"])
1454
- ]);
1455
- };
1456
- }
1457
- }), na = { class: "flex items-center" }, ra = { class: "fm-typo-en-title-md-800" }, ia = { class: "flex gap-4" }, ua = /* @__PURE__ */ pe({
1458
- __name: "TransferDialog",
1459
- props: {
1460
- mode: {},
1461
- modelValue: {},
1462
- templateId: {},
1463
- show: { type: Boolean },
1464
- lastClosingDate: {}
1465
- },
1466
- emits: ["update:show", "submitted"],
1467
- setup(m, { expose: y, emit: n }) {
1468
- var Q;
1469
- const i = m, b = n, t = rt(), f = ut(), g = qe(), w = Ke(), u = He(), a = je(), l = Ae(), { t: v } = he(), k = N(!1), h = N(!1), _ = N(!1);
1470
- async function x(p) {
1471
- if (p) {
1472
- h.value = !1;
1473
- try {
1474
- await w.readSuppliers(), h.value = !0;
1475
- } catch {
1476
- g.open({
1477
- title: v("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1478
- message: v("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1479
- type: "error"
1480
- });
1481
- }
1482
- }
1483
- }
1484
- a.watchLocation(x);
1485
- function F() {
1486
- return {
1487
- remark: void 0,
1488
- ref: void 0,
1489
- stockSnapshotId: void 0,
1490
- effectiveAt: void 0,
1491
- items: [],
1492
- supplier: {
1493
- _rev: void 0,
1494
- email: void 0,
1495
- internal: void 0,
1496
- contactName: void 0,
1497
- phoneNumber: void 0,
1498
- registrationNumber: void 0,
1499
- supplyItems: void 0,
1500
- _id: "",
1501
- name: "",
1502
- address: {
1503
- line2: void 0,
1504
- line1: "",
1505
- state: "",
1506
- city: "",
1507
- postcode: "",
1508
- country: ""
1509
- }
1510
- },
1511
- status: "DRAFT",
1512
- _id: "",
1513
- seqNumber: 0,
1514
- deliveryOrder: [],
1515
- template: i.templateId,
1516
- templateDoc: f.templates.find((c) => c._id === i.templateId)
1517
- };
1518
- }
1519
- const V = Nt(i, "show"), z = N(i.modelValue ?? F()), ue = N(((Q = i.modelValue) == null ? void 0 : Q._id) ?? `${Math.random()}`);
1520
- _e(
1521
- () => i.show,
1522
- (p) => {
1523
- var c;
1524
- p && (_.value = !1, z.value = i.modelValue ?? F(), ue.value = ((c = i.modelValue) == null ? void 0 : c._id) ?? `${Math.random()}`);
1525
- }
1526
- );
1527
- const T = q(() => !h.value || !_.value), $ = q(() => {
1528
- switch (i.mode) {
1529
- case De.READ:
1530
- return "View transfer";
1531
- case De.CREATE:
1532
- return v("inventory.transfer.receiveRequest.create.title");
1533
- case De.UPDATE:
1534
- return v("inventory.transfer.receiveRequest.update.title");
1535
- }
1536
- return "";
1537
- }), O = N();
1538
- y({
1539
- validateInputs: () => {
1540
- var p, c;
1541
- (c = (p = O.value) == null ? void 0 : p.validateInputs) == null || c.call(p);
1542
- },
1543
- resetInputsValidation: () => {
1544
- var p, c;
1545
- (c = (p = O.value) == null ? void 0 : p.resetInputsValidation) == null || c.call(p);
1546
- },
1547
- resetInputs: () => {
1548
- var p, c;
1549
- (c = (p = O.value) == null ? void 0 : p.resetInputs) == null || c.call(p);
1550
- }
1551
- });
1552
- async function R() {
1553
- const p = z.value;
1554
- k.value = !0, (p.supplier.internal === "warehouse" || p.supplier.internal === "restaurant") && (p.items = p.items.map(({ totalCost: c, ...H }) => H)), l.mustUseDefaultCost && (p.items = p.items.map((c) => ({
1555
- ...c,
1556
- totalCost: re(c.sku, c.quantity, c.measurement)
1557
- })));
1558
- try {
1559
- await t.createPurchaseOrder(p), await new Promise((c) => setTimeout(c, 1e3)), g.open({
1560
- title: v("inventory.transfer.receiveRequest.create.success"),
1561
- message: v("inventory.transfer.receiveRequest.create.successMessage"),
1562
- type: "success"
1563
- }), b("update:show", !1), b("submitted");
1564
- } catch (c) {
1565
- g.open({
1566
- title: v("inventory.transfer.receiveRequest.create.error.title"),
1567
- message: v("inventory.transfer.receiveRequest.create.error.message"),
1568
- type: "error"
1569
- }), console.error("Error in creating purchase order", c);
1570
- } finally {
1571
- k.value = !1;
1572
- }
1573
- }
1574
- async function I() {
1575
- const p = z.value;
1576
- k.value = !0, (p.supplier.internal === "warehouse" || p.supplier.internal === "restaurant") && (p.items = p.items.map(({ totalCost: c, ...H }) => H)), l.mustUseDefaultCost && (p.items = p.items.map((c) => ({
1577
- ...c,
1578
- totalCost: re(c.sku, c.quantity, c.measurement)
1579
- })));
1580
- try {
1581
- await t.updatePurchaseOrder(p), await new Promise((c) => setTimeout(c, 1e3)), g.open({
1582
- title: v("inventory.transfer.receiveRequest.update.success"),
1583
- message: v("inventory.transfer.receiveRequest.update.successMessage"),
1584
- type: "success"
1585
- }), b("update:show", !1), b("submitted");
1586
- } catch (c) {
1587
- g.open({
1588
- title: v("inventory.transfer.receiveRequest.update.error.title"),
1589
- message: v("inventory.transfer.receiveRequest.update.error.message"),
1590
- type: "error"
1591
- }), console.error("Error in updating purchase order", c);
1592
- } finally {
1593
- k.value = !1;
1594
- }
1595
- }
1596
- function B() {
1597
- switch (i.mode) {
1598
- case De.CREATE:
1599
- return R();
1600
- case De.UPDATE:
1601
- return I();
1602
- }
1603
- }
1604
- function K() {
1605
- var p, c;
1606
- (c = (p = O.value) == null ? void 0 : p.validateInputs) == null || c.call(p);
1607
- }
1608
- return (p, c) => {
1609
- const H = P("FmButton"), oe = P("FmSideSheet");
1610
- return S(), J(oe, {
1611
- modelValue: e(V),
1612
- "onUpdate:modelValue": c[3] || (c[3] = (X) => Se(V) ? V.value = X : null),
1613
- "dismiss-away": "",
1614
- "close-button": "",
1615
- "max-width": 900
1616
- }, {
1617
- "side-sheet-header": D(() => [
1618
- o("div", na, [
1619
- o("div", ra, U($.value), 1)
1620
- ])
1621
- ]),
1622
- default: D(() => [
1623
- (S(), J(la, {
1624
- class: "w-full",
1625
- ref_key: "formRef",
1626
- ref: O,
1627
- "onForm:ready": c[0] || (c[0] = () => _.value = !0),
1628
- onValidationSuccess: B,
1629
- modelValue: z.value,
1630
- "onUpdate:modelValue": c[1] || (c[1] = (X) => z.value = X),
1631
- disabled: k.value || T.value,
1632
- suppliers: e(w).suppliers,
1633
- skus: e(u).skus,
1634
- key: ue.value,
1635
- "last-closing-date": p.lastClosingDate
1636
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1637
- ]),
1638
- "side-sheet-footer": D(() => [
1639
- o("div", ia, [
1640
- d(H, {
1641
- loading: k.value,
1642
- disabled: T.value,
1643
- label: e(v)("common.save"),
1644
- onClick: K
1645
- }, null, 8, ["loading", "disabled", "label"]),
1646
- d(H, {
1647
- disabled: T.value,
1648
- variant: "tertiary",
1649
- label: e(v)("common.close"),
1650
- onClick: c[2] || (c[2] = (X) => b("update:show", !1))
1651
- }, null, 8, ["disabled", "label"])
1652
- ])
1653
- ]),
1654
- _: 1
1655
- }, 8, ["modelValue"]);
1656
- };
1657
- }
1658
- }), da = { class: "flex flex-col py-8" }, ca = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ma = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, pa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, fa = {
1659
- key: 0,
1660
- class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
1661
- }, va = { class: "pt-8" }, st = "ReceiveRequestViewSearchCriteria", Pa = /* @__PURE__ */ pe({
1662
- __name: "ReceiveRequestView",
1663
- setup(m) {
1664
- const { t: y } = he(), n = qe();
1665
- Ve.object({
1666
- name: Ve.string().optional().nullable(),
1667
- startDate: Ve.string().optional().nullable(),
1668
- endDate: Ve.string().optional().nullable()
1669
- });
1670
- const i = q(
1671
- () => !l._currentLocation || u.loading.value
1672
- ), b = Et(), t = Ae();
1673
- function f() {
1674
- const T = {
1675
- name: "",
1676
- ...Je()
1677
- }, $ = b.getItem(st);
1678
- if (!$)
1679
- return T;
1680
- try {
1681
- return JSON.parse($);
1682
- } catch {
1683
- return T;
1684
- }
1685
- }
1686
- function g() {
1687
- b.setItem(st, JSON.stringify(w.value));
1688
- }
1689
- const w = N(f()), u = It("receive/request", w.value), { columnDefs: a } = Vt("receive/request", u), l = je();
1690
- async function v() {
1691
- const T = `inventory-record_${We(w.value.startDate).format("DD-MM-YYYY_HH-mm")}-${We(w.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, $ = u.purchaseOrders.value.flatMap(
1692
- (R) => R.items.map((I) => {
1693
- const B = new Date(Mt(R._id) ?? ""), K = R.effectiveAt ? new Date(R.effectiveAt) : void 0, Q = ye(
1694
- At(I.sku, R.deliveryOrder || [])
1695
- ), p = ye(I.quantity);
1696
- return {
1697
- "SKU code": I.code,
1698
- "SKU name": I.name,
1699
- "PO #": R.seqNumber,
1700
- "Effective at": K,
1701
- Date: B,
1702
- Status: R.status,
1703
- Reference: R.ref ?? "",
1704
- "Received quantity": Q,
1705
- "Ordered quantity": p,
1706
- Unit: I.sku.unit.abbrev,
1707
- "Total cost": I.totalCost ? ze(I.totalCost) : null
1708
- };
1709
- })
1710
- ), O = [
1711
- "SKU code",
1712
- "SKU name",
1713
- "PO #",
1714
- "Date",
1715
- "Status",
1716
- "Reference",
1717
- "Received quantity",
1718
- "Ordered quantity",
1719
- "Unit"
1720
- ];
1721
- t.enableBackdatePo && O.insert("Effective at", 4), t.enableTotalCost && O.push("Total cost"), await Ut(
1722
- [
1723
- {
1724
- name: "purchases",
1725
- data: $,
1726
- columns: O
1727
- }
1728
- ],
1729
- T
1730
- ), n.open({
1731
- title: y("inventory.transfer.receiveRequest.export.success"),
1732
- message: y("inventory.transfer.receiveRequest.export.message", [T]),
1733
- type: "success"
1734
- });
1735
- }
1736
- const k = N(Je()), h = N("");
1737
- _e([() => k.value], ([T]) => {
1738
- !T.startDate || !T.endDate || (w.value.startDate = T.startDate, w.value.endDate = T.endDate, u.updateDateRange(
1739
- w.value.startDate,
1740
- w.value.endDate
1741
- ), g());
1742
- }), _e([() => h.value], () => {
1743
- g();
1744
- });
1745
- function _(T) {
1746
- if (T === "create") {
1747
- if (i.value) {
1748
- n.open({
1749
- title: "Loading data...",
1750
- message: "Please wait.",
1751
- type: "info"
1752
- });
1753
- return;
1754
- }
1755
- return u.promptCreateTransferDialog();
1756
- }
1757
- if (T === "refresh")
1758
- return u.fetchData();
1759
- if (T === "export")
1760
- return v();
1761
- }
1762
- const { breakpoints: x } = Ye(), F = q(() => x.value.xs || x.value.sm), V = q(() => F.value ? 10 : 20), z = $t(), ue = q(() => [
1763
- {
1764
- label: y("inventory.transfer.receiveRequest.actions.create"),
1765
- value: "create",
1766
- isPrimary: !0,
1767
- prependIcon: "add"
1768
- },
1769
- {
1770
- label: y("common.refresh"),
1771
- value: "refresh"
1772
- },
1773
- {
1774
- label: y("common.export"),
1775
- value: "export"
1776
- }
1777
- ]);
1778
- return (T, $) => {
1779
- const O = P("FmTable");
1780
- return S(), J(Tt, {
1781
- title: e(y)("inventory.transfer.receiveRequest.title2"),
1782
- actions: ue.value,
1783
- "onClick:action": _
1784
- }, {
1785
- default: D(() => {
1786
- var R;
1787
- return [
1788
- o("div", {
1789
- class: W([
1790
- "flex flex-col gap-8 max-h-full",
1791
- {
1792
- "p-0": F.value,
1793
- "px-24 ": !F.value
1794
- }
1795
- ])
1796
- }, [
1797
- d(Pt, {
1798
- "date-range-query": "",
1799
- "date-range": k.value,
1800
- "onUpdate:dateRange": $[0] || ($[0] = (I) => k.value = I),
1801
- searchable: "",
1802
- "change-location": "",
1803
- search: h.value,
1804
- "onUpdate:search": $[1] || ($[1] = (I) => h.value = I)
1805
- }, null, 8, ["date-range", "search"]),
1806
- (S(), J(O, {
1807
- style: ot(e(z).tableHeight),
1808
- "column-defs": e(a),
1809
- "row-data": e(u).purchaseOrders.value,
1810
- "search-value": h.value,
1811
- loading: i.value,
1812
- onRowClick: $[2] || ($[2] = (I) => e(u).promptShowTransferDetails(I.original)),
1813
- key: (R = e(l)._currentLocation) == null ? void 0 : R.dbName,
1814
- "page-size": V.value
1815
- }, {
1816
- "list-row": D((I) => [
1817
- d(nt, {
1818
- row: I,
1819
- onRowClick: e(u).promptShowTransferDetails
1820
- }, {
1821
- default: D((B) => {
1822
- var K, Q, p, c, H, oe, X, $e, Ce, Te, Me, Pe, s, r, E, Z, de, be, ae, fe;
1823
- return [
1824
- o("div", da, [
1825
- o("div", ca, [
1826
- d(e(ie), {
1827
- render: (p = (Q = (K = B._id) == null ? void 0 : K.column) == null ? void 0 : Q.columnDef) == null ? void 0 : p.cell,
1828
- props: (H = (c = B._id) == null ? void 0 : c.getContext) == null ? void 0 : H.call(c)
1829
- }, null, 8, ["render", "props"])
1830
- ]),
1831
- o("div", ma, [
1832
- d(e(ie), {
1833
- render: ($e = (X = (oe = B.supplier_name) == null ? void 0 : oe.column) == null ? void 0 : X.columnDef) == null ? void 0 : $e.cell,
1834
- props: (Te = (Ce = B.supplier_name) == null ? void 0 : Ce.getContext) == null ? void 0 : Te.call(Ce)
1835
- }, null, 8, ["render", "props"])
1836
- ]),
1837
- o("div", pa, U(I.original.items.map((xe) => `${xe.name}`).join(", ")), 1),
1838
- I.original.ref ? (S(), M("div", fa, [
1839
- d(e(ie), {
1840
- render: (s = (Pe = (Me = B.ref) == null ? void 0 : Me.column) == null ? void 0 : Pe.columnDef) == null ? void 0 : s.cell,
1841
- props: (E = (r = B.ref) == null ? void 0 : r.getContext) == null ? void 0 : E.call(r)
1842
- }, null, 8, ["render", "props"])
1843
- ])) : G("", !0),
1844
- o("div", va, [
1845
- d(e(ie), {
1846
- render: (be = (de = (Z = B.status) == null ? void 0 : Z.column) == null ? void 0 : de.columnDef) == null ? void 0 : be.cell,
1847
- props: (fe = (ae = B.status) == null ? void 0 : ae.getContext) == null ? void 0 : fe.call(ae)
1848
- }, null, 8, ["render", "props"])
1849
- ])
1850
- ])
1851
- ];
1852
- }),
1853
- _: 2
1854
- }, 1032, ["row", "onRowClick"])
1855
- ]),
1856
- _: 1
1857
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1858
- ], 2),
1859
- (S(), J(mt, { to: "body" }, [
1860
- d(ua, Oe(e(u).transferDialogProps.value, {
1861
- onSubmitted: e(u).fetchData
1862
- }), null, 16, ["onSubmitted"]),
1863
- d(Rt, Oe(e(u).transferDetailsProps.value, {
1864
- onSubmitted: e(u).fetchData
1865
- }), null, 16, ["onSubmitted"])
1866
- ]))
1867
- ];
1868
- }),
1869
- _: 1
1870
- }, 8, ["title", "actions"]);
1871
- };
1872
- }
1873
- });
1874
- export {
1875
- Pa as default
1876
- };