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