@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.40

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 (136) hide show
  1. package/dist/{App-DReDvY0M.js → App-D8DXxTIq.js} +84 -72
  2. package/dist/{ApprovalView-BMZlYmRk.js → ApprovalView-BWGXkHV6.js} +25 -28
  3. package/dist/{BindingsDialog-Y2K4I7H7.js → BindingsDialog-D7WypDot.js} +6 -6
  4. package/dist/{BindingsPicker-DKBq9c37.js → BindingsPicker-DUlGwkwM.js} +8 -9
  5. package/dist/{BindingsTable-45v4SDfp.js → BindingsTable-BjeZYCaJ.js} +18 -22
  6. package/dist/ClosingDraftView-o2LEUfo8.js +1190 -0
  7. package/dist/{ClosingTemplateView-CKJVYSbj.js → ClosingTemplateView-Dt983Cg4.js} +271 -285
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-Dc_7IyBG.js +142 -0
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CMEOp-0r.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-wocPyZls.js} +18 -19
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C1DjyjyH.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DzoEp-Pg.js} +25 -26
  11. package/dist/{IngredientGroupView-BuP-HGeg.js → IngredientGroupView-CIPpIpv1.js} +63 -69
  12. package/dist/IngredientsView-CFV3kX7Q.js +1707 -0
  13. package/dist/{IntegrationView-kYCaKG0o.js → IntegrationView-DkW32m-t.js} +89 -92
  14. package/dist/{InventoryBindingForm-BXHq4h-n.js → InventoryBindingForm-B4CBet9W.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CVxJ_bV3.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DpdDVf6O.js} +112 -104
  16. package/dist/{InventoryBindingSummary-Bjasfc_v.js → InventoryBindingSummary-75ImZtqK.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DM0C4raP.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DfpG3Fy8.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C3O3JebE.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B4d0c3nk.js} +19 -20
  19. package/dist/{PurchaseOrderPrintPreview-CmjkfTTS.js → PurchaseOrderPrintPreview-BYO0JcQW.js} +17 -18
  20. package/dist/ReceiveRequestView-cFLNExw9.js +4194 -0
  21. package/dist/RecipeView-CjfpaHaT.js +609 -0
  22. package/dist/StockView-HMtD9qar.js +1818 -0
  23. package/dist/{SupplierView-DAx7E7sR.js → SupplierView-Cidfe-Xm.js} +2325 -787
  24. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CdU3HPBC.js +1275 -0
  25. package/dist/TransferTemplateView-Doxr1fXP.js +1264 -0
  26. package/dist/{UnitView-CQPGZ8-r.js → UnitView-C1af71aM.js} +228 -227
  27. package/dist/{WarehouseView-jy-RNCgy.js → WarehouseView-CviOLXfX.js} +100 -106
  28. package/dist/api/adjustment-template.d.ts +25 -0
  29. package/dist/api/bill.d.ts +240 -84
  30. package/dist/api/closing-draft.d.ts +6 -0
  31. package/dist/api/closing.d.ts +1 -0
  32. package/dist/api/inventory.d.ts +15 -6
  33. package/dist/api/netsuite.d.ts +3 -3
  34. package/dist/app-BE8SgDqI.js +84466 -0
  35. package/dist/app.d.ts +64 -0
  36. package/dist/app.js +2 -2
  37. package/dist/components/FmCustomAttribute.vue.d.ts +23 -0
  38. package/dist/components/FmLockableField.vue.d.ts +37 -0
  39. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  40. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +3 -1
  41. package/dist/components/row-action.enum.d.ts +1 -0
  42. package/dist/components/shell/inventory/binding-ui.vue.d.ts +3 -1
  43. package/dist/composable/defineDeepModel.d.ts +1 -1
  44. package/dist/{decimal-BAc9M88Q.js → decimal-xj3kVOP6.js} +1 -1
  45. package/dist/feature-CWpNYcWJ.js +946 -0
  46. package/dist/format-unit-display-CZ835oaL.js +1215 -0
  47. package/dist/index-B8IWDKYv.js +29202 -0
  48. package/dist/{StockView-D9no-mrA.js → index-C6SzYqK7.js} +2242 -3986
  49. package/dist/router/name.d.ts +2 -0
  50. package/dist/stock-C2xyYnS7.js +125 -0
  51. package/dist/stores/feature.d.ts +6 -0
  52. package/dist/stores/integration/netsuite.d.ts +70 -2
  53. package/dist/stores/inventory.d.ts +21 -12
  54. package/dist/stores/supplier.d.ts +1 -1
  55. package/dist/style.css +1 -1
  56. package/dist/{supplier-DJC0UZWv.js → supplier-B-7o9hg1.js} +15 -15
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/{use-inventory-binding-dialog-PEQbFRvO.js → use-inventory-binding-dialog-Dm8Ky1MH.js} +10 -11
  59. package/dist/views/adjustment-template/import/AdjustmentTemplateImport.vue.d.ts +2 -0
  60. package/dist/views/adjustment-template/import/AdjustmentTemplateImportItem.vue.d.ts +18 -0
  61. package/dist/views/adjustment-template/import/export.d.ts +60 -0
  62. package/dist/views/adjustment-template/wastage-template/WastageTemplateDetails.vue.d.ts +2 -0
  63. package/dist/views/adjustment-template/wastage-template/WastageTemplateDialog.vue.d.ts +22 -0
  64. package/dist/views/adjustment-template/wastage-template/WastageTemplatePublish.vue.d.ts +6 -0
  65. package/dist/views/adjustment-template/wastage-template/WastageTemplateReason.vue.d.ts +18 -0
  66. package/dist/views/adjustment-template/wastage-template/WastageTemplateView.vue.d.ts +2 -0
  67. package/dist/views/adjustment-template/wastage-template/actions.d.ts +1329 -0
  68. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateForm.vue.d.ts +16 -0
  69. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +35 -0
  70. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +20 -0
  71. package/dist/views/adjustment-template/wastage-template/props.d.ts +36 -0
  72. package/dist/views/adjustment-template/wastage-template/table.d.ts +1303 -0
  73. package/dist/views/closing-draft/ClosingDraftView.vue.d.ts +2 -0
  74. package/dist/views/closing-draft/components/closing-draft-action/ClosingDraftAction.vue.d.ts +22 -0
  75. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +625 -0
  76. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +25 -0
  77. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +3645 -0
  78. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -0
  79. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +19 -0
  80. package/dist/views/closing-draft/helpers/get-calculated-total.helper.d.ts +4 -0
  81. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +2 -1
  82. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +48 -204
  83. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +49 -205
  84. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +6 -3
  85. package/dist/views/ingredients/components/convert/ConvertFormProps.d.ts +1 -0
  86. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +4 -2
  87. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +1 -0
  88. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +2 -1
  89. package/dist/views/receive-request/components/netsuite/NetSuiteInfo.vue.d.ts +12 -0
  90. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +13 -0
  91. package/dist/views/receive-request/components/netsuite/NetSuiteSync.vue.d.ts +12 -0
  92. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +2 -0
  93. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
  94. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +40 -17
  95. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +4 -2
  96. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -1
  97. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +57 -24
  98. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +57 -24
  99. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -0
  100. package/dist/views/stock/components/StockRecordCard.vue.d.ts +120 -42
  101. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +6 -4
  102. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  103. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +2 -1
  104. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +24 -12
  105. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +24 -12
  106. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +2 -1
  107. package/package.json +5 -4
  108. package/dist/FmDroppableField-8RzKjEdL.js +0 -154
  109. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BhdcqRh-.js +0 -436
  110. package/dist/FmMultiselectDialog-D7YtdoyJ.js +0 -415
  111. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-zjvFEF5C.js +0 -51
  112. package/dist/IngredientsView-DMRN-odY.js +0 -1613
  113. package/dist/ReceiveRequestView-aQZJO8sq.js +0 -4165
  114. package/dist/RecipeView-DXO43tFi.js +0 -597
  115. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js +0 -135
  116. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DCA0RUfu.js +0 -1209
  117. package/dist/TransferTemplateView-CfxdQF1t.js +0 -1261
  118. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +0 -9
  119. package/dist/app-KnSMkJBV.js +0 -33496
  120. package/dist/date2-CIeUqUIc.js +0 -117
  121. package/dist/dayjs.min-Df5jSnDJ.js +0 -282
  122. package/dist/defineDeepModel-BfuQAIoM.js +0 -13
  123. package/dist/feature-dwB4OxRQ.js +0 -86
  124. package/dist/format-time-from-id-BbvzyIN6.js +0 -15
  125. package/dist/format-unit-display-BBWblJEt.js +0 -1216
  126. package/dist/fuzzy-B9ryZ9VZ.js +0 -41
  127. package/dist/index-BN0CY3sZ.js +0 -22277
  128. package/dist/index-Bj1fJum-.js +0 -45
  129. package/dist/index-C4yL_7rR.js +0 -10545
  130. package/dist/netsuite-ByWOS6tI.js +0 -194
  131. package/dist/normalizeArguments-DP7Hrren.js +0 -1552
  132. package/dist/row-action.enum-PMKMRrZR.js +0 -50
  133. package/dist/rules-C12nWDD1.js +0 -198
  134. package/dist/use-template-enabled-locations-2-k9g5t8tt.js +0 -86
  135. package/dist/xlsx-B4XHad7S.js +0 -24004
  136. package/dist/xlsx.util-BSO4SHJi.js +0 -78
