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