@feedmepos/mf-inventory-portal 1.2.46 → 1.2.47

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 (96) hide show
  1. package/dist/{App-DBd4DVaZ.js → App-JsgP9iMu.js} +3 -3
  2. package/dist/{ApprovalView-C-XcEiMZ.js → ApprovalView-Co6sACH5.js} +5 -5
  3. package/dist/{BindingsDialog-CXKDYmmR.js → BindingsDialog-B73QXq1j.js} +2 -2
  4. package/dist/{BindingsPicker-Cq1yHJhJ.js → BindingsPicker-DuMTRelf.js} +3 -3
  5. package/dist/{BindingsTable-BL8DhipQ.js → BindingsTable-CcYQN1_L.js} +3 -3
  6. package/dist/ClosingDraftView-D3INnwT_.js +2410 -0
  7. package/dist/{ClosingHistoryView-BC8ZP51z.js → ClosingHistoryView-CSjxazA8.js} +3 -3
  8. package/dist/{ClosingTemplateView-B4jnOrpc.js → ClosingTemplateView-Ct0GFJ7D.js} +14 -14
  9. package/dist/{DeliveryOrderPrintPreview-Bxy5xIrP.js → DeliveryOrderPrintPreview-BS50CpKI.js} +4 -4
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-D5DApGXT.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bi9iqGTu.js} +12 -12
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHS5LMuy.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CRUsPKK3.js} +2 -2
  12. package/dist/{FmMultiselectDialog-C6OzbsWu.js → FmMultiselectDialog-B_aNaPp3.js} +2 -2
  13. package/dist/{FmMultiselectDialog-C7DVf8cL.js → FmMultiselectDialog-CaUUBqDA.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BtN3UL40.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CQqGUFIx.js} +3 -3
  15. package/dist/{ImportView-BhmfI7Am.js → ImportView-KjHa3RPH.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BXSO5UKK.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BBaVY_DM.js} +1 -1
  17. package/dist/{IngredientGroupView-DfAt-7Fz.js → IngredientGroupView-DPM9zcrM.js} +5 -5
  18. package/dist/{IngredientsView-4MNLuMhd.js → IngredientsView-DJGeVNXg.js} +916 -910
  19. package/dist/{IntegrationView-CvgAJIaG.js → IntegrationView-C1-xqYQI.js} +12 -12
  20. package/dist/{InventoryBindingForm-CQB1X3d5.js → InventoryBindingForm-B57y7_jC.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Sebvr-gm.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CHTnMNKl.js} +4 -4
  22. package/dist/{InventoryBindingSummary-_-dkvb4N.js → InventoryBindingSummary-Df70IKSg.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BGsjKOls.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DWe54YRe.js} +1 -1
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-D9goSrss.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BgCCrM-_.js} +2 -2
  25. package/dist/{PublishView-BFdsGmRf.js → PublishView-C5YHhPwg.js} +3 -3
  26. package/dist/{PurchaseOrderPrintPreview-DpaV5GjO.js → PurchaseOrderPrintPreview-BjopVTxs.js} +10 -10
  27. package/dist/{ReceiveRequestView-DNimgIgR.js → ReceiveRequestView-huk0yTuo.js} +896 -889
  28. package/dist/{RecipeView-D8CH2rJC.js → RecipeView-B2jYchFP.js} +8 -8
  29. package/dist/StockView-BhttACCV.js +2497 -0
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Bb-yJBxo.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DvviBt_n.js} +1 -1
  31. package/dist/{SupplierView-Bl0JNI44.js → SupplierView-6Vxxq9GN.js} +11 -11
  32. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-C-VmXiM3.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-C_nItuSz.js} +2 -2
  33. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DqmlOtC4.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Den4pUf9.js} +1 -1
  34. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D-4LyU74.js → TransferDetails.vue_vue_type_script_setup_true_lang-CmI0k0v2.js} +99 -99
  35. package/dist/{TransferTemplateView-COJEXmF0.js → TransferTemplateView-_WTnebCR.js} +412 -412
  36. package/dist/{UnitView-ecUANF8x.js → UnitView-BeP9MpmK.js} +6 -6
  37. package/dist/{WarehouseView-DZ9OCali.js → WarehouseView-pdM7HFYr.js} +5 -5
  38. package/dist/{WastageTemplateView-DXu5bayJ.js → WastageTemplateView-a4twoJLB.js} +14 -14
  39. package/dist/api/inventory.d.ts +10 -10
  40. package/dist/api/stock.d.ts +1 -0
  41. package/dist/{app-aLZoWUfQ.js → app-D-WXtKYn.js} +4623 -5097
  42. package/dist/app.d.ts +176 -834
  43. package/dist/app.js +1 -1
  44. package/dist/{closing-template-D-cf9Vnu.js → closing-template-O7lUhol7.js} +1 -1
  45. package/dist/{date2-DluMG3-3.js → date2-DkEAKP8N.js} +1 -1
  46. package/dist/{dayjs.min-UuQWuDkU.js → dayjs.min-DF1VUh0Q.js} +13 -13
  47. package/dist/{decimal-B2f58cUQ.js → decimal-CL_qgPqL.js} +2 -2
  48. package/dist/{defineDeepModel-DUvW0g9M.js → defineDeepModel-xcAkDmDA.js} +1 -1
  49. package/dist/{duplicate-template-BiGYHuPK.js → duplicate-template-TY54cIdK.js} +1 -1
  50. package/dist/{feature-B-rekKRC.js → feature-Dw3PJCX9.js} +2 -2
  51. package/dist/{format-time-from-id-CMm14GBq.js → format-time-from-id-Ceptcl3U.js} +1 -1
  52. package/dist/{format-unit-display-DeHfXVX_.js → format-unit-display-GRZQIgFD.js} +10 -10
  53. package/dist/{import-export.helper-rXmKqRlR.js → import-export.helper-Bl-r_RxV.js} +5 -5
  54. package/dist/{index-DGs4MBmv.js → index-CEbidibW.js} +3 -3
  55. package/dist/{index-CYdIQDVa.js → index-D-_4dS91.js} +1 -1
  56. package/dist/{index-CEK6OlSE.js → index-Dgk8_4hY.js} +1 -1
  57. package/dist/{lodash-DO8ShgBV.js → lodash-efdnV3n2.js} +1 -1
  58. package/dist/{netsuite-NShFW2SJ.js → netsuite-D4yOOSrW.js} +3 -3
  59. package/dist/{purchase-order-template-COeJz9vK.js → purchase-order-template-Dvs3YVVH.js} +1 -1
  60. package/dist/{rules-C_U2Ahtv.js → rules-BsrasJ6a.js} +3 -3
  61. package/dist/{stock-B9KGLNAt.js → stock-BITU59fq.js} +3 -3
  62. package/dist/{stock-DdZuie8e.js → stock-D0WV9zWp.js} +7 -1
  63. package/dist/stores/inventory.d.ts +13 -13
  64. package/dist/stores/stock.d.ts +5 -5
  65. package/dist/stores/supplier.d.ts +24 -24
  66. package/dist/{supplier-BCfa74hz.js → supplier-DSUvpEyd.js} +2 -2
  67. package/dist/tsconfig.app.tsbuildinfo +1 -1
  68. package/dist/{use-ingredient-select-dialog-CoAP08vZ.js → use-ingredient-select-dialog-CNpU0tfI.js} +2 -2
  69. package/dist/{use-inventory-binding-dialog-BPXhlhVD.js → use-inventory-binding-dialog-D7s2C-xQ.js} +2 -2
  70. package/dist/{use-template-enabled-locations-2-CYfkmGP5.js → use-template-enabled-locations-2-bflR8fp7.js} +2 -2
  71. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +29 -0
  72. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +20 -20
  73. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +3 -3
  74. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +60 -60
  75. package/dist/views/ingredient-group/components/ingredient-group-rule-field/IngredientGroupRuleField.vue.d.ts +2 -2
  76. package/dist/views/ingredient-group/composables/use-ingredient-group-rule-item.d.ts +1 -1
  77. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +6 -6
  78. package/dist/views/integration/components/netsuite/business/AddVendorDialog.vue.d.ts +12 -12
  79. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +2 -2
  80. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +2 -2
  81. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +12 -12
  82. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +14 -14
  83. package/dist/views/stock/components/StockRecordCard.vue.d.ts +29 -6
  84. package/dist/views/supplier/components/SupplierForm.vue.d.ts +2 -2
  85. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +2 -2
  86. package/dist/views/supplier/composables/use-supplier-table.d.ts +1 -1
  87. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +2 -2
  88. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +4 -4
  89. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +12 -12
  90. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +12 -12
  91. package/dist/{vue-i18n-Cn8L1Fah.js → vue-i18n-j0rHGXSn.js} +301 -301
  92. package/dist/{xlsx-jqtV3ziP.js → xlsx-CgB84NXq.js} +398 -398
  93. package/dist/{xlsx.util-BBey-FqO.js → xlsx.util-DeZhqfVV.js} +1 -1
  94. package/package.json +1 -1
  95. package/dist/ClosingDraftView-nwQQl4U1.js +0 -2164
  96. package/dist/StockView-cXMeYZEU.js +0 -2407