@@ -1,1216 +0,0 @@
1
- import { F as ne, D as W, R as A } from "./row-action.enum-PMKMRrZR.js";
2
- import { c as Ce } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
3
- import { j as Ie, a as L, u as z, i as Ne, x as oe, s as Ae, c as Z, R as ae } from "./app-KnSMkJBV.js";
4
- import { f as De } from "./format-time-from-id-BbvzyIN6.js";
5
- import { useCoreStore as J, useI18n as X } from "@feedmepos/mf-common";
6
- import { useDialogChild as Fe, useSnackbar as de, useDialog as Oe, FmButtonVariant as se, components as ie } from "@feedmepos/ui-library";
7
- import { defineStore as pe } from "pinia";
8
- import { defineComponent as fe, resolveComponent as B, openBlock as T, createElementBlock as w, createElementVNode as $, normalizeClass as M, createTextVNode as Pe, toDisplayString as I, unref as C, createCommentVNode as Q, createVNode as D, withCtx as G, Fragment as O, renderList as j, ref as R, onMounted as Ue, computed as le, watch as Be, createSlots as Me, createBlock as H, h as Y } from "vue";
9
- import { useRouter as Qe } from "vue-router";
10
- import { F as Le } from "./FmMultiselectDialog-D7YtdoyJ.js";
11
- import { a as P, b as ye, d as he, s as ve, r as He } from "./xlsx.util-BSO4SHJi.js";
12
- import { F as qe } from "./FmDroppableField-8RzKjEdL.js";
13
- import { c as Ve, a as U, t as q, g as V, m as je, B as ze } from "./rules-C12nWDD1.js";
14
- import { f as Ke } from "./date2-CIeUqUIc.js";
15
- import { u as ee } from "./supplier-DJC0UZWv.js";
16
- import { u as ge } from "./netsuite-ByWOS6tI.js";
17
- const be = Ie((e, r) => {
18
- function i() {
19
- var n;
20
- return `business_${((n = J().currentBusiness.value) == null ? void 0 : n._id) ?? ""}`;
21
- }
22
- return {
23
- async getTemplate(c) {
24
- const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template/${c}`;
25
- return r.get(n);
26
- },
27
- async readTemplates() {
28
- const c = i(), a = `${e.inventoryBackendUrl}/${c}/purchase-order-template`;
29
- return r.get(a);
30
- },
31
- async createTemplate(c) {
32
- const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
33
- return r.post(n, c);
34
- },
35
- async updateTemplate(c) {
36
- const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
37
- return r.put(n, c);
38
- },
39
- async deleteTemplate(c) {
40
- const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template`;
41
- return r.delete(n, { _id: c._id, _rev: c._rev });
42
- },
43
- async importTemplates(c) {
44
- const a = i(), n = `${e.inventoryBackendUrl}/${a}/purchase-order-template/import`;
45
- return r.post(n, c);
46
- }
47
- };
48
- });
49
- function xe(e) {
50
- const r = L(), i = e.sku, c = r.skuById[i._id];
51
- if (c.unit._id !== i.unit._id) return !0;
52
- const a = e.measurement;
53
- return a ? !r.unitById[c.unit._id].measurements.find((s) => s.id === a.id) : !1;
54
- }
55
- var E = /* @__PURE__ */ ((e) => (e.PURCHASE = "PURCHASE", e.TRANSFER = "TRANSFER", e))(E || {}), te = /* @__PURE__ */ ((e) => (e.Source = "Source", e.Destination = "Destination", e.Ingredient = "Ingredient", e))(te || {});
56
- const me = Ve(0);
57
- function Se(e) {
58
- var c;
59
- const r = e.sku;
60
- return {
61
- code: r.code,
62
- name: r.name,
63
- unit: ((c = r.unit.measurements.find((a) => a.id === r.trackingMeasurement)) == null ? void 0 : c.abbrev) ?? r.unit.abbrev,
64
- defaultQuantity: +U(e.quantity),
65
- minimumQuantity: +U(e.minimumQuantity ?? me),
66
- maximumQuantity: +U(e.maximumQuantity ?? me),
67
- quantityStep: +U(e.quantityStep)
68
- };
69
- }
70
- function Te() {
71
- return [
72
- {
73
- id: "code",
74
- name: "Code"
75
- },
76
- {
77
- id: "name",
78
- name: "Name"
79
- },
80
- {
81
- id: "unit",
82
- name: "Unit"
83
- },
84
- {
85
- id: "defaultQuantity",
86
- name: "Default Quantity"
87
- },
88
- {
89
- id: "minimumQuantity",
90
- name: "Minimum Quantity"
91
- },
92
- {
93
- id: "maximumQuantity",
94
- name: "Maximum Quantity"
95
- },
96
- {
97
- id: "quantityStep",
98
- name: "Quantity Step"
99
- }
100
- ];
101
- }
102
- function We(e) {
103
- var s;
104
- const i = J().currentBusiness.value, a = (s = e.map((l) => {
105
- var f;
106
- const m = l.purchaseOrder.items.map(Se), h = Te(), b = [
107
- ["Template ID", l._id],
108
- ["Template name", l.name],
109
- ["Business name", i == null ? void 0 : i.name],
110
- ["Business ID", i == null ? void 0 : i._id],
111
- ["Menu version", i == null ? void 0 : i.menuVersion],
112
- [
113
- "Purchase/Transfer",
114
- typeof l.purchaseOrder.supplier.internal == "string" ? E.TRANSFER : E.PURCHASE
115
- ],
116
- [
117
- "Transfer from",
118
- `${l.purchaseOrder.supplier.name} (${[
119
- l.purchaseOrder.supplier.internal,
120
- l.purchaseOrder.supplier._id
121
- ].filter((t) => t).join("_")})`
122
- ],
123
- ["Location codes", ...((f = l.locations) == null ? void 0 : f.map((t) => `${t.name} (${t.dbName})`)) ?? ["All"]],
124
- ["Reference", l.purchaseOrder.ref ?? ""],
125
- ["Remark", l.purchaseOrder.remark ?? ""],
126
- [],
127
- h.map((t) => t.name),
128
- ...m.map((t) => h.map((S) => t[S.id]))
129
- ], v = h.map((t) => `system:${t.id}`), y = P(b, v);
130
- return { name: l.name, sheet: y };
131
- }).reduce(
132
- (l, m) => {
133
- var b;
134
- const h = m.name.slice(0, 12);
135
- return (b = l.sheetOccurence)[h] ?? (b[h] = 0), l.sheetOccurence[h] += 1, l.sheets[`${h} (${l.sheetOccurence[h]})`] = m.sheet, l;
136
- },
137
- {
138
- sheets: {},
139
- sheetOccurence: {}
140
- }
141
- )) == null ? void 0 : s.sheets, n = `${i == null ? void 0 : i.name} transfer templates (${Ke(/* @__PURE__ */ new Date())}).xlsx`, p = ye(a);
142
- return he(p, n), n;
143
- }
144
- function Ye() {
145
- const e = J(), r = ee(), i = z(), c = L(), a = e.currentBusiness.value, n = Se({
146
- sku: {
147
- unit: {
148
- _id: "",
149
- name: "Unit",
150
- abbrev: "Unit",
151
- precision: 0,
152
- measurements: []
153
- },
154
- code: "ING001",
155
- _id: "",
156
- name: "Sugar"
157
- },
158
- code: "ING001",
159
- name: "Sugar",
160
- quantity: {
161
- amount: 1,
162
- precision: 0
163
- },
164
- quantityStep: {
165
- amount: 1,
166
- precision: 0
167
- },
168
- minimumQuantity: {
169
- amount: 1,
170
- precision: 0
171
- },
172
- maximumQuantity: {
173
- amount: 1,
174
- precision: 0
175
- }
176
- }), p = Te(), s = [
177
- ["Template ID (leave empty to create new)"],
178
- ["Template Name", "New template"],
179
- ["Business name", a == null ? void 0 : a.name],
180
- ["Business ID", a == null ? void 0 : a._id],
181
- ["Menu version", a == null ? void 0 : a.menuVersion],
182
- ["Purchase/Transfer", "Purchase"],
183
- [
184
- "Transfer from",
185
- "Example supplier (supplier_xxx)",
186
- "Refer to sources list & copy whole cell."
187
- ],
188
- [
189
- "Location codes (leave empty to enable all)",
190
- "Example outlet (restaurant_xxx)",
191
- "Example outlet 2 (restaurant_xxx)"
192
- ],
193
- ["Reference"],
194
- ["Remark"],
195
- [],
196
- p.map((t) => t.name),
197
- p.map((t) => n[t.id])
198
- ], l = p.map((t) => `system:${t.id}`), m = P(s, l), h = P(
199
- [
200
- ...r.businessSuppliers.map((t) => [
201
- `${t.name} (${t._id})`,
202
- "Purchase",
203
- t.address.line1,
204
- t.address.line2,
205
- t.address.city,
206
- t.address.postcode,
207
- t.address.state,
208
- t.address.country
209
- ]),
210
- ...i.locations.map((t) => {
211
- var S, _, d, o, u, x;
212
- return [
213
- `${t.name} (${t.dbName})`,
214
- "Transfer",
215
- (S = t.doc.profile.address) == null ? void 0 : S.line1,
216
- (_ = t.doc.profile.address) == null ? void 0 : _.line2,
217
- (d = t.doc.profile.address) == null ? void 0 : d.city,
218
- (o = t.doc.profile.address) == null ? void 0 : o.postcode,
219
- (u = t.doc.profile.address) == null ? void 0 : u.state,
220
- (x = t.doc.profile.address) == null ? void 0 : x.country
221
- ];
222
- })
223
- ],
224
- ["Name", "Type", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
225
- ), b = P(
226
- i.locations.map((t) => {
227
- var S, _, d, o, u, x;
228
- return [
229
- `${t.name} (${t.dbName})`,
230
- (S = t.doc.profile.address) == null ? void 0 : S.line1,
231
- (_ = t.doc.profile.address) == null ? void 0 : _.line2,
232
- (d = t.doc.profile.address) == null ? void 0 : d.city,
233
- (o = t.doc.profile.address) == null ? void 0 : o.postcode,
234
- (u = t.doc.profile.address) == null ? void 0 : u.state,
235
- (x = t.doc.profile.address) == null ? void 0 : x.country
236
- ];
237
- }),
238
- ["Name", "Line 1", "Line 2", "City", "Postal", "State", "Country"]
239
- ), v = P(
240
- c.skus.map((t) => [
241
- t.code,
242
- t.name,
243
- t.unit.abbrev,
244
- ...t.unit.measurements.map((S) => S.abbrev)
245
- ]),
246
- ["Code", "Name", "Base unit", "Measurements"]
247
- ), y = ye({
248
- Template: m,
249
- Source: h,
250
- Destination: b,
251
- Ingredient: v
252
- }), f = `${a == null ? void 0 : a.name} transfer templates import.xlsx`;
253
- return he(y, f), f;
254
- }
255
- function Ge(e, r) {
256
- const i = new Array(), c = /(.*) \(((supplier_|warehouse_|restaurant_).{24,})\)/, n = z().locationByDbName, s = ee().supplierById, l = e.trim(), m = c.exec(l);
257
- if (!m)
258
- return i.push(`Transfer from location value of ${l} cannot be read.`), {
259
- errors: i
260
- };
261
- const h = m[1], b = m[2];
262
- let v;
263
- if (b.startsWith("supplier"))
264
- v = s[b], r !== E.PURCHASE && i.push(`Expected transfer type Purchase but found ${r} instead.`);
265
- else {
266
- const y = n[b];
267
- if (!y)
268
- return i.push(`Location (${h}) of id ${b} is not found.`), {
269
- errors: i
270
- };
271
- h !== y.name && i.push(
272
- `Location id ${b} has non-matching name. Found ${h} but expected ${y.name}`
273
- ), v = {
274
- _id: y.doc._id,
275
- name: y.name,
276
- address: y.doc.profile.address ?? {
277
- line1: "",
278
- state: "",
279
- country: "",
280
- city: "",
281
- postcode: "",
282
- coordinates: [0, 0]
283
- },
284
- internal: b.split("_")[0] === "restaurant" ? oe.enum.restaurant : oe.enum.warehouse,
285
- phoneNumber: y.doc.profile.phoneNo ?? "",
286
- email: y.doc.profile.email ?? "",
287
- _rev: "",
288
- contactName: y.doc.profile.name ?? "",
289
- registrationNumber: y.doc.profile.regNo ?? ""
290
- };
291
- }
292
- return {
293
- from: v,
294
- errors: i
295
- };
296
- }
297
- function Ze(e) {
298
- if (!e.length || `${e[0]}`.toLocaleLowerCase() === "all")
299
- return [];
300
- const r = /(.*) \(((warehouse_|restaurant_).{24,})\)/, c = z().locationByDbName;
301
- return e.map((a) => {
302
- const n = new Array(), p = a.trim(), s = r.exec(p);
303
- if (!s)
304
- return n.push(`Enabled location value of ${p} cannot be read.`), {
305
- errors: n
306
- };
307
- const l = s[1], m = s[2], h = c[m];
308
- return h ? (l !== h.name && n.push(
309
- `Location id ${m} has non-matching name. Found ${l} but expected ${h.name}`
310
- ), {
311
- errors: n,
312
- location: h
313
- }) : (n.push(`Location (${l}) of id ${m} is not found.`), {
314
- errors: n
315
- });
316
- });
317
- }
318
- function Je(e) {
319
- const [
320
- r,
321
- i,
322
- c,
323
- a,
324
- n,
325
- p,
326
- s,
327
- l,
328
- m,
329
- h,
330
- b
331
- ] = ve(e);
332
- return {
333
- id: `${i[1] ?? ""}`.trim(),
334
- name: `${c[1] ?? ""}`.trim(),
335
- type: `${s[1] ?? ""}`.trim().toLocaleLowerCase() === "transfer" ? E.TRANSFER : E.PURCHASE,
336
- transferFrom: `${l[1] ?? ""}`.trim(),
337
- locations: m.slice(1).map((v) => `${v}`.trim()).filter((v) => v),
338
- reference: `${h[1] ?? ""}`.trim(),
339
- remark: `${b[1] ?? ""}`.trim()
340
- };
341
- }
342
- function Xe(e) {
343
- const [
344
- r,
345
- i,
346
- c,
347
- a,
348
- n,
349
- p,
350
- s,
351
- l,
352
- m,
353
- h,
354
- b,
355
- v,
356
- y,
357
- ...f
358
- ] = ve(e);
359
- if (!r || !r.length || r.some((o) => o.length && !o.startsWith("system:")))
360
- throw new Error("Missing meta header. Excel file does not come from the template.");
361
- const t = r.map((o) => o.split(":")[1]), _ = [
362
- "code",
363
- "name",
364
- "unit",
365
- "defaultQuantity",
366
- "minimumQuantity",
367
- "maximumQuantity",
368
- "quantityStep"
369
- ].filter((o) => !t.includes(o));
370
- if (_.length)
371
- throw new Error(
372
- `Missing meta headers (${_.join()}). Excel file does not come from the template.`
373
- );
374
- return f.map((o, u) => {
375
- const x = {};
376
- for (const k in t) {
377
- const g = t[k];
378
- Object.assign(x, { [g]: o[k] });
379
- }
380
- return {
381
- index: u,
382
- data: x
383
- };
384
- });
385
- }
386
- function et(e, r, i) {
387
- const a = L().skuByCode[e.code], n = new Array();
388
- if (!a)
389
- return n.push(`Cannot find ingredient with code (${e.code}) ${e.name}.`), {
390
- index: r,
391
- errors: n
392
- };
393
- if (i.filter((o) => o.data.code === e.code).length > 1)
394
- return n.push(`Ingredient ${e.code} is defined twice.`), {
395
- index: r,
396
- errors: n
397
- };
398
- const p = a.unit, s = p == null ? void 0 : p.measurements.find((o) => o.abbrev === e.unit);
399
- if (p.abbrev !== e.unit && !s) {
400
- const o = `Cannot find unit measurement of symbol ${e.unit || "[empty]"} for ingredient (${e.code}) ${e.name}.`;
401
- n.push(o);
402
- const u = {
403
- sku: a,
404
- code: a.code,
405
- name: a.name,
406
- measurement: s,
407
- quantity: { amount: 0, precision: 0 },
408
- quantityStep: { amount: 0, precision: 0 },
409
- minimumQuantity: { amount: 0, precision: 0 },
410
- maximumQuantity: { amount: 0, precision: 0 }
411
- };
412
- return {
413
- index: r,
414
- errors: n,
415
- templateItem: u
416
- };
417
- }
418
- const l = q(
419
- e.quantityStep,
420
- V(p, s)
421
- );
422
- (Number.isNaN(Number(e.quantityStep)) || Number(e.quantityStep) <= 0) && n.push("Amount step must be more than 0");
423
- const m = je(l), h = q(
424
- e.minimumQuantity,
425
- V(p, s)
426
- ), b = m(h);
427
- typeof b == "string" && n.push(`Minimum amount: ${b}`);
428
- const v = q(
429
- e.maximumQuantity,
430
- V(p, s)
431
- ), y = m(v);
432
- typeof y == "string" && n.push(`Maximum amount: ${y}`), +e.minimumQuantity > +e.maximumQuantity && n.push("Minimum amount must be less than or equal to maximum amount");
433
- const f = ze(+e.minimumQuantity, +e.maximumQuantity), t = q(
434
- e.defaultQuantity,
435
- V(p, s)
436
- ), S = m(t), _ = f(`${e.defaultQuantity}`);
437
- typeof S == "string" && n.push(`Default amount: ${S}`), typeof _ == "string" && n.push(`Default amount: ${_}`);
438
- const d = {
439
- sku: a,
440
- code: a.code,
441
- name: a.name,
442
- measurement: s,
443
- quantity: t,
444
- quantityStep: l,
445
- minimumQuantity: h,
446
- maximumQuantity: v
447
- };
448
- return {
449
- index: r,
450
- errors: n,
451
- templateItem: d
452
- };
453
- }
454
- function tt(e) {
455
- const r = e.SheetNames.filter(
456
- (n) => !Object.values(te).map(String).includes(n)
457
- ), c = $e().templates, a = Ne(c, "_id");
458
- try {
459
- return r.reduce(
460
- (n, p) => {
461
- var o;
462
- const s = new Array(), l = e.Sheets[p], m = Je(l), h = Ge(m.transferFrom, m.type);
463
- s.push(...h.errors);
464
- const b = h.from, v = Ze(m.locations), y = v.filter((u) => u.location).map((u) => u.location);
465
- s.push(...v.flatMap((u) => u.errors));
466
- const f = Xe(l).filter((u) => u.data.code), t = f.map(
467
- (u, x) => et(u.data, x, f)
468
- );
469
- s.push(
470
- ...t.flatMap(
471
- (u) => u.errors.map((x) => `(Excel row ${u.index + 14}) ${x}`)
472
- )
473
- );
474
- const S = t.filter((u) => u.templateItem).map((u) => u.templateItem);
475
- if (m.id) {
476
- const u = a[m.id];
477
- if (!u) {
478
- const k = {
479
- _id: m.id,
480
- _rev: "",
481
- name: m.name || `(unnamed from sheet ${p || "<unnamed sheet>"})`,
482
- purchaseOrder: rt()
483
- };
484
- return s.push(`Template ID ${m.id} is not found.`), n.importUpdateResult.push({
485
- type: "update",
486
- original: k,
487
- template: k,
488
- excelSheetName: p,
489
- errors: s
490
- }), n;
491
- }
492
- const x = {
493
- type: "update",
494
- original: u,
495
- template: {
496
- ...u,
497
- name: m.name,
498
- locations: y.length ? y : null,
499
- purchaseOrder: {
500
- ...u.purchaseOrder,
501
- supplier: b ?? ((o = u.purchaseOrder) == null ? void 0 : o.supplier),
502
- ref: m.reference,
503
- remark: m.remark,
504
- items: S
505
- }
506
- },
507
- excelSheetName: p,
508
- errors: s
509
- };
510
- return n.importUpdateResult.push(x), n;
511
- }
512
- const d = {
513
- type: "create",
514
- template: {
515
- name: m.id,
516
- locations: y,
517
- purchaseOrder: {
518
- supplier: b ?? _e(),
519
- ref: m.reference,
520
- remark: m.remark,
521
- items: S
522
- }
523
- },
524
- excelSheetName: p,
525
- errors: s
526
- };
527
- return n.importCreateResult.push(d), n;
528
- },
529
- {
530
- invalidExcel: !1,
531
- importCreateResult: new Array(),
532
- importUpdateResult: new Array()
533
- }
534
- );
535
- } catch (n) {
536
- return {
537
- invalidExcel: !0,
538
- invalidExcelMessage: (n == null ? void 0 : n.message) ?? "Invalid excel",
539
- importCreateResult: [],
540
- importUpdateResult: []
541
- };
542
- }
543
- }
544
- function _e() {
545
- return {
546
- _id: "",
547
- name: "",
548
- address: {
549
- line2: void 0,
550
- line1: "",
551
- state: "",
552
- city: "",
553
- postcode: "",
554
- country: ""
555
- }
556
- };
557
- }
558
- function rt() {
559
- return {
560
- remark: void 0,
561
- ref: void 0,
562
- items: [],
563
- supplier: _e()
564
- };
565
- }
566
- const nt = { class: "flex items-center gap-12 pl-8" }, ot = { class: "flex flex-col" }, at = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, st = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, it = {
567
- key: 0,
568
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
569
- }, lt = { key: 0 }, ce = /* @__PURE__ */ fe({
570
- __name: "TransferTemplateImportItem",
571
- props: {
572
- type: {},
573
- name: {},
574
- transferType: {},
575
- locations: {},
576
- items: {},
577
- errors: {}
578
- },
579
- setup(e) {
580
- return (r, i) => {
581
- var n, p, s;
582
- const c = B("FmIcon"), a = B("FmTooltip");
583
- return T(), w("div", nt, [
584
- i[0] || (i[0] = $("div", null, "•", -1)),
585
- $("div", ot, [
586
- $("div", at, [
587
- $("div", {
588
- class: M({
589
- "text-fm-color-system-error-300": r.errors.length
590
- })
591
- }, [
592
- Pe(I(r.name) + " ", 1),
593
- $("span", st, " (" + I(C(Ae)(`${r.transferType}`)) + ") ", 1),
594
- r.type === "create" ? (T(), w("span", it, "(new)")) : Q("", !0)
595
- ], 2),
596
- r.errors.length ? (T(), w("div", lt, [
597
- D(a, { "z-index": 50 }, {
598
- content: G(() => [
599
- $("ol", null, [
600
- (T(!0), w(O, null, j(r.errors, (l, m) => (T(), w("li", { key: m }, I(l), 1))), 128))
601
- ])
602
- ]),
603
- default: G(() => [
604
- D(c, {
605
- name: "error",
606
- size: "sm",
607
- color: "system-error-300"
608
- })
609
- ]),
610
- _: 1
611
- })
612
- ])) : Q("", !0)
613
- ]),
614
- $("div", {
615
- class: M([
616
- "fm-typo-en-body-sm-400",
617
- {
618
- "text-fm-color-system-error-200": r.errors.length,
619
- "text-fm-color-typo-secondary": !r.errors.length
620
- }
621
- ])
622
- }, I((n = r.locations) != null && n.length ? `${(p = r.locations) == null ? void 0 : p.length} locations` : "All locations") + ", " + I(`${(s = r.items) == null ? void 0 : s.length} items`), 3)
623
- ])
624
- ]);
625
- };
626
- }
627
- }), mt = { class: "flex flex-col gap-24" }, ct = {
628
- key: 0,
629
- class: "flex items-center gap-8"
630
- }, ut = { class: "flex flex-col gap-8" }, dt = { class: "line-clamp-2 text-ellipsis break-all" }, pt = {
631
- key: 2,
632
- class: "shrink-0"
633
- }, ft = {
634
- key: 0,
635
- class: "flex flex-col"
636
- }, yt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, ht = {
637
- key: 0,
638
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
639
- }, vt = { class: "fm-typo-en-body-lg-600" }, gt = /* @__PURE__ */ fe({
640
- __name: "TransferTemplateImport",
641
- setup(e) {
642
- const r = R(null), i = Fe(), c = de(), a = R(!1), n = R(!1), p = ee();
643
- Ue(async () => {
644
- n.value = !0;
645
- try {
646
- await p.readSuppliers().delayed(1e3);
647
- } catch {
648
- c.open({
649
- title: "Something went wrong.",
650
- message: "Error at reading suppliers list. Please try again.",
651
- type: "error"
652
- });
653
- } finally {
654
- n.value = !1;
655
- }
656
- });
657
- const s = R(new Array()), l = R([]), m = R([]), h = le(
658
- () => !!s.value.length || l.value.some((f) => f.errors.length) || m.value.some((f) => f.errors.length)
659
- ), b = le(
660
- () => !!l.value.length || !!m.value.length
661
- ), { t: v } = X();
662
- async function y(f) {
663
- s.value = [], l.value = [], m.value = [];
664
- try {
665
- a.value = !0;
666
- const [t] = await Promise.all([
667
- He(f),
668
- // fake buffer
669
- new Promise((o) => setTimeout(o, 1e3))
670
- ]);
671
- if (!t.SheetNames.filter(
672
- (o) => !Object.values(te).map(String).includes(o)
673
- ).find((o) => o)) {
674
- s.value.push(v("inventory.ingredient.import.fileError.noSheet"));
675
- return;
676
- }
677
- const d = tt(t);
678
- if (d.invalidExcel) {
679
- s.value.push(
680
- d.invalidExcelMessage ?? v("inventory.ingredient.import.fileError.invalidExcel")
681
- );
682
- return;
683
- }
684
- if (l.value = d.importCreateResult, m.value = d.importUpdateResult, !l.value.length && !m.value.length) {
685
- s.value.push(v("inventory.ingredient.import.fileError.noData"));
686
- return;
687
- }
688
- i.emitData(d);
689
- } catch (t) {
690
- c.open({
691
- title: v("inventory.ingredient.import.fileError.unableToRead"),
692
- message: t == null ? void 0 : t.message,
693
- type: "error"
694
- }), console.error("Error in reading file", t);
695
- } finally {
696
- s.value.length && c.open({
697
- title: v("inventory.ingredient.import.fileError.invalidExcel"),
698
- type: "error"
699
- }), a.value = !1;
700
- }
701
- }
702
- return Be(r, (f) => {
703
- f && y(f);
704
- }), (f, t) => {
705
- const S = B("FmCircularProgress"), _ = B("FmIcon"), d = B("FmButton");
706
- return T(), w("div", mt, [
707
- t[2] || (t[2] = $("div", { class: "fm-typo-en-body-md-400" }, "Import transfer templates from excel sheets.", -1)),
708
- n.value ? (T(), w("div", ct, [
709
- $("div", null, [
710
- D(S, {
711
- size: "md",
712
- color: "neutral-gray-200"
713
- })
714
- ]),
715
- t[1] || (t[1] = $("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
716
- ])) : (T(), w(O, { key: 1 }, [
717
- D(qe, {
718
- class: M({
719
- "w-full": !0,
720
- "h-[200px]": !r.value
721
- }),
722
- accept: ".xlsx",
723
- onFileUpload: t[0] || (t[0] = (o) => r.value = o),
724
- label: C(v)("inventory.ingredient.import.uploadTemplate"),
725
- "button-label": C(v)("inventory.ingredient.import.selectFile")
726
- }, Me({ _: 2 }, [
727
- r.value ? {
728
- name: "default",
729
- fn: G(({ openFileDialog: o }) => [
730
- $("div", ut, [
731
- $("div", {
732
- class: M([
733
- "fm-corner-radius-md p-16 flex items-center gap-16",
734
- {
735
- "border border-fm-color-neutral-gray-100": a.value,
736
- "border border-fm-color-neutral-gray-200": !a.value && !h.value,
737
- "border border-fm-color-system-error-200": h.value
738
- }
739
- ])
740
- }, [
741
- a.value ? (T(), H(S, {
742
- key: 0,
743
- size: "md",
744
- color: "neutral-gray-200"
745
- })) : (T(), H(_, {
746
- key: 1,
747
- name: h.value ? "error" : "attach_file",
748
- outline: "",
749
- color: h.value ? "system-error-300" : void 0
750
- }, null, 8, ["name", "color"])),
751
- $("div", {
752
- class: M([
753
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
754
- {
755
- "text-fm-color-typo-disabled": a.value,
756
- "text-fm-color-typo-primary": !a.value
757
- }
758
- ])
759
- }, [
760
- $("div", dt, I(r.value.name), 1)
761
- ], 2),
762
- a.value ? Q("", !0) : (T(), w("div", pt, [
763
- D(d, {
764
- label: C(v)("inventory.ingredient.import.replaceFile"),
765
- variant: h.value ? "destructive" : "secondary",
766
- "prepend-icon": h.value ? void 0 : "autorenew",
767
- onClick: o
768
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
769
- ]))
770
- ], 2),
771
- s.value.length ? (T(), w("div", ft, [
772
- (T(!0), w(O, null, j(s.value, (u, x) => (T(), w("div", {
773
- key: x,
774
- class: "flex gap-8 items-center"
775
- }, [
776
- D(_, {
777
- name: "error",
778
- size: "sm",
779
- color: "system-error-300"
780
- }),
781
- $("div", yt, I(u), 1)
782
- ]))), 128))
783
- ])) : Q("", !0)
784
- ])
785
- ]),
786
- key: "0"
787
- } : void 0
788
- ]), 1032, ["class", "label", "button-label"]),
789
- b.value ? (T(), w("div", ht, [
790
- $("div", vt, I(C(v)("inventory.ingredient.import.summary")), 1),
791
- (T(!0), w(O, null, j(l.value, (o, u) => (T(), H(ce, {
792
- key: u,
793
- name: o.template.name,
794
- "transfer-type": typeof o.template.purchaseOrder.supplier.internal == "string" ? C(E).TRANSFER : C(E).PURCHASE,
795
- locations: o.template.locations,
796
- items: o.template.purchaseOrder.items,
797
- errors: o.errors,
798
- type: "create"
799
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128)),
800
- (T(!0), w(O, null, j(m.value, (o) => (T(), H(ce, {
801
- key: o.template._id,
802
- name: o.template.name,
803
- "transfer-type": typeof o.template.purchaseOrder.supplier.internal == "string" ? C(E).TRANSFER : C(E).PURCHASE,
804
- locations: o.template.locations,
805
- items: o.template.purchaseOrder.items,
806
- errors: o.errors,
807
- type: "update"
808
- }, null, 8, ["name", "transfer-type", "locations", "items", "errors"]))), 128))
809
- ])) : Q("", !0)
810
- ], 64))
811
- ]);
812
- };
813
- }
814
- });
815
- function bt(e) {
816
- var n, p;
817
- const r = ge();
818
- if (!r.isEnabled) return !0;
819
- if (!e.internal) {
820
- const s = r.getNetSuiteVendor(e._id), l = s == null ? void 0 : s.subsidiaryId, m = (n = r.currentVendorSubsidiary(e._id)) == null ? void 0 : n.id;
821
- return l && l == m;
822
- }
823
- const i = r.getNetSuiteLocation(`${e.internal}_${e._id}`), c = r.getLocationSubsidiary(i == null ? void 0 : i.netSuiteId).id, a = (p = r.currentLocationSubsidiary()) == null ? void 0 : p.id;
824
- return c && c == a;
825
- }
826
- const xt = pe("transferTemplateActions", () => {
827
- const e = Oe(), r = de(), i = z(), c = $e(), a = be(), n = ge(), p = Qe(), { t: s } = X(), l = R({});
828
- function m() {
829
- l.value = {
830
- mode: ne.CREATE,
831
- show: !0,
832
- "onUpdate:show"(d) {
833
- l.value.show = d;
834
- }
835
- };
836
- }
837
- function h(d) {
838
- l.value = {
839
- mode: ne.UPDATE,
840
- modelValue: d,
841
- show: !0,
842
- "onUpdate:show"(o) {
843
- l.value.show = o;
844
- }
845
- };
846
- }
847
- function b(d, o, u) {
848
- e.open({
849
- title: `Confirm deleting template ${d.name}?`,
850
- message: "Deleted template can no longer be retrieved",
851
- primaryActions: {
852
- text: "Delete",
853
- variant: se.Destructive,
854
- close: !0
855
- },
856
- secondaryActions: {
857
- text: "Cancel",
858
- variant: se.Plain,
859
- close: !0
860
- }
861
- }).onPrimary(async () => {
862
- r.open({
863
- title: `Deleting ${d.name}`,
864
- type: "info"
865
- });
866
- try {
867
- o.value = !0;
868
- const [x] = await Promise.allSettled([
869
- a.deleteTemplate(d),
870
- new Promise((k) => setTimeout(k, 1e3))
871
- ]);
872
- if (x.status === "rejected") throw x.reason;
873
- r.open({
874
- title: `Deleted ${d.name}`,
875
- type: "success"
876
- });
877
- } catch (x) {
878
- r.open({
879
- title: `Unable to delete ${d.name}`,
880
- message: `See error from server: ${x}`,
881
- type: "error"
882
- }), console.error("error on deleting purchase order template", x);
883
- } finally {
884
- o.value = !1, u();
885
- }
886
- });
887
- }
888
- const v = R({});
889
- function y(d) {
890
- v.value = {
891
- template: d,
892
- show: !0,
893
- "onUpdate:show"(o) {
894
- v.value.show = o;
895
- },
896
- "onAction:edit"() {
897
- v.value.show = !1, h(Z(d));
898
- }
899
- };
900
- }
901
- function f() {
902
- const { promise: d, resolve: o } = Promise.withResolvers(), u = (g) => {
903
- o(g);
904
- }, x = c.templates.filter(
905
- (g) => {
906
- var N;
907
- return (!g.locations || g.locations.find((F) => F.doc._id === i.currentLocation.doc._id)) && ((N = g.purchaseOrder.supplier) == null ? void 0 : N._id) !== i.currentLocation.doc._id;
908
- }
909
- );
910
- if (!x.length)
911
- return e.open({
912
- title: "Select one template",
913
- message: "There is no available template in your business. Configure a new template?",
914
- primaryActions: {
915
- text: "Close",
916
- close: !0
917
- },
918
- secondaryActions: {
919
- text: "Close",
920
- close: !0
921
- }
922
- }).onPrimary(() => {
923
- p.push({ name: ae.TRANSFER_TEMPLATE }), u(void 0);
924
- }).onSecondary(() => u(void 0)).onClose(() => u(void 0)), d;
925
- const k = x.map((g) => {
926
- var re;
927
- const N = !g.purchaseOrder.items.length || g.purchaseOrder.items.some(xe), F = !bt(g.purchaseOrder.supplier), K = g.purchaseOrder.supplier.internal ? n.getNetSuiteLocation(
928
- `${g.purchaseOrder.supplier.internal}_${g.purchaseOrder.supplier._id}`
929
- ) : n.getNetSuiteVendor(g.purchaseOrder.supplier._id), we = F ? `The subsidiary of the request
930
- location is ${(re = n.getLocationSubsidiary(K == null ? void 0 : K.netSuiteId)) == null ? void 0 : re.fullName}.` : void 0, ke = N || F, Re = N ? "This template is invalid. Update this template." : F ? we : void 0, Ee = `${g.purchaseOrder.supplier.internal ? "Transfer" : "Purchase"} from ${g.purchaseOrder.supplier.name}`;
931
- return {
932
- label: g.name,
933
- value: g._id,
934
- disabled: ke,
935
- sublabel: Re ?? Ee
936
- };
937
- });
938
- return k.sort((g, N) => +!!g.disabled - +!!N.disabled), e.open({
939
- title: "Select one template",
940
- contentComponent: Le,
941
- contentComponentProps: {
942
- items: k,
943
- singleSelect: !0
944
- },
945
- primaryActions: {
946
- text: "Confirm",
947
- close: !0
948
- },
949
- secondaryActions: {
950
- text: "Close",
951
- close: !0
952
- },
953
- tertiaryActions: {
954
- text: "Templates",
955
- close: !0
956
- }
957
- }).onPrimary((g) => Array.isArray(g) ? u(g[0]) : null).onSecondary(() => u(void 0)).onTertiary(() => {
958
- p.push({ name: ae.TRANSFER_TEMPLATE }), u(void 0);
959
- }).onClose(() => u(void 0)), d;
960
- }
961
- function t() {
962
- e.open({
963
- title: s("inventory.ingredient.import.title"),
964
- contentComponent: gt,
965
- overlay: !0,
966
- closeButton: !0,
967
- primaryActions: {
968
- text: s("common.import"),
969
- close: !1
970
- },
971
- secondaryActions: {
972
- text: s("common.close"),
973
- close: !0
974
- },
975
- tertiaryActions: {
976
- text: s("inventory.ingredient.import.actions.downloadTemplate"),
977
- close: !1,
978
- variant: "plain"
979
- }
980
- }).onPrimary((d) => {
981
- if (!d) {
982
- r.open({
983
- title: s("inventory.ingredient.import.error.noData"),
984
- type: "error"
985
- });
986
- return;
987
- }
988
- if (!d.importCreateResult.length && !d.importUpdateResult.length) {
989
- r.open({
990
- title: s("inventory.ingredient.import.error.invalidContent"),
991
- message: s("inventory.ingredient.import.error.noImportData"),
992
- type: "error"
993
- });
994
- return;
995
- }
996
- if (d.importCreateResult.some((o) => o.errors.length) || d.importUpdateResult.some((o) => o.errors.length)) {
997
- r.open({
998
- title: s("inventory.ingredient.import.error.invalidContent"),
999
- message: s("inventory.ingredient.import.error.hasErrors"),
1000
- type: "error"
1001
- });
1002
- return;
1003
- }
1004
- e.close(), S(d);
1005
- }).onTertiary(Ye);
1006
- }
1007
- async function S(d) {
1008
- try {
1009
- const o = [
1010
- ...d.importCreateResult.map(
1011
- (g) => g.template
1012
- ),
1013
- ...d.importUpdateResult.map(
1014
- (g) => g.template
1015
- )
1016
- ], u = 100;
1017
- let x = 0;
1018
- const k = () => {
1019
- x += u, r.open({
1020
- title: s("inventory.ingredient.import.progress", [
1021
- Math.min(x, o.length),
1022
- o.length
1023
- ])
1024
- });
1025
- };
1026
- for (const g of o.chunk(100))
1027
- k(), await a.importTemplates(g);
1028
- r.open({
1029
- title: s("inventory.ingredient.import.success"),
1030
- type: "success"
1031
- });
1032
- } catch (o) {
1033
- r.open({
1034
- title: s("inventory.ingredient.import.error.failed"),
1035
- message: s("inventory.ingredient.import.error.systemMessage", [o == null ? void 0 : o.message]),
1036
- type: "error"
1037
- }), console.error("Error in importing skus", d, o);
1038
- } finally {
1039
- c.fetchTemplates();
1040
- }
1041
- }
1042
- function _() {
1043
- const d = We(c.templates);
1044
- r.open({
1045
- title: s("inventory.ingredient.export.success"),
1046
- message: s("inventory.ingredient.export.filename", [d]),
1047
- type: "success"
1048
- });
1049
- }
1050
- return {
1051
- createTemplate: m,
1052
- viewTemplate: y,
1053
- updateTemplate: h,
1054
- deleteTemplate: b,
1055
- getTemplateId: f,
1056
- importTemplates: t,
1057
- exportTemplates: _,
1058
- templateDialogProps: l,
1059
- templateDetailsProps: v
1060
- };
1061
- });
1062
- function ue(e) {
1063
- const { skuById: r } = L(), i = Z(e);
1064
- return i.purchaseOrder.items = e.purchaseOrder.items.filter((c) => r[c.sku._id]), i;
1065
- }
1066
- const $e = pe(
1067
- "transferTemplateTable",
1068
- function() {
1069
- const { t: r } = X(), { viewTemplate: i, updateTemplate: c, deleteTemplate: a } = xt(), n = R(!1), p = R(new Array()), s = be(), l = L();
1070
- async function m() {
1071
- p.value = [], n.value = !0;
1072
- try {
1073
- const [y] = await Promise.all([
1074
- s.readTemplates(),
1075
- l.readInventory()
1076
- ]).delayed(1e3);
1077
- p.value = y.map(ue);
1078
- } catch (y) {
1079
- console.log("Something went wrong when fetching templates:", y);
1080
- } finally {
1081
- n.value = !1;
1082
- }
1083
- }
1084
- async function h(y) {
1085
- if (!p.value.find((f) => f._id)) {
1086
- n.value = !0;
1087
- try {
1088
- p.value = [
1089
- await s.getTemplate(y).then(ue).delayed(1e3)
1090
- ];
1091
- } catch (f) {
1092
- console.log("Something went wrong when fetching templates:", f);
1093
- } finally {
1094
- n.value = !1;
1095
- }
1096
- }
1097
- }
1098
- function b(y, f) {
1099
- switch (f = Z(f), y) {
1100
- case A.Details:
1101
- return i(f);
1102
- case A.Edit:
1103
- return c(f);
1104
- case A.Delete:
1105
- return a(f, n, m);
1106
- }
1107
- }
1108
- return {
1109
- columnDefs: [
1110
- {
1111
- id: "_id",
1112
- accessorKey: "_id",
1113
- header: () => r("inventory.transfer.table.createdAt"),
1114
- cell(y) {
1115
- return De(`${y.getValue()}`);
1116
- },
1117
- enableSorting: !0
1118
- },
1119
- {
1120
- id: "name",
1121
- accessorKey: "name",
1122
- header: () => r("inventory.transfer.table.name"),
1123
- enableSorting: !0,
1124
- size: 200
1125
- },
1126
- {
1127
- id: "noOfItems",
1128
- accessorKey: "purchaseOrder.items.length",
1129
- header: () => r("inventory.transfer.table.noOfItems"),
1130
- enableSorting: !1,
1131
- meta: {
1132
- width: "10rem",
1133
- textAlign: "right"
1134
- },
1135
- cell(y) {
1136
- const f = Number(y.getValue()) || 0, t = y.row.original.purchaseOrder.items.some(xe);
1137
- return f === 0 || t ? Y("div", { class: "flex justify-end gap-4 items-center" }, [
1138
- Y(
1139
- ie.FmTooltip,
1140
- {},
1141
- {
1142
- content() {
1143
- return t ? "The template is invalid due to invalid unit on some of the items. Please update this template." : "The template is invalid due to deleted ingredients. Please update this template.";
1144
- },
1145
- default() {
1146
- return Y(ie.FmIcon, {
1147
- name: "error",
1148
- color: "system-error-300",
1149
- size: "sm"
1150
- });
1151
- }
1152
- }
1153
- ),
1154
- f
1155
- ]) : f;
1156
- }
1157
- },
1158
- {
1159
- id: "enabledLocations",
1160
- accessorKey: "purchaseOrder.locations.length",
1161
- header: () => "Enabled outlets",
1162
- cell(y) {
1163
- var t;
1164
- const f = (t = y.row.original.locations) == null ? void 0 : t.length;
1165
- return f ? `${f}` : "All";
1166
- },
1167
- enableSorting: !1,
1168
- meta: {
1169
- width: "10rem",
1170
- textAlign: "right"
1171
- }
1172
- },
1173
- {
1174
- id: "ref",
1175
- accessorKey: "purchaseOrder.ref",
1176
- header: () => r("inventory.transfer.table.reference"),
1177
- enableSorting: !1,
1178
- size: "auto"
1179
- },
1180
- {
1181
- id: "action",
1182
- cell(y) {
1183
- const f = y.row.original, t = [
1184
- W[A.Details],
1185
- W[A.Edit],
1186
- W[A.Delete]
1187
- ];
1188
- return Ce(t, (S) => b(S, f));
1189
- },
1190
- enableSorting: !1,
1191
- size: 40,
1192
- meta: {
1193
- cellClass: "",
1194
- headerClass: ""
1195
- }
1196
- }
1197
- ],
1198
- templates: p,
1199
- loading: n,
1200
- fetchTemplates: m,
1201
- loadTemplate: h
1202
- };
1203
- }
1204
- );
1205
- function Bt(e, r, i) {
1206
- const c = (i == null ? void 0 : i.abbrev) ?? r.abbrev;
1207
- return `${U(e, !1)} ${c}`;
1208
- }
1209
- export {
1210
- E as P,
1211
- be as a,
1212
- xt as b,
1213
- Bt as f,
1214
- xe as t,
1215
- $e as u
1216
- };