@feedmepos/mf-inventory-portal 0.0.22-dev.9 → 0.0.23-dev.1

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 (163) hide show
  1. package/dist/App-Y3Ez8Rjf.js +255 -0
  2. package/dist/ApprovalView-BUU1G4Q2.js +141 -0
  3. package/dist/{BindingsDialog-GzX9Bo2g.js → BindingsDialog-8wc4Q0JQ.js} +13 -12
  4. package/dist/{BindingsPicker-SbOetc0-.js → BindingsPicker-DGWN1LQc.js} +19 -18
  5. package/dist/{BindingsTable-CAcE5y8U.js → BindingsTable-7NJP2jT6.js} +20 -16
  6. package/dist/ClosingTemplateView-9s7vmwaT.js +1833 -0
  7. package/dist/FmDroppableField-8RzKjEdL.js +154 -0
  8. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B4DDh9-a.js +267 -0
  9. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-5DINn0ZB.js +436 -0
  10. package/dist/FmMultiselectDialog-7hok9sJP.js +411 -0
  11. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-CxR1FCft.js +326 -0
  12. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-FQ0HjuL3.js +51 -0
  13. package/dist/IngredientGroupView-C3maHTCg.js +610 -0
  14. package/dist/IngredientsView-DCR3IBkR.js +1613 -0
  15. package/dist/IntegrationView-gO4h89Wj.js +1227 -0
  16. package/dist/InventoryBindingForm-dh3GeyG-.js +4 -0
  17. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CJuo3i7W.js +278 -0
  18. package/dist/InventoryBindingSummary-BPoPcEoe.js +75 -0
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-1FCwvO8A.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-olm8sZKt.js} +1 -1
  20. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BezTV43V.js +116 -0
  21. package/dist/{PurchaseOrderPrintPreview-5HIWHR_f.js → PurchaseOrderPrintPreview-Dix_fIoo.js} +14 -13
  22. package/dist/ReceiveRequestView-DdPiYb2P.js +4082 -0
  23. package/dist/RecipeView-C4-a4IEW.js +597 -0
  24. package/dist/Standalone.vue.d.ts +2 -0
  25. package/dist/StockView-Du2txrIP.js +7778 -0
  26. package/dist/SupplierView-D_09FbQh.js +1474 -0
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C9MOos--.js +1144 -0
  28. package/dist/TransferTemplateView-j3CRy6Lc.js +1262 -0
  29. package/dist/{UnitView-BpU0Yk7X.js → UnitView-BXw2Vwq1.js} +30 -29
  30. package/dist/{WarehouseView-DqxWgogc.js → WarehouseView-CKamiETC.js} +205 -202
  31. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  32. package/dist/api/bill.d.ts +86 -240
  33. package/dist/api/closing-template.d.ts +6 -4
  34. package/dist/api/inventory.d.ts +281 -88
  35. package/dist/api/netsuite.d.ts +32 -1
  36. package/dist/api/purchase-order-template.d.ts +4 -2
  37. package/dist/api/supplier.d.ts +1 -0
  38. package/dist/app-GUbzqEtW.js +33456 -0
  39. package/dist/app.d.ts +259 -6
  40. package/dist/app.js +8 -7
  41. package/dist/array-hChJVZLE.js +43 -0
  42. package/dist/components/FmFilterableMenuOptions.vue.d.ts +54 -0
  43. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  44. package/dist/components/FmMultiselectDialog.vue.d.ts +3 -9
  45. package/dist/components/FmMultiselectDialogProps.d.ts +0 -2
  46. package/dist/components/FmUnitInputRules.d.ts +2 -0
  47. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +5 -5
  48. package/dist/components/map/GoogleMap.vue.d.ts +4 -4
  49. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +2 -2
  50. package/dist/components/shell/inventory/binding-ui.vue.d.ts +2 -2
  51. package/dist/date2-CLE9fB2R.js +117 -0
  52. package/dist/dayjs.min-CY1d38w7.js +282 -0
  53. package/dist/{decimal-DWbwRn_v.js → decimal-SIjO6Mjw.js} +1 -1
  54. package/dist/defineDeepModel-l40rX7kr.js +13 -0
  55. package/dist/extensions/array.d.ts +1 -0
  56. package/dist/feature-BXruKUhX.js +78 -0
  57. package/dist/{format-time-from-id-BnmaRuab.js → format-time-from-id-CcFsBXmk.js} +1 -1
  58. package/dist/format-unit-display-DEKg8cJm.js +1198 -0
  59. package/dist/fuzzy-CVOV9zJc.js +41 -0
  60. package/dist/googlemap-Dm8ERVai.js +97 -0
  61. package/dist/helper/rules.d.ts +7 -0
  62. package/dist/helper/rules.spec.d.ts +1 -0
  63. package/dist/helper/xlsx.util.d.ts +7 -0
  64. package/dist/index-BX5KZXhI.js +22279 -0
  65. package/dist/index-CVsyOEb1.js +10545 -0
  66. package/dist/index-m9e9nYfl.js +45 -0
  67. package/dist/netsuite-DAKRv7zr.js +146 -0
  68. package/dist/normalizeArguments-DP7Hrren.js +1552 -0
  69. package/dist/router/name.d.ts +1 -0
  70. package/dist/rules-DlnN8IP3.js +198 -0
  71. package/dist/stores/integration/foodmarkethub.d.ts +391 -0
  72. package/dist/stores/integration/index.d.ts +7 -0
  73. package/dist/stores/integration/netsuite.d.ts +102 -0
  74. package/dist/stores/inventory.d.ts +295 -9
  75. package/dist/stores/location.d.ts +508 -485
  76. package/dist/stores/supplier.d.ts +124 -4
  77. package/dist/stores/warehouse.d.ts +7 -4
  78. package/dist/style.css +1 -1
  79. package/dist/supplier-B21WlSAM.js +77 -0
  80. package/dist/tsconfig.app.tsbuildinfo +1 -1
  81. package/dist/use-inventory-binding-dialog-D3x6xj2O.js +95 -0
  82. package/dist/{use-template-enabled-locations-2-ClBq9FjN.js → use-template-enabled-locations-2-z-b-UXef.js} +9 -8
  83. package/dist/useTabStorage-BkIVScW_.js +25 -0
  84. package/dist/views/closing-template/closing-template-import/ClosingTemplateImport.vue.d.ts +2 -0
  85. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItem.vue.d.ts +12 -0
  86. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItemProps.d.ts +7 -0
  87. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  88. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +877 -1002
  89. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +882 -1013
  90. package/dist/views/closing-template/helpers/import-export.helper.d.ts +58 -0
  91. package/dist/views/ingredient-group/IngredientGroupView.vue.d.ts +3 -0
  92. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +31 -0
  93. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +12 -0
  94. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +20 -0
  95. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +12 -0
  96. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +24 -0
  97. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +215 -0
  98. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +2 -2
  99. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  100. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +5 -5
  101. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +2 -2
  102. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  103. package/dist/views/integration/FoodMarketHub.vue.d.ts +2 -0
  104. package/dist/views/integration/NetSuite.vue.d.ts +2 -0
  105. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +7 -7
  106. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +7 -7
  107. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  108. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +49 -0
  109. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +1913 -53
  110. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  111. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -2
  112. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -1
  113. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +2370 -327
  114. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +2304 -261
  115. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -2
  116. package/dist/views/recipe/composables/use-recipe-form.d.ts +2 -2
  117. package/dist/views/stock/components/StockRecordCard.vue.d.ts +43 -120
  118. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +34 -4
  119. package/dist/views/stock/composables/use-stock-action.d.ts +2 -2
  120. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  121. package/dist/views/supplier/components/supplier-import/SupplierImport.vue.d.ts +2 -0
  122. package/dist/views/supplier/components/supplier-import/SupplierImportItem.vue.d.ts +12 -0
  123. package/dist/views/supplier/components/supplier-import/SupplierImportItemProps.d.ts +6 -0
  124. package/dist/views/supplier/composables/use-supplier-actions.d.ts +10 -0
  125. package/dist/views/supplier/helpers/import-export.helper.d.ts +50 -0
  126. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +0 -2
  127. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +0 -1
  128. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +71 -82
  129. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +38 -1
  130. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -1
  131. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImport.vue.d.ts +2 -0
  132. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItem.vue.d.ts +12 -0
  133. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItemProps.d.ts +9 -0
  134. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1279 -1528
  135. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +2207 -446
  136. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +76 -0
  137. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +1 -251
  138. package/dist/views/transfer-template/helpers/template-item.error.helper.d.ts +1 -0
  139. package/dist/views/unit/composables/use-unit-form.d.ts +2 -2
  140. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +14 -8
  141. package/dist/{xlsx-DiOKvJ6l.js → xlsx-6mM1eNiL.js} +1525 -1525
  142. package/dist/xlsx.util-BLftcF4q.js +78 -0
  143. package/package.json +7 -4
  144. package/dist/ApprovalView-BPsScR5_.js +0 -129
  145. package/dist/ClosingTemplateView-DECwEnlK.js +0 -1066
  146. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DnogYrRE.js +0 -372
  147. package/dist/IngredientsView-8fT1Ljd5.js +0 -1758
  148. package/dist/IntegrationView-CjGLRM78.js +0 -1141
  149. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-DlhNc8Vk.js +0 -88
  150. package/dist/ReceiveRequestView-CXZv8g5U.js +0 -215
  151. package/dist/RecipeView-sB0Lgmob.js +0 -581
  152. package/dist/StockView-CY2kNohB.js +0 -1892
  153. package/dist/SupplierView-DTqeZPts.js +0 -827
  154. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BBby29tW.js +0 -762
  155. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-ByNQap9n.js +0 -1498
  156. package/dist/TransferTemplateView-DkRVfAox.js +0 -1277
  157. package/dist/app-BuyAj4kw.js +0 -69068
  158. package/dist/defineDeepModel-DuVmbMwq.js +0 -13
  159. package/dist/id-to-date-CI5Vv0Ji.js +0 -30
  160. package/dist/purchase-order-transaction-type-DrFJFvtK.js +0 -676
  161. package/dist/stores/netsuite.d.ts +0 -49
  162. package/dist/supplier-BQyK2eSZ.js +0 -69
  163. package/dist/xlsx.util-CZ7zYxdP.js +0 -109