@@ -1,2407 +0,0 @@
1
- import { defineComponent as ue, ref as O, computed as P, resolveComponent as U, openBlock as $, createBlock as z, withCtx as T, createElementVNode as e, normalizeClass as _e, toDisplayString as v, createVNode as y, createElementBlock as Y, Fragment as ne, renderList as ie, unref as a, h as ye, watch as xe, isRef as je, createCommentVNode as te, reactive as ot, mergeModels as qe, useModel as pt, onMounted as Le, createTextVNode as de, normalizeStyle as nt, Teleport as ft, normalizeProps as Te, mergeProps as He } from "vue";
2
- import { F as ze, u as vt, _ as yt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
3
- import { u as be, c as De, a as Be, F as Xe, G as _t, C as oe, v as kt, o as bt, A as gt, s as Q, h as Ee, i as ht, e as xt } from "./app-aLZoWUfQ.js";
4
- import { u as Me } from "./stock-B9KGLNAt.js";
5
- import { c as St, _ as Ft, F as Je } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-cfFHDIwQ.js";
6
- import { g as Se } from "./decimal-B2f58cUQ.js";
7
- import { d as pe } from "./dayjs.min-UuQWuDkU.js";
8
- import { e as wt, u as st, i as at, _ as Qe } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-D9goSrss.js";
9
- import { _ as Ne, S as Pe, g as lt, a as $t } from "./SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Bb-yJBxo.js";
10
- import { _ as At } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
11
- import { useI18n as ce, useCoreStore as Ge } from "@feedmepos/mf-common";
12
- import { useSnackbar as ge, useDialog as Ie, useProxiedModel as Ue, useBreakpoints as Vt } from "@feedmepos/ui-library";
13
- import { defineStore as Ct } from "pinia";
14
- import { g as Ye, a as ve, f as jt, t as Ae, h as Ve, A as Dt, M as Bt, d as ke, i as Mt, j as Ze, k as rt, l as Ke, R as It, e as we, m as Ut } from "./rules-C_U2Ahtv.js";
15
- import { u as he } from "./stock-DdZuie8e.js";
16
- import { u as Tt } from "./use-inventory-binding-dialog-BPXhlhVD.js";
17
- import { a as it } from "./FmMultiselectDialog-C6OzbsWu.js";
18
- import { _ as Ht } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BGsjKOls.js";
19
- import { a as Et, b as Pt, f as ut, t as Rt, c as Ot, p as Nt, n as Yt, d as Lt } from "./date2-DluMG3-3.js";
20
- import { i as zt, _ as Gt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DHS5LMuy.js";
21
- import { E as Kt } from "./empty-placeholder-wf6-BWE8.js";
22
- import { F as Re, u as Wt } from "./feature-B-rekKRC.js";
23
- import { u as qt } from "./netsuite-NShFW2SJ.js";
24
- import { N as Xt, H as Jt } from "./app-uBuHtW8m.js";
25
- var $e = /* @__PURE__ */ ((k) => (k.History = "History", k.Convert = "Convert", k.Adjust = "Adjust", k))($e || {});
26
- const Qt = [
27
- {
28
- translationKey: "inventory.stock.action.history",
29
- color: "text-neutral-700",
30
- value: "History"
31
- /* History */
32
- }
33
- ], Zt = [
34
- {
35
- translationKey: "inventory.stock.action.history",
36
- color: "text-neutral-700",
37
- value: "History"
38
- /* History */
39
- },
40
- {
41
- translationKey: "inventory.stock.action.convert",
42
- color: "text-neutral-700",
43
- value: "Convert"
44
- /* Convert */
45
- },
46
- {
47
- translationKey: "inventory.stock.action.adjust",
48
- color: "text-neutral-700",
49
- value: "Adjust"
50
- /* Adjust */
51
- }
52
- ];
53
- async function eo(k) {
54
- const d = `${(be().currentLocation.name || "").replace(
55
- / /g,
56
- "_"
57
- )}_${pe().format("DD_MM_YYYY_HHmm")}.xlsx`;
58
- await wt(
59
- [
60
- {
61
- name: "stock",
62
- data: k,
63
- columns: [
64
- {
65
- name: "Code",
66
- selector: "code"
67
- },
68
- {
69
- name: "Name",
70
- selector: "name"
71
- },
72
- {
73
- name: "Balance",
74
- selector: (n) => {
75
- const A = Ce(n, n.unit);
76
- return A.type === "unit" ? Se(n.balance, n.unit, null, !1) : Se(n.balance, n.unit, A.measurement, !1);
77
- }
78
- },
79
- {
80
- name: "Unit",
81
- selector: (n) => {
82
- var S;
83
- const A = Ce(n, n.unit);
84
- return A.type === "unit" ? n.unit.abbrev : ((S = n.unit.measurements.find((m) => m.id === A.measurement)) == null ? void 0 : S.abbrev) || "";
85
- }
86
- }
87
- ]
88
- }
89
- ],
90
- d
91
- );
92
- }
93
- function Ce(k, g) {
94
- const d = localStorage.getItem(`uom:${k._id}`);
95
- return d ? d === g._id ? {
96
- type: "unit"
97
- } : g.measurements.find((n) => n.id === d) ? {
98
- type: "measurement",
99
- measurement: d
100
- } : {
101
- type: "unit"
102
- } : k.trackingMeasurement && g.measurements.find((n) => n.id === k.trackingMeasurement) ? {
103
- type: "measurement",
104
- measurement: k.trackingMeasurement
105
- } : {
106
- type: "unit"
107
- };
108
- }
109
- const to = { class: "fm-typo-en-body-md-400 flex-grow" }, ct = /* @__PURE__ */ ue({
110
- __name: "UnitDisplayControl",
111
- props: {
112
- unit: {},
113
- sku: {},
114
- amount: {},
115
- defaultTrackingMeasurement: {}
116
- },
117
- setup(k) {
118
- function g(j) {
119
- return `uom:${j._id}`;
120
- }
121
- function d(j) {
122
- const w = g(n.sku);
123
- j ? localStorage.setItem(w, j) : localStorage.setItem(w, n.unit._id), A.value = Ce(n.sku, n.unit);
124
- }
125
- const n = k, A = O(Ce(n.sku, n.unit)), S = P(() => {
126
- const { measurements: j } = n.unit;
127
- return [
128
- {
129
- label: `${Se(n.amount, n.unit)}`,
130
- value: null
131
- },
132
- ...j.map(({ id: w }) => ({
133
- label: `${Se(n.amount, n.unit, w)}`,
134
- value: w
135
- }))
136
- ];
137
- });
138
- function m({ value: j }) {
139
- return a(A).type === "unit" ? j === null : j === a(A).measurement;
140
- }
141
- const i = P(
142
- () => {
143
- var j;
144
- return ((j = S.value.find((w) => m(w))) == null ? void 0 : j.label) ?? "";
145
- }
146
- ), F = O(!1);
147
- return (j, w) => {
148
- const u = U("FmIcon"), b = U("FmMenuItem"), C = U("FmMenu");
149
- return $(), z(C, {
150
- "stop-click-propagation": "",
151
- onMenuChanged: w[0] || (w[0] = (B) => F.value = B)
152
- }, {
153
- "menu-button": T(() => [
154
- e("button", {
155
- type: "button",
156
- class: _e([
157
- "w-full text-left flex items-center gap-8 cursor-pointer fm-corner-radius-sm px-8 py-4 border bg-white",
158
- F.value ? "border-fm-color-primary" : "border-fm-color-neutral-gray-100"
159
- ])
160
- }, [
161
- e("div", to, v(i.value), 1),
162
- y(u, {
163
- class: "text-fm-color-neutral-gray-400",
164
- name: "expand_more"
165
- })
166
- ], 2)
167
- ]),
168
- default: T(() => [
169
- ($(!0), Y(ne, null, ie(S.value, (B) => ($(), z(b, {
170
- key: B.value ?? 0,
171
- label: B.label,
172
- "model-value": m(B),
173
- onClick: (D) => d(B.value)
174
- }, null, 8, ["label", "model-value", "onClick"]))), 128))
175
- ]),
176
- _: 1
177
- });
178
- };
179
- }
180
- }), oo = { class: "whitespace-nowrap" }, no = /* @__PURE__ */ ue({
181
- __name: "StockHeaderPreview",
182
- setup(k) {
183
- const { t: g } = ce();
184
- return (d, n) => ($(), z(At, null, {
185
- default: T(() => [
186
- e("div", oo, v(a(g)("inventory.stock.prediction.daysRemaining")), 1)
187
- ]),
188
- _: 1
189
- }));
190
- }
191
- }), dt = Ct("stockActions", () => {
192
- const k = O(!1), g = be(), d = Me(), n = st(), A = ge(), S = Ie(), { t: m } = ce();
193
- async function i() {
194
- if (g._currentLocation) {
195
- k.value = !0;
196
- try {
197
- await d.readStockBalance(), await d.readProductBalance(), await n.readStockEstimateBalance();
198
- } catch {
199
- A.open({
200
- title: m("inventory.stock.error.title"),
201
- message: m("inventory.stock.error.message"),
202
- type: "error"
203
- });
204
- } finally {
205
- k.value = !1;
206
- }
207
- }
208
- }
209
- const F = O();
210
- async function j(D) {
211
- var x, _, V;
212
- if (!!!((_ = (x = D.convert) == null ? void 0 : x.inventoryBindings) != null && _.length)) {
213
- S.open({
214
- title: m("inventory.stock.error.convert.title"),
215
- message: m("inventory.stock.error.convert.message")
216
- });
217
- return;
218
- }
219
- const l = {
220
- maxCount: ((V = d.productBalance.find(({ id: H }) => H === D._id)) == null ? void 0 : V.count) || 0,
221
- sku: D,
222
- show: !0,
223
- "onUpdate:show"(H) {
224
- F.value.show = H;
225
- },
226
- onSubmitted() {
227
- i();
228
- }
229
- };
230
- F.value = l;
231
- }
232
- const w = O();
233
- async function u(D) {
234
- const s = {
235
- stock: D,
236
- show: !0,
237
- "onUpdate:show"(t) {
238
- w.value.show = t;
239
- },
240
- onSubmitted() {
241
- i();
242
- }
243
- };
244
- w.value = s;
245
- }
246
- const b = O();
247
- async function C(D) {
248
- const s = {
249
- sku: D,
250
- show: !0,
251
- "onUpdate:show"(t) {
252
- b.value.show = t;
253
- }
254
- };
255
- b.value = s;
256
- }
257
- function B(D, s) {
258
- const t = De(s);
259
- switch (D) {
260
- case $e.History:
261
- C(t);
262
- return;
263
- case $e.Convert:
264
- j(t);
265
- return;
266
- case $e.Adjust:
267
- u(t);
268
- return;
269
- }
270
- }
271
- return {
272
- fetchStockBalance: i,
273
- onActionMenu: B,
274
- stockHistoryProps: b,
275
- showSkuHistory: C,
276
- convertSkuDialogProps: F,
277
- adjustSkuDialogProps: w
278
- };
279
- });
280
- function so() {
281
- var S;
282
- const k = be(), g = dt(), d = Ge(), { t: n } = ce();
283
- return {
284
- columnDefs: [
285
- {
286
- accessorKey: "code",
287
- header: () => n("inventory.stock.code"),
288
- enableSorting: !0,
289
- size: 300
290
- },
291
- {
292
- accessorKey: "name",
293
- header: () => n("inventory.stock.product"),
294
- enableSorting: !0,
295
- size: "auto"
296
- },
297
- {
298
- id: "UOM",
299
- header: () => n("inventory.stock.balance"),
300
- cell(m) {
301
- const i = m.row.original, F = {
302
- unit: i.unit,
303
- sku: i,
304
- amount: i.balance,
305
- defaultTrackingMeasurement: i.trackingMeasurement ?? void 0
306
- };
307
- return ye(ct, F);
308
- },
309
- size: 180
310
- },
311
- ...(S = d.sessionUser.value) != null && S.role.isAdmin ? [
312
- {
313
- accessorKey: "isInactive",
314
- header: () => ye(ze, {}, () => `${n("inventory.ingredient.status.title")}`),
315
- cell(m) {
316
- const i = m.row.original.isInactive;
317
- return ye(
318
- "span",
319
- {
320
- class: [
321
- "inline-block px-3 py-1 rounded-full text-xs font-semibold",
322
- i ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
323
- ].join(" ")
324
- },
325
- n(i ? "inventory.ingredient.status.inactive" : "inventory.ingredient.status.active")
326
- );
327
- },
328
- enableSorting: !0
329
- }
330
- ] : [],
331
- {
332
- accessorKey: "day",
333
- id: "expireDate",
334
- header: () => ye(no),
335
- enableSorting: !0,
336
- sortUndefined: "last",
337
- cell(m) {
338
- var b, C;
339
- const i = m.row.original.day, F = (b = m.row.original.thresholds) == null ? void 0 : b.low, j = (C = m.row.original.thresholds) == null ? void 0 : C.mid;
340
- if (typeof i != "number" || typeof F != "number" || typeof j != "number")
341
- return ye(Ne, {
342
- days: i
343
- });
344
- const w = i <= F ? Pe.low : i <= j ? Pe.mid : Pe.high;
345
- return ye(Ne, {
346
- days: i,
347
- level: w
348
- });
349
- },
350
- size: 200
351
- },
352
- {
353
- id: "action",
354
- cell(m) {
355
- var i;
356
- return St(
357
- ((i = k._currentLocation) == null ? void 0 : i.type) === "restaurant" ? Qt : Zt,
358
- (F) => g.onActionMenu(F, m.row.original)
359
- );
360
- },
361
- enableSorting: !1,
362
- size: 40,
363
- meta: {
364
- cellClass: "",
365
- headerClass: ""
366
- }
367
- }
368
- ]
369
- };
370
- }
371
- const ao = {
372
- context: null,
373
- error: null,
374
- isRequired(k = "This field is required") {
375
- return `${this.context ?? ""}`.length === 0 && (this.error = k), this;
376
- },
377
- isString(k = "Must be a valid string") {
378
- return this.error ? this : (typeof this.context != "string" && (this.error ?? (this.error = k)), this);
379
- },
380
- toInt() {
381
- return this.error ? this : (this.context = +this.context, this);
382
- },
383
- isInteger(k = "Must be an integer") {
384
- return this.error ? this : (this.toInt(), isNaN(this.context) && (this.error = k), this);
385
- },
386
- min(k, g) {
387
- if (this.error) return this;
388
- try {
389
- typeof this.context == "number" ? +this.context < k && (this.error = g ?? `Must be at least ${k}`) : Object.prototype.hasOwnProperty.call(this.context, "length") ? +this.context.length < k && (this.error = g ?? `Must be at least ${k}`) : this.error = "Length cannot be determined";
390
- } catch {
391
- this.error = "Length cannot be determined";
392
- }
393
- return this;
394
- },
395
- max(k, g) {
396
- if (this.error) return this;
397
- try {
398
- typeof this.context == "number" ? +this.context > k && (this.error = g ?? `Must be at most ${k}`) : "length" in this.context ? +this.context.length > k && (this.error = g ?? `Must be at most ${k}`) : this.error = "Length cannot be determined";
399
- } catch {
400
- this.error = "Length cannot be determined";
401
- }
402
- return this;
403
- }
404
- };
405
- function et(k) {
406
- return { ...ao, context: k };
407
- }
408
- const lo = { class: "flex items-center" }, ro = { class: "fm-typo-en-title-md-800" }, io = { class: "flex flex-col gap-24 w-full" }, uo = { class: "flex flex-col gap-8" }, co = { class: "fm-typo-en-body-lg-600" }, mo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary flex-grow" }, po = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-error" }, fo = { class: "flex flex-col p-16 gap-8" }, vo = { class: "flex flex-col gap-4" }, yo = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border-b py-12 px-16" }, _o = { class: "grid grid-cols-[auto_100px_100px_48px] xs:grid-cols-[auto_80px_120px_48px] gap-8 px-8 items-center" }, ko = { class: "xs:col-span-3" }, bo = { class: "flex gap-8" }, go = /* @__PURE__ */ ue({
409
- __name: "ConvertSkuDialog",
410
- props: {
411
- sku: {},
412
- maxCount: {},
413
- show: { type: Boolean }
414
- },
415
- emits: ["update:show", "submitted"],
416
- setup(k, { expose: g, emit: d }) {
417
- const n = k, A = d, S = Tt(), m = Be(), i = he(), F = ge(), { t: j } = ce(), w = O(0), u = O(null), b = P(() => m.skus), C = P(
418
- () => {
419
- var p, o;
420
- return (((o = (p = n.sku) == null ? void 0 : p.convert) == null ? void 0 : o.inventoryBindings) ?? []).filter(
421
- (r) => r.type === Xe.enum.SKU
422
- );
423
- }
424
- ), B = P({
425
- get() {
426
- return !!u.value;
427
- },
428
- set(p) {
429
- p ? u.value = De(C.value) : (u.value = null, w.value = Math.min(w.value, n.maxCount ?? 0));
430
- }
431
- }), D = O(!1);
432
- xe([() => n.show], ([p]) => {
433
- p && (w.value = 0);
434
- });
435
- function s() {
436
- N(n.sku, Ae(w.value), u.value);
437
- }
438
- function t(p) {
439
- if (u.value)
440
- return !0;
441
- const o = et(p).isInteger().max(n.maxCount ?? 0).error ?? "";
442
- return o || !0;
443
- }
444
- function l(p) {
445
- var f;
446
- const o = (f = n.sku.convert) != null && f.measurement ? n.sku.unit.measurements.find((M) => {
447
- var I;
448
- return M.id === ((I = n.sku.convert) == null ? void 0 : I.measurement);
449
- }) ?? null : null, r = Ye(n.sku.unit, o), h = Mt(+p);
450
- return et(h).isInteger().max(r).error ? "Precision cannot be more than " + r : !0;
451
- }
452
- const x = P(
453
- () => {
454
- var p, o;
455
- return (p = n.sku.convert) != null && p.measurement ? (o = n.sku.unit.measurements.find((r) => {
456
- var h;
457
- return r.id === ((h = n.sku.convert) == null ? void 0 : h.measurement);
458
- })) == null ? void 0 : o.abbrev : n.sku.unit.abbrev;
459
- }
460
- ), _ = P(() => {
461
- var h, c;
462
- const o = _t({
463
- bindings: ((h = n.sku.convert) == null ? void 0 : h.inventoryBindings) ?? [],
464
- skus: m.skus,
465
- skuGroups: m.skuGroups,
466
- recipes: m.recipes
467
- }).inventoryBindings.filter((f) => "success" in f && f.success).map((f) => f).map((f) => f.binding);
468
- return (c = u.value ?? o) == null ? void 0 : c.map((f) => {
469
- var le, re, Z, ae, fe;
470
- const M = m.skus.find((me) => me._id === f.id), I = ((le = f.measurement) == null ? void 0 : le.abbrev) ?? ((re = M == null ? void 0 : M.unit) == null ? void 0 : re.abbrev), G = (Z = n.sku.convert) != null && Z.measurement ? n.sku.unit.measurements.find((me) => {
471
- var We;
472
- return me.id === ((We = n.sku.convert) == null ? void 0 : We.measurement);
473
- }) ?? null : null, se = Ye(n.sku.unit, G), E = l(`${w.value}`) === !0 ? ve(
474
- jt(
475
- f.amount,
476
- Ae(+w.value, se)
477
- ),
478
- !1
479
- ) : "0", W = (fe = (ae = u.value) == null ? void 0 : ae.find((me) => me.id === (M == null ? void 0 : M._id))) == null ? void 0 : fe.amount, q = W ? ve(W, !1) : null;
480
- return {
481
- sku: M,
482
- convertAmount: q ?? E,
483
- abbrev: I
484
- };
485
- });
486
- }), V = O();
487
- g({
488
- validateInputs: () => {
489
- var p, o;
490
- (o = (p = V.value) == null ? void 0 : p.validateInputs) == null || o.call(p);
491
- },
492
- resetInputsValidation: () => {
493
- var p, o;
494
- (o = (p = V.value) == null ? void 0 : p.resetInputsValidation) == null || o.call(p);
495
- },
496
- resetInputs: () => {
497
- var p, o;
498
- (o = (p = V.value) == null ? void 0 : p.resetInputs) == null || o.call(p);
499
- }
500
- });
501
- const H = Ue(n, "show");
502
- async function N(p, o, r) {
503
- D.value = !0;
504
- try {
505
- await i.convertSku({
506
- conversions: [
507
- {
508
- doc: p,
509
- amount: o,
510
- overrides: r == null ? void 0 : r.map((h) => ({
511
- ...h,
512
- amount: {
513
- ...h.amount,
514
- amount: -1 * Math.abs(h.amount.amount)
515
- // ensure truly negative
516
- }
517
- }))
518
- }
519
- ]
520
- }), A("update:show", !1), A("submitted");
521
- } catch (h) {
522
- F.open({
523
- title: "Something went wrong",
524
- message: `Cannot convert ${p.name}. Please try again.`,
525
- type: "error"
526
- }), console.error("error at converting stock amount", p, o, h);
527
- } finally {
528
- D.value = !1;
529
- }
530
- }
531
- function K(p, o, r) {
532
- const h = +o;
533
- let c = r;
534
- o.length > 0 && isFinite(h) ? c = r.map((f) => (f.id !== p || (f.amount = ke(h)), f)) : c = r.map((f) => (f.id !== p || (f.amount = { amount: 0, precision: 0 }), f)), u.value = c;
535
- }
536
- function R(p) {
537
- const o = b.value.find((r) => r._id === p);
538
- return o ? lt(o.unit, !0) : [];
539
- }
540
- function X(p, o) {
541
- const r = R(p), h = r.find((c) => c.value === o) ?? r.find((c) => c.value === null);
542
- return h ? {
543
- ...h,
544
- label: h.abbrev
545
- } : null;
546
- }
547
- function L(p, o, r) {
548
- let h;
549
- if (o === null)
550
- h = r.map((c) => (c.id !== p || (c.measurement = null), c)) ?? [];
551
- else {
552
- const c = b.value.find((f) => f._id === p);
553
- h = r.map((f) => {
554
- var M, I;
555
- return f.id !== p || (f.measurement = (I = (M = c == null ? void 0 : c.unit) == null ? void 0 : M.measurements) == null ? void 0 : I.find((G) => G.id === o)), f;
556
- }) ?? [];
557
- }
558
- u.value = h;
559
- }
560
- function ee(p, o) {
561
- const r = o.filter((h) => h.id !== p);
562
- u.value = r;
563
- }
564
- function J() {
565
- const p = (u.value ?? []).map((o) => ({
566
- ...o,
567
- type: Xe.enum.SKU
568
- }));
569
- S.promptIngredientsBinding(
570
- p,
571
- (o) => u.value = o,
572
- n.sku._id
573
- );
574
- }
575
- return xe(
576
- () => n.show,
577
- (p) => {
578
- p || (u.value = null, w.value = 0);
579
- }
580
- ), (p, o) => {
581
- const r = U("FmTextField"), h = U("FmForm"), c = U("FmCard"), f = U("FmSwitch"), M = U("FmFormGroup"), I = U("FmSelect"), G = U("FmButton"), se = U("FmSideSheet");
582
- return $(), z(se, {
583
- "dismiss-away": "",
584
- modelValue: a(H),
585
- "onUpdate:modelValue": o[3] || (o[3] = (E) => je(H) ? H.value = E : null),
586
- "max-width": 500
587
- }, {
588
- "side-sheet-header": T(() => [
589
- e("div", lo, [
590
- e("div", ro, v(a(j)("inventory.stock.convert.title", { name: p.sku.name })), 1)
591
- ])
592
- ]),
593
- default: T(() => [
594
- e("div", io, [
595
- y(h, {
596
- ref_key: "formRef",
597
- ref: V,
598
- onValidationSuccess: s
599
- }, {
600
- default: T(() => [
601
- y(r, {
602
- disabled: D.value,
603
- "model-value": w.value,
604
- "onUpdate:modelValue": o[0] || (o[0] = (E) => w.value = E),
605
- label: a(j)("inventory.stock.convert.amount"),
606
- rules: [t, l, a(Ve)(0)],
607
- "append-text": x.value,
608
- "helper-text": u.value ? void 0 : `Max ${p.maxCount} ${x.value}`
609
- }, null, 8, ["disabled", "model-value", "label", "rules", "append-text", "helper-text"])
610
- ]),
611
- _: 1
612
- }, 512),
613
- y(c, {
614
- variant: "outlined",
615
- class: "p-16"
616
- }, {
617
- default: T(() => [
618
- e("div", uo, [
619
- e("div", co, v(a(j)("inventory.stock.convert.deductionSummary")), 1),
620
- ($(!0), Y(ne, null, ie(_.value, (E) => {
621
- var W, q;
622
- return $(), Y("div", {
623
- key: (W = E.sku) == null ? void 0 : W._id,
624
- class: "flex items-center"
625
- }, [
626
- e("div", mo, v((q = E.sku) == null ? void 0 : q.name), 1),
627
- e("div", po, " -" + v(E.convertAmount) + " " + v(E.abbrev), 1)
628
- ]);
629
- }), 128))
630
- ])
631
- ]),
632
- _: 1
633
- }),
634
- y(c, { variant: "outlined" }, {
635
- default: T(() => [
636
- e("div", fo, [
637
- y(f, {
638
- value: "",
639
- modelValue: B.value,
640
- "onUpdate:modelValue": o[1] || (o[1] = (E) => B.value = E),
641
- label: a(j)("inventory.stock.convert.overrideDeduction"),
642
- "label-placement": "right"
643
- }, null, 8, ["modelValue", "label"]),
644
- B.value ? ($(), Y(ne, { key: 0 }, [
645
- y(M, {
646
- modelValue: u.value,
647
- rules: [a(Dt)(1, "Must have at least one ingredient binding")]
648
- }, null, 8, ["modelValue", "rules"]),
649
- e("div", vo, [
650
- e("div", yo, v(a(j)("inventory.stock.convert.ingredients")), 1),
651
- ($(!0), Y(ne, null, ie(u.value, (E) => ($(), z(M, {
652
- key: E.id,
653
- disabled: D.value,
654
- modelValue: +a(ve)(E.amount ?? { amount: 1, precision: 0 }),
655
- rules: [
656
- a(Bt)(
657
- b.value.find((W) => W._id === E.id).unit,
658
- E.measurement
659
- ),
660
- a(Ve)(0)
661
- ]
662
- }, {
663
- default: T(({ invalid: W }) => {
664
- var q, le, re;
665
- return [
666
- e("div", _o, [
667
- e("div", ko, v((q = b.value.find((Z) => Z._id === E.id)) == null ? void 0 : q.name), 1),
668
- y(r, {
669
- class: "xs:col-span-2",
670
- disabled: D.value,
671
- modelValue: +a(ve)(
672
- E.amount ?? { amount: 1, precision: 0 }
673
- ),
674
- "onUpdate:modelValue": (Z) => K(E.id, Z, u.value ?? []),
675
- invalid: W
676
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"]),
677
- y(I, {
678
- disabled: D.value,
679
- class: "translate-y-[2px]",
680
- items: R(E.id),
681
- "model-value": (re = X(E.id, (le = E.measurement) == null ? void 0 : le.id)) == null ? void 0 : re.value,
682
- "onUpdate:modelValue": (Z) => L(E.id, Z, u.value ?? []),
683
- invalid: W
684
- }, {
685
- "helper-text": T(() => o[4] || (o[4] = [])),
686
- _: 2
687
- }, 1032, ["disabled", "items", "model-value", "onUpdate:modelValue", "invalid"]),
688
- y(G, {
689
- disabled: D.value,
690
- type: "button",
691
- variant: "tertiary",
692
- icon: "delete",
693
- onClick: (Z) => ee(E.id, u.value ?? [])
694
- }, null, 8, ["disabled", "onClick"])
695
- ])
696
- ];
697
- }),
698
- _: 2
699
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
700
- ]),
701
- e("div", null, [
702
- y(G, {
703
- icon: "link",
704
- label: a(j)("inventory.stock.convert.linkIngredient"),
705
- variant: "plain",
706
- onClick: J
707
- }, null, 8, ["label"])
708
- ])
709
- ], 64)) : te("", !0)
710
- ])
711
- ]),
712
- _: 1
713
- })
714
- ])
715
- ]),
716
- "side-sheet-footer": T(() => [
717
- e("div", bo, [
718
- y(G, {
719
- loading: D.value,
720
- label: a(j)("inventory.stock.convert.convertButton"),
721
- onClick: o[2] || (o[2] = (E) => {
722
- var W, q;
723
- return (q = (W = V.value) == null ? void 0 : W.validateInputs) == null ? void 0 : q.call(W);
724
- })
725
- }, null, 8, ["loading", "label"])
726
- ])
727
- ]),
728
- _: 1
729
- }, 8, ["modelValue"]);
730
- };
731
- }
732
- });
733
- function Fe(k, g) {
734
- const d = Ae(k, g);
735
- return { ...d, amount: -d.amount };
736
- }
737
- function tt(k, g) {
738
- return Ae(Math.abs(k), g);
739
- }
740
- const Oe = {
741
- [oe.enum.DAMAGE]: {
742
- label: "Damage",
743
- toAdjustmentAmount: Fe
744
- },
745
- [oe.enum.WASTAGE]: {
746
- label: "Wastage",
747
- toAdjustmentAmount: Fe
748
- },
749
- [oe.enum.THEFT]: {
750
- label: "Theft",
751
- toAdjustmentAmount: Fe
752
- },
753
- [oe.enum.LOSE]: {
754
- label: "Lose",
755
- toAdjustmentAmount: Fe
756
- },
757
- [oe.enum.EXTRA]: {
758
- label: "Extra",
759
- toAdjustmentAmount: tt
760
- },
761
- [oe.enum.PURCHASE]: {
762
- label: "Purchase",
763
- toAdjustmentAmount: tt
764
- }
765
- }, ho = { class: "col-span-2 flex" }, xo = { class: "flex-1" }, So = { class: "fm-typo-en-body-lg-600" }, Fo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wo = { class: "col-span-2 flex flex-col gap-4" }, $o = { class: "flex gap-4 text-fm-color-typo-primary fm-typo-en-body-lg-600" }, mt = /* @__PURE__ */ ue({
766
- __name: "AdjustedItemForm",
767
- props: {
768
- modelValue: {},
769
- disabled: { type: Boolean }
770
- },
771
- emits: ["update:modelValue", "click:delete"],
772
- setup(k, { emit: g }) {
773
- const d = k, n = g, { t: A } = ce(), S = Me(), m = P(
774
- () => Object.keys(Oe).map((t) => ({
775
- label: kt(t),
776
- value: t
777
- }))
778
- ), i = P(() => lt(d.modelValue.doc.unit, !0)), F = P({
779
- get() {
780
- return d.modelValue.type ?? oe.enum.PURCHASE;
781
- },
782
- set(t) {
783
- const l = {
784
- ...d.modelValue
785
- };
786
- l.type = t;
787
- const x = Ze(d.modelValue.amount);
788
- l.amount = Oe[l.type].toAdjustmentAmount(
789
- +ve(x),
790
- x.precision
791
- ), n("update:modelValue", l);
792
- }
793
- }), j = P({
794
- get() {
795
- const t = Ze(d.modelValue.amount);
796
- return +ve(t);
797
- },
798
- set(t) {
799
- const l = {
800
- ...d.modelValue
801
- }, x = ke(t);
802
- l.amount = Oe[F.value].toAdjustmentAmount(
803
- t,
804
- x.precision
805
- ), n("update:modelValue", l);
806
- }
807
- }), w = P({
808
- get() {
809
- var t;
810
- return ((t = d.modelValue.measurement) == null ? void 0 : t.id) ?? null;
811
- },
812
- set(t) {
813
- var x, _;
814
- const l = {
815
- ...d.modelValue
816
- };
817
- l.measurement = ((_ = (x = d.modelValue.doc.unit) == null ? void 0 : x.measurements) == null ? void 0 : _.find((V) => V.id === t)) ?? null, n("update:modelValue", l);
818
- }
819
- }), u = P({
820
- get() {
821
- return d.modelValue.remark ?? "";
822
- },
823
- set(t) {
824
- const l = {
825
- ...d.modelValue
826
- };
827
- l.remark = t, n("update:modelValue", l);
828
- }
829
- }), b = P(() => {
830
- var l;
831
- const t = (l = S.stockBalance.skus) == null ? void 0 : l.find((x) => x.id === d.modelValue.doc._id);
832
- return (t == null ? void 0 : t.balance) ?? { amount: 0, precision: 0 };
833
- }), C = P(() => {
834
- const t = d.modelValue.amount, l = d.modelValue.measurement;
835
- return l ? rt(t, l.conversion) : t;
836
- }), B = P(
837
- () => Ke(b.value, C.value)
838
- ), D = P(
839
- () => Se(B.value, d.modelValue.doc.unit)
840
- ), s = P(() => C.value.amount < 0);
841
- return (t, l) => {
842
- const x = U("FmButton"), _ = U("FmSelect"), V = U("FmTextarea"), H = U("FmCard");
843
- return $(), z(H, {
844
- variant: "outlined",
845
- class: "grid grid-cols-2 gap-8 p-16"
846
- }, {
847
- default: T(() => [
848
- e("div", ho, [
849
- e("div", xo, [
850
- e("div", So, v(t.modelValue.doc.name), 1),
851
- e("div", Fo, v(t.modelValue.doc.code), 1)
852
- ]),
853
- y(x, {
854
- variant: "tertiary",
855
- "prepend-icon": "delete",
856
- onClick: l[0] || (l[0] = (N) => n("click:delete"))
857
- })
858
- ]),
859
- y(_, {
860
- disabled: t.disabled,
861
- class: "col-span-2",
862
- label: "Type",
863
- items: m.value,
864
- modelValue: F.value,
865
- "onUpdate:modelValue": l[1] || (l[1] = (N) => F.value = N),
866
- rules: [a(It)()],
867
- "label-mark": "required"
868
- }, null, 8, ["disabled", "items", "modelValue", "rules"]),
869
- y(Ht, {
870
- disabled: t.disabled,
871
- label: "Amount",
872
- step: +a(ve)({
873
- amount: 1,
874
- precision: a(Ye)(t.modelValue.doc.unit, t.modelValue.measurement)
875
- }),
876
- modelValue: j.value,
877
- "onUpdate:modelValue": l[2] || (l[2] = (N) => j.value = N),
878
- rules: [a(Ve)(0)]
879
- }, null, 8, ["disabled", "step", "modelValue", "rules"]),
880
- y(_, {
881
- disabled: t.disabled,
882
- label: "Unit",
883
- items: i.value,
884
- modelValue: w.value,
885
- "onUpdate:modelValue": l[3] || (l[3] = (N) => w.value = N)
886
- }, null, 8, ["disabled", "items", "modelValue"]),
887
- y(V, {
888
- class: "col-span-2",
889
- disabled: t.disabled,
890
- label: "Remark",
891
- modelValue: u.value,
892
- "onUpdate:modelValue": l[4] || (l[4] = (N) => u.value = N),
893
- "label-mark": "optional"
894
- }, null, 8, ["disabled", "modelValue"]),
895
- e("div", wo, [
896
- e("div", $o, v(a(A)("inventory.stock.stock_adjustment.stockAfter")), 1),
897
- e("div", {
898
- class: _e(["fm-typo-en-body-lg-600", s.value ? "text-red-700" : "text-green-700"])
899
- }, v(D.value), 3)
900
- ])
901
- ]),
902
- _: 1
903
- });
904
- };
905
- }
906
- }), Ao = { class: "flex items-center" }, Vo = { class: "fm-typo-en-title-md-800" }, Co = { class: "flex items-center" }, jo = { class: "fm-typo-en-title-sm-800 flex-1" }, Do = { class: "flex gap-8" }, Bo = /* @__PURE__ */ ue({
907
- __name: "AdjustSkuDialog",
908
- props: {
909
- stock: {},
910
- show: { type: Boolean }
911
- },
912
- emits: ["update:show", "submitted"],
913
- setup(k, { expose: g, emit: d }) {
914
- const n = k, A = d, S = Be(), m = Ie(), i = he(), F = ge(), j = O(!1), { t: w } = ce();
915
- function u() {
916
- D(De(B));
917
- }
918
- const b = O();
919
- g({
920
- validateInputs: () => {
921
- var l, x;
922
- (x = (l = b.value) == null ? void 0 : l.validateInputs) == null || x.call(l);
923
- },
924
- resetInputsValidation: () => {
925
- var l, x;
926
- (x = (l = b.value) == null ? void 0 : l.resetInputsValidation) == null || x.call(l);
927
- },
928
- resetInputs: () => {
929
- var l, x;
930
- (x = (l = b.value) == null ? void 0 : l.resetInputs) == null || x.call(l);
931
- }
932
- });
933
- const C = Ue(n, "show"), B = ot({
934
- remark: "",
935
- adjustments: [
936
- {
937
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
938
- type: oe.enum.PURCHASE,
939
- doc: n.stock,
940
- measurement: null,
941
- remark: "",
942
- amount: ke(1)
943
- }
944
- ]
945
- });
946
- xe([() => n.show], ([l]) => {
947
- l && (B.remark = "", B.adjustments = [
948
- {
949
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
950
- type: oe.enum.PURCHASE,
951
- doc: n.stock,
952
- measurement: null,
953
- remark: "",
954
- amount: ke(1)
955
- }
956
- ]);
957
- });
958
- async function D(l) {
959
- j.value = !0;
960
- try {
961
- await i.adjustSku({
962
- remark: l.remark,
963
- adjustments: l.adjustments.map(({ doc: x, remark: _, type: V, amount: H, measurement: N }) => ({
964
- id: x._id,
965
- amount: H,
966
- measurement: N,
967
- remark: _,
968
- doc: x,
969
- type: V
970
- }))
971
- }), A("update:show", !1), A("submitted");
972
- } catch (x) {
973
- F.open({
974
- title: w("inventory.stock.adjust.error.title"),
975
- message: w("inventory.stock.adjust.error.message"),
976
- type: "error"
977
- }), console.log("error on adjust ingredients", l, x);
978
- } finally {
979
- j.value = !1;
980
- }
981
- }
982
- function s() {
983
- const l = S.skus.map((_) => ({
984
- label: _.name,
985
- sublabel: _.code,
986
- value: _._id
987
- })), x = l.filter((_) => B.adjustments.find((V) => V.doc._id === _.value)).map((_) => _.value);
988
- m.open({
989
- title: "Select ingredients",
990
- contentComponent: it,
991
- contentComponentProps: {
992
- items: l,
993
- modelValue: x
994
- },
995
- overlay: !0,
996
- closeButton: !0,
997
- dismissAway: !0,
998
- primaryActions: {
999
- text: "Confirm",
1000
- close: !0
1001
- },
1002
- secondaryActions: {
1003
- text: "Close",
1004
- close: !0,
1005
- variant: "tertiary"
1006
- }
1007
- }).onPrimary((_) => {
1008
- B.adjustments = _.map(
1009
- (V) => B.adjustments.find((H) => H.doc._id === V) ?? {
1010
- id: `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
1011
- type: oe.enum.PURCHASE,
1012
- doc: S.skus.find((H) => H._id === V),
1013
- measurement: null,
1014
- remark: "",
1015
- amount: ke(1)
1016
- }
1017
- );
1018
- });
1019
- }
1020
- function t(l) {
1021
- B.adjustments.splice(l, 1);
1022
- }
1023
- return (l, x) => {
1024
- const _ = U("FmTextarea"), V = U("FmButton"), H = U("FmForm"), N = U("FmSideSheet");
1025
- return $(), z(N, {
1026
- modelValue: a(C),
1027
- "onUpdate:modelValue": x[2] || (x[2] = (K) => je(C) ? C.value = K : null),
1028
- "dismiss-away": "",
1029
- "max-width": 500
1030
- }, {
1031
- "side-sheet-header": T(() => [
1032
- e("div", Ao, [
1033
- e("div", Vo, v(a(w)("inventory.stock.adjust.title")), 1)
1034
- ])
1035
- ]),
1036
- default: T(() => [
1037
- y(H, {
1038
- class: "w-full flex flex-col gap-12",
1039
- ref_key: "formRef",
1040
- ref: b,
1041
- onValidationSuccess: u
1042
- }, {
1043
- default: T(() => [
1044
- y(_, {
1045
- label: a(w)("inventory.stock.adjust.remark"),
1046
- modelValue: B.remark,
1047
- "onUpdate:modelValue": x[0] || (x[0] = (K) => B.remark = K)
1048
- }, null, 8, ["label", "modelValue"]),
1049
- e("div", Co, [
1050
- e("div", jo, v(a(w)("inventory.stock.adjust.adjustedItems")), 1),
1051
- y(V, {
1052
- "prepend-icon": "add",
1053
- variant: "tertiary",
1054
- size: "md",
1055
- onClick: s
1056
- })
1057
- ]),
1058
- ($(!0), Y(ne, null, ie(B.adjustments, (K, R) => ($(), z(mt, {
1059
- key: K.id,
1060
- modelValue: B.adjustments[R],
1061
- "onUpdate:modelValue": (X) => B.adjustments[R] = X,
1062
- "onClick:delete": (X) => t(R)
1063
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
1064
- ]),
1065
- _: 1
1066
- }, 512)
1067
- ]),
1068
- "side-sheet-footer": T(() => [
1069
- e("div", Do, [
1070
- y(V, {
1071
- label: a(w)("inventory.stock.adjust.adjustButton"),
1072
- loading: j.value,
1073
- onClick: x[1] || (x[1] = (K) => {
1074
- var R, X;
1075
- return (X = (R = b.value) == null ? void 0 : R.validateInputs) == null ? void 0 : X.call(R);
1076
- })
1077
- }, null, 8, ["label", "loading"])
1078
- ])
1079
- ]),
1080
- _: 1
1081
- }, 8, ["modelValue"]);
1082
- };
1083
- }
1084
- }), Mo = { class: "flex items-center w-full gap-8" }, Io = { class: "fm-typo-en-title-md-800 flex-1" }, Uo = { class: "flex flex-col gap-16" }, To = { class: "flex flex-col gap-4" }, Ho = { class: "fm-typo-en-body-md-600" }, Eo = { class: "flex gap-8 items-start" }, Po = { class: "flex-1 min-w-0" }, Ro = { class: "flex-1 min-w-0" }, Oo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, No = { class: "flex items-center" }, Yo = { class: "fm-typo-en-title-sm-800 flex-1" }, Lo = { class: "flex gap-8" }, zo = /* @__PURE__ */ ue({
1085
- __name: "StockAdjustmentSideSheet",
1086
- props: {
1087
- show: { type: Boolean }
1088
- },
1089
- emits: ["update:show", "submitted"],
1090
- setup(k, { emit: g }) {
1091
- const d = k, n = g, { t: A } = ce(), S = Be(), m = he(), i = Ie(), F = ge(), j = Ue(d, "show"), w = O(!1), u = ot({
1092
- remark: "",
1093
- effectiveAt: /* @__PURE__ */ new Date(),
1094
- adjustments: []
1095
- }), b = O(pe().format("YYYY-MM-DD")), C = O(pe().format("HH:mm"));
1096
- xe([b, C], () => {
1097
- if (b.value && C.value) {
1098
- const _ = pe(`${b.value} ${C.value}`, "YYYY-MM-DD HH:mm");
1099
- if (_.isValid()) {
1100
- const V = pe();
1101
- _.isAfter(V) ? u.effectiveAt = V.toDate() : u.effectiveAt = _.toDate();
1102
- }
1103
- }
1104
- });
1105
- function B() {
1106
- u.remark = "", u.effectiveAt = /* @__PURE__ */ new Date(), u.adjustments = [], b.value = pe(u.effectiveAt).format("YYYY-MM-DD"), C.value = pe(u.effectiveAt).format("HH:mm");
1107
- }
1108
- function D() {
1109
- B();
1110
- }
1111
- const s = P(() => {
1112
- const _ = {};
1113
- return S.skus.forEach((V) => {
1114
- _[V._id] = V;
1115
- }), _;
1116
- });
1117
- function t() {
1118
- const _ = S.skus.map((H) => ({
1119
- label: H.name,
1120
- sublabel: H.code,
1121
- value: H._id
1122
- })), V = u.adjustments.map((H) => H.doc._id);
1123
- i.open({
1124
- title: A("inventory.stock.adjust.selectIngredients"),
1125
- contentComponent: it,
1126
- contentComponentProps: {
1127
- items: _,
1128
- modelValue: V,
1129
- virtualScroll: !0
1130
- },
1131
- overlay: !0,
1132
- closeButton: !0,
1133
- dismissAway: !0,
1134
- primaryActions: {
1135
- text: A("common.confirm"),
1136
- close: !0
1137
- },
1138
- secondaryActions: {
1139
- text: A("common.close"),
1140
- close: !0,
1141
- variant: "tertiary"
1142
- }
1143
- }).onPrimary((H) => {
1144
- u.adjustments = H.map(
1145
- (N) => u.adjustments.find((K) => K.doc._id === N) ?? {
1146
- id: "",
1147
- type: oe.enum.PURCHASE,
1148
- doc: s.value[N],
1149
- measurement: null,
1150
- remark: "",
1151
- amount: ke(1)
1152
- }
1153
- );
1154
- });
1155
- }
1156
- function l(_) {
1157
- u.adjustments.splice(_, 1);
1158
- }
1159
- async function x() {
1160
- if (u.adjustments.length === 0) {
1161
- F.open({
1162
- title: A("inventory.stock.error.title"),
1163
- message: A("inventory.stock.stock_adjustment.noAdjustments"),
1164
- type: "warning"
1165
- });
1166
- return;
1167
- }
1168
- w.value = !0;
1169
- try {
1170
- const _ = u.adjustments.map(
1171
- ({ doc: H, remark: N, type: K, amount: R, measurement: X }) => ({
1172
- id: H._id,
1173
- amount: R,
1174
- measurement: X,
1175
- remark: N,
1176
- doc: H,
1177
- type: K
1178
- })
1179
- ), V = {
1180
- remark: u.remark,
1181
- adjustments: _,
1182
- effectiveAt: u.effectiveAt.toISOString()
1183
- };
1184
- await m.adjustSku(De(V)), n("submitted"), n("update:show", !1);
1185
- } catch (_) {
1186
- F.open({
1187
- title: A("inventory.stock.adjust.error.title"),
1188
- message: A("inventory.stock.adjust.error.message"),
1189
- type: "error"
1190
- }), console.error("error on stock adjustment", _);
1191
- } finally {
1192
- w.value = !1;
1193
- }
1194
- }
1195
- return (_, V) => {
1196
- const H = U("FmTextarea"), N = U("FmDatePicker"), K = U("FmTimePicker"), R = U("FmButton"), X = U("FmSideSheet");
1197
- return $(), z(X, {
1198
- modelValue: a(j),
1199
- "onUpdate:modelValue": V[4] || (V[4] = (L) => je(j) ? j.value = L : null),
1200
- "dismiss-away": "",
1201
- "max-width": 560,
1202
- onAfterEnter: D
1203
- }, {
1204
- "side-sheet-header": T(() => [
1205
- e("div", Mo, [
1206
- e("div", Io, v(a(A)("inventory.stock.stock_adjustment.title")), 1)
1207
- ])
1208
- ]),
1209
- default: T(() => [
1210
- e("div", Uo, [
1211
- y(H, {
1212
- label: a(A)("inventory.stock.adjust.remark"),
1213
- modelValue: u.remark,
1214
- "onUpdate:modelValue": V[0] || (V[0] = (L) => u.remark = L),
1215
- "label-mark": "optional"
1216
- }, null, 8, ["label", "modelValue"]),
1217
- e("div", To, [
1218
- e("label", Ho, v(a(A)("inventory.stock.stock_adjustment.effectiveAt")), 1),
1219
- e("div", Eo, [
1220
- e("div", Po, [
1221
- y(N, {
1222
- class: "w-full",
1223
- modelValue: b.value,
1224
- "onUpdate:modelValue": V[1] || (V[1] = (L) => b.value = L),
1225
- clearable: !1,
1226
- max: a(pe)().format("YYYY-MM-DD")
1227
- }, null, 8, ["modelValue", "max"])
1228
- ]),
1229
- e("div", Ro, [
1230
- y(K, {
1231
- class: "w-full",
1232
- modelValue: C.value,
1233
- "onUpdate:modelValue": V[2] || (V[2] = (L) => C.value = L),
1234
- format: "HH:mm"
1235
- }, null, 8, ["modelValue"])
1236
- ])
1237
- ]),
1238
- e("div", Oo, v(a(A)("inventory.stock.stock_adjustment.immediateHint")), 1)
1239
- ]),
1240
- e("div", No, [
1241
- e("div", Yo, v(a(A)("inventory.stock.adjust.adjustedItems")), 1),
1242
- y(R, {
1243
- "prepend-icon": "add",
1244
- variant: "tertiary",
1245
- size: "md",
1246
- onClick: t
1247
- })
1248
- ]),
1249
- ($(!0), Y(ne, null, ie(u.adjustments, (L, ee) => ($(), z(mt, {
1250
- key: L.id,
1251
- modelValue: u.adjustments[ee],
1252
- "onUpdate:modelValue": (J) => u.adjustments[ee] = J,
1253
- "onClick:delete": (J) => l(ee)
1254
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onClick:delete"]))), 128))
1255
- ])
1256
- ]),
1257
- "side-sheet-footer": T(() => [
1258
- e("div", Lo, [
1259
- y(R, {
1260
- label: a(A)("common.confirm"),
1261
- loading: w.value,
1262
- onClick: x
1263
- }, null, 8, ["label", "loading"]),
1264
- y(R, {
1265
- label: a(A)("common.close"),
1266
- variant: "tertiary",
1267
- onClick: V[3] || (V[3] = (L) => n("update:show", !1))
1268
- }, null, 8, ["label"])
1269
- ])
1270
- ]),
1271
- _: 1
1272
- }, 8, ["modelValue"]);
1273
- };
1274
- }
1275
- }), Go = bt((k, g) => ({
1276
- // TODO: remove once latest inventory backend has been push
1277
- async findBillsByBusinessId(d, n, A) {
1278
- const S = `${k.businessesBackendUrl}/${d}/reports/find-many`, m = {
1279
- // type: TYPE.bill,
1280
- type: "bill",
1281
- restaurantIds: n,
1282
- ids: A
1283
- };
1284
- return await g.post(S, m);
1285
- },
1286
- async findBillsById(d) {
1287
- const A = be().currentLocationDBName, S = `${k.inventoryBackendUrl}/${A}/bill/search`, m = {
1288
- ids: d
1289
- };
1290
- return await g.post(S, m);
1291
- }
1292
- })), Ko = {
1293
- key: 0,
1294
- class: "flex justify-center items-center h-32"
1295
- }, Wo = { class: "mb-3" }, qo = { class: "flex flex-col gap-8" }, Xo = { class: "flex flex-col text-fm-color-typo-primary mb-3 text-center" }, Jo = { class: "text-fm-color-neutral-gray-400 fm-typo-en-body-sm-600" }, Qo = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, Zo = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, en = { class: "flex flex-col gap-4 text-fm-color-typo-primary mb-3" }, tn = { class: "flex flex-col w-full px-2" }, on = { class: "flex gap-2" }, nn = /* @__PURE__ */ ue({
1296
- __name: "AmendAdjustmentForm",
1297
- props: /* @__PURE__ */ qe({
1298
- adjustmentId: {}
1299
- }, {
1300
- modelValue: {},
1301
- modelModifiers: {}
1302
- }),
1303
- emits: /* @__PURE__ */ qe(["refreshHistory"], ["update:modelValue"]),
1304
- setup(k, { emit: g }) {
1305
- const d = k, n = g, A = he(), S = pt(k, "modelValue"), m = O(!1), i = O(!1), F = O(!1), j = O({
1306
- _id: `inventoryAdjustment_${(/* @__PURE__ */ new Date()).toISOString()}_XXXXX`,
1307
- skus: []
1308
- }), w = O();
1309
- Le(async () => {
1310
- m.value = !0;
1311
- const s = await A.readSingleAdjustment(d.adjustmentId);
1312
- if (!s) throw new Error("Adjustment not found");
1313
- j.value = s, m.value = !1;
1314
- });
1315
- async function u() {
1316
- var t, l;
1317
- if ((l = (t = w == null ? void 0 : w.value) == null ? void 0 : t.validateInputs) == null || l.call(t), !i.value) return;
1318
- const s = {};
1319
- Object.keys(S.value || {}).forEach((x) => {
1320
- var _;
1321
- Object.keys(((_ = S.value) == null ? void 0 : _[x]) || {}).forEach((V) => {
1322
- var N, K;
1323
- const H = (K = (N = S.value) == null ? void 0 : N[x]) == null ? void 0 : K[Number(V)];
1324
- H && C(H.amount) > 0 && (s[x] || (s[x] = []), s[x].push(H));
1325
- });
1326
- }), await A.revertWastageAdjustment({
1327
- targetWastageAdjustmentId: d.adjustmentId,
1328
- amountsGoingToAdjust: s
1329
- }), n("refreshHistory"), F.value = !1, S.value = {};
1330
- }
1331
- function b(s, t, l) {
1332
- return P({
1333
- get: () => {
1334
- var _, V, H;
1335
- const x = (H = (V = (_ = S.value) == null ? void 0 : _[s]) == null ? void 0 : V[t]) == null ? void 0 : H.amount;
1336
- return x ? C(x, !0) : 0;
1337
- },
1338
- set: (x) => {
1339
- S.value || (S.value = {});
1340
- const _ = { ...S.value };
1341
- _[s] || (_[s] = {}), _[s][t] = {
1342
- amount: Re.fromNumber(x),
1343
- type: oe.Enum.WASTAGE,
1344
- measurement: l
1345
- }, S.value = _;
1346
- }
1347
- });
1348
- }
1349
- function C(s, t = !0) {
1350
- const l = Number(Re.toFormatString({ value: s }));
1351
- return t ? Math.abs(l) : l;
1352
- }
1353
- function B(s, t) {
1354
- return t.measurement ? t.measurement.abbrev : s.sku.unit.abbrev;
1355
- }
1356
- function D(s, t) {
1357
- return t === 0 ? "N/A" : (s + t).toString();
1358
- }
1359
- return (s, t) => {
1360
- const l = U("FmIcon"), x = U("FmStepperField"), _ = U("FmCard"), V = U("FmForm"), H = U("FmSpacer"), N = U("FmButton"), K = U("FmDialog");
1361
- return $(), z(K, {
1362
- modelValue: F.value,
1363
- "onUpdate:modelValue": t[4] || (t[4] = (R) => F.value = R),
1364
- overlay: !0
1365
- }, {
1366
- "dialog-button": T(() => [
1367
- y(ze, null, {
1368
- default: T(() => [
1369
- e("button", {
1370
- onClick: t[0] || (t[0] = (R) => F.value = !0),
1371
- class: "rounded-md hover:bg-gray-100 transition-colors"
1372
- }, [
1373
- y(l, {
1374
- name: "edit",
1375
- size: "sm"
1376
- })
1377
- ])
1378
- ]),
1379
- _: 1
1380
- })
1381
- ]),
1382
- "dialog-header": T(() => t[5] || (t[5] = [
1383
- e("div", null, "Amend Adjustment", -1)
1384
- ])),
1385
- "dialog-footer": T(() => [
1386
- e("div", tn, [
1387
- t[13] || (t[13] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "1. New adjustment EXTRA will be created for each reversal", -1)),
1388
- e("div", on, [
1389
- y(H),
1390
- y(N, {
1391
- class: "sm:w-full xs:w-full",
1392
- label: "Close",
1393
- size: "md",
1394
- variant: "tertiary",
1395
- onClick: t[3] || (t[3] = (R) => F.value = !1)
1396
- }),
1397
- y(N, {
1398
- class: "sm:w-full xs:w-full",
1399
- label: "Submit",
1400
- size: "md",
1401
- variant: "primary",
1402
- onClick: u
1403
- })
1404
- ])
1405
- ])
1406
- ]),
1407
- default: T(() => [
1408
- m.value ? ($(), Y("div", Ko)) : ($(), z(V, {
1409
- key: 1,
1410
- ref_key: "formRef",
1411
- ref: w,
1412
- onValidationFailed: t[1] || (t[1] = () => {
1413
- i.value = !1;
1414
- }),
1415
- onValidationSuccess: t[2] || (t[2] = () => {
1416
- i.value = !0;
1417
- }),
1418
- blameFormChildOnValidationFailed: ""
1419
- }, {
1420
- default: T(() => [
1421
- e("p", Wo, [
1422
- t[6] || (t[6] = e("b", null, "Date:", -1)),
1423
- t[7] || (t[7] = e("br", null, null, -1)),
1424
- de(" " + v(a(Et)(a(gt)(j.value._id))), 1)
1425
- ]),
1426
- e("div", qo, [
1427
- ($(!0), Y(ne, null, ie(j.value.skus, (R, X) => ($(), Y(ne, { key: X }, [
1428
- ($(!0), Y(ne, null, ie(R.amounts, (L, ee) => ($(), z(_, {
1429
- key: ee,
1430
- variant: "outlined",
1431
- class: "p-2"
1432
- }, {
1433
- default: T(() => [
1434
- e("div", Xo, [
1435
- e("span", Jo, v(R.sku.code), 1),
1436
- e("span", null, v(R.sku.name), 1)
1437
- ]),
1438
- t[12] || (t[12] = e("hr", { class: "m-2" }, null, -1)),
1439
- e("div", Qo, [
1440
- t[8] || (t[8] = e("span", { class: "fm-typo-en-body-lg-600" }, "Adjustment type:", -1)),
1441
- e("span", null, v(L.type), 1)
1442
- ]),
1443
- e("div", Zo, [
1444
- t[9] || (t[9] = e("span", { class: "fm-typo-en-body-lg-600" }, "Current amount:", -1)),
1445
- e("span", null, v(a(Re).toFormatString({ value: L.amount })) + " " + v(B(R, L)), 1)
1446
- ]),
1447
- y(x, {
1448
- "model-value": b(R.sku._id, ee).value,
1449
- "onUpdate:modelValue": (J) => b(R.sku._id, ee).value = J,
1450
- class: "mb-3",
1451
- label: "Adjust Amount (Leave 0 to skip)",
1452
- "helper-text": `Max: ${C(L.amount)}`,
1453
- "append-text": B(R, L),
1454
- rules: [
1455
- (J) => J <= C(L.amount) || `Cannot be more than ${C(L.amount)}`,
1456
- a(Ve)(-1)
1457
- ]
1458
- }, null, 8, ["model-value", "onUpdate:modelValue", "helper-text", "append-text", "rules"]),
1459
- e("div", en, [
1460
- t[10] || (t[10] = e("span", { class: "fm-typo-en-body-lg-600" }, "Amount after amend:", -1)),
1461
- t[11] || (t[11] = e("span", { class: "text-fm-color-system-warning-400 fm-typo-en-body-sm-400" }, "* It's an estimate for your reference, as it didn't include all the reversals related to this adjustment", -1)),
1462
- de(" " + v(D(
1463
- C(L.amount, !1),
1464
- b(R.sku._id, ee).value
1465
- )) + " " + v(B(R, L)), 1)
1466
- ])
1467
- ]),
1468
- _: 2
1469
- }, 1024))), 128))
1470
- ], 64))), 128))
1471
- ])
1472
- ]),
1473
- _: 1
1474
- }, 512))
1475
- ]),
1476
- _: 1
1477
- }, 8, ["modelValue"]);
1478
- };
1479
- }
1480
- }), sn = { class: "p-16" }, an = { class: "fm-typo-en-body-md-600 flex-grow" }, ln = { class: "flex-grow text-fm-color-typo-secondary" }, rn = {
1481
- key: 0,
1482
- class: "my-5"
1483
- }, un = { class: "text-neutral-400" }, cn = { class: "flex-grow" }, dn = { class: "flex gap-1" }, mn = { class: "flex flex-col gap-1" }, pn = {
1484
- key: 1,
1485
- class: "t-system text-fsecondary"
1486
- }, fn = {
1487
- key: 3,
1488
- class: "inline-flex items-center rounded-md bg-yellow-400/10 px-2 text-xs font-medium text-yellow-500 inset-ring inset-ring-yellow-400/20"
1489
- }, vn = {
1490
- key: 1,
1491
- class: "shrink-0 text-fm-color-typo-secondary"
1492
- }, yn = /* @__PURE__ */ ue({
1493
- __name: "StockRecordCard",
1494
- props: {
1495
- record: {},
1496
- sku: {},
1497
- bills: { default: () => [] }
1498
- },
1499
- emits: ["refreshHistory"],
1500
- setup(k, { emit: g }) {
1501
- const d = k, n = O(!1);
1502
- Ge();
1503
- const A = O(), S = O(null), m = P(() => S.value === null ? "unset" : n.value ? `${S.value}px` : "0px");
1504
- Le(() => {
1505
- var w;
1506
- S.value = ((w = A.value) == null ? void 0 : w.scrollHeight) || 0;
1507
- });
1508
- const i = P(() => {
1509
- var D;
1510
- const w = d.record.adjustments, u = d.sku, b = {}, B = w.flatMap((s) => {
1511
- var t;
1512
- return ((t = s.skus) == null ? void 0 : t.filter((l) => l.sku._id === u._id)) ?? [];
1513
- }).flatMap((s) => s.amounts);
1514
- for (const s of B) {
1515
- const t = s.measurement ? rt(s.measurement.conversion, s.amount) : s.amount;
1516
- b[D = s.type] ?? (b[D] = { amount: 0, precision: 0 }), b[s.type] = Ke(t, b[s.type]);
1517
- }
1518
- return Object.entries(b).reduce(
1519
- (s, [t, l]) => (s[t] = /// comment, because without it formatter makes code uglier
1520
- `${Q.toFormatString({
1521
- value: l,
1522
- precision: 4
1523
- })} ${u.unit.abbrev}`, s),
1524
- {}
1525
- );
1526
- }), { t: F } = ce(), j = P(() => d.record.adjustmentsByTime.map(({ date: w, adjustments: u }) => ({
1527
- time: Pt(new Date(w)),
1528
- adjustments: u.flatMap(
1529
- (b) => {
1530
- var C, B;
1531
- return ((B = (C = b.skus) == null ? void 0 : C.map) == null ? void 0 : B.call(C, (D) => {
1532
- var s, t;
1533
- return {
1534
- ...D,
1535
- ref: b.ref,
1536
- backdateFrom: b.effectiveAt != null ? at(b._id) : null,
1537
- toBalance: (t = (s = b.skus) == null ? void 0 : s[0]) == null ? void 0 : t.toBalance,
1538
- adjustmentId: b._id
1539
- };
1540
- })) ?? [];
1541
- }
1542
- ).flatMap((b) => {
1543
- var D;
1544
- const C = (D = d.bills.find((s) => s._id === b.ref)) == null ? void 0 : D.seqNumber, B = C ? F("inventory.stock.record.bill", [C]) : "";
1545
- return b.amounts.map((s) => {
1546
- var t;
1547
- return {
1548
- amount: `${Q.toFormatString({ value: s.amount, precision: 4 })} ${((t = s.measurement) == null ? void 0 : t.abbrev) ?? b.sku.unit.abbrev}`,
1549
- backdateFrom: b.backdateFrom,
1550
- name: s.type,
1551
- billRemark: B,
1552
- remark: s.remark || "",
1553
- cost: s.cost,
1554
- toBalance: Q.toFormatString({
1555
- value: b.toBalance ?? Q.fromNumber(0),
1556
- precision: 4
1557
- }),
1558
- baseUnit: b.sku.unit.abbrev,
1559
- adjustmentId: b.adjustmentId
1560
- };
1561
- });
1562
- })
1563
- })));
1564
- return (w, u) => {
1565
- const b = U("FmIcon"), C = U("FmTooltip"), B = U("FmCard");
1566
- return $(), z(B, { variant: "outlined" }, {
1567
- default: T(() => [
1568
- e("div", sn, [
1569
- e("div", {
1570
- class: "flex items-center cursor-pointer mb-1",
1571
- onClick: u[0] || (u[0] = (D) => n.value = !n.value)
1572
- }, [
1573
- e("div", an, v(w.record.date), 1),
1574
- y(b, {
1575
- name: n.value ? "expand_more" : "expand_less",
1576
- color: "#777777",
1577
- size: "md"
1578
- }, null, 8, ["name"])
1579
- ]),
1580
- ($(!0), Y(ne, null, ie(i.value, (D, s) => ($(), Y("div", {
1581
- key: s,
1582
- class: "flex flex-row py-1",
1583
- style: { "font-size": "0.8rem" }
1584
- }, [
1585
- e("div", ln, v(a(F)(`inventory.inventoryAdjustment.type.${s}`)), 1),
1586
- e("div", {
1587
- class: _e({
1588
- "text-fm-color-typo-error": D.startsWith("-"),
1589
- "text-fm-color-typo-success": !D.startsWith("-"),
1590
- "ml-auto": !0
1591
- })
1592
- }, v(D), 3)
1593
- ]))), 128)),
1594
- e("div", {
1595
- ref_key: "detailRef",
1596
- ref: A,
1597
- style: nt({
1598
- fontSize: "0.8rem",
1599
- maxHeight: m.value,
1600
- overflow: "hidden",
1601
- transition: "max-height 0.2s ease-out"
1602
- })
1603
- }, [
1604
- j.value.length ? ($(), Y("hr", rn)) : te("", !0),
1605
- ($(!0), Y(ne, null, ie(j.value, (D) => ($(), Y("div", {
1606
- key: D.time,
1607
- class: "flex gap-1 w-full"
1608
- }, [
1609
- e("div", un, v(D.time), 1),
1610
- e("div", cn, [
1611
- ($(!0), Y(ne, null, ie(D.adjustments, (s) => ($(), Y("div", {
1612
- key: s.name,
1613
- class: "flex gap-1"
1614
- }, [
1615
- e("div", dn, [
1616
- de(v(a(F)(`inventory.inventoryAdjustment.type.${s.name}`)) + " ", 1),
1617
- s.backdateFrom ? ($(), z(C, {
1618
- key: 0,
1619
- variant: "plain",
1620
- placement: "top",
1621
- "z-index": 50
1622
- }, {
1623
- content: T(() => [
1624
- e("div", mn, v(a(F)("inventory.stock.record.backdate", [
1625
- a(ut)(new Date(s.backdateFrom))
1626
- ])), 1)
1627
- ]),
1628
- default: T(() => [
1629
- y(b, {
1630
- name: "info",
1631
- size: "sm",
1632
- color: "primary"
1633
- })
1634
- ]),
1635
- _: 2
1636
- }, 1024)) : te("", !0),
1637
- s.billRemark ? ($(), Y("span", pn, " # " + v(s.billRemark), 1)) : te("", !0),
1638
- s.remark ? ($(), Y("span", {
1639
- key: 2,
1640
- class: _e(s.billRemark ? "text-xs text-gray-400" : "")
1641
- }, v(s.billRemark ? `(${s.remark})` : `# ${s.remark}`), 3)) : te("", !0),
1642
- s.name === a(oe).Enum.CLOSING ? ($(), Y("span", fn, " Actual Balance: " + v(s.toBalance) + " " + v(s.baseUnit), 1)) : te("", !0)
1643
- ]),
1644
- e("div", {
1645
- class: _e({
1646
- "text-fm-color-typo-error": s.amount.startsWith("-"),
1647
- "text-fm-color-typo-success": !s.amount.startsWith("-"),
1648
- "ml-auto": !0
1649
- })
1650
- }, v(s.amount), 3),
1651
- s.name === a(oe).Enum.WASTAGE ? ($(), z(nn, {
1652
- key: 0,
1653
- adjustmentId: s.adjustmentId,
1654
- onRefreshHistory: u[1] || (u[1] = (t) => w.$emit("refreshHistory"))
1655
- }, null, 8, ["adjustmentId"])) : te("", !0),
1656
- s.cost ? ($(), Y("div", vn, " (" + v(a(we)(s.cost, !1, s.cost.precision)) + ") ", 1)) : te("", !0)
1657
- ]))), 128))
1658
- ])
1659
- ]))), 128))
1660
- ], 4)
1661
- ])
1662
- ]),
1663
- _: 1
1664
- });
1665
- };
1666
- }
1667
- });
1668
- function _n(k, g) {
1669
- var S;
1670
- const d = Object.keys(oe.enum).reduce(
1671
- (m, i) => (m[i] = { amount: 0, precision: 0 }, m),
1672
- {}
1673
- );
1674
- if (!g)
1675
- return Object.entries(d).reduce(
1676
- (m, [i]) => (m[i] = Q.fromNumber(0), m),
1677
- {}
1678
- );
1679
- const A = k.flatMap((m) => {
1680
- var i;
1681
- return ((i = m.skus) == null ? void 0 : i.filter((F) => F.sku._id === g._id)) ?? [];
1682
- }).flatMap((m) => m.amounts);
1683
- for (const m of A) {
1684
- const i = m.measurement ? Q.multiply([m.measurement.conversion, m.amount]) : m.amount;
1685
- d[S = m.type] ?? (d[S] = { amount: 0, precision: 0 }), d[m.type] = Q.add([i, d[m.type]]);
1686
- }
1687
- return Object.entries(d).reduce(
1688
- (m, [i, F]) => {
1689
- const j = {
1690
- ...F,
1691
- amount: Math.abs(F.amount)
1692
- };
1693
- return m[i] = /// comment, because without it formatter makes code uglier
1694
- `${Q.toFormatString({
1695
- value: j,
1696
- precision: 4
1697
- })} ${g.unit.abbrev}`, m;
1698
- },
1699
- {}
1700
- );
1701
- }
1702
- function kn(k, g) {
1703
- if (!g)
1704
- return null;
1705
- let d = null;
1706
- const A = k.flatMap((S) => {
1707
- var m;
1708
- return ((m = S.skus) == null ? void 0 : m.filter((i) => i.sku._id === g._id)) ?? [];
1709
- }).flatMap((S) => {
1710
- var m;
1711
- return !S.history || ((m = S.history) == null ? void 0 : m.length) === 0 ? [] : S.history[0];
1712
- });
1713
- for (const S of A) {
1714
- const m = S.amounts;
1715
- for (const i of m) {
1716
- if (i.type !== oe.Enum.SALES)
1717
- continue;
1718
- const F = i.measurement ? Q.multiply([i.measurement.conversion, i.amount]) : i.amount;
1719
- d ?? (d = Q.fromNumber(0)), d = Q.add([d, F]);
1720
- }
1721
- }
1722
- return d != null ? (d.amount = Math.abs(d.amount), `${Q.toFormatString({
1723
- value: d,
1724
- precision: 4
1725
- })} ${g.unit.abbrev}`) : null;
1726
- }
1727
- const bn = { class: "flex items-center w-full fm-typo-en-title-md-800" }, gn = { class: "flex-1 line-clamp-2" }, hn = { class: "flex flex-col gap-32 w-full h-full" }, xn = { class: "flex items-center relative gap-4" }, Sn = { class: "flex-1" }, Fn = {
1728
- key: 0,
1729
- class: "flex-1 flex flex-col items-center gap-16"
1730
- }, wn = { class: "fm-typo-en-body-lg-400 translate-x-4" }, $n = {
1731
- key: 1,
1732
- class: "flex flex-col gap-12"
1733
- }, An = { class: "pb-16" }, Vn = { class: "fm-typo-cn-body-lg-600" }, Cn = {
1734
- class: "grid gap-12 fm-typo-en-body-md-400",
1735
- style: { "grid-template-columns": "auto auto auto", "grid-auto-rows": "1fr" }
1736
- }, jn = { class: "flex flex-col gap-1" }, Dn = { class: "text-fm-color-typo-secondary" }, Bn = { class: "font-bold" }, Mn = { class: "flex flex-col gap-1" }, In = { class: "text-fm-color-typo-secondary flex" }, Un = { class: "font-bold" }, Tn = { class: "flex flex-col gap-1" }, Hn = { class: "text-fm-color-typo-secondary" }, En = { class: "font-bold" }, Pn = { class: "flex flex-col gap-1" }, Rn = { class: "text-fm-color-typo-secondary" }, On = { class: "font-bold" }, Nn = { class: "flex flex-col gap-1" }, Yn = { class: "text-fm-color-typo-secondary" }, Ln = { class: "font-bold" }, zn = { class: "flex flex-col gap-1" }, Gn = { class: "text-fm-color-typo-secondary" }, Kn = { class: "font-bold" }, Wn = { class: "flex flex-col gap-1" }, qn = { class: "text-fm-color-typo-secondary" }, Xn = { class: "font-bold" }, Jn = { class: "flex flex-col gap-1" }, Qn = { class: "text-fm-color-typo-secondary" }, Zn = { class: "font-bold" }, es = { class: "flex flex-col gap-1" }, ts = { class: "text-fm-color-typo-secondary" }, os = { class: "font-bold" }, ns = {
1737
- key: 0,
1738
- class: "flex flex-col gap-8"
1739
- }, ss = { class: "flex" }, as = { class: "flex-1 flex flex-col gap-1" }, ls = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, rs = { class: "font-bold" }, is = { class: "flex-1 flex flex-col gap-1" }, us = { class: "flex gap-1 items-center text-fm-color-typo-secondary" }, cs = { class: "flex flex-col gap-1" }, ds = { class: "font-bold" }, ms = {
1740
- key: 2,
1741
- class: "flex-1 flex flex-col items-center gap-8"
1742
- }, ps = ["src"], fs = { class: "font-bold text-lg" }, vs = { class: "text-xs text-neutral-400 text-center" }, ys = /* @__PURE__ */ ue({
1743
- __name: "StockHistory",
1744
- props: {
1745
- sku: {},
1746
- show: { type: Boolean }
1747
- },
1748
- emits: ["update:show"],
1749
- setup(k) {
1750
- const g = Ge(), d = Me(), n = he(), A = Go(), S = be(), m = Wt(), { t: i } = ce(), F = k, j = O(!1), w = ge(), u = O(zt(0));
1751
- async function b() {
1752
- j.value = !0;
1753
- try {
1754
- await l(), await d.readStockBalance();
1755
- } catch (o) {
1756
- w.open({
1757
- title: "Something went wrong",
1758
- message: "Cannot fetch stock history. Please try again.",
1759
- type: "error"
1760
- }), console.log("failed at fetching item adjustment history", F.sku, u, o);
1761
- } finally {
1762
- j.value = !1;
1763
- }
1764
- }
1765
- Le(() => {
1766
- b();
1767
- }), xe([() => u.value, () => F.sku], () => {
1768
- b();
1769
- });
1770
- const C = O([]), B = O([]), D = O(new Array());
1771
- function s(o, r) {
1772
- return r === "day" ? Lt(o) : ut(o);
1773
- }
1774
- function t(o, r) {
1775
- const h = o.reduce(
1776
- (c, f) => {
1777
- const M = f.effectiveAt ?? at(f._id);
1778
- if (!M)
1779
- return c;
1780
- const I = s(new Date(M), r);
1781
- return c[I] ?? (c[I] = []), c[I].push(f), c;
1782
- },
1783
- {}
1784
- );
1785
- return Object.keys(h).map((c) => ({
1786
- date: c,
1787
- adjustments: h[c]
1788
- }));
1789
- }
1790
- async function l() {
1791
- let o = await n.readStockAdjustment(
1792
- F.sku._id,
1793
- Rt(new Date(u.value.startDate)).toISOString(),
1794
- Ot(new Date(u.value.endDate)).toISOString()
1795
- );
1796
- C.value = o;
1797
- const r = o.filter(({ ref: h }) => h == null ? void 0 : h.startsWith("bill_")).map(({ ref: h }) => h);
1798
- await x(r), B.value = t(o, "day").map(({ date: h, adjustments: c }) => ({
1799
- date: h,
1800
- adjustments: c,
1801
- adjustmentsByTime: t(c, "minute")
1802
- }));
1803
- }
1804
- async function x(o) {
1805
- o.length && (D.value = await A.findBillsById(o).catch((r) => {
1806
- var f;
1807
- console.error("Error on using latest bill API, retrying using legacy api", r);
1808
- const h = ((f = g.currentBusiness.value) == null ? void 0 : f._id) ?? "", c = S.currentLocation.doc._id;
1809
- return A.findBillsByBusinessId(h, [c], o);
1810
- }));
1811
- }
1812
- const _ = P(() => {
1813
- const o = C.value, r = F.sku;
1814
- return _n(o, r);
1815
- }), V = P(() => {
1816
- const o = C.value, r = F.sku;
1817
- return kn(o, r);
1818
- }), H = P(() => {
1819
- const o = [...C.value].computeFirst((h) => {
1820
- var f, M;
1821
- const c = (M = (f = h.skus) == null ? void 0 : f.find) == null ? void 0 : M.call(f, (I) => I.sku._id === F.sku._id);
1822
- return c == null ? void 0 : c.fromBalance;
1823
- }) ?? {
1824
- amount: 0,
1825
- precision: 0
1826
- }, r = F.sku;
1827
- return r ? `${Q.toFormatString({
1828
- value: o,
1829
- precision: 4
1830
- })} ${r.unit.abbrev}` : "";
1831
- }), N = P(() => {
1832
- const o = [...C.value].reverse().computeFirst((h) => {
1833
- var f, M;
1834
- const c = (M = (f = h.skus) == null ? void 0 : f.find) == null ? void 0 : M.call(f, (I) => I.sku._id === F.sku._id);
1835
- return c == null ? void 0 : c.toBalance;
1836
- }) ?? {
1837
- amount: 0,
1838
- precision: 0
1839
- }, r = F.sku;
1840
- return r ? `${Q.toFormatString({ value: o, precision: 4 })} ${r.unit.abbrev}` : "";
1841
- }), K = P(() => {
1842
- var h;
1843
- const r = C.value.flatMap((c) => {
1844
- var f;
1845
- return ((f = c.skus) == null ? void 0 : f.flatMap((M) => M.amounts)) ?? [];
1846
- }).filter((c) => c.amount.amount < 0).reduce(
1847
- (c, f) => {
1848
- const M = f.cost;
1849
- if (!M) return c;
1850
- const I = {
1851
- ...Ut(c, Math.max(c.precision, M.precision)),
1852
- currency: M.currency
1853
- };
1854
- return {
1855
- ...Ke(I, M),
1856
- currency: c.currency
1857
- };
1858
- },
1859
- {
1860
- amount: 0,
1861
- precision: 0,
1862
- currency: Ee((h = g.currentCountry) == null ? void 0 : h.value)
1863
- }
1864
- );
1865
- return we(r, !1, r.precision);
1866
- });
1867
- function R() {
1868
- const { startDate: o, endDate: r } = Nt(u.value);
1869
- o !== null && r !== null && (u.value = {
1870
- startDate: o,
1871
- endDate: r
1872
- });
1873
- }
1874
- const X = P(() => i("inventory.ingredient.valuationMethod.WAVG")), L = P(() => {
1875
- var I, G, se, E;
1876
- const o = [...C.value].reverse().computeFirst((W) => {
1877
- var q, le;
1878
- return (le = (q = W.skus) == null ? void 0 : q.find) == null ? void 0 : le.call(q, (re) => re.sku._id === F.sku._id);
1879
- });
1880
- if (!o) return "No data";
1881
- const r = [...o.amounts].reverse()[0], h = {
1882
- amount: ((I = r.cost) == null ? void 0 : I.amount) ?? 0,
1883
- precision: ((G = r.cost) == null ? void 0 : G.precision) ?? 0
1884
- }, c = r.amount, f = c.amount == 0 ? Q.fromNumber(0) : Q.divide([h, c]);
1885
- return {
1886
- ...Q.multiply([f, c]),
1887
- currency: ((se = r.cost) == null ? void 0 : se.currency) || Ee(((E = g.currentCountry) == null ? void 0 : E.value) ?? ht)
1888
- };
1889
- }), ee = P(() => {
1890
- var h;
1891
- const o = [...C.value].reverse().computeFirst((c) => {
1892
- var M, I;
1893
- const f = (I = (M = c.skus) == null ? void 0 : M.find) == null ? void 0 : I.call(M, (G) => G.sku._id === F.sku._id);
1894
- return f == null ? void 0 : f.toCostBalances;
1895
- });
1896
- return o ? {
1897
- ...o.reduce((c, f) => Q.add([c, Q.fromDinero(f.cost)]), {
1898
- amount: 0,
1899
- precision: 0
1900
- }),
1901
- currency: Ee((h = g.currentCountry) == null ? void 0 : h.value)
1902
- } : "No data";
1903
- });
1904
- function J() {
1905
- const { startDate: o, endDate: r } = Yt(u.value);
1906
- o !== null && r !== null && (u.value = {
1907
- startDate: o,
1908
- endDate: r
1909
- });
1910
- }
1911
- const p = Ue(F, "show");
1912
- return (o, r) => {
1913
- const h = U("FmButton"), c = U("FmField"), f = U("FmDateRangePicker"), M = U("FmSpacer"), I = U("FmCircularProgress"), G = U("FmIcon"), se = U("FmTooltip"), E = U("FmMenuDivider"), W = U("FmChip"), q = U("FmCardSection"), le = U("FmCard"), re = U("FmSideSheet");
1914
- return $(), z(re, {
1915
- "dismiss-away": "",
1916
- modelValue: a(p),
1917
- "onUpdate:modelValue": r[4] || (r[4] = (Z) => je(p) ? p.value = Z : null),
1918
- "close-button": !1,
1919
- "max-width": 560
1920
- }, {
1921
- "side-sheet-header": T(() => [
1922
- e("div", bn, [
1923
- e("div", gn, v(a(i)("inventory.stock.history.title", [o.sku.name])), 1),
1924
- y(h, {
1925
- variant: "tertiary",
1926
- "prepend-icon": "close",
1927
- onClick: r[0] || (r[0] = (Z) => p.value = !1)
1928
- })
1929
- ])
1930
- ]),
1931
- default: T(() => {
1932
- var Z;
1933
- return [
1934
- e("div", hn, [
1935
- e("div", xn, [
1936
- e("div", Sn, [
1937
- y(f, {
1938
- modelValue: u.value,
1939
- "onUpdate:modelValue": r[1] || (r[1] = (ae) => u.value = ae),
1940
- "show-predefined-range": "",
1941
- "start-label": "",
1942
- "end-label": "",
1943
- "z-index": 50
1944
- }, {
1945
- "trigger-button": T(({ opened: ae }) => [
1946
- y(c, {
1947
- "prepend-icon": "calendar_month",
1948
- focused: ae
1949
- }, {
1950
- default: T(() => [
1951
- de(v(u.value.startDate) + " - " + v(u.value.endDate), 1)
1952
- ]),
1953
- _: 2
1954
- }, 1032, ["focused"])
1955
- ]),
1956
- _: 1
1957
- }, 8, ["modelValue"])
1958
- ]),
1959
- y(h, {
1960
- variant: "tertiary",
1961
- onClick: r[2] || (r[2] = (ae) => R()),
1962
- "prepend-icon": "navigate_before"
1963
- }),
1964
- y(h, {
1965
- variant: "tertiary",
1966
- onClick: r[3] || (r[3] = (ae) => J()),
1967
- "prepend-icon": "navigate_next"
1968
- })
1969
- ]),
1970
- j.value ? ($(), Y("div", Fn, [
1971
- y(M),
1972
- y(I, { size: "xl" }),
1973
- e("div", wn, v(a(i)("inventory.stock.history.loading")), 1),
1974
- y(M),
1975
- y(M)
1976
- ])) : B.value && ((Z = B.value) == null ? void 0 : Z.length) > 0 ? ($(), Y("div", $n, [
1977
- y(le, { variant: "outlined" }, {
1978
- default: T(() => [
1979
- y(q, { class: "flex flex-col gap-4" }, {
1980
- default: T(() => [
1981
- e("div", An, [
1982
- e("div", Vn, v(a(i)("inventory.stock.history.summary.title")), 1)
1983
- ]),
1984
- e("div", Cn, [
1985
- e("div", jn, [
1986
- e("div", Dn, v(a(i)("inventory.stock.history.summary.totalPurchase")), 1),
1987
- e("div", Bn, v(_.value.PURCHASE), 1)
1988
- ]),
1989
- e("div", Mn, [
1990
- e("div", In, [
1991
- de(v(a(i)("inventory.stock.history.summary.totalSales")) + "  ", 1),
1992
- V.value != null ? ($(), z(se, {
1993
- key: 0,
1994
- variant: "plain",
1995
- placement: "top",
1996
- content: `Before: ${V.value}`,
1997
- "z-index": 50
1998
- }, {
1999
- default: T(() => [
2000
- y(G, {
2001
- name: "warning",
2002
- size: "sm"
2003
- })
2004
- ]),
2005
- _: 1
2006
- }, 8, ["content"])) : te("", !0)
2007
- ]),
2008
- e("div", Un, v(_.value.SALES), 1)
2009
- ]),
2010
- e("div", Tn, [
2011
- e("div", Hn, v(a(i)("inventory.stock.history.summary.totalLose")), 1),
2012
- e("div", En, v(_.value.LOSE), 1)
2013
- ]),
2014
- e("div", Pn, [
2015
- e("div", Rn, v(a(i)("inventory.stock.history.summary.totalRequest")), 1),
2016
- e("div", On, v(_.value.REQUEST), 1)
2017
- ]),
2018
- e("div", Nn, [
2019
- e("div", Yn, v(a(i)("inventory.stock.history.summary.totalReceive")), 1),
2020
- e("div", Ln, v(_.value.RECEIVE), 1)
2021
- ]),
2022
- e("div", zn, [
2023
- e("div", Gn, v(a(i)("inventory.stock.history.summary.totalConvert")), 1),
2024
- e("div", Kn, v(_.value.CONVERT), 1)
2025
- ]),
2026
- e("div", Wn, [
2027
- e("div", qn, v(a(i)("inventory.stock.history.summary.totalDamage")), 1),
2028
- e("div", Xn, v(_.value.DAMAGE), 1)
2029
- ]),
2030
- e("div", Jn, [
2031
- e("div", Qn, v(a(i)("inventory.stock.history.summary.openingBalance")), 1),
2032
- e("div", Zn, v(H.value), 1)
2033
- ]),
2034
- e("div", es, [
2035
- e("div", ts, v(a(i)("inventory.stock.history.summary.lastStockBalance")), 1),
2036
- e("div", os, v(N.value), 1)
2037
- ])
2038
- ]),
2039
- a(m).enableTotalCost ? ($(), Y("div", ns, [
2040
- y(E, { class: "w-full" }),
2041
- e("div", ss, [
2042
- e("div", as, [
2043
- y(Qe, { "z-index": 50 }, {
2044
- default: T(() => [
2045
- e("div", ls, [
2046
- de(v(a(i)("inventory.stock.history.estimatedValue")) + " ", 1),
2047
- y(se, {
2048
- variant: "plain",
2049
- placement: "top",
2050
- content: `[${X.value}] ${a(i)("inventory.stock.history.estimatedValueTooltip")}`,
2051
- "z-index": 50
2052
- }, {
2053
- default: T(() => [
2054
- y(G, {
2055
- name: "help",
2056
- size: "sm"
2057
- })
2058
- ]),
2059
- _: 1
2060
- }, 8, ["content"])
2061
- ])
2062
- ]),
2063
- _: 1
2064
- }),
2065
- e("div", rs, [
2066
- o.sku.valuation === a(xt).Enum.FIFO ? ($(), Y(ne, { key: 0 }, [
2067
- y(W, {
2068
- label: "FIFO",
2069
- compact: ""
2070
- }),
2071
- de(" " + v(typeof ee.value != "string" ? a(we)(
2072
- ee.value,
2073
- !1,
2074
- ee.value.precision
2075
- ) : ee.value), 1)
2076
- ], 64)) : ($(), Y(ne, { key: 1 }, [
2077
- de(v(typeof L.value != "string" ? a(we)(
2078
- L.value,
2079
- !1,
2080
- L.value.precision
2081
- ) : L.value), 1)
2082
- ], 64))
2083
- ])
2084
- ]),
2085
- e("div", is, [
2086
- y(Qe, { "z-index": 50 }, {
2087
- default: T(() => [
2088
- e("div", us, [
2089
- de(v(a(i)("inventory.stock.history.costSold")) + " ", 1),
2090
- y(se, {
2091
- variant: "plain",
2092
- placement: "top",
2093
- "z-index": 50
2094
- }, {
2095
- content: T(() => [
2096
- e("div", cs, v(a(i)("inventory.stock.history.costSoldTooltip")), 1)
2097
- ]),
2098
- default: T(() => [
2099
- y(G, {
2100
- name: "help",
2101
- size: "sm"
2102
- })
2103
- ]),
2104
- _: 1
2105
- })
2106
- ])
2107
- ]),
2108
- _: 1
2109
- }),
2110
- e("div", ds, v(K.value), 1)
2111
- ])
2112
- ])
2113
- ])) : te("", !0)
2114
- ]),
2115
- _: 1
2116
- })
2117
- ]),
2118
- _: 1
2119
- }),
2120
- r[5] || (r[5] = e("div", null, null, -1)),
2121
- ($(!0), Y(ne, null, ie(B.value, (ae) => ($(), Y(ne, {
2122
- key: ae.date
2123
- }, [
2124
- o.sku ? ($(), z(yn, {
2125
- key: 0,
2126
- record: ae,
2127
- sku: o.sku,
2128
- bills: D.value,
2129
- onRefreshHistory: b
2130
- }, null, 8, ["record", "sku", "bills"])) : te("", !0)
2131
- ], 64))), 128))
2132
- ])) : ($(), Y("div", ms, [
2133
- y(M),
2134
- e("div", null, [
2135
- e("img", {
2136
- src: a(Kt),
2137
- alt: "List is empty"
2138
- }, null, 8, ps)
2139
- ]),
2140
- e("div", fs, v(a(i)("inventory.stock.history.noRecords")), 1),
2141
- e("div", vs, v(a(i)("inventory.stock.history.changeDateRange")), 1),
2142
- y(M),
2143
- y(M)
2144
- ]))
2145
- ])
2146
- ];
2147
- }),
2148
- _: 1
2149
- }, 8, ["modelValue"]);
2150
- };
2151
- }
2152
- }), _s = {
2153
- key: 0,
2154
- class: "flex items-center gap-1"
2155
- }, ks = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bs = { class: "flex flex-col gap-8" }, gs = { class: "flex flex-col" }, hs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, xs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Ks = /* @__PURE__ */ ue({
2156
- __name: "StockView",
2157
- setup(k) {
2158
- const { t: g } = ce(), d = Be(), n = be(), A = Me(), S = dt(), m = he(), i = st(), F = qt(), { columnDefs: j } = so(), w = Ie(), u = ge();
2159
- n.watchLocation(D);
2160
- const b = P(
2161
- () => new Set(F.getAvailableItems(F.businessSubsidiaryId))
2162
- ), C = O(!1);
2163
- async function B() {
2164
- w.open({
2165
- title: g("inventory.stock.stock_balance.refreshBalance"),
2166
- message: g("inventory.stock.stock_balance.refreshBalanceDescription"),
2167
- closeButton: !0,
2168
- primaryActions: {
2169
- text: g("common.confirm"),
2170
- close: !0
2171
- },
2172
- secondaryActions: {
2173
- text: g("common.close"),
2174
- close: !0,
2175
- variant: "tertiary"
2176
- }
2177
- }).onPrimary(async () => {
2178
- await m.recalculation.refreshCurrentBalances(), u.open({
2179
- title: "Refresh Stock Balance",
2180
- message: "Stock balance refresh has been queued. This may take a moment to complete.",
2181
- type: "success"
2182
- });
2183
- });
2184
- }
2185
- async function D() {
2186
- if (n._currentLocation) {
2187
- C.value = !0;
2188
- try {
2189
- await A.readStockBalance(), await A.readProductBalance(), await i.readStockEstimateBalance();
2190
- } catch (J) {
2191
- u.open({
2192
- title: g("inventory.stock.error.title"),
2193
- message: g("inventory.stock.error.message"),
2194
- type: "error"
2195
- }), console.error("error on fetch stock balance", J);
2196
- } finally {
2197
- C.value = !1;
2198
- }
2199
- }
2200
- }
2201
- const s = P(() => [
2202
- {
2203
- type: "string",
2204
- key: "status",
2205
- entity: "sku",
2206
- values: ["Active", "Inactive"]
2207
- }
2208
- ]), t = O({
2209
- logic: "AND",
2210
- rules: [
2211
- {
2212
- property: "status",
2213
- operator: "$in",
2214
- value: ["Active"],
2215
- type: "string"
2216
- }
2217
- ]
2218
- }), l = P(() => {
2219
- var o, r, h;
2220
- const J = t.value ? Xt.build(t.value) : null, p = [];
2221
- for (const c of d.skus) {
2222
- let f = !0;
2223
- if (F.isEnabled && _.value && b.value && f && (f = b.value.has(c._id)), J && f && (f = Jt(
2224
- {
2225
- status: c.isInactive ? "Inactive" : "Active"
2226
- },
2227
- J
2228
- )), f) {
2229
- const M = c.trackingMeasurement;
2230
- let I = (r = (o = A.stockBalance.skus) == null ? void 0 : o.find(
2231
- (E) => E.id === c._id
2232
- )) == null ? void 0 : r.balance, G = i.inventoryForecast.skus.find(
2233
- (E) => E.id === c._id
2234
- );
2235
- const se = {
2236
- ...c,
2237
- balance: I ?? {
2238
- amount: 0,
2239
- precision: 0
2240
- },
2241
- day: (G == null ? void 0 : G.depletionDays) ?? void 0,
2242
- trackingUnitAbbrev: M ? ((h = c.unit.measurements.find((E) => E.id === M)) == null ? void 0 : h.abbrev) ?? "" : c.unit.abbrev
2243
- };
2244
- p.push(se);
2245
- }
2246
- }
2247
- return p;
2248
- }), x = O(""), _ = O(!0), { breakpoints: V } = Vt(), H = P(() => V.value.xs || V.value.sm), N = P(() => H.value ? 10 : 20), K = vt(), R = P(() => [
2249
- {
2250
- label: g("inventory.stock.stock_balance.refreshBalance"),
2251
- value: "refresh-balance",
2252
- isPrimary: !0,
2253
- prependIcon: "calculate"
2254
- },
2255
- {
2256
- label: g("inventory.common.refresh"),
2257
- value: "refresh"
2258
- },
2259
- {
2260
- label: g("inventory.common.export"),
2261
- value: "export"
2262
- },
2263
- {
2264
- label: g("inventory.stock.stock_adjustment.title"),
2265
- value: "stockAdjustment",
2266
- isAdminOnly: !0
2267
- }
2268
- ]), X = O(!1);
2269
- function L() {
2270
- X.value = !0;
2271
- }
2272
- function ee(J) {
2273
- switch (J) {
2274
- case "refresh-balance":
2275
- return B();
2276
- case "refresh":
2277
- return D();
2278
- case "export":
2279
- return eo(l.value);
2280
- case "stockAdjustment":
2281
- return L();
2282
- }
2283
- }
2284
- return (J, p) => {
2285
- const o = U("FmSwitch"), r = U("FmTable");
2286
- return $(), z(yt, {
2287
- title: a(g)("inventory.stock.title"),
2288
- actions: R.value,
2289
- "onClick:action": ee
2290
- }, {
2291
- default: T(() => {
2292
- var h, c, f, M;
2293
- return [
2294
- e("div", {
2295
- class: _e([
2296
- "flex flex-col gap-8 max-h-full",
2297
- {
2298
- "p-0": H.value,
2299
- "px-24 ": !H.value
2300
- }
2301
- ])
2302
- }, [
2303
- y(Gt, {
2304
- searchable: "",
2305
- "change-location": "",
2306
- search: x.value,
2307
- "onUpdate:search": p[1] || (p[1] = (I) => x.value = I),
2308
- "hide-filter-options": !0,
2309
- filterable: "",
2310
- "filter-attributes": s.value,
2311
- filter: t.value,
2312
- "onUpdate:filter": p[2] || (p[2] = (I) => t.value = I)
2313
- }, {
2314
- default: T(() => [
2315
- a(F).isEnabled ? ($(), Y("div", _s, [
2316
- e("span", ks, v(a(g)("inventory.integration.netsuite.subsidiaryHierarchy.filtering")), 1),
2317
- y($t),
2318
- y(ze, null, {
2319
- default: T(() => [
2320
- y(o, {
2321
- modelValue: _.value,
2322
- "onUpdate:modelValue": p[0] || (p[0] = (I) => _.value = I)
2323
- }, null, 8, ["modelValue"])
2324
- ]),
2325
- _: 1
2326
- })
2327
- ])) : te("", !0)
2328
- ]),
2329
- _: 1
2330
- }, 8, ["search", "filter-attributes", "filter"]),
2331
- ($(), z(r, {
2332
- style: nt(a(K).tableHeight),
2333
- "column-defs": a(j),
2334
- "row-data": l.value,
2335
- "search-value": x.value,
2336
- loading: C.value || !a(n)._currentLocation,
2337
- key: (h = a(n)._currentLocation) == null ? void 0 : h.dbName,
2338
- onRowClick: p[3] || (p[3] = (I) => a(S).showSkuHistory(I.original)),
2339
- "page-size": N.value
2340
- }, {
2341
- "list-row": T((I) => [
2342
- y(Ft, {
2343
- row: I,
2344
- onRowClick: a(S).showSkuHistory
2345
- }, {
2346
- default: T((G) => {
2347
- var se, E, W, q, le, re, Z, ae, fe, me;
2348
- return [
2349
- e("div", bs, [
2350
- e("div", gs, [
2351
- e("div", hs, [
2352
- y(a(Je), {
2353
- render: (W = (E = (se = G.code) == null ? void 0 : se.column) == null ? void 0 : E.columnDef) == null ? void 0 : W.cell,
2354
- props: (le = (q = G.code) == null ? void 0 : q.getContext) == null ? void 0 : le.call(q)
2355
- }, null, 8, ["render", "props"])
2356
- ]),
2357
- e("div", xs, [
2358
- y(a(Je), {
2359
- render: (ae = (Z = (re = G.name) == null ? void 0 : re.column) == null ? void 0 : Z.columnDef) == null ? void 0 : ae.cell,
2360
- props: (me = (fe = G.name) == null ? void 0 : fe.getContext) == null ? void 0 : me.call(fe)
2361
- }, null, 8, ["render", "props"])
2362
- ])
2363
- ]),
2364
- e("div", null, [
2365
- y(Ne, {
2366
- days: I.original.day
2367
- }, null, 8, ["days"])
2368
- ]),
2369
- e("div", null, [
2370
- y(ct, {
2371
- class: "xs:w-[160px]",
2372
- unit: I.original.unit,
2373
- sku: I.original,
2374
- amount: I.original.balance,
2375
- "default-tracking-measurement": I.original.trackingMeasurement ?? void 0
2376
- }, null, 8, ["unit", "sku", "amount", "default-tracking-measurement"])
2377
- ])
2378
- ])
2379
- ];
2380
- }),
2381
- _: 2
2382
- }, 1032, ["row", "onRowClick"])
2383
- ]),
2384
- _: 1
2385
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2386
- ], 2),
2387
- ($(), z(ft, { to: "body" }, [
2388
- (c = a(S).stockHistoryProps) != null && c.sku ? ($(), z(ys, Te(He({ key: 0 }, a(S).stockHistoryProps)), null, 16)) : te("", !0),
2389
- (f = a(S).convertSkuDialogProps) != null && f.sku ? ($(), z(go, Te(He({ key: 1 }, a(S).convertSkuDialogProps)), null, 16)) : te("", !0),
2390
- (M = a(S).adjustSkuDialogProps) != null && M.stock ? ($(), z(Bo, Te(He({ key: 2 }, a(S).adjustSkuDialogProps)), null, 16)) : te("", !0),
2391
- X.value ? ($(), z(zo, {
2392
- key: 3,
2393
- show: X.value,
2394
- "onUpdate:show": p[4] || (p[4] = (I) => X.value = I),
2395
- onSubmitted: p[5] || (p[5] = (I) => D())
2396
- }, null, 8, ["show"])) : te("", !0)
2397
- ]))
2398
- ];
2399
- }),
2400
- _: 1
2401
- }, 8, ["title", "actions"]);
2402
- };
2403
- }
2404
- });
2405
- export {
2406
- Ks as default
2407
- };