@@ -1,1498 +0,0 @@
1
- import { reactive as Ge, onMounted as Ee, computed as P, h as M, defineComponent as re, openBlock as F, createElementBlock as I, Fragment as ae, renderList as Pe, createElementVNode as r, toDisplayString as A, unref as e, resolveComponent as T, createVNode as k, withCtx as R, createCommentVNode as N, ref as q, createBlock as H, watch as Le, normalizeClass as W, normalizeStyle as et, isRef as ce } from "vue";
2
- import { useBreakpoints as qe, components as de, FmButtonVariant as tt, useSnackbar as $e, useDialog as st, useProxiedModel as ot } from "@feedmepos/ui-library";
3
- import { F as be } from "./row-action.enum-PMKMRrZR.js";
4
- import { P as V, d as Ne, c as nt } from "./purchase-order-transaction-type-DrFJFvtK.js";
5
- import { a as Y, t as lt, a9 as Te, D as at, b as He, R as Ie, a3 as rt, a4 as it, r as ut, a5 as Be, G as ze, l as dt, A as Se, M as ct, aa as je, O as Ve, P as We, ab as pt, j as Ae, ac as mt, u as De, ad as ft, ae as yt, af as vt, E as bt, ag as _t, ah as gt, y as kt } from "./app-BuyAj4kw.js";
6
- import { _ as Ye, u as Ct } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DlhNc8Vk.js";
7
- import { useI18n as me } from "@feedmepos/mf-common";
8
- import "vue-router";
9
- import { u as xe } from "./supplier-BQyK2eSZ.js";
10
- import { d as ht } from "./defineDeepModel-DuVmbMwq.js";
11
- import { F as pe, _ as wt } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
12
- import { _ as St } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- function le(o, f, u, l) {
14
- var d, c, g;
15
- if (l != null && l.manualTotalCost)
16
- return l == null ? void 0 : l.manualTotalCost;
17
- const _ = (g = (c = (d = l == null ? void 0 : l.supplier) == null ? void 0 : d.supplyItems) == null ? void 0 : c.find(
18
- (m) => m.skuId === o._id
19
- )) == null ? void 0 : g.defaultCost, t = o.defaultCost, n = _ ?? t, w = n == null ? void 0 : n.costPerUnit, p = w ? n != null && n.measurement ? +Y(w) / +Y(n == null ? void 0 : n.measurement.conversion) : +Y(w) : void 0, s = p ? u ? p * +Y(u.conversion) : p : void 0, i = s ? +Y(f) * s : void 0;
20
- return i ? {
21
- ...lt(i ?? 0, 2),
22
- currency: Te()
23
- } : {
24
- amount: 0,
25
- precision: 0,
26
- currency: Te()
27
- };
28
- }
29
- var B = /* @__PURE__ */ ((o) => (o.Code = "Code", o.Name = "Name", o.Amount = "Amount", o.Cost = "Cost", o.Delete = "Delete", o))(B || {});
30
- const xt = () => {
31
- const { t: o } = me();
32
- return M(
33
- Ye,
34
- {
35
- zIndex: 50,
36
- class: "whitespace-nowrap"
37
- },
38
- o("inventory.transfer.form.items.table.Cost", [je()])
39
- );
40
- };
41
- function Ft(o) {
42
- const { t: f } = me(), u = Ge({}), { breakpoints: l } = qe(), _ = He();
43
- Ee(() => {
44
- for (const p of o.items) {
45
- if (!p.totalCost)
46
- continue;
47
- const s = le(p.sku, p.quantity, p.measurement, {
48
- supplier: o.supplier
49
- }), i = p.totalCost ?? at.reset();
50
- s ? u[p.sku._id] = s.amount !== i.amount || s.precision !== i.precision : u[p.sku._id] = !0;
51
- }
52
- });
53
- function t(p) {
54
- var i, y, d, c, g, m, S;
55
- return !!(((y = (i = p.defaultCost) == null ? void 0 : i.costPerUnit) == null ? void 0 : y.amount) ?? ((S = (m = (g = (c = (d = o.supplier) == null ? void 0 : d.supplyItems) == null ? void 0 : c.find((x) => x.skuId === p._id)) == null ? void 0 : g.defaultCost) == null ? void 0 : m.costPerUnit) == null ? void 0 : S.amount));
56
- }
57
- const n = [
58
- {
59
- id: "Code",
60
- header: () => f("inventory.transfer.form.items.table.Code"),
61
- accessorKey: "code",
62
- size: 96,
63
- cell(p) {
64
- const s = p.row.original;
65
- return M(de.FmTextField, {
66
- modelValue: s.code,
67
- "onUpdate:modelValue": (i) => {
68
- o.updateItem({
69
- ...s,
70
- code: i
71
- });
72
- },
73
- key: s.sku._id,
74
- rules: [Ie()],
75
- labelMark: "required"
76
- });
77
- },
78
- enableSorting: !1
79
- },
80
- {
81
- id: "Name",
82
- header: () => f("inventory.transfer.form.items.table.Name"),
83
- minSize: 300,
84
- cell(p) {
85
- const s = p.row.original;
86
- return M(de.FmTextField, {
87
- modelValue: s.name,
88
- "onUpdate:modelValue": (i) => {
89
- o.updateItem({
90
- ...s,
91
- name: i
92
- });
93
- },
94
- key: s.sku._id,
95
- rules: [Ie()],
96
- labelMark: "required"
97
- });
98
- },
99
- enableSorting: !1
100
- },
101
- {
102
- id: "Amount",
103
- header: () => f("inventory.transfer.form.items.table.Amount"),
104
- minSize: 200,
105
- cell(p) {
106
- var y, d, c;
107
- const s = p.row.original, i = (c = (d = (y = o.template) == null ? void 0 : y.purchaseOrder) == null ? void 0 : d.items) == null ? void 0 : c.find(
108
- (g) => g.sku._id === s.sku._id
109
- );
110
- return M(rt, {
111
- style: {
112
- flex: "1 1 0%"
113
- },
114
- modelValue: {
115
- amount: s.quantity ?? { amount: 1, precision: 0 },
116
- measurement: s.measurement ?? null
117
- },
118
- key: s.sku._id,
119
- unit: s.sku.unit,
120
- "onUpdate:modelValue": (g) => {
121
- const m = {
122
- ...s,
123
- quantity: g.amount,
124
- measurement: g.measurement
125
- };
126
- _.enableTotalCost && (m.totalCost = le(s.sku, s.quantity, s.measurement, {
127
- supplier: o.supplier,
128
- // NOTE: set undefined here if `manualTotalCost[row.sku._id] = false`, so that the function
129
- // will return the auto calculated default cost instead of the manual total cost
130
- manualTotalCost: u[s.sku._id] ? m.totalCost : void 0
131
- })), o.updateItem(m);
132
- },
133
- stepper: i == null ? void 0 : i.quantityStep,
134
- disableUnit: !!i,
135
- disabled: o.disabled,
136
- rules: [
137
- it(
138
- +Y(
139
- (i == null ? void 0 : i.minimumQuantity) ?? {
140
- amount: 1,
141
- precision: ut(s.sku.unit, s.measurement)
142
- }
143
- )
144
- ),
145
- i != null && i.maximumQuantity ? Be(
146
- +Y(i == null ? void 0 : i.maximumQuantity)
147
- ) : Be(1 / 0)
148
- ],
149
- applyDefaultRules: !0
150
- });
151
- },
152
- enableSorting: !1
153
- },
154
- {
155
- id: "Cost",
156
- header: xt,
157
- size: 180,
158
- cell(p) {
159
- const s = p.row.original, i = t(s.sku), y = l.value.xs || l.value.sm;
160
- return !u[s.sku._id] && i ? M(
161
- "div",
162
- {
163
- class: [
164
- "flex gap-4 fm-typo-en-body-md-400 items-center",
165
- o.disabled ? "text-fm-color-typo-disabled" : ""
166
- ],
167
- key: s.sku._id
168
- },
169
- [
170
- M(de.FmButton, {
171
- prependIcon: "edit",
172
- variant: tt.Tertiary,
173
- disabled: o.disabled,
174
- onClick() {
175
- o.updateItem({
176
- ...s,
177
- totalCost: le(s.sku, s.quantity, s.measurement, {
178
- supplier: o.supplier
179
- })
180
- }), u[s.sku._id] = !0;
181
- }
182
- }),
183
- M(
184
- "div",
185
- {
186
- class: "flex flex-col"
187
- },
188
- [
189
- M(
190
- "span",
191
- y ? ze(
192
- le(s.sku, s.quantity, s.measurement, {
193
- supplier: o.supplier
194
- })
195
- ) : Y(
196
- le(s.sku, s.quantity, s.measurement, {
197
- supplier: o.supplier
198
- })
199
- )
200
- ),
201
- M(
202
- "span",
203
- {
204
- class: [
205
- "fm-typo-en-body-sm-400",
206
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
207
- ]
208
- },
209
- f("inventory.transfer.form.items.autoCalculated")
210
- )
211
- ]
212
- )
213
- ]
214
- ) : M(
215
- de.FmTextField,
216
- {
217
- modelValue: Y(s.totalCost ?? { amount: 0, precision: 0 }),
218
- key: s.sku._id,
219
- "onUpdate:modelValue": (d) => {
220
- o.updateItem({
221
- ...s,
222
- totalCost: {
223
- ...dt(+d),
224
- currency: Te()
225
- }
226
- });
227
- },
228
- rules: [Se(0), ct(2)]
229
- },
230
- {
231
- prepend() {
232
- return y ? M(
233
- "div",
234
- {
235
- class: [
236
- "text-fm-typo-en-body-lg-400",
237
- o.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
238
- ]
239
- },
240
- je()
241
- ) : null;
242
- },
243
- append() {
244
- return i ? M(de.FmButton, {
245
- prependIcon: "close",
246
- variant: "tertiary",
247
- disabled: o.disabled,
248
- onClick() {
249
- o.updateItem({
250
- ...s,
251
- // NOTE: different from PO template, if a default cost is reenabled,
252
- // the total cost will automatically assigned
253
- totalCost: le(s.sku, s.quantity, s.measurement, {
254
- supplier: o.supplier
255
- })
256
- }), u[s.sku._id] = !1;
257
- }
258
- }) : null;
259
- }
260
- }
261
- );
262
- },
263
- enableSorting: !1
264
- },
265
- {
266
- id: "Delete",
267
- header: "",
268
- cell(p) {
269
- const s = p.row.original;
270
- return M(de.FmButton, {
271
- key: s.sku._id,
272
- class: "delete-button",
273
- type: "button",
274
- icon: "delete",
275
- variant: "tertiary",
276
- size: "md",
277
- disabled: o.disabled,
278
- onClick: () => {
279
- o.deleteItem(s);
280
- }
281
- });
282
- },
283
- enableSorting: !1,
284
- size: 40,
285
- meta: {
286
- cellClass: "",
287
- headerClass: ""
288
- }
289
- }
290
- ];
291
- return {
292
- columnDefs: P(() => _.enableTotalCost && o.transferType === V.PURCHASE ? n : n.filter(
293
- (p) => p.id !== "Cost"
294
- /* Cost */
295
- ))
296
- };
297
- }
298
- const Pt = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Tt = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, It = { class: "w-[450px] xs:w-full flex" }, $t = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Vt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ze = /* @__PURE__ */ re({
299
- __name: "SupplierPriceHistory",
300
- props: {
301
- prices: {}
302
- },
303
- setup(o) {
304
- const f = xe();
305
- function u(l) {
306
- return f.suppliers.find((_) => _._id === l);
307
- }
308
- return (l, _) => (F(), I("div", Pt, [
309
- (F(!0), I(ae, null, Pe(Object.keys(l.prices), (t) => {
310
- var n;
311
- return F(), I("div", {
312
- key: t,
313
- class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
314
- }, [
315
- r("div", Tt, A((n = u(t)) == null ? void 0 : n.name), 1),
316
- r("div", It, [
317
- (F(!0), I(ae, null, Pe(l.prices[t].slice(0, 3), (w) => {
318
- var p;
319
- return F(), I("div", {
320
- key: w.date,
321
- class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
322
- }, [
323
- r("div", $t, [
324
- r("span", null, A(w.totalCost ? e(ze)(w.totalCost) : "No data"), 1),
325
- _[0] || (_[0] = r("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
326
- r("span", null, A(e(Y)(w.totalUnit, !1)), 1),
327
- r("span", null, A(((p = w.measurement) == null ? void 0 : p.abbrev) ?? w.unit.abbrev), 1)
328
- ]),
329
- r("div", Vt, [
330
- r("span", null, "(#" + A(w.seqNumber) + ")", 1),
331
- _[1] || (_[1] = r("span", null, A(" "), -1)),
332
- r("span", null, A(e(Ve)(new Date(w.date))), 1)
333
- ])
334
- ]);
335
- }), 128))
336
- ])
337
- ]);
338
- }), 128))
339
- ]));
340
- }
341
- }), At = { class: "flex flex-col gap-8 py-16" }, Dt = { class: "flex items-center" }, Rt = { class: "flex-1 flex gap-1 items-center" }, Ot = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ut = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Bt = { class: "flex gap-8 w-full" }, Mt = { class: "flex-1 flex flex-col gap-4" }, Et = { class: "flex-1 flex flex-col gap-4" }, Lt = { class: "flex gap-8 w-full" }, qt = { class: "flex-1 flex flex-col gap-4" }, Nt = {
342
- key: 0,
343
- class: "flex-1 flex flex-col gap-4"
344
- }, Ht = /* @__PURE__ */ re({
345
- __name: "TransferItem",
346
- props: {
347
- cellByColId: {},
348
- comparePriceBySku: {},
349
- showComparePrice: { type: Boolean },
350
- row: {}
351
- },
352
- setup(o) {
353
- const { t: f } = me();
354
- return (u, l) => {
355
- var n, w, p, s, i, y, d, c, g, m, S, x, E, $, O, L, X, G, Z, Q, z, v, C, D, ee, j, te;
356
- const _ = T("FmLabel"), t = T("FmSpacer");
357
- return F(), I("div", At, [
358
- r("div", Dt, [
359
- r("div", Rt, [
360
- r("span", Ot, " (" + A(u.row.original.sku.code) + ") ", 1),
361
- r("span", Ut, A(u.row.original.sku.name), 1)
362
- ]),
363
- r("div", null, [
364
- k(e(pe), {
365
- render: (p = (w = (n = u.cellByColId.Delete) == null ? void 0 : n.column) == null ? void 0 : w.columnDef) == null ? void 0 : p.cell,
366
- props: (i = (s = u.cellByColId.Delete) == null ? void 0 : s.getContext) == null ? void 0 : i.call(s)
367
- }, null, 8, ["render", "props"])
368
- ])
369
- ]),
370
- r("div", Bt, [
371
- r("div", Mt, [
372
- k(_, {
373
- label: e(f)(`inventory.transfer.form.items.table.${e(B).Code}`)
374
- }, null, 8, ["label"]),
375
- k(e(pe), {
376
- render: (c = (d = (y = u.cellByColId[e(B).Code]) == null ? void 0 : y.column) == null ? void 0 : d.columnDef) == null ? void 0 : c.cell,
377
- props: (m = (g = u.cellByColId[e(B).Code]) == null ? void 0 : g.getContext) == null ? void 0 : m.call(g)
378
- }, null, 8, ["render", "props"]),
379
- l[0] || (l[0] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
380
- ]),
381
- r("div", Et, [
382
- k(_, {
383
- label: e(f)(`inventory.transfer.form.items.table.${e(B).Name}`)
384
- }, null, 8, ["label"]),
385
- k(e(pe), {
386
- render: (E = (x = (S = u.cellByColId[e(B).Name]) == null ? void 0 : S.column) == null ? void 0 : x.columnDef) == null ? void 0 : E.cell,
387
- props: (O = ($ = u.cellByColId[e(B).Name]) == null ? void 0 : $.getContext) == null ? void 0 : O.call($)
388
- }, null, 8, ["render", "props"]),
389
- l[1] || (l[1] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
390
- ])
391
- ]),
392
- r("div", Lt, [
393
- r("div", qt, [
394
- k(_, {
395
- label: e(f)(`inventory.transfer.form.items.table.${e(B).Amount}`)
396
- }, null, 8, ["label"]),
397
- k(e(pe), {
398
- render: (G = (X = (L = u.cellByColId[e(B).Amount]) == null ? void 0 : L.column) == null ? void 0 : X.columnDef) == null ? void 0 : G.cell,
399
- props: (Q = (Z = u.cellByColId[e(B).Amount]) == null ? void 0 : Z.getContext) == null ? void 0 : Q.call(Z)
400
- }, null, 8, ["render", "props"]),
401
- l[2] || (l[2] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
402
- ]),
403
- u.cellByColId[e(B).Cost] ? (F(), I("div", Nt, [
404
- k(Ye, { "z-index": 50 }, {
405
- default: R(() => [
406
- k(_, {
407
- label: e(f)(`inventory.transfer.form.items.table.${e(B).Cost}2`)
408
- }, null, 8, ["label"])
409
- ]),
410
- _: 1
411
- }),
412
- k(e(pe), {
413
- render: (C = (v = (z = u.cellByColId[e(B).Cost]) == null ? void 0 : z.column) == null ? void 0 : v.columnDef) == null ? void 0 : C.cell,
414
- props: (ee = (D = u.cellByColId[e(B).Cost]) == null ? void 0 : D.getContext) == null ? void 0 : ee.call(D)
415
- }, null, 8, ["render", "props"]),
416
- l[3] || (l[3] = r("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
417
- ])) : N("", !0)
418
- ]),
419
- u.showComparePrice && Object.keys(u.comparePriceBySku[(j = u.row.original.sku) == null ? void 0 : j._id] ?? {}).length > 0 ? (F(), I(ae, { key: 0 }, [
420
- k(t, { class: "h-8" }),
421
- k(Ze, {
422
- prices: u.comparePriceBySku[(te = u.row.original.sku) == null ? void 0 : te._id]
423
- }, null, 8, ["prices"])
424
- ], 64)) : N("", !0)
425
- ]);
426
- };
427
- }
428
- });
429
- function _e(o) {
430
- return pt.parse(o);
431
- }
432
- function we(o) {
433
- return {
434
- _id: o.doc._id,
435
- internal: o.type,
436
- contactName: o.doc.profile.name,
437
- name: o.doc.profile.name,
438
- email: o.doc.profile.email,
439
- phoneNumber: o.doc.profile.phoneNo,
440
- registrationNumber: o.doc.profile.regNo,
441
- address: o.doc.profile.address
442
- };
443
- }
444
- function zt(o, f) {
445
- const u = xe(), l = Ae(), _ = P(() => !l.businessLevel);
446
- l.watchLocation(async () => {
447
- var S;
448
- await u.readSuppliers();
449
- const d = o();
450
- if ((S = d.supplier) != null && S._id) return;
451
- const c = l.businessLevel ? u.businessSuppliers[0] : u.suppliers[0], m = (_.value ? l.locations.filter((x) => x.doc._id !== l.currentLocation.doc._id) : l.locations)[0];
452
- f({
453
- ...d,
454
- supplier: c ? _e(c) : m ? we(m) : d.supplier
455
- });
456
- });
457
- const t = P(
458
- () => {
459
- var d, c;
460
- return typeof ((c = (d = o()) == null ? void 0 : d.supplier) == null ? void 0 : c.internal) == "string" ? V.TRANSFER : V.PURCHASE;
461
- }
462
- ), n = P({
463
- get() {
464
- var d, c;
465
- return (c = (d = o()) == null ? void 0 : d.supplier) == null ? void 0 : c._id;
466
- },
467
- set(d) {
468
- const c = o() ?? {};
469
- if (t.value === V.PURCHASE) {
470
- const E = (l.businessLevel ? u.businessSuppliers : u.suppliers).find(($) => $._id === d);
471
- f({
472
- ...c,
473
- supplier: E ? _e(E) : c.supplier
474
- });
475
- return;
476
- }
477
- const S = (_.value ? l.locations.filter((x) => x.doc._id !== l.currentLocation.doc._id) : l.locations).find((x) => x.doc._id === d);
478
- f({
479
- ...c,
480
- supplier: S ? we(S) : c.supplier
481
- });
482
- }
483
- }), w = P(() => u.locationSuppliers.map(_e)), p = P(() => u.businessSuppliers.map(_e)), s = P(() => {
484
- var g;
485
- const d = ((g = l._currentLocation) == null ? void 0 : g.type) === We.warehouse;
486
- return (_.value ? l.locations.filter((m) => m.doc._id !== l.currentLocation.doc._id) : l.locations).filter((m) => d || m.acceptRequest).map(we);
487
- }), i = P(() => {
488
- if (t.value === V.PURCHASE) {
489
- const c = w.value.map((m) => ({
490
- label: m.name,
491
- value: m._id
492
- })), g = p.value.map((m) => ({
493
- label: m.name,
494
- sublabel: "Business supplier",
495
- value: m._id
496
- }));
497
- return l.businessLevel ? g : [...c, ...g];
498
- }
499
- return s.value.map((c) => ({
500
- label: c.name,
501
- sublabel: c.internal ? `${c.internal}` : void 0,
502
- value: c._id
503
- }));
504
- }), y = P(() => {
505
- var m, S;
506
- const d = (S = (m = o()) == null ? void 0 : m.supplier) == null ? void 0 : S._id;
507
- if (t.value === V.PURCHASE) {
508
- const x = u.suppliers.find((E) => E._id === d);
509
- return x ? _e(x) : null;
510
- }
511
- const g = l.locations.find((x) => x.doc._id);
512
- return g ? we(g) : null;
513
- });
514
- return {
515
- transferLocationModel: n,
516
- transferLocationOptions: i,
517
- locationOptionsTypePurchase: w,
518
- locationOptionsTypeTransfer: s,
519
- selectedLocation: y
520
- };
521
- }
522
- function jt(o) {
523
- const f = P({
524
- get() {
525
- const t = o.getEffectiveAt();
526
- return t ? new Date(t) : null;
527
- },
528
- set(t) {
529
- o.setEffectiveAt((t == null ? void 0 : t.toISOString()) ?? null);
530
- }
531
- }), u = P({
532
- get() {
533
- return !!f.value;
534
- },
535
- set(t) {
536
- t ? f.value = /* @__PURE__ */ new Date() : f.value = null;
537
- }
538
- }), l = P({
539
- get() {
540
- return f.value === null ? "" : Ve(f.value);
541
- },
542
- set(t) {
543
- t ? f.value = /* @__PURE__ */ new Date(`${t} ${_.value}`) : f.value = null;
544
- }
545
- }), _ = P({
546
- get() {
547
- return f.value === null ? "" : mt(f.value);
548
- },
549
- set(t) {
550
- t ? f.value = /* @__PURE__ */ new Date(`${l.value} ${t}`) : f.value = null;
551
- }
552
- });
553
- return {
554
- backdatePo: f,
555
- backdateSwitch: u,
556
- backdateModel: l,
557
- backdateTimeModel: _
558
- };
559
- }
560
- const Wt = {
561
- width: "24",
562
- height: "24",
563
- viewBox: "0 0 24 24",
564
- fill: "none",
565
- xmlns: "http://www.w3.org/2000/svg"
566
- }, Yt = ["fill"], Zt = ["fill"], Qt = ["stroke"], Kt = ["stroke"], Jt = /* @__PURE__ */ re({
567
- __name: "SparkIcon",
568
- props: {
569
- size: {
570
- type: Number,
571
- default: 24
572
- },
573
- color: {
574
- type: String,
575
- default: "#c7c7cc"
576
- }
577
- },
578
- setup(o) {
579
- return (f, u) => (F(), I("svg", Wt, [
580
- r("path", {
581
- 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",
582
- fill: o.color
583
- }, null, 8, Yt),
584
- r("path", {
585
- 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",
586
- fill: o.color
587
- }, null, 8, Zt),
588
- r("path", {
589
- 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",
590
- stroke: o.color,
591
- "stroke-width": "1.5",
592
- "stroke-linecap": "round",
593
- "stroke-linejoin": "round"
594
- }, null, 8, Qt),
595
- r("path", {
596
- 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",
597
- stroke: o.color,
598
- "stroke-width": "1.5",
599
- "stroke-linecap": "round",
600
- "stroke-linejoin": "round"
601
- }, null, 8, Kt)
602
- ]));
603
- }
604
- }), Xt = { class: "flex gap-8 items-center" }, Gt = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, es = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, ts = { class: "flex items-center w-full" }, ss = { class: "flex-1" }, os = { class: "fm-typo-en-title-sm-800" }, ns = { class: "flex items-start gap-8" }, ls = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, as = { class: "flex gap-1" }, Me = /* @__PURE__ */ re({
605
- __name: "ForecastStock",
606
- props: {
607
- disabled: { type: Boolean }
608
- },
609
- emits: ["update:poItems"],
610
- setup(o, { emit: f }) {
611
- const u = f, l = q(!1), _ = q(7), t = Ct(), n = $e(), w = De(), { t: p } = me();
612
- async function s() {
613
- if (_.value < 1)
614
- return;
615
- l.value = !1, await t.readPurchaseOrder(_.value);
616
- const i = [];
617
- if (t.purchaseOrderForecast.skus.length <= 0) {
618
- n.open({
619
- message: p("inventory.transfer.form.items.forecastStock.notAvailable"),
620
- type: "info"
621
- });
622
- return;
623
- }
624
- const y = t.purchaseOrderForecast.skus.reduce((d, c) => {
625
- const g = w.skus.find((x) => x._id === c.id);
626
- if (d.find((x) => x.sku._id === c.id) || !g)
627
- return d;
628
- const S = {
629
- sku: g,
630
- code: g.code,
631
- name: g.name,
632
- quantity: {
633
- amount: c.amount,
634
- precision: 0
635
- }
636
- };
637
- return d.push(S), d;
638
- }, i);
639
- u("update:poItems", y);
640
- }
641
- return (i, y) => {
642
- const d = T("FmButton"), c = T("FmIcon"), g = T("FmStepperField"), m = T("FmPopover");
643
- return F(), H(m, {
644
- disabled: i.disabled,
645
- class: "flex",
646
- "show-popover": l.value,
647
- onPopoverChanged: y[3] || (y[3] = (S) => l.value = S)
648
- }, {
649
- "popover-button": R(() => [
650
- k(d, {
651
- label: "unused",
652
- variant: "secondary",
653
- "text-color": i.disabled ? "disabled" : "primary",
654
- "bg-color": "transparent",
655
- "border-color": i.disabled ? "disabled" : "primary",
656
- disabled: i.disabled
657
- }, {
658
- default: R(() => [
659
- r("div", Xt, [
660
- k(Jt, {
661
- size: 24,
662
- color: i.disabled ? "#c7c7cc" : "#ff7823"
663
- }, null, 8, ["color"]),
664
- r("div", Gt, A(e(p)("inventory.transfer.form.items.forecastStock.title")), 1)
665
- ])
666
- ]),
667
- _: 1
668
- }, 8, ["text-color", "border-color", "disabled"])
669
- ]),
670
- default: R(() => [
671
- r("div", es, [
672
- r("div", ts, [
673
- r("div", ss, [
674
- k(St, { "z-index": 99 }, {
675
- default: R(() => [
676
- r("p", os, A(e(p)("inventory.transfer.form.items.forecastStock.title")), 1)
677
- ]),
678
- _: 1
679
- })
680
- ]),
681
- k(d, {
682
- icon: "close",
683
- size: "md",
684
- variant: "tertiary",
685
- onClick: y[0] || (y[0] = (S) => l.value = !1)
686
- })
687
- ]),
688
- k(g, {
689
- modelValue: _.value,
690
- "onUpdate:modelValue": y[1] || (y[1] = (S) => _.value = S),
691
- label: e(p)("inventory.transfer.form.items.forecastStock.days"),
692
- rules: [e(Se)(1)]
693
- }, {
694
- "helper-text": R(() => [
695
- r("div", ns, [
696
- k(c, {
697
- name: "warning",
698
- size: "sm",
699
- class: "text-fm-color-system-warning-300"
700
- }),
701
- r("div", ls, A(e(p)("inventory.transfer.form.items.forecastStock.replace")), 1)
702
- ])
703
- ]),
704
- _: 1
705
- }, 8, ["modelValue", "label", "rules"]),
706
- r("div", as, [
707
- y[4] || (y[4] = r("div", { class: "grow" }, null, -1)),
708
- k(d, {
709
- label: e(p)("common.cancel"),
710
- variant: "tertiary",
711
- onClick: y[2] || (y[2] = (S) => l.value = !1)
712
- }, null, 8, ["label"]),
713
- k(d, {
714
- label: e(p)("inventory.transfer.form.items.forecastStock.generate"),
715
- onClick: s
716
- }, null, 8, ["label"])
717
- ])
718
- ])
719
- ]),
720
- _: 1
721
- }, 8, ["disabled", "show-popover"]);
722
- };
723
- }
724
- });
725
- function rs() {
726
- const o = $e(), f = Ne(), u = q(!1);
727
- Le(u, (n) => {
728
- n && (_.value = !0, l().finally(() => {
729
- _.value = !1;
730
- }));
731
- });
732
- async function l() {
733
- try {
734
- const { startDate: n, endDate: w } = ft(6), i = (await f.getPurchaseOrders({ start: n, end: w })).filter(
735
- (y) => {
736
- var d, c;
737
- return y.status === yt.enum.COMPLETE && ((d = y.supplier) == null ? void 0 : d.internal) !== "warehouse" && ((c = y.supplier) == null ? void 0 : c.internal) !== "restaurant";
738
- }
739
- ).reduce((y, d) => {
740
- const c = new Date(vt(d._id)), g = d.supplier._id;
741
- for (const m of d.items) {
742
- if (!m.totalCost) continue;
743
- const S = y[m.sku._id] ?? {}, x = S[g] ?? [];
744
- x.push({
745
- date: c.toISOString(),
746
- totalUnit: m.quantity,
747
- totalCost: m.totalCost,
748
- unit: m.sku.unit,
749
- measurement: m.measurement,
750
- seqNumber: d.seqNumber
751
- }), S[g] = x, y[m.sku._id] = S;
752
- }
753
- return y;
754
- }, {});
755
- t.value = i;
756
- } catch {
757
- o.open({
758
- title: "Something went wrong",
759
- message: "Cannot retrieve supplier purchase history. Please try again."
760
- }), u.value = !1;
761
- }
762
- }
763
- const _ = q(!1), t = q({});
764
- return {
765
- comparePricesToggle: u,
766
- comparePriceFetching: _,
767
- comparePriceBySku: t
768
- };
769
- }
770
- const is = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, us = { key: 0 }, ds = ["colspan"], cs = /* @__PURE__ */ re({
771
- __name: "TransferItemTable",
772
- props: {
773
- row: {},
774
- comparePriceBySku: {},
775
- showComparePrice: { type: Boolean }
776
- },
777
- setup(o) {
778
- function f(u) {
779
- return u.column.columnDef.meta;
780
- }
781
- return (u, l) => {
782
- var _, t;
783
- return F(), I(ae, null, [
784
- r("tr", {
785
- class: W(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
786
- "bg-fm-color-neutral-gray-100": u.row.getIsSelected()
787
- }])
788
- }, [
789
- (F(!0), I(ae, null, Pe(u.row.getVisibleCells(), (n) => {
790
- var w, p, s, i;
791
- return F(), I("td", {
792
- key: n.id,
793
- class: W([
794
- "h-[52px] px-16 text-fm-color-typo-primary",
795
- ((w = f(n)) == null ? void 0 : w.cellClass) ?? "px-16"
796
- ]),
797
- style: et({
798
- width: (p = f(n)) == null ? void 0 : p.width,
799
- maxWidth: (s = f(n)) == null ? void 0 : s.maxWidth,
800
- textAlign: ((i = f(n)) == null ? void 0 : i.textAlign) ?? "left"
801
- })
802
- }, [
803
- r("span", is, [
804
- k(e(pe), {
805
- render: n.column.columnDef.cell,
806
- props: n.getContext()
807
- }, null, 8, ["render", "props"])
808
- ])
809
- ], 6);
810
- }), 128))
811
- ], 2),
812
- u.showComparePrice && Object.keys(u.comparePriceBySku[(_ = u.row.original.sku) == null ? void 0 : _._id] ?? {}).length > 0 ? (F(), I("tr", us, [
813
- r("td", {
814
- colspan: u.row.getVisibleCells().length
815
- }, [
816
- k(Ze, {
817
- prices: u.comparePriceBySku[(t = u.row.original.sku) == null ? void 0 : t._id]
818
- }, null, 8, ["prices"])
819
- ], 8, ds)
820
- ])) : N("", !0)
821
- ], 64);
822
- };
823
- }
824
- }), ps = { class: "flex flex-col gap-4" }, ms = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, fs = { class: "flex flex-col gap-16" }, ys = { class: "flex flex-col gap-24" }, vs = { class: "flex flex-col gap-8" }, bs = { class: "flex flex-col gap-4" }, _s = { class: "flex flex-col gap-8" }, gs = { class: "flex flex-col gap-4" }, ks = {
825
- key: 3,
826
- class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
827
- }, Cs = {
828
- key: 0,
829
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
830
- }, hs = { class: "flex-1" }, ws = { class: "flex-1" }, Ss = {
831
- key: 1,
832
- class: "flex items-center gap-4"
833
- }, xs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Fs = { class: "flex flex-col gap-16" }, Ps = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, Ts = { class: "flex gap-8" }, Is = { key: 0 }, $s = /* @__PURE__ */ re({
834
- __name: "TransferForm2",
835
- props: {
836
- modelValue: {},
837
- disabled: { type: Boolean },
838
- suppliers: {},
839
- skus: {},
840
- lastClosingDate: {}
841
- },
842
- emits: ["validation-success", "form:ready"],
843
- setup(o, { expose: f, emit: u }) {
844
- const l = o, _ = u, t = ht(), { t: n } = me(), w = Ae(), p = De(), s = gt(), i = xe(), y = He(), d = nt(), { breakpoints: c } = qe(), g = P(() => c.value.xs || c.value.sm), m = P(
845
- () => d.templates.value.find((a) => a._id === t.template)
846
- ), S = P(() => t.status === "DRAFT" || !t._rev);
847
- Ee(async () => {
848
- var a;
849
- try {
850
- if (!t.template) return;
851
- await d.loadTemplate(t.template), t.items.length || (t.items = ((a = m.value) == null ? void 0 : a.purchaseOrder.items) ?? []);
852
- } finally {
853
- _("form:ready");
854
- }
855
- await s.readSubsidiaryOptions();
856
- });
857
- const x = P(
858
- () => w.currentLocation.type === We.restaurant
859
- );
860
- w.watchLocation(async () => {
861
- location && (t.supplier || (t.supplier = i.suppliers.find((a) => a) ?? t.supplier));
862
- });
863
- const E = st(), $ = zt(
864
- () => t,
865
- (a) => {
866
- Object.assign(t, a);
867
- }
868
- ), O = P({
869
- get() {
870
- var a;
871
- return typeof ((a = t == null ? void 0 : t.supplier) == null ? void 0 : a.internal) == "string" ? V.TRANSFER : V.PURCHASE;
872
- },
873
- set(a) {
874
- var K;
875
- const b = typeof ((K = t == null ? void 0 : t.supplier) == null ? void 0 : K.internal) == "string" ? V.TRANSFER : V.PURCHASE;
876
- a !== b && (t.supplier = a === V.PURCHASE ? $.locationOptionsTypePurchase.value[0] : $.locationOptionsTypeTransfer.value[0]);
877
- }
878
- }), L = P(() => $.transferLocationOptions.value), X = P({
879
- get() {
880
- return t.supplier._id;
881
- },
882
- set(a) {
883
- $.transferLocationModel.value = a;
884
- }
885
- }), G = P({
886
- get() {
887
- return t.remark ?? void 0;
888
- },
889
- set(a) {
890
- t.remark = a;
891
- }
892
- }), Z = P({
893
- get() {
894
- var a;
895
- return ((a = t.netSuite) == null ? void 0 : a.subsidiary) || {
896
- subsidiary: {
897
- id: "",
898
- name: ""
899
- }
900
- };
901
- },
902
- set(a) {
903
- t.netSuite = {
904
- ...t.netSuite,
905
- subsidiary: a
906
- };
907
- }
908
- }), { backdatePo: Q, backdateSwitch: z, backdateModel: v, backdateTimeModel: C } = jt({
909
- getEffectiveAt() {
910
- return t.effectiveAt;
911
- },
912
- setEffectiveAt(a) {
913
- t.effectiveAt = a;
914
- }
915
- }), { comparePricesToggle: D, comparePriceFetching: ee, comparePriceBySku: j } = rs(), te = q();
916
- f({
917
- validateInputs: () => {
918
- var a, b;
919
- (b = (a = te.value) == null ? void 0 : a.validateInputs) == null || b.call(a);
920
- },
921
- resetInputsValidation: () => {
922
- var a, b;
923
- (b = (a = te.value) == null ? void 0 : a.resetInputsValidation) == null || b.call(a);
924
- },
925
- resetInputs: () => {
926
- var a, b;
927
- (b = (a = te.value) == null ? void 0 : a.resetInputs) == null || b.call(a);
928
- }
929
- });
930
- const Qe = Ft({
931
- updateItem: (a) => {
932
- t.items = t.items.map((b) => b.sku._id !== a.sku._id ? b : a);
933
- },
934
- deleteItem: (a) => {
935
- t.items = t.items.filter((b) => b.sku._id !== a.sku._id);
936
- },
937
- get supplier() {
938
- return t.supplier;
939
- },
940
- get items() {
941
- return t.items;
942
- },
943
- get transferType() {
944
- return O.value;
945
- },
946
- get template() {
947
- return m.value;
948
- },
949
- get disabled() {
950
- return l.disabled;
951
- }
952
- }), Ke = P(() => Qe.columnDefs.value);
953
- function Je() {
954
- var fe, ie, ke;
955
- const a = new Set((ke = (ie = (fe = m.value) == null ? void 0 : fe.purchaseOrder) == null ? void 0 : ie.items) == null ? void 0 : ke.map((U) => U.sku._id)), K = (a.size ? p.skus.filter((U) => a.has(U._id)) : p.skus).map(
956
- (U) => ({
957
- label: U.name,
958
- sublabel: U.code,
959
- value: U
960
- })
961
- ), ge = K.filter((U) => {
962
- var se;
963
- return (se = t.items) == null ? void 0 : se.find((ue) => ue.sku._id === U.value._id);
964
- }).map((U) => U.value);
965
- E.open({
966
- title: n("inventory.transfer.form.items.selectItem"),
967
- closeButton: !0,
968
- contentComponent: kt,
969
- contentComponentProps: {
970
- modelValue: ge,
971
- items: K,
972
- virtualScroll: !0
973
- },
974
- primaryActions: {
975
- text: n("common.confirm"),
976
- close: !0
977
- },
978
- secondaryActions: {
979
- text: n("common.close"),
980
- close: !0,
981
- variant: "tertiary"
982
- }
983
- }).onPrimary((U) => {
984
- const se = t.items ?? [], ue = U.map((J) => {
985
- var Ce, he;
986
- const oe = se.find((ye) => ye.sku._id === J._id);
987
- if (oe)
988
- return oe;
989
- const ne = ((he = (Ce = m.value) == null ? void 0 : Ce.purchaseOrder.items) == null ? void 0 : he.find(
990
- (ye) => ye.sku._id === J._id
991
- )) ?? {
992
- sku: J,
993
- code: J.code,
994
- name: J.name,
995
- quantity: {
996
- amount: 1,
997
- precision: 0
998
- }
999
- };
1000
- return O.value == V.PURCHASE && (ne.totalCost = le(
1001
- ne.sku,
1002
- ne.quantity,
1003
- ne.measurement,
1004
- {
1005
- supplier: t.supplier
1006
- }
1007
- )), ne;
1008
- });
1009
- ue.sort((J, oe) => J.sku.code.localeCompare(oe.sku.code)), t.items = ue;
1010
- });
1011
- }
1012
- function Rs(a) {
1013
- return a;
1014
- }
1015
- return (a, b) => {
1016
- var Re, Oe;
1017
- const K = T("FmChip"), ge = T("FmLabel"), fe = T("FmField"), ie = T("FmSelect"), ke = T("FmTextField"), U = T("FmTextarea"), se = T("FmSwitch"), ue = T("FmDatePicker"), J = T("FmTimePicker"), oe = T("FmFormGroup"), ne = T("FmIcon"), Ce = T("FmButton"), he = T("FmTooltip"), ye = T("FmTable"), Xe = T("FmForm");
1018
- return F(), I("div", ps, [
1019
- r("div", ms, [
1020
- (Re = l.modelValue) != null && Re.template ? (F(), H(K, {
1021
- key: 0,
1022
- variant: a.disabled ? "warning" : void 0,
1023
- label: `${e(n)("inventory.transfer.template.title")}: ${((Oe = m.value) == null ? void 0 : Oe.name) ?? e(n)("inventory.transfer.form.loading")}`,
1024
- icon: "summarize",
1025
- compact: ""
1026
- }, null, 8, ["variant", "label"])) : N("", !0),
1027
- k(K, {
1028
- label: e(w).currentLocation.name,
1029
- icon: "storefront",
1030
- compact: ""
1031
- }, null, 8, ["label"]),
1032
- a.lastClosingDate ? (F(), H(K, {
1033
- key: 1,
1034
- label: `${e(n)("inventory.transfer.form.lastClosing")}: ${e(Ve)(a.lastClosingDate)} ${e(bt)(a.lastClosingDate)}`,
1035
- icon: "calendar_month",
1036
- compact: ""
1037
- }, null, 8, ["label"])) : N("", !0)
1038
- ]),
1039
- k(Xe, {
1040
- ref_key: "formRef",
1041
- ref: te,
1042
- class: "flex flex-col gap-32",
1043
- disabled: a.disabled,
1044
- onValidationFailed: console.log,
1045
- onValidationSuccess: b[13] || (b[13] = (Fe) => _("validation-success"))
1046
- }, {
1047
- default: R(() => {
1048
- var Fe, Ue;
1049
- return [
1050
- r("div", fs, [
1051
- r("div", ys, [
1052
- (Fe = l.modelValue) != null && Fe.template ? (F(), I(ae, { key: 0 }, [
1053
- r("div", vs, [
1054
- k(ge, {
1055
- label: e(n)("inventory.transfer.form.type.title")
1056
- }, null, 8, ["label"]),
1057
- r("div", bs, [
1058
- k(fe, null, {
1059
- default: R(() => [
1060
- r("span", {
1061
- class: W({ "text-fm-color-typo-disabled": a.disabled })
1062
- }, A(e(n)(`inventory.transfer.form.type.${O.value.toLocaleLowerCase("en-us")}`)), 3)
1063
- ]),
1064
- _: 1
1065
- }),
1066
- r("div", {
1067
- class: W([
1068
- "fm-typo-en-body-sm-400",
1069
- a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1070
- ])
1071
- }, " This field is locked from template. ", 2)
1072
- ])
1073
- ]),
1074
- r("div", _s, [
1075
- k(ge, {
1076
- label: O.value === e(V).PURCHASE ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom")
1077
- }, null, 8, ["label"]),
1078
- r("div", gs, [
1079
- k(fe, null, {
1080
- default: R(() => {
1081
- var h;
1082
- return [
1083
- r("span", {
1084
- class: W({ "text-fm-color-typo-disabled": a.disabled })
1085
- }, A((h = L.value.find((ve) => ve.value === X.value)) == null ? void 0 : h.label), 3)
1086
- ];
1087
- }),
1088
- _: 1
1089
- }),
1090
- r("div", {
1091
- class: W([
1092
- "fm-typo-en-body-sm-400",
1093
- a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1094
- ])
1095
- }, " This field is locked from template. ", 2)
1096
- ])
1097
- ])
1098
- ], 64)) : (F(), I(ae, { key: 1 }, [
1099
- k(ie, {
1100
- label: e(n)("inventory.transfer.form.type.title"),
1101
- "model-value": O.value,
1102
- "onUpdate:modelValue": b[0] || (b[0] = (h) => O.value = h),
1103
- items: [
1104
- {
1105
- label: e(n)("inventory.transfer.form.type.purchase"),
1106
- value: e(V).PURCHASE,
1107
- disabled: !e($).locationOptionsTypePurchase.value.length,
1108
- sublabel: e($).locationOptionsTypePurchase.value.length ? void 0 : e(n)("inventory.transfer.form.noSupplierAvailable")
1109
- },
1110
- {
1111
- label: e(n)("inventory.transfer.form.type.transfer"),
1112
- value: e(V).TRANSFER,
1113
- disabled: !e($).locationOptionsTypeTransfer.value.length,
1114
- sublabel: e($).locationOptionsTypeTransfer.value.length ? void 0 : e(n)("inventory.transfer.form.noLocationAvailable")
1115
- }
1116
- ],
1117
- rules: [e(Se)(1)(L.value)]
1118
- }, null, 8, ["label", "model-value", "items", "rules"]),
1119
- k(ie, {
1120
- label: O.value === e(V).PURCHASE ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
1121
- modelValue: X.value,
1122
- "onUpdate:modelValue": b[1] || (b[1] = (h) => X.value = h),
1123
- items: L.value
1124
- }, null, 8, ["label", "modelValue", "items"])
1125
- ], 64)),
1126
- k(ke, {
1127
- label: e(n)("inventory.transfer.form.reference"),
1128
- "label-mark": "optional",
1129
- modelValue: e(t).ref,
1130
- "onUpdate:modelValue": b[2] || (b[2] = (h) => e(t).ref = h)
1131
- }, null, 8, ["label", "modelValue"]),
1132
- k(U, {
1133
- label: e(n)("inventory.transfer.form.remark"),
1134
- "label-mark": "optional",
1135
- "max-length": 240,
1136
- modelValue: G.value,
1137
- "onUpdate:modelValue": b[3] || (b[3] = (h) => G.value = h),
1138
- class: W([a.disabled ? "text-fm-color-typo-disabled " : ""])
1139
- }, null, 8, ["label", "modelValue", "class"]),
1140
- e(s).isEnabled ? (F(), H(ie, {
1141
- key: 2,
1142
- modelValue: Z.value,
1143
- "onUpdate:modelValue": b[4] || (b[4] = (h) => Z.value = h),
1144
- label: `NetSuite ${e(n)("inventory.transfer.form.netsuite.subsidiary")}`,
1145
- items: e(s).subsidiaryOptions,
1146
- "label-mark": "required",
1147
- rules: [e(Ie)()]
1148
- }, null, 8, ["modelValue", "label", "items", "rules"])) : N("", !0),
1149
- e(y).enableBackdatePo ? (F(), I("div", ks, [
1150
- r("div", {
1151
- class: W([
1152
- "flex",
1153
- {
1154
- "flex-col": g.value
1155
- }
1156
- ])
1157
- }, [
1158
- k(se, {
1159
- modelValue: e(z),
1160
- "onUpdate:modelValue": b[5] || (b[5] = (h) => ce(z) ? z.value = h : null),
1161
- label: e(n)("inventory.transfer.form.backdate.title"),
1162
- sublabel: e(n)("inventory.transfer.form.backdate.subtitle"),
1163
- "label-placement": "right",
1164
- disabled: x.value && !a.lastClosingDate || a.disabled
1165
- }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1166
- r("div", {
1167
- class: W({ hidden: g.value, "w-16": !g.value })
1168
- }, null, 2),
1169
- e(z) ? (F(), I("div", Cs, [
1170
- r("div", hs, [
1171
- k(ue, {
1172
- modelValue: e(v),
1173
- "onUpdate:modelValue": b[6] || (b[6] = (h) => ce(v) ? v.value = h : null)
1174
- }, null, 8, ["modelValue"])
1175
- ]),
1176
- r("div", ws, [
1177
- k(J, {
1178
- modelValue: e(C),
1179
- "onUpdate:modelValue": b[7] || (b[7] = (h) => ce(C) ? C.value = h : null)
1180
- }, null, 8, ["modelValue"])
1181
- ])
1182
- ])) : N("", !0)
1183
- ], 2),
1184
- e(Q) ? (F(), H(oe, {
1185
- key: 0,
1186
- modelValue: e(Q),
1187
- "onUpdate:modelValue": b[8] || (b[8] = (h) => ce(Q) ? Q.value = h : null),
1188
- rules: [e(_t)(new Date(a.lastClosingDate), /* @__PURE__ */ new Date())]
1189
- }, null, 8, ["modelValue", "rules"])) : N("", !0),
1190
- x.value && !a.lastClosingDate ? (F(), I("div", Ss, [
1191
- k(ne, {
1192
- name: "error",
1193
- size: "sm",
1194
- class: "text-fm-color-typo-warning"
1195
- }),
1196
- r("span", xs, A(e(n)("inventory.transfer.form.backdate.error")), 1)
1197
- ])) : N("", !0)
1198
- ])) : N("", !0)
1199
- ])
1200
- ]),
1201
- r("div", Fs, [
1202
- k(oe, {
1203
- "model-value": e(t).items,
1204
- rules: [e(Se)(1)]
1205
- }, null, 8, ["model-value", "rules"]),
1206
- r("div", {
1207
- class: W([
1208
- "flex gap-16",
1209
- {
1210
- "flex-col items-start": g.value,
1211
- "items-center": !g.value
1212
- }
1213
- ])
1214
- }, [
1215
- r("div", Ps, A(e(n)("inventory.transfer.form.items.title")), 1),
1216
- r("div", Ts, [
1217
- k(Ce, {
1218
- disabled: a.disabled,
1219
- label: e(n)("inventory.transfer.form.items.addItem"),
1220
- "prepend-icon": "add",
1221
- variant: "secondary",
1222
- "text-color": "primary",
1223
- "bg-color": "transparent",
1224
- "border-color": "primary",
1225
- onClick: b[9] || (b[9] = (h) => Je()),
1226
- size: "md"
1227
- }, null, 8, ["disabled", "label"]),
1228
- e(t).template ? (F(), H(he, {
1229
- key: 0,
1230
- "z-index": 50
1231
- }, {
1232
- content: R(() => [
1233
- r("div", null, A(e(n)("inventory.transfer.form.items.forecastStock.notAvailable")), 1)
1234
- ]),
1235
- default: R(() => [
1236
- k(Me, {
1237
- "onUpdate:poItems": b[10] || (b[10] = (h) => e(t).items = h),
1238
- disabled: ""
1239
- })
1240
- ]),
1241
- _: 1
1242
- })) : (F(), H(Me, {
1243
- key: 1,
1244
- "onUpdate:poItems": b[11] || (b[11] = (h) => e(t).items = h),
1245
- disabled: a.disabled || !!e(t).template
1246
- }, null, 8, ["disabled"]))
1247
- ])
1248
- ], 2),
1249
- O.value === e(V).PURCHASE && S.value && e(y).enableTotalCost && ((Ue = a.modelValue) != null && Ue.items.length) ? (F(), I("div", Is, [
1250
- k(se, {
1251
- label: e(ee) ? e(n)("inventory.transfer.form.items.fetchingData") : e(n)("inventory.transfer.form.items.comparePriceHistory"),
1252
- "prepend-icon": "compare_arrows",
1253
- "label-placement": "right",
1254
- "model-value": e(D),
1255
- "onUpdate:modelValue": b[12] || (b[12] = (h) => ce(D) ? D.value = h : null),
1256
- disabled: e(ee) || a.disabled
1257
- }, null, 8, ["label", "model-value", "disabled"])
1258
- ])) : N("", !0),
1259
- (F(), H(ye, {
1260
- "column-defs": Ke.value,
1261
- "row-data": e(t).items,
1262
- key: e(t).items.map((h) => h.sku._id).join("."),
1263
- "hide-footer": "",
1264
- "page-size": e(t).items.length
1265
- }, {
1266
- "table-row": R((h) => [
1267
- k(cs, {
1268
- "compare-price-by-sku": e(j),
1269
- "show-compare-price": O.value === e(V).PURCHASE && e(D),
1270
- row: h
1271
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row"])
1272
- ]),
1273
- "list-row": R((h) => [
1274
- (F(), H(wt, {
1275
- row: h,
1276
- key: e(t).items.map((ve) => ve.sku._id).join(".")
1277
- }, {
1278
- default: R((ve) => [
1279
- k(Ht, {
1280
- "compare-price-by-sku": e(j),
1281
- "show-compare-price": O.value === e(V).PURCHASE && e(D),
1282
- row: h,
1283
- "cell-by-col-id": ve
1284
- }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1285
- ]),
1286
- _: 2
1287
- }, 1032, ["row"]))
1288
- ]),
1289
- _: 1
1290
- }, 8, ["column-defs", "row-data", "page-size"]))
1291
- ])
1292
- ];
1293
- }),
1294
- _: 1
1295
- }, 8, ["disabled", "onValidationFailed"])
1296
- ]);
1297
- };
1298
- }
1299
- }), Vs = { class: "flex items-center" }, As = { class: "fm-typo-en-title-md-800" }, Ds = { class: "flex gap-4" }, Ys = /* @__PURE__ */ re({
1300
- __name: "TransferDialog",
1301
- props: {
1302
- mode: {},
1303
- modelValue: {},
1304
- templateId: {},
1305
- show: { type: Boolean },
1306
- lastClosingDate: {}
1307
- },
1308
- emits: ["update:show", "submitted"],
1309
- setup(o, { expose: f, emit: u }) {
1310
- var z;
1311
- const l = o, _ = u, t = Ne(), n = $e(), w = xe(), p = De(), s = Ae(), { t: i } = me(), y = q(!1), d = q(!1), c = q(!1);
1312
- async function g(v) {
1313
- if (v) {
1314
- d.value = !1;
1315
- try {
1316
- await w.readSuppliers(), d.value = !0;
1317
- } catch {
1318
- n.open({
1319
- title: i("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1320
- message: i("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1321
- type: "error"
1322
- });
1323
- }
1324
- }
1325
- }
1326
- s.watchLocation(g);
1327
- function m() {
1328
- return {
1329
- remark: void 0,
1330
- ref: void 0,
1331
- stockSnapshotId: void 0,
1332
- effectiveAt: void 0,
1333
- items: [],
1334
- supplier: {
1335
- _rev: void 0,
1336
- email: void 0,
1337
- internal: void 0,
1338
- contactName: void 0,
1339
- phoneNumber: void 0,
1340
- registrationNumber: void 0,
1341
- supplyItems: void 0,
1342
- _id: "",
1343
- name: "",
1344
- address: {
1345
- line2: void 0,
1346
- line1: "",
1347
- state: "",
1348
- city: "",
1349
- postcode: "",
1350
- country: ""
1351
- }
1352
- },
1353
- status: "DRAFT",
1354
- _id: "",
1355
- seqNumber: 0,
1356
- deliveryOrder: [],
1357
- template: l.templateId
1358
- };
1359
- }
1360
- const S = ot(l, "show"), x = q(l.modelValue ?? m()), E = q(((z = l.modelValue) == null ? void 0 : z._id) ?? `${Math.random()}`);
1361
- Le(
1362
- () => l.show,
1363
- (v) => {
1364
- var C;
1365
- v && (c.value = !1, x.value = l.modelValue ?? m(), E.value = ((C = l.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1366
- }
1367
- );
1368
- const $ = P(() => !d.value || !c.value), O = P(() => {
1369
- switch (l.mode) {
1370
- case be.READ:
1371
- return "View transfer";
1372
- case be.CREATE:
1373
- return i("inventory.transfer.receiveRequest.create.title");
1374
- case be.UPDATE:
1375
- return i("inventory.transfer.receiveRequest.update.title");
1376
- }
1377
- return "";
1378
- }), L = q();
1379
- f({
1380
- validateInputs: () => {
1381
- var v, C;
1382
- (C = (v = L.value) == null ? void 0 : v.validateInputs) == null || C.call(v);
1383
- },
1384
- resetInputsValidation: () => {
1385
- var v, C;
1386
- (C = (v = L.value) == null ? void 0 : v.resetInputsValidation) == null || C.call(v);
1387
- },
1388
- resetInputs: () => {
1389
- var v, C;
1390
- (C = (v = L.value) == null ? void 0 : v.resetInputs) == null || C.call(v);
1391
- }
1392
- });
1393
- async function X() {
1394
- const v = x.value;
1395
- y.value = !0, (v.supplier.internal === "warehouse" || v.supplier.internal === "restaurant") && (v.items = v.items.map(({ totalCost: C, ...D }) => D));
1396
- try {
1397
- await t.createPurchaseOrder(v), await new Promise((C) => setTimeout(C, 1e3)), n.open({
1398
- title: i("inventory.transfer.receiveRequest.create.success"),
1399
- message: i("inventory.transfer.receiveRequest.create.successMessage"),
1400
- type: "success"
1401
- }), _("update:show", !1), _("submitted");
1402
- } catch (C) {
1403
- n.open({
1404
- title: i("inventory.transfer.receiveRequest.create.error.title"),
1405
- message: i("inventory.transfer.receiveRequest.create.error.message"),
1406
- type: "error"
1407
- }), console.error("Error in creating purchase order", C);
1408
- } finally {
1409
- y.value = !1;
1410
- }
1411
- }
1412
- async function G() {
1413
- const v = x.value;
1414
- y.value = !0, (v.supplier.internal === "warehouse" || v.supplier.internal === "restaurant") && (v.items = v.items.map(({ totalCost: C, ...D }) => D));
1415
- try {
1416
- await t.updatePurchaseOrder(v), await new Promise((C) => setTimeout(C, 1e3)), n.open({
1417
- title: i("inventory.transfer.receiveRequest.update.success"),
1418
- message: i("inventory.transfer.receiveRequest.update.successMessage"),
1419
- type: "success"
1420
- }), _("update:show", !1), _("submitted");
1421
- } catch (C) {
1422
- n.open({
1423
- title: i("inventory.transfer.receiveRequest.update.error.title"),
1424
- message: i("inventory.transfer.receiveRequest.update.error.message"),
1425
- type: "error"
1426
- }), console.error("Error in updating purchase order", C);
1427
- } finally {
1428
- y.value = !1;
1429
- }
1430
- }
1431
- function Z() {
1432
- switch (l.mode) {
1433
- case be.CREATE:
1434
- return X();
1435
- case be.UPDATE:
1436
- return G();
1437
- }
1438
- }
1439
- function Q() {
1440
- var v, C;
1441
- (C = (v = L.value) == null ? void 0 : v.validateInputs) == null || C.call(v);
1442
- }
1443
- return (v, C) => {
1444
- const D = T("FmButton"), ee = T("FmSideSheet");
1445
- return F(), H(ee, {
1446
- modelValue: e(S),
1447
- "onUpdate:modelValue": C[3] || (C[3] = (j) => ce(S) ? S.value = j : null),
1448
- "dismiss-away": "",
1449
- "close-button": "",
1450
- "max-width": 900
1451
- }, {
1452
- "side-sheet-header": R(() => [
1453
- r("div", Vs, [
1454
- r("div", As, A(O.value), 1)
1455
- ])
1456
- ]),
1457
- default: R(() => [
1458
- (F(), H($s, {
1459
- class: "w-full",
1460
- ref_key: "formRef",
1461
- ref: L,
1462
- "onForm:ready": C[0] || (C[0] = () => c.value = !0),
1463
- onValidationSuccess: Z,
1464
- modelValue: x.value,
1465
- "onUpdate:modelValue": C[1] || (C[1] = (j) => x.value = j),
1466
- disabled: y.value || $.value,
1467
- suppliers: e(w).suppliers,
1468
- skus: e(p).skus,
1469
- key: E.value,
1470
- "last-closing-date": v.lastClosingDate
1471
- }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1472
- ]),
1473
- "side-sheet-footer": R(() => [
1474
- r("div", Ds, [
1475
- k(D, {
1476
- loading: y.value,
1477
- disabled: $.value,
1478
- label: e(i)("common.save"),
1479
- onClick: Q
1480
- }, null, 8, ["loading", "disabled", "label"]),
1481
- k(D, {
1482
- disabled: $.value,
1483
- variant: "tertiary",
1484
- label: e(i)("common.close"),
1485
- onClick: C[2] || (C[2] = (j) => _("update:show", !1))
1486
- }, null, 8, ["disabled", "label"])
1487
- ])
1488
- ]),
1489
- _: 1
1490
- }, 8, ["modelValue"]);
1491
- };
1492
- }
1493
- });
1494
- export {
1495
- Ys as _,
1496
- le as c,
1497
- zt as u
1498
- };