@feedmepos/mf-inventory-portal 1.2.61-dev.1 → 1.2.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/{App-Dj4TFhg1.js → App-BqScGtJx.js} +78 -82
  2. package/dist/{ApprovalView-Cpbfph-H.js → ApprovalView-BFdlYIot.js} +5 -5
  3. package/dist/{BindingsDialog-CUbU9tih.js → BindingsDialog-Dvmrms77.js} +5 -5
  4. package/dist/{BindingsPicker-CMlAGOJT.js → BindingsPicker-fPVSXv-h.js} +3 -3
  5. package/dist/{BindingsTable-DvOE5QM2.js → BindingsTable-CnUa8VOi.js} +5 -5
  6. package/dist/{ClosingDraftView-DKv-ehO_.js → ClosingDraftView-10BcpWkm.js} +216 -217
  7. package/dist/{ClosingHistoryView-DIl78iH9.js → ClosingHistoryView-zLh0HCIb.js} +36 -36
  8. package/dist/{ClosingTemplateView-DPDh_geQ.js → ClosingTemplateView-BFupX87V.js} +14 -14
  9. package/dist/{DeliveryOrderPrintPreview-Bi3xgagw.js → DeliveryOrderPrintPreview-BLBqmOjw.js} +7 -7
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-B_5_SxUn.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DN8ziFA_.js} +20 -20
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B3Kl8YBw.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DJT_7Uus.js} +2 -2
  12. package/dist/{FmMultiselectDialog-1IUxEPwt.js → FmMultiselectDialog-B5paZk6T.js} +16 -16
  13. package/dist/{FmMultiselectDialog-BSOTemHV.js → FmMultiselectDialog-DmnYEmN1.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BMK8Az4J.js → FmUnitInput.vue_vue_type_script_setup_true_lang-MW749j29.js} +22 -23
  15. package/dist/{ImportView-CkitDDEU.js → ImportView-BsI1_unJ.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DZUQavPo.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-D8hvH-4n.js} +1 -1
  17. package/dist/{IngredientGroupView-ogDZwQFL.js → IngredientGroupView-BALVTSwF.js} +5 -5
  18. package/dist/{IngredientsView-B5AWPQhS.js → IngredientsView-C-sauieO.js} +24 -25
  19. package/dist/{IntegrationView-DIx6B_wR.js → IntegrationView-GG2E4Yrl.js} +17 -18
  20. package/dist/{InventoryBindingForm-CAs2PaKF.js → InventoryBindingForm-DCSBFj6b.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-D62U_Ewm.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-4_i25unG.js} +16 -17
  22. package/dist/{InventoryBindingSummary-DNWMJUDR.js → InventoryBindingSummary-6dFJPewB.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-flGJ-4xe.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CU9mgYbv.js} +5 -5
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CwcKHn69.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DC1HpuMm.js} +2 -2
  25. package/dist/{PublishView-IYCGQZF7.js → PublishView-DO7k1AeP.js} +8 -8
  26. package/dist/{PurchaseOrderPrintPreview-CQ-J1uJn.js → PurchaseOrderPrintPreview-C3VqOLCi.js} +11 -11
  27. package/dist/ReceiveRequestView-CpgLQtbw.js +2806 -0
  28. package/dist/RecipeView-C2D7FdzN.js +646 -0
  29. package/dist/{StockView-F7oGArF7.js → StockView-CtC3ldc6.js} +105 -106
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-j6pS_g4o.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cj6cVmd0.js} +1 -1
  31. package/dist/{SupplierView-DaDXVRF6.js → SupplierView-DKFtc22j.js} +19 -20
  32. package/dist/{SurchargeView-CBkF-szL.js → SurchargeView-B-EYMp6w.js} +6 -6
  33. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BDxbVt07.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CDeeFvnm.js} +2 -2
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DnoutmMc.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CH3hjFS8.js} +1 -1
  35. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-rAyYuhku.js +3493 -0
  36. package/dist/{TransferTemplateView-BlyMl_7M.js → TransferTemplateView-FeC34QoJ.js} +21 -22
  37. package/dist/{UnitView-JRqgYWbI.js → UnitView-BoJisnXd.js} +10 -11
  38. package/dist/{WarehouseView-Cb5Dj6f4.js → WarehouseView-s-xF6xJ0.js} +5 -5
  39. package/dist/{WastageTemplateView-DoyXkHM6.js → WastageTemplateView-BQBlHZLh.js} +14 -14
  40. package/dist/api/inventory.d.ts +36 -126
  41. package/dist/api/netsuite.d.ts +1 -8
  42. package/dist/{app-DMbbrEyL.js → app-_4kRbuQl.js} +7147 -8148
  43. package/dist/app.d.ts +0 -228
  44. package/dist/app.js +1 -1
  45. package/dist/{closing-template-B68c4BCg.js → closing-template-BBWYKm_X.js} +1 -1
  46. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -37
  47. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +0 -14
  48. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -16
  49. package/dist/{date2-WSrIZrGN.js → date2-Cd93SZu4.js} +1 -1
  50. package/dist/{dayjs.min-BEzS3oNC.js → dayjs.min-DeHn_Fz-.js} +16 -16
  51. package/dist/{defineDeepModel-B7GuNHyt.js → defineDeepModel-DUOLQh1E.js} +1 -1
  52. package/dist/{duplicate-template-BTdZ25aR.js → duplicate-template-BgpMF-fd.js} +1 -1
  53. package/dist/{feature-DJFFmYSS.js → feature-DqGkM6Yx.js} +1439 -1334
  54. package/dist/{format-time-from-id-BEqcrmTR.js → format-time-from-id-BkH4swoc.js} +1 -1
  55. package/dist/{format-unit-display-DIqyPFuN.js → format-unit-display-rkrD3WLD.js} +15 -16
  56. package/dist/{import-export.helper-Dnvx2Wa0.js → import-export.helper-C8Q4AMQx.js} +15 -16
  57. package/dist/{index-dh2P5FKl.js → index-B0WTs-3a.js} +1412 -1471
  58. package/dist/{index-J3wFLjDN.js → index-B3m_9m2a.js} +3 -3
  59. package/dist/{index-BNBtrozQ.js → index-O5M93j6z.js} +1 -1
  60. package/dist/{lodash-DoqYeksT.js → lodash-Dj6GdEkm.js} +1 -1
  61. package/dist/{netsuite-C87QvoFY.js → netsuite-DpQxb3vH.js} +60 -60
  62. package/dist/{purchase-order-template-CbRmEHxi.js → purchase-order-template-DKuo07gT.js} +1 -1
  63. package/dist/router/name.d.ts +0 -1
  64. package/dist/rules-D6o4zK8x.js +327 -0
  65. package/dist/{stock-DrdiXQFX.js → stock-D7HQf4-H.js} +1 -1
  66. package/dist/stock-DLFjfcAv.js +75 -0
  67. package/dist/stores/feature.d.ts +0 -2
  68. package/dist/stores/integration/netsuite.d.ts +1 -8
  69. package/dist/stores/inventory.d.ts +30 -119
  70. package/dist/{supplier-DWophRmk.js → supplier-B3kE2tbF.js} +2 -2
  71. package/dist/{surcharge-Ds9TtpDs.js → surcharge-Cc9vownX.js} +1 -1
  72. package/dist/tsconfig.app.tsbuildinfo +1 -1
  73. package/dist/{use-ingredient-select-dialog-CPugamev.js → use-ingredient-select-dialog-MnUTm-3P.js} +2 -2
  74. package/dist/{use-inventory-binding-dialog-Vj7T-h-w.js → use-inventory-binding-dialog-_J9LNiGo.js} +2 -2
  75. package/dist/{use-template-enabled-locations-2-DfKY5avH.js → use-template-enabled-locations-2-B9gbuIPM.js} +2 -2
  76. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -64
  77. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +24 -192
  78. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -8
  79. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +12 -96
  80. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +12 -96
  81. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +18 -18
  82. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +0 -14
  83. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +4 -32
  84. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -28
  85. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -8
  86. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +2 -16
  87. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +5 -33
  88. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -16
  89. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +4 -32
  90. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -8
  91. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +6 -41
  92. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +36 -246
  93. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +42 -287
  94. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +0 -16
  95. package/dist/views/stock/components/StockRecordCard.vue.d.ts +0 -1
  96. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -16
  97. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +2 -16
  98. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +2 -16
  99. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -16
  100. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -8
  101. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +3 -24
  102. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +12 -96
  103. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +12 -96
  104. package/dist/{vue-i18n-Td4-wYd2.js → vue-i18n-BvsTy4Fg.js} +535 -535
  105. package/dist/{xlsx-DFL__z5b.js → xlsx-BvjocXXw.js} +398 -398
  106. package/dist/{xlsx.util-Bi7Vb-wa.js → xlsx.util-D65Nsat4.js} +1 -1
  107. package/package.json +3 -3
  108. package/dist/ReceiveRequestView-NOIHVxoI.js +0 -2916
  109. package/dist/RecipeView-KZV269Yw.js +0 -1558
  110. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B_u8kuNh.js +0 -3354
  111. package/dist/UnitCostHistoryView-B6mco57v.js +0 -651
  112. package/dist/api/unit-cost-history.d.ts +0 -28
  113. package/dist/number-nN9jCKom.js +0 -232
  114. package/dist/rules-Dbz4JyZU.js +0 -98
  115. package/dist/stock-ChSl_QOD.js +0 -75
  116. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -169
  117. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingAlternative.vue.d.ts +0 -43
  118. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingRule.vue.d.ts +0 -25
  119. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +0 -125
  120. package/dist/views/ingredients/components/inventory-binding/v2/components/InventorySkuBindingV2Field.vue.d.ts +0 -129
  121. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-alternative-table.d.ts +0 -30
  122. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +0 -4
  123. package/dist/views/unit-cost-history/UnitCostHistoryView.vue.d.ts +0 -2
  124. package/dist/views/unit-cost-history/components/UnitCostDetailsSideSheet.vue.d.ts +0 -19
  125. package/dist/views/unit-cost-history/components/UnitCostRecalculationDialog.vue.d.ts +0 -11
  126. package/dist/views/unit-cost-history/composables/use-unit-cost-history.d.ts +0 -65
@@ -0,0 +1,2806 @@
1
+ import { computed as q, h as Y, defineComponent as ne, openBlock as b, createElementBlock as T, Fragment as re, renderList as fe, createElementVNode as t, toDisplayString as $, unref as e, resolveComponent as O, createVNode as m, withCtx as A, createCommentVNode as K, ref as U, createBlock as oe, watch as he, normalizeClass as W, normalizeStyle as vt, onMounted as He, createTextVNode as ke, reactive as Vt, mergeProps as je, isRef as ge, createSlots as Pt, Teleport as Rt, normalizeProps as Ot, guardReactiveProps as At } from "vue";
2
+ import { t as de, s as ce, f as yt, M as Mt, B as Et, u as Qe, a as Ye, O as qt, P as Ut, v as Nt, w as bt, m as Ae } from "./app-_4kRbuQl.js";
3
+ import { i as dt, _ as Bt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DJT_7Uus.js";
4
+ import { u as zt, a as Lt, P as Le, b as jt, _ as Ht, g as Qt } from "./TransferDetails.vue_vue_type_script_setup_true_lang-rAyYuhku.js";
5
+ import { R as De, a as _e, e as Ce, d as Yt, A as Ee, M as Kt, h as ct, B as Xt } from "./rules-D6o4zK8x.js";
6
+ import { _ as gt, u as Zt, i as Wt, e as Jt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-DC1HpuMm.js";
7
+ import { d as mt } from "./dayjs.min-DeHn_Fz-.js";
8
+ import { u as Gt } from "./useTabStorage-BkIVScW_.js";
9
+ import { u as eo, _ as to } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
10
+ import { useBreakpoints as Ke, components as pe, FmButtonVariant as oo, useSnackbar as we, useDialog as so, useProxiedModel as _t } from "@feedmepos/ui-library";
11
+ import { F as Ie } from "./form-mode.enum-BKiNVH6A.js";
12
+ import { _ as ao, a as ro, b as lo, F as no } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-MW749j29.js";
13
+ import { F as Me, u as Xe, P as io } from "./feature-DqGkM6Yx.js";
14
+ import { u as qe } from "./netsuite-DpQxb3vH.js";
15
+ import { useI18n as ye } from "@feedmepos/mf-common";
16
+ import { u as uo } from "./surcharge-Cc9vownX.js";
17
+ import { a as co } from "./FmMultiselectDialog-B5paZk6T.js";
18
+ import { F as me, _ as ht } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
19
+ import { u as xt } from "./supplier-B3kE2tbF.js";
20
+ import { d as Ze, e as mo, g as po, b as fo } from "./date2-Cd93SZu4.js";
21
+ import { u as vo, _ as yo } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DN8ziFA_.js";
22
+ import { _ as bo } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
23
+ import { a as kt } from "./format-unit-display-rkrD3WLD.js";
24
+ import { u as We } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-CDeeFvnm.js";
25
+ import { u as go } from "./vue-i18n-BvsTy4Fg.js";
26
+ import { s as _o, r as ho } from "./xlsx.util-D65Nsat4.js";
27
+ import { F as xo } from "./FmDroppableField-J0xUsOTV.js";
28
+ import { d as ko } from "./defineDeepModel-DUOLQh1E.js";
29
+ import { P as Co, J as wo } from "./app-DiX-EfV6.js";
30
+ var te = /* @__PURE__ */ ((y) => (y.Code = "Code", y.Name = "Name", y.TemplateName = "TemplateName", y.Amount = "Amount", y.Cost = "Cost", y.TotalCost = "TotalCost", y.Delete = "Delete", y))(te || {});
31
+ const So = () => Y(
32
+ gt,
33
+ {
34
+ zIndex: 50,
35
+ class: "whitespace-nowrap"
36
+ },
37
+ `Total (${yt()})`
38
+ );
39
+ function Fo(y) {
40
+ const { t: x } = ye(), { breakpoints: d } = Ke(), u = Xe(), g = qe();
41
+ function n(i) {
42
+ const o = y.formController.getAllPurchaseOrderItems().find((s) => s.item.sku._id === i);
43
+ return (o == null ? void 0 : o.isCustomCost) ?? !1;
44
+ }
45
+ function h(i) {
46
+ var s, r, a, _, F, c, f;
47
+ return !!(((r = (s = i.defaultCost) == null ? void 0 : s.costPerUnit) == null ? void 0 : r.amount) ?? ((f = (c = (F = (_ = (a = y.supplier) == null ? void 0 : a.supplyItems) == null ? void 0 : _.find((D) => D.skuId === i._id)) == null ? void 0 : F.defaultCost) == null ? void 0 : c.costPerUnit) == null ? void 0 : f.amount));
48
+ }
49
+ function S(i) {
50
+ if (!n(i.sku._id) && h(i.sku)) {
51
+ const { cost: o, supplierOverrideCost: s } = Me.calculateDefaultCost({
52
+ item: i.sku,
53
+ amount: i.quantity,
54
+ measurement: i.measurement,
55
+ overrides: {
56
+ supplier: y.supplier
57
+ },
58
+ defaultCurrency: ce()
59
+ });
60
+ return { cost: o, supplierOverrideCost: s };
61
+ } else
62
+ return {
63
+ cost: i.totalCost ?? { amount: 0, precision: 0, currency: ce() }
64
+ };
65
+ }
66
+ const V = [
67
+ {
68
+ id: "Code",
69
+ header: () => x("inventory.transfer.form.items.table.Code"),
70
+ accessorKey: "code",
71
+ size: 200,
72
+ cell(i) {
73
+ const o = i.row.original;
74
+ return g.isEnabled ? Y(
75
+ pe.FmTooltip,
76
+ {
77
+ content: o.code,
78
+ placement: "top",
79
+ variant: "plain",
80
+ zIndex: 50
81
+ },
82
+ Y(
83
+ "span",
84
+ {
85
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
86
+ },
87
+ o.code
88
+ )
89
+ ) : Y(pe.FmTextField, {
90
+ modelValue: o.code,
91
+ "onUpdate:modelValue": (s) => {
92
+ y.updateItem({
93
+ ...o,
94
+ code: s
95
+ });
96
+ },
97
+ key: o.sku._id,
98
+ rules: [De()],
99
+ labelMark: "required"
100
+ });
101
+ },
102
+ enableSorting: !1
103
+ },
104
+ {
105
+ id: "Name",
106
+ header: () => x("inventory.transfer.form.items.table.Name"),
107
+ minSize: 300,
108
+ cell(i) {
109
+ const o = i.row.original;
110
+ return g.isEnabled ? Y(
111
+ pe.FmTooltip,
112
+ {
113
+ content: o.name,
114
+ placement: "top",
115
+ variant: "plain",
116
+ zIndex: 50
117
+ },
118
+ Y(
119
+ "span",
120
+ {
121
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
122
+ },
123
+ o.name
124
+ )
125
+ ) : Y(pe.FmTextField, {
126
+ modelValue: o.name,
127
+ "onUpdate:modelValue": (s) => {
128
+ y.updateItem({
129
+ ...o,
130
+ name: s
131
+ });
132
+ },
133
+ key: o.sku._id,
134
+ rules: [De()],
135
+ labelMark: "required"
136
+ });
137
+ },
138
+ enableSorting: !1
139
+ },
140
+ {
141
+ id: "TemplateName",
142
+ header: () => x("inventory.transfer.form.items.table.Name"),
143
+ minSize: 300,
144
+ enableSorting: !1,
145
+ cell(i) {
146
+ const o = i.row.original, s = o.code, r = o.name;
147
+ return Y(
148
+ pe.FmTooltip,
149
+ { zIndex: 50 },
150
+ {
151
+ default() {
152
+ return Y("div", { class: "flex flex-col w-full" }, [
153
+ Y(
154
+ "div",
155
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
156
+ r
157
+ ),
158
+ Y(
159
+ "div",
160
+ {
161
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
162
+ },
163
+ s
164
+ )
165
+ ]);
166
+ },
167
+ content() {
168
+ return r;
169
+ }
170
+ }
171
+ );
172
+ }
173
+ },
174
+ {
175
+ id: "Amount",
176
+ header: () => x("inventory.transfer.form.items.table.Amount"),
177
+ minSize: 200,
178
+ cell(i) {
179
+ var _, F, c, f, D;
180
+ const o = i.row.original, s = (_ = y.forecastAmounts) == null ? void 0 : _.find((M) => M.skuId === o.sku._id), r = s ? s.helperState === "error" ? `Predicted: ${s.amount} (out of range)` : `Predicted: ${s.amount}` : void 0, a = (f = (c = (F = y.template) == null ? void 0 : F.purchaseOrder) == null ? void 0 : c.items) == null ? void 0 : f.find(
181
+ (M) => M.sku._id === o.sku._id
182
+ );
183
+ return Y(ao, {
184
+ style: {
185
+ flex: "1 1 0%"
186
+ },
187
+ modelValue: {
188
+ amount: o.quantity ?? { amount: 1, precision: 0 },
189
+ measurement: o.measurement ?? null
190
+ },
191
+ key: o.sku._id,
192
+ unit: o.sku.unit,
193
+ helperText: r,
194
+ helperState: s == null ? void 0 : s.helperState,
195
+ "onUpdate:modelValue": (M) => {
196
+ if (!M) return;
197
+ const Z = {
198
+ ...o,
199
+ quantity: M.amount,
200
+ measurement: M.measurement
201
+ };
202
+ y.updateItem(Z);
203
+ },
204
+ stepper: a == null ? void 0 : a.quantityStep,
205
+ disableUnit: !!a,
206
+ disabled: y.disabled,
207
+ rules: [
208
+ ro(
209
+ +_e(
210
+ ((D = o.quantity) == null ? void 0 : D.amount) === 0 ? { amount: 0, precision: 0 } : (a == null ? void 0 : a.minimumQuantity) ?? { amount: 0, precision: 0 }
211
+ )
212
+ ),
213
+ lo(
214
+ a != null && a.maximumQuantity ? +_e(a == null ? void 0 : a.maximumQuantity) : 1 / 0
215
+ ),
216
+ ...a != null && a.quantityStep ? [no(a.quantityStep)] : []
217
+ ],
218
+ applyDefaultRules: !0
219
+ });
220
+ },
221
+ enableSorting: !1
222
+ },
223
+ {
224
+ id: "Cost",
225
+ header: So,
226
+ size: 180,
227
+ cell(i) {
228
+ const o = i.row.original, s = h(o.sku), r = d.value.xs || d.value.sm;
229
+ if (!n(o.sku._id) && s) {
230
+ const { cost: a, supplierOverrideCost: _ } = y.formController.getItemCost(
231
+ o,
232
+ ce()
233
+ );
234
+ return Y(
235
+ "div",
236
+ {
237
+ class: [
238
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
239
+ y.disabled ? "text-fm-color-typo-disabled" : ""
240
+ ],
241
+ key: o.sku._id
242
+ },
243
+ [
244
+ u.enablePurchaseOrderCostEdit ? Y(pe.FmButton, {
245
+ prependIcon: "edit",
246
+ variant: oo.Tertiary,
247
+ disabled: y.disabled,
248
+ onClick() {
249
+ y.updateItem(
250
+ {
251
+ ...o,
252
+ totalCost: a
253
+ },
254
+ !0
255
+ );
256
+ }
257
+ }) : null,
258
+ Y(
259
+ "div",
260
+ {
261
+ class: "flex flex-col"
262
+ },
263
+ [
264
+ Y(
265
+ "span",
266
+ r ? Ce(a) : _e(a)
267
+ ),
268
+ Y(
269
+ "span",
270
+ {
271
+ class: [
272
+ "fm-typo-en-body-sm-400",
273
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
274
+ ]
275
+ },
276
+ x("inventory.transfer.form.items.autoCalculated")
277
+ ),
278
+ _ ? Y(
279
+ "span",
280
+ {
281
+ class: [
282
+ "fm-typo-en-body-sm-400",
283
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
284
+ ]
285
+ },
286
+ [
287
+ Ce(_.costPerUnit),
288
+ "/",
289
+ _.measurement ? Y(
290
+ "span",
291
+ { class: "text-blue-500 font-semibold" },
292
+ _.measurement.abbrev
293
+ ) : Y("span", { class: "text-green-500 font-bold" }, o.sku.unit.abbrev)
294
+ // base unit style
295
+ ]
296
+ ) : null
297
+ ]
298
+ )
299
+ ]
300
+ );
301
+ }
302
+ return Y(
303
+ pe.FmTextField,
304
+ {
305
+ disabled: y.disabled || !u.enablePurchaseOrderCostEdit,
306
+ modelValue: _e(o.totalCost ?? { amount: 0, precision: 0 }),
307
+ key: o.sku._id,
308
+ "onUpdate:modelValue": (a) => {
309
+ u.enablePurchaseOrderCostEdit && y.updateItem(
310
+ {
311
+ ...o,
312
+ totalCost: {
313
+ ...Yt(+a),
314
+ currency: ce()
315
+ }
316
+ },
317
+ !0
318
+ );
319
+ },
320
+ rules: [Ee(0), Kt(2)]
321
+ },
322
+ {
323
+ prepend() {
324
+ return r ? Y(
325
+ "div",
326
+ {
327
+ class: [
328
+ "text-fm-typo-en-body-lg-400",
329
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
330
+ ]
331
+ },
332
+ yt()
333
+ ) : null;
334
+ },
335
+ append() {
336
+ return !s || !u.enablePurchaseOrderCostEdit ? null : Y(pe.FmButton, {
337
+ prependIcon: "close",
338
+ variant: "tertiary",
339
+ disabled: y.disabled,
340
+ onClick() {
341
+ const { cost: a } = Me.calculateDefaultCost({
342
+ item: o.sku,
343
+ amount: o.quantity,
344
+ measurement: o.measurement,
345
+ overrides: {
346
+ supplier: y.supplier
347
+ },
348
+ defaultCurrency: ce()
349
+ });
350
+ y.updateItem(
351
+ {
352
+ ...o,
353
+ // NOTE: different from PO template, if a default cost is reenabled,
354
+ // the total cost will automatically assigned
355
+ totalCost: a
356
+ },
357
+ !1
358
+ );
359
+ }
360
+ });
361
+ }
362
+ }
363
+ );
364
+ },
365
+ enableSorting: !1
366
+ },
367
+ {
368
+ id: "Delete",
369
+ header: "",
370
+ cell(i) {
371
+ const o = i.row.original;
372
+ return Y("div", { class: "flex justify-end" }, [
373
+ Y(pe.FmButton, {
374
+ key: o.sku._id,
375
+ class: "delete-button",
376
+ type: "button",
377
+ icon: "delete",
378
+ variant: "tertiary",
379
+ size: "md",
380
+ disabled: y.disabled,
381
+ onClick: () => {
382
+ y.deleteItem(o);
383
+ }
384
+ })
385
+ ]);
386
+ },
387
+ enableSorting: !1,
388
+ size: 40,
389
+ meta: {
390
+ cellClass: "",
391
+ headerClass: ""
392
+ }
393
+ }
394
+ ], w = q(() => u.enableTotalCost && y.transferType === de.enum.purchase ? V : V.filter(
395
+ (i) => i.id !== "Cost"
396
+ /* Cost */
397
+ )), v = q(() => ({
398
+ ...y.items.reduce((o, s) => {
399
+ const { cost: r } = S(s);
400
+ return Me.add([o, r]);
401
+ }, Me.reset()),
402
+ currency: y.items[0] ? S(y.items[0]).cost.currency : ce()
403
+ }));
404
+ return {
405
+ columnDefs: w,
406
+ totalCost: v
407
+ };
408
+ }
409
+ const $o = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Io = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Do = { class: "w-[450px] xs:w-full flex" }, To = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ct = /* @__PURE__ */ ne({
410
+ __name: "SupplierPriceHistory",
411
+ props: {
412
+ prices: {}
413
+ },
414
+ setup(y) {
415
+ const x = xt();
416
+ function d(u) {
417
+ return x.suppliers.find((g) => g._id === u);
418
+ }
419
+ return (u, g) => (b(), T("div", $o, [
420
+ (b(!0), T(re, null, fe(Object.keys(u.prices), (n) => {
421
+ var h;
422
+ return b(), T("div", {
423
+ key: n,
424
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
425
+ }, [
426
+ t("div", Io, $((h = d(n)) == null ? void 0 : h.name), 1),
427
+ t("div", Do, [
428
+ (b(!0), T(re, null, fe(u.prices[n].slice(0, 3), (S) => {
429
+ var V;
430
+ return b(), T("div", {
431
+ key: S.date,
432
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
433
+ }, [
434
+ t("div", To, [
435
+ t("span", null, $(S.totalCost ? e(Ce)(S.totalCost) : "No data"), 1),
436
+ g[0] || (g[0] = t("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
437
+ t("span", null, $(e(_e)(S.totalUnit, !1)), 1),
438
+ t("span", null, $(((V = S.measurement) == null ? void 0 : V.abbrev) ?? S.unit.abbrev), 1)
439
+ ]),
440
+ t("div", Vo, [
441
+ t("span", null, "(#" + $(S.seqNumber) + ")", 1),
442
+ g[1] || (g[1] = t("span", null, $(" "), -1)),
443
+ t("span", null, $(e(Ze)(new Date(S.date))), 1)
444
+ ])
445
+ ]);
446
+ }), 128))
447
+ ])
448
+ ]);
449
+ }), 128))
450
+ ]));
451
+ }
452
+ }), Po = { class: "flex flex-col gap-8 py-16" }, Ro = { class: "flex items-center" }, Oo = { class: "flex-1 flex gap-1 items-center" }, Ao = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Mo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Eo = { class: "flex gap-8 w-full" }, qo = { class: "flex-1 flex flex-col gap-4" }, Uo = { class: "flex-1 flex flex-col gap-4" }, No = { class: "flex gap-8 w-full" }, Bo = { class: "flex-1 flex flex-col gap-4" }, zo = {
453
+ key: 0,
454
+ class: "flex-1 flex flex-col gap-4"
455
+ }, Lo = /* @__PURE__ */ ne({
456
+ __name: "TransferItem",
457
+ props: {
458
+ cellByColId: {},
459
+ comparePriceBySku: {},
460
+ showComparePrice: { type: Boolean },
461
+ row: {}
462
+ },
463
+ setup(y) {
464
+ const { t: x } = ye();
465
+ return (d, u) => {
466
+ var h, S, V, w, v, i, o, s, r, a, _, F, c, f, D, M, Z, z, X, N, B, P, I, E, L, J, se;
467
+ const g = O("FmLabel"), n = O("FmSpacer");
468
+ return b(), T("div", Po, [
469
+ t("div", Ro, [
470
+ t("div", Oo, [
471
+ t("span", Ao, " (" + $(d.row.original.sku.code) + ") ", 1),
472
+ t("span", Mo, $(d.row.original.sku.name), 1)
473
+ ]),
474
+ t("div", null, [
475
+ m(e(me), {
476
+ render: (V = (S = (h = d.cellByColId.Delete) == null ? void 0 : h.column) == null ? void 0 : S.columnDef) == null ? void 0 : V.cell,
477
+ props: (v = (w = d.cellByColId.Delete) == null ? void 0 : w.getContext) == null ? void 0 : v.call(w)
478
+ }, null, 8, ["render", "props"])
479
+ ])
480
+ ]),
481
+ t("div", Eo, [
482
+ t("div", qo, [
483
+ m(g, {
484
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Code}`)
485
+ }, null, 8, ["label"]),
486
+ m(e(me), {
487
+ render: (s = (o = (i = d.cellByColId[e(te).Code]) == null ? void 0 : i.column) == null ? void 0 : o.columnDef) == null ? void 0 : s.cell,
488
+ props: (a = (r = d.cellByColId[e(te).Code]) == null ? void 0 : r.getContext) == null ? void 0 : a.call(r)
489
+ }, null, 8, ["render", "props"]),
490
+ u[0] || (u[0] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
491
+ ]),
492
+ t("div", Uo, [
493
+ m(g, {
494
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Name}`)
495
+ }, null, 8, ["label"]),
496
+ m(e(me), {
497
+ render: (c = (F = (_ = d.cellByColId[e(te).Name]) == null ? void 0 : _.column) == null ? void 0 : F.columnDef) == null ? void 0 : c.cell,
498
+ props: (D = (f = d.cellByColId[e(te).Name]) == null ? void 0 : f.getContext) == null ? void 0 : D.call(f)
499
+ }, null, 8, ["render", "props"]),
500
+ u[1] || (u[1] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
501
+ ])
502
+ ]),
503
+ t("div", No, [
504
+ t("div", Bo, [
505
+ m(g, {
506
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Amount}`)
507
+ }, null, 8, ["label"]),
508
+ m(e(me), {
509
+ render: (z = (Z = (M = d.cellByColId[e(te).Amount]) == null ? void 0 : M.column) == null ? void 0 : Z.columnDef) == null ? void 0 : z.cell,
510
+ props: (N = (X = d.cellByColId[e(te).Amount]) == null ? void 0 : X.getContext) == null ? void 0 : N.call(X)
511
+ }, null, 8, ["render", "props"]),
512
+ u[2] || (u[2] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
513
+ ]),
514
+ d.cellByColId[e(te).Cost] ? (b(), T("div", zo, [
515
+ m(gt, { "z-index": 50 }, {
516
+ default: A(() => [
517
+ m(g, {
518
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Cost}2`)
519
+ }, null, 8, ["label"])
520
+ ]),
521
+ _: 1
522
+ }),
523
+ m(e(me), {
524
+ render: (I = (P = (B = d.cellByColId[e(te).Cost]) == null ? void 0 : B.column) == null ? void 0 : P.columnDef) == null ? void 0 : I.cell,
525
+ props: (L = (E = d.cellByColId[e(te).Cost]) == null ? void 0 : E.getContext) == null ? void 0 : L.call(E)
526
+ }, null, 8, ["render", "props"]),
527
+ u[3] || (u[3] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
528
+ ])) : K("", !0)
529
+ ]),
530
+ d.showComparePrice && Object.keys(d.comparePriceBySku[(J = d.row.original.sku) == null ? void 0 : J._id] ?? {}).length > 0 ? (b(), T(re, { key: 0 }, [
531
+ m(n, { class: "h-8" }),
532
+ m(Ct, {
533
+ prices: d.comparePriceBySku[(se = d.row.original.sku) == null ? void 0 : se._id]
534
+ }, null, 8, ["prices"])
535
+ ], 64)) : K("", !0)
536
+ ]);
537
+ };
538
+ }
539
+ });
540
+ function jo(y) {
541
+ const x = q({
542
+ get() {
543
+ const n = y.getEffectiveAt();
544
+ return n ? new Date(n) : null;
545
+ },
546
+ set(n) {
547
+ y.setEffectiveAt((n == null ? void 0 : n.toISOString()) ?? null);
548
+ }
549
+ }), d = q({
550
+ get() {
551
+ return !!x.value;
552
+ },
553
+ set(n) {
554
+ n ? x.value = /* @__PURE__ */ new Date() : x.value = null;
555
+ }
556
+ }), u = q({
557
+ get() {
558
+ return x.value === null ? "" : Ze(x.value);
559
+ },
560
+ set(n) {
561
+ n ? x.value = /* @__PURE__ */ new Date(`${n} ${g.value}`) : x.value = null;
562
+ }
563
+ }), g = q({
564
+ get() {
565
+ return x.value === null ? "" : mo(x.value);
566
+ },
567
+ set(n) {
568
+ n ? x.value = /* @__PURE__ */ new Date(`${u.value} ${n}`) : x.value = null;
569
+ }
570
+ });
571
+ return {
572
+ backdatePo: x,
573
+ backdateSwitch: d,
574
+ backdateModel: u,
575
+ backdateTimeModel: g
576
+ };
577
+ }
578
+ const Ho = {
579
+ width: "24",
580
+ height: "24",
581
+ viewBox: "0 0 24 24",
582
+ fill: "none",
583
+ xmlns: "http://www.w3.org/2000/svg"
584
+ }, Qo = ["fill"], Yo = ["fill"], Ko = ["stroke"], Xo = ["stroke"], Zo = /* @__PURE__ */ ne({
585
+ __name: "SparkIcon",
586
+ props: {
587
+ size: {
588
+ type: Number,
589
+ default: 24
590
+ },
591
+ color: {
592
+ type: String,
593
+ default: "#c7c7cc"
594
+ }
595
+ },
596
+ setup(y) {
597
+ return (x, d) => (b(), T("svg", Ho, [
598
+ t("path", {
599
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
600
+ fill: y.color
601
+ }, null, 8, Qo),
602
+ t("path", {
603
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
604
+ fill: y.color
605
+ }, null, 8, Yo),
606
+ t("path", {
607
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
608
+ stroke: y.color,
609
+ "stroke-width": "1.5",
610
+ "stroke-linecap": "round",
611
+ "stroke-linejoin": "round"
612
+ }, null, 8, Ko),
613
+ t("path", {
614
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
615
+ stroke: y.color,
616
+ "stroke-width": "1.5",
617
+ "stroke-linecap": "round",
618
+ "stroke-linejoin": "round"
619
+ }, null, 8, Xo)
620
+ ]));
621
+ }
622
+ }), Wo = { class: "flex gap-8 items-center" }, Jo = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Go = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, es = { class: "flex items-center w-full" }, ts = { class: "flex-1" }, os = { class: "fm-typo-en-title-sm-800" }, ss = { class: "flex items-start gap-8" }, as = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, rs = { class: "flex gap-1" }, ls = /* @__PURE__ */ ne({
623
+ __name: "ForecastStock",
624
+ props: {
625
+ templateId: {},
626
+ disabled: { type: Boolean },
627
+ poItems: {},
628
+ templateItems: {}
629
+ },
630
+ emits: ["update:poItems", "update:forecastAmounts", "update:predictionId"],
631
+ setup(y, { emit: x }) {
632
+ const d = y, u = x, g = U(!1), n = U(7), h = Zt(), S = we(), { t: V } = ye();
633
+ function w(s, r, a) {
634
+ return r != null && s < r && (s = r), a != null && s > a && (s = a), s;
635
+ }
636
+ function v(s) {
637
+ if (!((s == null ? void 0 : s.amount) == null || (s == null ? void 0 : s.precision) == null))
638
+ return s.amount / Math.pow(10, s.precision);
639
+ }
640
+ function i({
641
+ sku: s,
642
+ code: r,
643
+ name: a,
644
+ baseAmount: _,
645
+ measurement: F,
646
+ min: c,
647
+ max: f
648
+ }) {
649
+ if (F) {
650
+ const D = F.conversion.amount;
651
+ let M = Math.ceil(_ / D);
652
+ return M = w(M, c, f), {
653
+ sku: s,
654
+ code: r,
655
+ name: a,
656
+ quantity: { amount: M, precision: 0 },
657
+ measurement: F
658
+ };
659
+ } else {
660
+ const D = Math.ceil(w(_, c, f));
661
+ return {
662
+ sku: s,
663
+ code: r,
664
+ name: a,
665
+ quantity: { amount: D, precision: 0 },
666
+ measurement: null
667
+ };
668
+ }
669
+ }
670
+ async function o() {
671
+ const s = ct(0)(n.value);
672
+ if (typeof s == "string") {
673
+ S.open({
674
+ message: s,
675
+ type: "error"
676
+ });
677
+ return;
678
+ }
679
+ g.value = !1, await h.readPurchaseOrder(n.value, d.templateId);
680
+ const r = h.purchaseOrderForecast.skus;
681
+ if (r.length === 0) {
682
+ S.open({
683
+ message: V("inventory.transfer.form.items.forecastStock.notAvailable"),
684
+ type: "info"
685
+ }), u("update:predictionId", h.purchaseOrderForecast.prediction_id);
686
+ return;
687
+ }
688
+ const a = d.templateItems.reduce((F, c) => {
689
+ var Z;
690
+ const f = (Z = d.poItems) == null ? void 0 : Z.find((z) => z.sku._id === c.sku._id), D = r.find((z) => z.id === c.sku._id);
691
+ if (!D)
692
+ return f && F.push(f), F;
693
+ if (!d.templateId && D.amount <= 0) return F;
694
+ const M = D.amount ?? v(f == null ? void 0 : f.quantity) ?? 0;
695
+ return F.push(
696
+ i({
697
+ sku: c.sku,
698
+ code: c.code,
699
+ name: c.name,
700
+ baseAmount: M,
701
+ measurement: c.measurement || null,
702
+ min: v(c.minimumQuantity),
703
+ max: v(c.maximumQuantity)
704
+ })
705
+ ), F;
706
+ }, []), _ = r.map((F) => {
707
+ const c = d.templateItems.find((X) => X.sku._id === F.id);
708
+ let f = F.amount, D = 0;
709
+ if (c != null && c.measurement) {
710
+ const X = v(c.measurement.conversion) ?? 1;
711
+ f = Math.ceil(F.amount / X);
712
+ } else
713
+ f = Math.ceil(F.amount);
714
+ const M = v(c == null ? void 0 : c.minimumQuantity) ?? 0, Z = v(c == null ? void 0 : c.maximumQuantity) ?? 1 / 0, z = f < M || f > Z ? "error" : "success";
715
+ return { skuId: F.id, amount: f, precision: D, helperState: z };
716
+ });
717
+ u("update:poItems", a), u("update:forecastAmounts", _), u("update:predictionId", h.purchaseOrderForecast.prediction_id);
718
+ }
719
+ return (s, r) => {
720
+ const a = O("FmButton"), _ = O("FmIcon"), F = O("FmStepperField"), c = O("FmPopover");
721
+ return b(), oe(c, {
722
+ disabled: s.disabled,
723
+ class: "flex",
724
+ "show-popover": g.value,
725
+ onPopoverChanged: r[3] || (r[3] = (f) => g.value = f)
726
+ }, {
727
+ "popover-button": A(() => [
728
+ m(a, {
729
+ label: "unused",
730
+ variant: "secondary",
731
+ "text-color": s.disabled ? "disabled" : "primary",
732
+ "bg-color": "transparent",
733
+ "border-color": s.disabled ? "disabled" : "primary",
734
+ disabled: s.disabled
735
+ }, {
736
+ default: A(() => [
737
+ t("div", Wo, [
738
+ m(Zo, {
739
+ size: 24,
740
+ color: s.disabled ? "#c7c7cc" : "#ff7823"
741
+ }, null, 8, ["color"]),
742
+ t("div", Jo, $(e(V)("inventory.transfer.form.items.forecastStock.title")), 1)
743
+ ])
744
+ ]),
745
+ _: 1
746
+ }, 8, ["text-color", "border-color", "disabled"])
747
+ ]),
748
+ default: A(() => [
749
+ t("div", Go, [
750
+ t("div", es, [
751
+ t("div", ts, [
752
+ m(bo, { "z-index": 99 }, {
753
+ default: A(() => [
754
+ t("p", os, $(e(V)("inventory.transfer.form.items.forecastStock.title")), 1)
755
+ ]),
756
+ _: 1
757
+ })
758
+ ]),
759
+ m(a, {
760
+ icon: "close",
761
+ size: "md",
762
+ variant: "tertiary",
763
+ onClick: r[0] || (r[0] = (f) => g.value = !1)
764
+ })
765
+ ]),
766
+ m(F, {
767
+ modelValue: n.value,
768
+ "onUpdate:modelValue": r[1] || (r[1] = (f) => n.value = f),
769
+ label: e(V)("inventory.transfer.form.items.forecastStock.days"),
770
+ rules: [e(ct)(0)]
771
+ }, {
772
+ "helper-text": A(() => [
773
+ t("div", ss, [
774
+ m(_, {
775
+ name: "warning",
776
+ size: "sm",
777
+ class: "text-fm-color-system-warning-300"
778
+ }),
779
+ t("div", as, $(e(V)("inventory.transfer.form.items.forecastStock.replace")), 1)
780
+ ])
781
+ ]),
782
+ _: 1
783
+ }, 8, ["modelValue", "label", "rules"]),
784
+ t("div", rs, [
785
+ r[4] || (r[4] = t("div", { class: "grow" }, null, -1)),
786
+ m(a, {
787
+ label: e(V)("common.cancel"),
788
+ variant: "tertiary",
789
+ onClick: r[2] || (r[2] = (f) => g.value = !1)
790
+ }, null, 8, ["label"]),
791
+ m(a, {
792
+ label: e(V)("inventory.transfer.form.items.forecastStock.generate"),
793
+ onClick: o
794
+ }, null, 8, ["label"])
795
+ ])
796
+ ])
797
+ ]),
798
+ _: 1
799
+ }, 8, ["disabled", "show-popover"]);
800
+ };
801
+ }
802
+ });
803
+ function ns() {
804
+ const y = we(), x = We(), d = U(!1);
805
+ he(d, (h) => {
806
+ h && (g.value = !0, u().finally(() => {
807
+ g.value = !1;
808
+ }));
809
+ });
810
+ async function u() {
811
+ try {
812
+ const { startDate: h, endDate: S } = po(6), v = (await x.getPurchaseOrders({ start: h, end: S })).filter(
813
+ (i) => {
814
+ var o, s;
815
+ return i.status === Mt.enum.COMPLETE && ((o = i.supplier) == null ? void 0 : o.internal) !== "warehouse" && ((s = i.supplier) == null ? void 0 : s.internal) !== "restaurant";
816
+ }
817
+ ).reduce((i, o) => {
818
+ const s = new Date(Et(o._id)), r = o.supplier._id;
819
+ for (const a of o.items) {
820
+ if (!a.totalCost) continue;
821
+ const _ = i[a.sku._id] ?? {}, F = _[r] ?? [];
822
+ F.push({
823
+ date: s.toISOString(),
824
+ totalUnit: a.quantity,
825
+ totalCost: a.totalCost,
826
+ unit: a.sku.unit,
827
+ measurement: a.measurement,
828
+ seqNumber: o.seqNumber
829
+ }), _[r] = F, i[a.sku._id] = _;
830
+ }
831
+ return i;
832
+ }, {});
833
+ n.value = v;
834
+ } catch {
835
+ y.open({
836
+ title: "Something went wrong",
837
+ message: "Cannot retrieve supplier purchase history. Please try again."
838
+ }), d.value = !1;
839
+ }
840
+ }
841
+ const g = U(!1), n = U({});
842
+ return {
843
+ comparePricesToggle: d,
844
+ comparePriceFetching: g,
845
+ comparePriceBySku: n
846
+ };
847
+ }
848
+ const is = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, us = { key: 0 }, ds = ["colspan"], cs = /* @__PURE__ */ ne({
849
+ __name: "TransferItemTable",
850
+ props: {
851
+ templateItem: {},
852
+ row: {},
853
+ comparePriceBySku: {},
854
+ showComparePrice: { type: Boolean },
855
+ disabled: { type: Boolean }
856
+ },
857
+ emits: ["update:item"],
858
+ setup(y) {
859
+ function x(d) {
860
+ return d.column.columnDef.meta;
861
+ }
862
+ return (d, u) => {
863
+ var g, n;
864
+ return b(), T(re, null, [
865
+ t("tr", {
866
+ class: W(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
867
+ "bg-fm-color-neutral-gray-100": d.row.getIsSelected()
868
+ }])
869
+ }, [
870
+ (b(!0), T(re, null, fe(d.row.getVisibleCells(), (h) => {
871
+ var S, V, w, v;
872
+ return b(), T("td", {
873
+ key: h.id,
874
+ class: W(["h-[56px] text-fm-color-typo-primary", ((S = x(h)) == null ? void 0 : S.cellClass) ?? "px-16"]),
875
+ style: vt({
876
+ width: (V = x(h)) == null ? void 0 : V.width,
877
+ maxWidth: (w = x(h)) == null ? void 0 : w.maxWidth,
878
+ textAlign: ((v = x(h)) == null ? void 0 : v.textAlign) ?? "left"
879
+ })
880
+ }, [
881
+ t("span", is, [
882
+ m(e(me), {
883
+ render: h.column.columnDef.cell,
884
+ props: h.getContext()
885
+ }, null, 8, ["render", "props"])
886
+ ])
887
+ ], 6);
888
+ }), 128))
889
+ ], 2),
890
+ d.showComparePrice && Object.keys(d.comparePriceBySku[(g = d.row.original.sku) == null ? void 0 : g._id] ?? {}).length > 0 ? (b(), T("tr", us, [
891
+ t("td", {
892
+ colspan: d.row.getVisibleCells().length
893
+ }, [
894
+ m(Ct, {
895
+ prices: d.comparePriceBySku[(n = d.row.original.sku) == null ? void 0 : n._id]
896
+ }, null, 8, ["prices"])
897
+ ], 8, ds)
898
+ ])) : K("", !0)
899
+ ], 64);
900
+ };
901
+ }
902
+ }), ms = {
903
+ key: 0,
904
+ class: "flex flex-col gap-8"
905
+ }, ps = { class: "flex flex-col gap-4" }, fs = { class: "flex items-center gap-4" }, vs = {
906
+ key: 0,
907
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
908
+ }, ys = /* @__PURE__ */ ne({
909
+ __name: "NetSuiteField",
910
+ props: {
911
+ required: { type: Boolean },
912
+ disabled: { type: Boolean },
913
+ subsidiaryOptional: { type: Boolean },
914
+ supplier: {},
915
+ setting: {},
916
+ items: {},
917
+ onChange: { type: Function }
918
+ },
919
+ emits: ["netsuite:ready"],
920
+ setup(y, { emit: x }) {
921
+ const d = qe(), u = y, g = x, { t: n } = go(), h = U(!1), S = U();
922
+ function V() {
923
+ var s, r, a, _;
924
+ if (!u.supplier) return;
925
+ u.supplier.internal ? S.value = d.getNetSuiteLocation(
926
+ `${u.supplier.internal}_${u.supplier._id}`
927
+ ) : S.value = d.getNetSuiteVendor(u.supplier._id);
928
+ const i = u.supplier.internal ? d.getLocationSubsidiary((s = S.value) == null ? void 0 : s.netSuiteId).id : (r = S.value) == null ? void 0 : r.subsidiaryId, o = u.supplier.internal ? (a = d.currentLocationSubsidiary()) == null ? void 0 : a.id : (_ = d.currentVendorSubsidiary(u.supplier._id)) == null ? void 0 : _.id;
929
+ h.value = !(!d.isEnabled || i && d.isEnabled && i == o);
930
+ }
931
+ he(
932
+ () => u.supplier,
933
+ () => {
934
+ u.subsidiaryOptional && V();
935
+ },
936
+ { deep: !0 }
937
+ ), He(() => {
938
+ let i = {
939
+ id: "",
940
+ subsidiary: { id: "", name: "" },
941
+ errors: []
942
+ };
943
+ if (d.isReady) {
944
+ if (!d.isEnabled || !u.required) {
945
+ g("netsuite:ready", i);
946
+ return;
947
+ }
948
+ try {
949
+ const o = d.currentLocationSubsidiary();
950
+ u.setting ? i = {
951
+ ...u.setting,
952
+ subsidiary: {
953
+ id: o.id || "",
954
+ name: o.name
955
+ }
956
+ } : i = {
957
+ ...i,
958
+ subsidiary: {
959
+ id: o.id || "",
960
+ name: o.name
961
+ }
962
+ };
963
+ const s = d.getAvailableItems(o.id), r = u.items.filter((a) => {
964
+ if (a.measurement != null) {
965
+ const _ = d.getAvailableMeasurements(
966
+ a.sku._id,
967
+ o.id
968
+ );
969
+ return s.includes(a.sku._id) && _.includes(a.measurement.id);
970
+ }
971
+ return s.includes(a.sku._id);
972
+ }).map((a) => a.sku._id);
973
+ u.onChange(
974
+ u.items.filter((a) => r.includes(a.sku._id)),
975
+ i
976
+ );
977
+ } finally {
978
+ V(), h.value ? u.subsidiaryOptional && g("netsuite:ready", i) : g("netsuite:ready", i);
979
+ }
980
+ }
981
+ });
982
+ const w = q(
983
+ () => u.supplier.internal ? d.currentLocationSubsidiary() : d.currentVendorSubsidiary(u.supplier._id)
984
+ ), v = q(() => {
985
+ var i, o;
986
+ return S.value == null ? `Cannot find the NetSuite location for "${u.supplier.name}"` : `The subsidiary of the request
987
+ location is ${(o = d.getLocationSubsidiary((i = S.value) == null ? void 0 : i.netSuiteId)) == null ? void 0 : o.fullName}`;
988
+ });
989
+ return (i, o) => {
990
+ const s = O("FmLabel"), r = O("FmIcon"), a = O("FmField"), _ = O("FmTooltip");
991
+ return e(d).isEnabled && u.required ? (b(), T("div", ms, [
992
+ m(s, {
993
+ label: `NetSuite ${e(n)("inventory.transfer.form.netsuite.subsidiary")}`
994
+ }, null, 8, ["label"]),
995
+ t("div", ps, [
996
+ m(_, {
997
+ "z-index": 51,
998
+ placement: "left",
999
+ disabled: i.disabled
1000
+ }, {
1001
+ content: A(() => o[0] || (o[0] = [
1002
+ ke("This field is locked and based on the location of the request.")
1003
+ ])),
1004
+ default: A(() => [
1005
+ m(a, null, {
1006
+ default: A(() => {
1007
+ var F;
1008
+ return [
1009
+ t("div", fs, [
1010
+ m(r, {
1011
+ name: "lock_outline",
1012
+ size: "sm",
1013
+ color: i.disabled ? "neutral-gray-200" : "neutral-gray-400"
1014
+ }, null, 8, ["color"]),
1015
+ t("div", {
1016
+ class: W([i.disabled ? "text-fm-color-typo-disabled" : ""])
1017
+ }, $((F = w.value) == null ? void 0 : F.fullName), 3)
1018
+ ])
1019
+ ];
1020
+ }),
1021
+ _: 1
1022
+ })
1023
+ ]),
1024
+ _: 1
1025
+ }, 8, ["disabled"]),
1026
+ h.value ? (b(), T("div", vs, $(v.value), 1)) : K("", !0)
1027
+ ])
1028
+ ])) : K("", !0);
1029
+ };
1030
+ }
1031
+ }), bs = { class: "flex flex-col gap-4" }, gs = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, _s = { class: "flex flex-col gap-16" }, hs = { class: "flex flex-col gap-24" }, xs = { class: "flex flex-col gap-8" }, ks = { class: "flex flex-col gap-4" }, Cs = { class: "flex items-center gap-4" }, ws = { class: "flex flex-col gap-8" }, Ss = { class: "flex flex-col gap-4" }, Fs = { class: "flex items-center gap-4" }, $s = {
1032
+ key: 3,
1033
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1034
+ }, Is = {
1035
+ key: 0,
1036
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1037
+ }, Ds = { class: "flex-1" }, Ts = { class: "flex-1" }, Vs = {
1038
+ key: 1,
1039
+ class: "flex items-center gap-4"
1040
+ }, Ps = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Rs = { class: "flex flex-col gap-16" }, Os = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, As = { class: "flex gap-8" }, Ms = { key: 0 }, Es = {
1041
+ key: 0,
1042
+ class: "flex justify-end p-16 border-t border-fm-color-neutral-gray-300"
1043
+ }, qs = { class: "flex items-center gap-16" }, Us = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, Ns = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Bs = {
1044
+ key: 1,
1045
+ class: "flex flex-col gap-16"
1046
+ }, zs = { class: "flex items-center gap-8" }, Ls = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, js = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-8" }, Hs = { class: "flex flex-col gap-8 border border-fm-color-neutral-gray-300 fm-corner-radius-md overflow-hidden" }, Qs = { class: "flex flex-col gap-4 flex-1" }, Ys = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ks = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary whitespace-nowrap ml-16" }, Zs = /* @__PURE__ */ ne({
1047
+ __name: "TransferFormWithController",
1048
+ props: {
1049
+ modelValue: {},
1050
+ request: {},
1051
+ disabled: { type: Boolean },
1052
+ suppliers: {},
1053
+ skus: {},
1054
+ lastClosingDate: {}
1055
+ },
1056
+ emits: ["validation-success", "form:ready"],
1057
+ setup(y, { expose: x, emit: d }) {
1058
+ const u = y, g = d, { t: n } = ye(), h = Qe(), S = Ye(), V = uo(), w = Xe(), v = kt(), { breakpoints: i } = Ke(), o = q(() => i.value.xs || i.value.sm), s = zt();
1059
+ s.init(u.modelValue);
1060
+ const { controller: r, state: a } = s, _ = Vt({
1061
+ value: !1
1062
+ }), F = U(!1), c = U(0), f = U([]), D = U(void 0), M = q(
1063
+ () => {
1064
+ var l;
1065
+ return ((l = u.modelValue) == null ? void 0 : l.templateDoc) ?? v.templates.find((p) => {
1066
+ var j;
1067
+ return p._id === ((j = u.modelValue) == null ? void 0 : j.template);
1068
+ });
1069
+ }
1070
+ ), Z = q(() => a.value.status === "DRAFT" || !a.value.rev), z = q(
1071
+ () => {
1072
+ var l;
1073
+ return ((l = a.value.items) == null ? void 0 : l.map((p) => p.item)) || [];
1074
+ }
1075
+ );
1076
+ He(async () => {
1077
+ await V.browse(), F.value = !0;
1078
+ }), he([F, _], ([l, p], [j, H]) => {
1079
+ p.value && H.value && g("form:ready");
1080
+ });
1081
+ const X = q(
1082
+ () => h.currentLocation.type === qt.restaurant
1083
+ ), N = so(), B = vo(
1084
+ () => a.value,
1085
+ (l) => {
1086
+ r.value.selectSupplier(l.supplier._id);
1087
+ },
1088
+ !0,
1089
+ !w.businessSupplierOnly
1090
+ ), P = q({
1091
+ get() {
1092
+ var l;
1093
+ return typeof ((l = a.value.supplier) == null ? void 0 : l.internal) == "string" ? de.enum.transfer : de.enum.purchase;
1094
+ },
1095
+ set(l) {
1096
+ r.value.selectType(l);
1097
+ }
1098
+ }), I = q(() => {
1099
+ let l = B.transferLocationOptions.value;
1100
+ return w.mustUsePoTemplate && !a.value.template && (l = l.filter((p) => {
1101
+ var j;
1102
+ return (j = p.sublabel) == null ? void 0 : j.startsWith("restaurant");
1103
+ })), l;
1104
+ }), E = q({
1105
+ get() {
1106
+ var l;
1107
+ return (l = a.value.supplier) == null ? void 0 : l._id;
1108
+ },
1109
+ set(l) {
1110
+ B.transferLocationModel.value = l;
1111
+ }
1112
+ }), L = q({
1113
+ get() {
1114
+ return a.value.remark ?? "";
1115
+ },
1116
+ set(l) {
1117
+ r.value.addRemark(l ?? "");
1118
+ }
1119
+ }), J = q({
1120
+ get() {
1121
+ return a.value.ref ?? "";
1122
+ },
1123
+ set(l) {
1124
+ r.value.addReference(l ?? "");
1125
+ }
1126
+ }), { backdatePo: se, backdateSwitch: k, backdateModel: C, backdateTimeModel: Q } = jo({
1127
+ getEffectiveAt() {
1128
+ return a.value.effectiveAt;
1129
+ },
1130
+ setEffectiveAt(l) {
1131
+ r.value.setEffectiveAt(l);
1132
+ }
1133
+ }), { comparePricesToggle: le, comparePriceFetching: ie, comparePriceBySku: ee } = ns(), be = U();
1134
+ x({
1135
+ validateInputs: () => {
1136
+ var l, p;
1137
+ (p = (l = be.value) == null ? void 0 : l.validateInputs) == null || p.call(l);
1138
+ },
1139
+ resetInputsValidation: () => {
1140
+ var l, p;
1141
+ (p = (l = be.value) == null ? void 0 : l.resetInputsValidation) == null || p.call(l);
1142
+ },
1143
+ resetInputs: () => {
1144
+ var l, p;
1145
+ (p = (l = be.value) == null ? void 0 : l.resetInputs) == null || p.call(l);
1146
+ },
1147
+ getFormData: () => {
1148
+ r.value.prepareForSubmit();
1149
+ const p = !!(a.value.id && a.value.rev) ? r.value.toUpdateData() : r.value.toCreateData();
1150
+ return D.value ? { ...p, predictionId: D.value } : p;
1151
+ }
1152
+ });
1153
+ const ve = q(() => ({
1154
+ updateItem: (l, p) => {
1155
+ const j = Ut.parse(l), H = r.value.toFdtoPOItem(j), ae = r.value.getSkuInfo(l.sku), ue = {
1156
+ ...H,
1157
+ isCustomCost: p ?? ae.isCustomCost
1158
+ };
1159
+ r.value.updateSkuInfo(ue);
1160
+ },
1161
+ deleteItem: (l) => {
1162
+ r.value.removeSku(l.sku);
1163
+ }
1164
+ })), Te = Fo({
1165
+ formController: r.value,
1166
+ updateItem: (l, p) => ve.value.updateItem(l, p),
1167
+ deleteItem: (l) => ve.value.deleteItem(l),
1168
+ get supplier() {
1169
+ return a.value.supplier;
1170
+ },
1171
+ get items() {
1172
+ return z.value;
1173
+ },
1174
+ get transferType() {
1175
+ return P.value;
1176
+ },
1177
+ get template() {
1178
+ return M.value;
1179
+ },
1180
+ get disabled() {
1181
+ return u.disabled;
1182
+ },
1183
+ get forecastAmounts() {
1184
+ return f.value;
1185
+ }
1186
+ }), Ve = q(() => Te.columnDefs.value);
1187
+ function Pe() {
1188
+ const l = r.value.getSkuOptions(), p = z.value.map((H) => H.sku._id), j = [
1189
+ {
1190
+ type: "string",
1191
+ key: "tags",
1192
+ entity: "item",
1193
+ values: ["Inactive", "Active"]
1194
+ }
1195
+ ];
1196
+ N.open({
1197
+ title: n("inventory.transfer.form.items.selectItem"),
1198
+ closeButton: !0,
1199
+ contentComponent: co,
1200
+ contentComponentProps: {
1201
+ modelValue: p,
1202
+ items: l,
1203
+ virtualScroll: !0,
1204
+ filterAttributes: j
1205
+ },
1206
+ primaryActions: {
1207
+ text: n("common.confirm"),
1208
+ close: !0
1209
+ },
1210
+ secondaryActions: {
1211
+ text: n("common.close"),
1212
+ close: !0,
1213
+ variant: "tertiary"
1214
+ }
1215
+ }).onPrimary((H) => {
1216
+ r.value.applySelectedSku(new Set(H));
1217
+ });
1218
+ }
1219
+ function Ue(l) {
1220
+ return l;
1221
+ }
1222
+ const xe = q(() => {
1223
+ var l;
1224
+ return M.value ? ((l = M.value) == null ? void 0 : l.purchaseOrder.items) || [] : S.skus.map((p) => ({
1225
+ quantity: {
1226
+ amount: 0,
1227
+ precision: 0
1228
+ },
1229
+ name: p.name,
1230
+ code: p.code,
1231
+ sku: p,
1232
+ quantityStep: {
1233
+ amount: 0,
1234
+ precision: 0
1235
+ },
1236
+ measurement: p.trackingMeasurement ? p.unit.measurements.find((j) => j.id === p.trackingMeasurement) : null
1237
+ }));
1238
+ }), Se = q(() => {
1239
+ const l = [];
1240
+ return (!w.mustUsePoTemplate || w.mustUsePoTemplate && a.value.template) && l.push({
1241
+ label: n("inventory.transfer.form.type.purchase"),
1242
+ value: de.enum.purchase
1243
+ }), l.push({
1244
+ label: n("inventory.transfer.form.type.transfer"),
1245
+ value: de.enum.transfer
1246
+ }), l;
1247
+ }), Fe = q(
1248
+ () => {
1249
+ var l;
1250
+ return ((l = a.value.items) == null ? void 0 : l.every((p) => p.item.quantity.amount <= 0)) ?? !0;
1251
+ }
1252
+ );
1253
+ function Re(l) {
1254
+ if (!l) return "";
1255
+ const p = [];
1256
+ if (l.$and && Array.isArray(l.$and))
1257
+ for (const j of l.$and) {
1258
+ if (j.supplierId && j.supplierId.$eq) {
1259
+ const H = I.value.find((ae) => ae.value === j.supplierId.$eq);
1260
+ H && p.push(`Supplier: ${H.label}`);
1261
+ }
1262
+ if (j.totalCost) {
1263
+ const H = j.totalCost;
1264
+ let ae = "", ue = 0;
1265
+ if (H.$lt !== void 0 ? (ae = "<", ue = H.$lt) : H.$lte !== void 0 ? (ae = "≤", ue = H.$lte) : H.$gt !== void 0 ? (ae = ">", ue = H.$gt) : H.$gte !== void 0 ? (ae = "≥", ue = H.$gte) : H.$eq !== void 0 && (ae = "=", ue = H.$eq), ae) {
1266
+ const Oe = ce();
1267
+ p.push(`Total cost ${ae} ${Oe} ${ue.toFixed(2)}`);
1268
+ }
1269
+ }
1270
+ }
1271
+ return p.length > 0 ? p.join(" and ") : "Always applied";
1272
+ }
1273
+ return (l, p) => {
1274
+ var et, tt;
1275
+ const j = O("FmChip"), H = O("FmLabel"), ae = O("FmIcon"), ue = O("FmField"), Oe = O("FmTooltip"), Je = O("FmSelect"), wt = O("FmTextField"), St = O("FmTextarea"), Ge = O("FmSwitch"), Ft = O("FmDatePicker"), $t = O("FmTimePicker"), Ne = O("FmFormGroup"), It = O("FmButton"), Dt = O("FmTable"), Tt = O("FmForm");
1276
+ return b(), T("div", bs, [
1277
+ t("div", gs, [
1278
+ (et = u.modelValue) != null && et.template ? (b(), oe(j, {
1279
+ key: 0,
1280
+ variant: l.disabled ? "warning" : void 0,
1281
+ label: `${e(n)("inventory.transfer.template.title")}: ${((tt = M.value) == null ? void 0 : tt.name) ?? e(n)("inventory.transfer.form.loading")}`,
1282
+ icon: "summarize",
1283
+ compact: ""
1284
+ }, null, 8, ["variant", "label"])) : K("", !0),
1285
+ m(j, {
1286
+ label: e(h).currentLocation.name,
1287
+ icon: "storefront",
1288
+ compact: ""
1289
+ }, null, 8, ["label"]),
1290
+ l.lastClosingDate ? (b(), oe(j, {
1291
+ key: 1,
1292
+ label: `${e(n)("inventory.transfer.form.lastClosing")}: ${e(Ze)(l.lastClosingDate)} ${e(fo)(l.lastClosingDate)}`,
1293
+ icon: "calendar_month",
1294
+ compact: ""
1295
+ }, null, 8, ["label"])) : K("", !0)
1296
+ ]),
1297
+ m(Tt, {
1298
+ ref_key: "formRef",
1299
+ ref: be,
1300
+ class: "flex flex-col gap-32",
1301
+ disabled: l.disabled,
1302
+ onValidationFailed: console.log,
1303
+ onValidationSuccess: p[15] || (p[15] = (Be) => g("validation-success"))
1304
+ }, {
1305
+ default: A(() => {
1306
+ var Be, ot, st, at, rt, lt, nt;
1307
+ return [
1308
+ t("div", _s, [
1309
+ t("div", hs, [
1310
+ (Be = u.modelValue) != null && Be.template ? (b(), T(re, { key: 0 }, [
1311
+ t("div", xs, [
1312
+ m(H, {
1313
+ label: e(n)("inventory.transfer.form.type.title")
1314
+ }, null, 8, ["label"]),
1315
+ t("div", ks, [
1316
+ m(Oe, {
1317
+ "z-index": 51,
1318
+ placement: "left",
1319
+ disabled: l.disabled
1320
+ }, {
1321
+ content: A(() => p[16] || (p[16] = [
1322
+ ke("This field is locked from template.")
1323
+ ])),
1324
+ default: A(() => [
1325
+ m(ue, null, {
1326
+ default: A(() => [
1327
+ t("div", Cs, [
1328
+ m(ae, {
1329
+ name: "lock_outline",
1330
+ size: "sm",
1331
+ color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1332
+ }, null, 8, ["color"]),
1333
+ t("div", {
1334
+ class: W({ "text-fm-color-typo-disabled": l.disabled })
1335
+ }, $(e(n)(`inventory.transfer.form.type.${P.value.toLocaleLowerCase("en-us")}`)), 3)
1336
+ ])
1337
+ ]),
1338
+ _: 1
1339
+ })
1340
+ ]),
1341
+ _: 1
1342
+ }, 8, ["disabled"]),
1343
+ t("div", {
1344
+ class: W([
1345
+ "fm-typo-en-body-sm-400",
1346
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1347
+ ])
1348
+ }, null, 2)
1349
+ ])
1350
+ ]),
1351
+ t("div", ws, [
1352
+ m(H, {
1353
+ label: P.value === e(de).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom")
1354
+ }, null, 8, ["label"]),
1355
+ t("div", Ss, [
1356
+ m(Oe, {
1357
+ "z-index": 51,
1358
+ placement: "left",
1359
+ disabled: l.disabled
1360
+ }, {
1361
+ content: A(() => p[17] || (p[17] = [
1362
+ ke("This field is locked from template.")
1363
+ ])),
1364
+ default: A(() => [
1365
+ m(ue, null, {
1366
+ default: A(() => {
1367
+ var R;
1368
+ return [
1369
+ t("div", Fs, [
1370
+ m(ae, {
1371
+ name: "lock_outline",
1372
+ size: "sm",
1373
+ color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1374
+ }, null, 8, ["color"]),
1375
+ t("div", {
1376
+ class: W({ "text-fm-color-typo-disabled": l.disabled })
1377
+ }, $((R = I.value.find((G) => G.value === E.value)) == null ? void 0 : R.label), 3)
1378
+ ])
1379
+ ];
1380
+ }),
1381
+ _: 1
1382
+ })
1383
+ ]),
1384
+ _: 1
1385
+ }, 8, ["disabled"])
1386
+ ])
1387
+ ])
1388
+ ], 64)) : (b(), T(re, { key: 1 }, [
1389
+ m(Je, {
1390
+ label: e(n)("inventory.transfer.form.type.title"),
1391
+ "label-mark": "required",
1392
+ modelValue: P.value,
1393
+ "onUpdate:modelValue": p[0] || (p[0] = (R) => P.value = R),
1394
+ items: Se.value,
1395
+ rules: [e(Ee)(1)(Se.value)]
1396
+ }, {
1397
+ default: A(() => [
1398
+ t("span", {
1399
+ class: W([
1400
+ "line-clamp-1 fm-typo-en-body-lg-400",
1401
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1402
+ ])
1403
+ }, $(e(Nt)(P.value)), 3)
1404
+ ]),
1405
+ _: 1
1406
+ }, 8, ["label", "modelValue", "items", "rules"]),
1407
+ m(Je, {
1408
+ label: P.value === e(de).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
1409
+ "label-mark": "required",
1410
+ modelValue: E.value,
1411
+ "onUpdate:modelValue": p[1] || (p[1] = (R) => E.value = R),
1412
+ items: I.value,
1413
+ rules: [e(Ee)(1)(I.value)]
1414
+ }, {
1415
+ "menu-wrapper": A((R) => {
1416
+ var G, $e;
1417
+ return [
1418
+ m(yo, je(R, {
1419
+ items: I.value,
1420
+ "model-value": ($e = (G = l.modelValue) == null ? void 0 : G.supplier) == null ? void 0 : $e._id
1421
+ }), null, 16, ["items", "model-value"])
1422
+ ];
1423
+ }),
1424
+ default: A(() => {
1425
+ var R;
1426
+ return [
1427
+ t("span", {
1428
+ class: W([
1429
+ "line-clamp-1 fm-typo-en-body-lg-400",
1430
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1431
+ ])
1432
+ }, $((R = I.value.find((G) => G.value === E.value)) == null ? void 0 : R.label), 3)
1433
+ ];
1434
+ }),
1435
+ _: 1
1436
+ }, 8, ["label", "modelValue", "items", "rules"])
1437
+ ], 64)),
1438
+ m(wt, {
1439
+ label: e(n)("inventory.transfer.form.reference"),
1440
+ "label-mark": "optional",
1441
+ modelValue: J.value,
1442
+ "onUpdate:modelValue": p[2] || (p[2] = (R) => J.value = R)
1443
+ }, null, 8, ["label", "modelValue"]),
1444
+ m(St, {
1445
+ label: e(n)("inventory.transfer.form.remark"),
1446
+ "label-mark": "optional",
1447
+ "max-length": 240,
1448
+ modelValue: L.value,
1449
+ "onUpdate:modelValue": p[3] || (p[3] = (R) => L.value = R),
1450
+ class: W([l.disabled ? "text-fm-color-typo-disabled " : ""])
1451
+ }, null, 8, ["label", "modelValue", "class"]),
1452
+ F.value ? (b(), oe(ys, {
1453
+ key: 2,
1454
+ required: e(a).template != null || e(a).netSuite != null,
1455
+ subsidiaryOptional: e(a).template == null,
1456
+ disabled: l.disabled,
1457
+ supplier: e(a).supplier,
1458
+ setting: e(a).netSuite,
1459
+ items: z.value,
1460
+ onChange: (R, G) => {
1461
+ e(r).setNetSuiteSetting(G);
1462
+ },
1463
+ "onNetsuite:ready": p[4] || (p[4] = (R) => {
1464
+ _.value = !0;
1465
+ })
1466
+ }, null, 8, ["required", "subsidiaryOptional", "disabled", "supplier", "setting", "items", "onChange"])) : K("", !0),
1467
+ e(w).enableBackdatePo ? (b(), T("div", $s, [
1468
+ t("div", {
1469
+ class: W([
1470
+ "flex",
1471
+ {
1472
+ "flex-col": o.value
1473
+ }
1474
+ ])
1475
+ }, [
1476
+ m(Ge, {
1477
+ modelValue: e(k),
1478
+ "onUpdate:modelValue": p[5] || (p[5] = (R) => ge(k) ? k.value = R : null),
1479
+ label: e(n)("inventory.transfer.form.backdate.title"),
1480
+ sublabel: e(n)("inventory.transfer.form.backdate.subtitle"),
1481
+ "label-placement": "right",
1482
+ disabled: X.value && !l.lastClosingDate || l.disabled
1483
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1484
+ t("div", {
1485
+ class: W({ hidden: o.value, "w-16": !o.value })
1486
+ }, null, 2),
1487
+ e(k) ? (b(), T("div", Is, [
1488
+ t("div", Ds, [
1489
+ m(Ft, {
1490
+ modelValue: e(C),
1491
+ "onUpdate:modelValue": p[6] || (p[6] = (R) => ge(C) ? C.value = R : null)
1492
+ }, null, 8, ["modelValue"])
1493
+ ]),
1494
+ t("div", Ts, [
1495
+ m($t, {
1496
+ modelValue: e(Q),
1497
+ "onUpdate:modelValue": p[7] || (p[7] = (R) => ge(Q) ? Q.value = R : null)
1498
+ }, null, 8, ["modelValue"])
1499
+ ])
1500
+ ])) : K("", !0)
1501
+ ], 2),
1502
+ e(se) ? (b(), oe(Ne, {
1503
+ key: 0,
1504
+ modelValue: e(se),
1505
+ "onUpdate:modelValue": p[8] || (p[8] = (R) => ge(se) ? se.value = R : null),
1506
+ rules: [e(Xt)(new Date(l.lastClosingDate), /* @__PURE__ */ new Date())]
1507
+ }, null, 8, ["modelValue", "rules"])) : K("", !0),
1508
+ X.value && !l.lastClosingDate ? (b(), T("div", Vs, [
1509
+ m(ae, {
1510
+ name: "error",
1511
+ size: "sm",
1512
+ class: "text-fm-color-typo-warning"
1513
+ }),
1514
+ t("span", Ps, $(e(n)("inventory.transfer.form.backdate.error")), 1)
1515
+ ])) : K("", !0)
1516
+ ])) : K("", !0)
1517
+ ])
1518
+ ]),
1519
+ t("div", Rs, [
1520
+ m(Ne, {
1521
+ "model-value": z.value,
1522
+ rules: [e(Ee)(1)]
1523
+ }, null, 8, ["model-value", "rules"]),
1524
+ t("div", {
1525
+ class: W([
1526
+ "flex gap-16",
1527
+ {
1528
+ "flex-col items-start": o.value,
1529
+ "items-center": !o.value
1530
+ }
1531
+ ])
1532
+ }, [
1533
+ t("div", Os, $(e(n)("inventory.transfer.form.items.title")), 1),
1534
+ t("div", As, [
1535
+ m(It, {
1536
+ disabled: l.disabled,
1537
+ label: e(n)("inventory.transfer.form.items.addItem"),
1538
+ "prepend-icon": "add",
1539
+ variant: "secondary",
1540
+ "text-color": "primary",
1541
+ "bg-color": "transparent",
1542
+ "border-color": "primary",
1543
+ onClick: p[9] || (p[9] = (R) => Pe()),
1544
+ size: "md"
1545
+ }, null, 8, ["disabled", "label"]),
1546
+ m(ls, {
1547
+ "template-id": e(a).template || void 0,
1548
+ "template-items": xe.value,
1549
+ "po-items": z.value,
1550
+ "onUpdate:forecastAmounts": p[10] || (p[10] = (R) => {
1551
+ f.value = R;
1552
+ }),
1553
+ "onUpdate:poItems": p[11] || (p[11] = (R) => {
1554
+ e(r).updateItems(R), c.value++;
1555
+ }),
1556
+ "onUpdate:predictionId": p[12] || (p[12] = (R) => {
1557
+ D.value = R;
1558
+ })
1559
+ }, null, 8, ["template-id", "template-items", "po-items"])
1560
+ ])
1561
+ ], 2),
1562
+ P.value === e(de).enum.purchase && Z.value && e(w).enableTotalCost && z.value.length ? (b(), T("div", Ms, [
1563
+ m(Ge, {
1564
+ label: e(ie) ? e(n)("inventory.transfer.form.items.fetchingData") : e(n)("inventory.transfer.form.items.comparePriceHistory"),
1565
+ "prepend-icon": "compare_arrows",
1566
+ "label-placement": "right",
1567
+ "model-value": e(le),
1568
+ "onUpdate:modelValue": p[13] || (p[13] = (R) => ge(le) ? le.value = R : null),
1569
+ disabled: e(ie) || l.disabled
1570
+ }, null, 8, ["label", "model-value", "disabled"])
1571
+ ])) : K("", !0),
1572
+ m(Ne, {
1573
+ "model-value": Fe.value,
1574
+ rules: [() => Fe.value ? "Must have at least one non-zero item" : !0]
1575
+ }, null, 8, ["model-value", "rules"]),
1576
+ (b(), oe(Dt, {
1577
+ "column-defs": Ve.value,
1578
+ "column-visibility": {
1579
+ [e(te).Code]: !(((ot = l.modelValue) == null ? void 0 : ot.template) ?? ((st = l.modelValue) == null ? void 0 : st.templateDoc)),
1580
+ [e(te).Name]: !(((at = l.modelValue) == null ? void 0 : at.template) ?? ((rt = l.modelValue) == null ? void 0 : rt.templateDoc)),
1581
+ [e(te).TemplateName]: !!(((lt = l.modelValue) == null ? void 0 : lt.template) ?? ((nt = l.modelValue) == null ? void 0 : nt.templateDoc))
1582
+ },
1583
+ "row-data": z.value,
1584
+ key: c.value,
1585
+ "hide-footer": "",
1586
+ "page-size": z.value.length
1587
+ }, {
1588
+ "table-row": A((R) => {
1589
+ var G, $e, it, ut;
1590
+ return [
1591
+ m(cs, {
1592
+ "compare-price-by-sku": e(ee),
1593
+ "show-compare-price": P.value === e(de).enum.purchase && e(le),
1594
+ row: R,
1595
+ "template-item": (ut = (it = ($e = (G = l.modelValue) == null ? void 0 : G.templateDoc) == null ? void 0 : $e.purchaseOrder) == null ? void 0 : it.items) == null ? void 0 : ut.find(
1596
+ (ze) => ze.sku._id === R.original.sku._id
1597
+ ),
1598
+ "onUpdate:item": p[14] || (p[14] = (ze) => ve.value.updateItem(ze)),
1599
+ disabled: l.disabled
1600
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1601
+ ];
1602
+ }),
1603
+ "list-row": A((R) => [
1604
+ (b(), oe(ht, {
1605
+ row: R,
1606
+ key: z.value.map((G) => G.sku._id).join(".")
1607
+ }, {
1608
+ default: A((G) => [
1609
+ m(Lo, {
1610
+ "compare-price-by-sku": e(ee),
1611
+ "show-compare-price": P.value === e(de).enum.purchase && e(le),
1612
+ row: R,
1613
+ "cell-by-col-id": G
1614
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1615
+ ]),
1616
+ _: 2
1617
+ }, 1032, ["row"]))
1618
+ ]),
1619
+ _: 1
1620
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1621
+ ]),
1622
+ e(w).enableTotalCost ? (b(), T("div", Es, [
1623
+ t("div", qs, [
1624
+ t("div", Us, $(e(n)("inventory.transfer.form.surcharges.totalCost")), 1),
1625
+ t("div", Ns, $(e(ce)()) + " " + $(e(Ce)({
1626
+ ...e(r).getTotalCosts(),
1627
+ currency: e(ce)()
1628
+ }).replace(/[^0-9.,]/g, "")), 1)
1629
+ ])
1630
+ ])) : K("", !0),
1631
+ e(r).getMatchedSurcharges().length > 0 ? (b(), T("div", Bs, [
1632
+ t("div", zs, [
1633
+ t("div", Ls, $(e(n)("inventory.transfer.form.surcharges.title")), 1),
1634
+ m(j, {
1635
+ label: e(n)("inventory.transfer.form.surcharges.autoApplied"),
1636
+ icon: "auto_awesome",
1637
+ variant: "info",
1638
+ compact: ""
1639
+ }, null, 8, ["label"])
1640
+ ]),
1641
+ t("div", js, $(e(n)("inventory.transfer.form.surcharges.appliedBased")), 1),
1642
+ t("div", Hs, [
1643
+ (b(!0), T(re, null, fe(e(r).getMatchedSurcharges(), (R, G) => (b(), T("div", {
1644
+ key: G,
1645
+ class: W([
1646
+ "p-16 flex items-center justify-between",
1647
+ G !== e(r).getMatchedSurcharges().length - 1 ? "border-b border-fm-color-neutral-gray-300" : ""
1648
+ ])
1649
+ }, [
1650
+ t("div", Qs, [
1651
+ t("div", Ys, $(R.item.name), 1),
1652
+ t("div", Ks, $(e(n)("inventory.transfer.form.surcharges.appliedBased")) + ": " + $(Re(R.surcharge.rule)), 1)
1653
+ ]),
1654
+ t("div", Xs, $(e(ce)()) + " " + $(e(Ce)(R.item.totalCost).replace(/[^0-9.,]/g, "")), 1)
1655
+ ], 2))), 128))
1656
+ ])
1657
+ ])) : K("", !0)
1658
+ ];
1659
+ }),
1660
+ _: 1
1661
+ }, 8, ["disabled", "onValidationFailed"])
1662
+ ]);
1663
+ };
1664
+ }
1665
+ }), Ws = { class: "flex items-center" }, Js = { class: "fm-typo-en-title-md-800" }, Gs = { class: "flex gap-4" }, ea = { class: "fm-typo-en-title-md-600" }, ta = { class: "flex flex-col gap-16" }, oa = { class: "fm-typo-en-body-md-400" }, sa = { class: "max-h-[300px] overflow-y-auto" }, aa = { class: "list-disc pl-16" }, ra = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, la = { class: "flex w-full gap-8 justify-end" }, na = /* @__PURE__ */ ne({
1666
+ __name: "TransferDialog",
1667
+ props: {
1668
+ mode: {},
1669
+ modelValue: {},
1670
+ templateId: {},
1671
+ show: { type: Boolean },
1672
+ lastClosingDate: {}
1673
+ },
1674
+ emits: ["update:show", "submitted"],
1675
+ setup(y, { expose: x, emit: d }) {
1676
+ var se;
1677
+ const u = y, g = d, n = We(), h = kt(), S = we(), V = xt(), w = Ye(), v = Qe(), { t: i } = ye(), o = U(!1), s = U(!1), r = U(!1), a = U(!1), _ = q(() => {
1678
+ var k;
1679
+ return ((k = D.value.items) == null ? void 0 : k.filter((C) => C.quantity.amount === 0)) ?? [];
1680
+ });
1681
+ async function F(k) {
1682
+ if (k) {
1683
+ s.value = !1;
1684
+ try {
1685
+ await V.readSuppliers(), s.value = !0;
1686
+ } catch {
1687
+ S.open({
1688
+ title: i("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1689
+ message: i("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1690
+ type: "error"
1691
+ });
1692
+ }
1693
+ }
1694
+ }
1695
+ v.watchLocation(F);
1696
+ function c() {
1697
+ return {
1698
+ remark: void 0,
1699
+ ref: void 0,
1700
+ stockSnapshotId: void 0,
1701
+ effectiveAt: void 0,
1702
+ items: [],
1703
+ supplier: {
1704
+ _rev: void 0,
1705
+ email: void 0,
1706
+ internal: void 0,
1707
+ contactName: void 0,
1708
+ phoneNumber: void 0,
1709
+ registrationNumber: void 0,
1710
+ supplyItems: void 0,
1711
+ _id: "",
1712
+ name: "",
1713
+ address: {
1714
+ line2: void 0,
1715
+ line1: "",
1716
+ state: "",
1717
+ city: "",
1718
+ postcode: "",
1719
+ country: ""
1720
+ }
1721
+ },
1722
+ status: "DRAFT",
1723
+ _id: "",
1724
+ seqNumber: 0,
1725
+ deliveryOrder: [],
1726
+ template: u.templateId,
1727
+ templateDoc: h.templates.find((C) => C._id === u.templateId)
1728
+ };
1729
+ }
1730
+ const f = _t(u, "show"), D = U(u.modelValue ?? c()), M = U(((se = u.modelValue) == null ? void 0 : se._id) ?? `${Math.random()}`);
1731
+ he(
1732
+ () => u.show,
1733
+ (k) => {
1734
+ var C;
1735
+ k && (r.value = !1, D.value = u.modelValue ?? c(), M.value = ((C = u.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1736
+ }
1737
+ );
1738
+ const Z = q(() => !s.value || !r.value), z = q(() => {
1739
+ switch (u.mode) {
1740
+ case Ie.READ:
1741
+ return "View transfer";
1742
+ case Ie.CREATE:
1743
+ return i("inventory.transfer.receiveRequest.create.title");
1744
+ case Ie.UPDATE:
1745
+ return i("inventory.transfer.receiveRequest.update.title");
1746
+ }
1747
+ return "";
1748
+ }), X = U();
1749
+ x({
1750
+ validateInputs: () => {
1751
+ var k, C;
1752
+ (C = (k = X.value) == null ? void 0 : k.validateInputs) == null || C.call(k);
1753
+ },
1754
+ resetInputsValidation: () => {
1755
+ var k, C;
1756
+ (C = (k = X.value) == null ? void 0 : k.resetInputsValidation) == null || C.call(k);
1757
+ },
1758
+ resetInputs: () => {
1759
+ var k, C;
1760
+ (C = (k = X.value) == null ? void 0 : k.resetInputs) == null || C.call(k);
1761
+ }
1762
+ });
1763
+ async function N() {
1764
+ const k = D.value;
1765
+ if (o.value = !0, k.items = k.items.filter((C) => C.quantity.amount > 0), !k.items.length) {
1766
+ S.open({
1767
+ title: "Cannot create order",
1768
+ message: "There are no items with non-zero amount in your request.",
1769
+ type: "error"
1770
+ });
1771
+ return;
1772
+ }
1773
+ (k.supplier.internal === "warehouse" || k.supplier.internal === "restaurant") && (k.items = k.items.map(({ totalCost: C, ...Q }) => Q));
1774
+ try {
1775
+ await n.createPurchaseOrder(k), await new Promise((C) => setTimeout(C, 1e3)), S.open({
1776
+ title: i("inventory.transfer.receiveRequest.create.success"),
1777
+ message: i("inventory.transfer.receiveRequest.create.successMessage"),
1778
+ type: "success"
1779
+ }), g("update:show", !1), g("submitted");
1780
+ } catch (C) {
1781
+ S.open({
1782
+ title: i("inventory.transfer.receiveRequest.create.error.title"),
1783
+ message: i("inventory.transfer.receiveRequest.create.error.message"),
1784
+ type: "error"
1785
+ }), console.error("Error in creating purchase order", C);
1786
+ } finally {
1787
+ o.value = !1;
1788
+ }
1789
+ }
1790
+ async function B() {
1791
+ const k = D.value;
1792
+ if (o.value = !0, k.items = k.items.filter((C) => C.quantity.amount > 0), !k.items.length) {
1793
+ S.open({
1794
+ title: "Cannot create order",
1795
+ message: "There are no items with non-zero amount in your request.",
1796
+ type: "error"
1797
+ });
1798
+ return;
1799
+ }
1800
+ (k.supplier.internal === "warehouse" || k.supplier.internal === "restaurant") && (k.items = k.items.map(({ totalCost: C, ...Q }) => Q));
1801
+ try {
1802
+ await n.updatePurchaseOrder(k), await new Promise((C) => setTimeout(C, 1e3)), S.open({
1803
+ title: i("inventory.transfer.receiveRequest.update.success"),
1804
+ message: i("inventory.transfer.receiveRequest.update.successMessage"),
1805
+ type: "success"
1806
+ }), g("update:show", !1), g("submitted");
1807
+ } catch (C) {
1808
+ S.open({
1809
+ title: i("inventory.transfer.receiveRequest.update.error.title"),
1810
+ message: i("inventory.transfer.receiveRequest.update.error.message"),
1811
+ type: "error"
1812
+ }), console.error("Error in updating purchase order", C);
1813
+ } finally {
1814
+ o.value = !1;
1815
+ }
1816
+ }
1817
+ function P() {
1818
+ switch (u.mode) {
1819
+ case Ie.CREATE:
1820
+ return N();
1821
+ case Ie.UPDATE:
1822
+ return B();
1823
+ }
1824
+ }
1825
+ function I() {
1826
+ var k;
1827
+ D.value.items = ((k = D.value.items) == null ? void 0 : k.filter((C) => C.quantity.amount > 0)) ?? [], a.value = !1, L();
1828
+ }
1829
+ function E() {
1830
+ X.value.getFormData && (D.value = {
1831
+ ...D.value,
1832
+ ...X.value.getFormData()
1833
+ });
1834
+ }
1835
+ function L() {
1836
+ var Q, le;
1837
+ const k = io.validatePurchaseOrderItems({
1838
+ skusById: w.skuById ?? {},
1839
+ items: D.value.items ?? []
1840
+ }), C = Object.values(k).flat();
1841
+ if (C.length > 0) {
1842
+ const ie = C[0];
1843
+ S.open({
1844
+ title: `[Row ${ie.index + 1}] "${ie.poItem.sku.name}"`,
1845
+ message: `${ie.message}`,
1846
+ type: "error"
1847
+ });
1848
+ return;
1849
+ }
1850
+ (le = (Q = X.value) == null ? void 0 : Q.validateInputs) == null || le.call(Q);
1851
+ }
1852
+ function J() {
1853
+ if (E(), _.value.length > 0) {
1854
+ a.value = !0;
1855
+ return;
1856
+ }
1857
+ L();
1858
+ }
1859
+ return (k, C) => {
1860
+ const Q = O("FmButton"), le = O("FmSideSheet"), ie = O("FmDialog");
1861
+ return b(), T(re, null, [
1862
+ m(le, {
1863
+ modelValue: e(f),
1864
+ "onUpdate:modelValue": C[3] || (C[3] = (ee) => ge(f) ? f.value = ee : null),
1865
+ "dismiss-away": "",
1866
+ "close-button": "",
1867
+ "max-width": 900
1868
+ }, {
1869
+ "side-sheet-header": A(() => [
1870
+ t("div", Ws, [
1871
+ t("div", Js, $(z.value), 1)
1872
+ ])
1873
+ ]),
1874
+ default: A(() => [
1875
+ (b(), oe(Zs, {
1876
+ class: "w-full",
1877
+ ref_key: "formRef",
1878
+ ref: X,
1879
+ "onForm:ready": C[0] || (C[0] = () => r.value = !0),
1880
+ onValidationSuccess: P,
1881
+ modelValue: D.value,
1882
+ "onUpdate:modelValue": C[1] || (C[1] = (ee) => D.value = ee),
1883
+ disabled: o.value || Z.value,
1884
+ suppliers: e(V).suppliers,
1885
+ skus: e(w).skus,
1886
+ key: M.value,
1887
+ "last-closing-date": k.lastClosingDate
1888
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1889
+ ]),
1890
+ "side-sheet-footer": A(() => [
1891
+ t("div", Gs, [
1892
+ m(Q, {
1893
+ loading: o.value,
1894
+ disabled: Z.value,
1895
+ label: e(i)("common.save"),
1896
+ onClick: J
1897
+ }, null, 8, ["loading", "disabled", "label"]),
1898
+ m(Q, {
1899
+ disabled: Z.value,
1900
+ variant: "tertiary",
1901
+ label: e(i)("common.close"),
1902
+ onClick: C[2] || (C[2] = (ee) => g("update:show", !1))
1903
+ }, null, 8, ["disabled", "label"])
1904
+ ])
1905
+ ]),
1906
+ _: 1
1907
+ }, 8, ["modelValue"]),
1908
+ m(ie, {
1909
+ modelValue: a.value,
1910
+ "onUpdate:modelValue": C[5] || (C[5] = (ee) => a.value = ee),
1911
+ overlay: !0
1912
+ }, {
1913
+ "dialog-header": A(() => [
1914
+ t("div", ea, $(e(i)("inventory.transfer.template.zeroQuantity.title")), 1)
1915
+ ]),
1916
+ "dialog-footer": A(() => [
1917
+ t("div", la, [
1918
+ m(Q, {
1919
+ label: e(i)("common.cancel"),
1920
+ variant: "tertiary",
1921
+ onClick: C[4] || (C[4] = (ee) => a.value = !1)
1922
+ }, null, 8, ["label"]),
1923
+ m(Q, {
1924
+ label: e(i)("inventory.transfer.template.zeroQuantity.removeAll"),
1925
+ variant: "primary",
1926
+ "prepend-icon": "delete",
1927
+ onClick: I
1928
+ }, null, 8, ["label"])
1929
+ ])
1930
+ ]),
1931
+ default: A(() => [
1932
+ t("div", ta, [
1933
+ t("div", oa, $(e(i)("inventory.transfer.template.zeroQuantity.message", { count: _.value.length })), 1),
1934
+ t("div", sa, [
1935
+ t("ul", aa, [
1936
+ (b(!0), T(re, null, fe(_.value, (ee) => (b(), T("li", {
1937
+ key: ee.sku._id,
1938
+ class: "fm-typo-en-body-md-400"
1939
+ }, $(ee.sku.name) + " (" + $(ee.sku.code) + ") ", 1))), 128))
1940
+ ])
1941
+ ]),
1942
+ t("div", ra, $(e(i)("inventory.transfer.template.zeroQuantity.prompt")), 1)
1943
+ ])
1944
+ ]),
1945
+ _: 1
1946
+ }, 8, ["modelValue"])
1947
+ ], 64);
1948
+ };
1949
+ }
1950
+ });
1951
+ function ia(y) {
1952
+ const [x, d, u, ...g] = _o(y), n = u.map((w) => w.toLowerCase().trim().replace(/ /g, "_")), S = ["item_name", "transfer_quantity(uom)", "uom", "scanned_code"].filter((w) => !n.includes(w));
1953
+ if (S.length)
1954
+ throw new Error(
1955
+ `Missing headers (${S.join()}). Excel file does not come from the template.`
1956
+ );
1957
+ return g.map((w, v) => {
1958
+ const i = {};
1959
+ for (const o in n) {
1960
+ const s = n[o];
1961
+ Object.assign(i, { [s]: w[o] });
1962
+ }
1963
+ return {
1964
+ index: v,
1965
+ data: i
1966
+ };
1967
+ });
1968
+ }
1969
+ function ua(y) {
1970
+ const x = y.SheetNames;
1971
+ try {
1972
+ return x.reduce(
1973
+ (u, g) => {
1974
+ const n = new Array(), h = y.Sheets[g], S = Ye(), V = ia(h), w = [];
1975
+ for (const { index: i, data: o } of V) {
1976
+ o.scanned_code === "" && n.push(`Row ${i + 1}: Scanned code is empty`), o.item_name === "" && n.push(`Row ${i + 1}: Item name is empty`), o.uom === "" && n.push(`Row ${i + 1}: UOM is empty`), o["transfer_quantity(uom)"] === "" && n.push(`Row ${i + 1}: Transfer quantity is empty`);
1977
+ const s = S.skus.find((_) => _.code === o.scanned_code);
1978
+ if (!s) {
1979
+ n.push(`Row ${i + 1}: SKU not found`);
1980
+ continue;
1981
+ }
1982
+ const r = s.unit.abbrev === o.uom;
1983
+ let a = null;
1984
+ if (!r) {
1985
+ const _ = s.unit.measurements.find((F) => F.abbrev === o.uom);
1986
+ if (!_) {
1987
+ n.push(`Row ${i + 1}: Measurement not found`);
1988
+ continue;
1989
+ }
1990
+ a = _;
1991
+ }
1992
+ w.push({
1993
+ sku: s,
1994
+ code: o.scanned_code,
1995
+ name: o.item_name,
1996
+ quantity: bt.fromNumber(Number(o["transfer_quantity(uom)"])),
1997
+ measurement: a
1998
+ });
1999
+ }
2000
+ const v = {
2001
+ type: "create",
2002
+ poItems: w,
2003
+ excelSheetName: g,
2004
+ errors: n
2005
+ };
2006
+ return u.importCreateResult.push(v), u;
2007
+ },
2008
+ {
2009
+ invalidExcel: !1,
2010
+ importCreateResult: new Array()
2011
+ }
2012
+ );
2013
+ } catch (d) {
2014
+ return {
2015
+ invalidExcel: !0,
2016
+ invalidExcelMessage: (d == null ? void 0 : d.message) ?? "Invalid excel",
2017
+ importCreateResult: []
2018
+ };
2019
+ }
2020
+ }
2021
+ const da = { class: "flex flex-col flex-1" }, ca = { class: "flex flex-col" }, ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, pa = {
2022
+ key: 0,
2023
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
2024
+ }, fa = { key: 0 }, va = {
2025
+ class: /* @__PURE__ */ W(["fm-typo-en-body-lg-600"])
2026
+ }, ya = { class: "flex-1" }, ba = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, ga = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, _a = { class: "text-fm-color-typo-primary" }, ha = { class: "ml-auto" }, xa = { key: 0 }, ka = /* @__PURE__ */ ne({
2027
+ __name: "XilnexResult",
2028
+ props: {
2029
+ type: {},
2030
+ name: {},
2031
+ items: {},
2032
+ errors: {}
2033
+ },
2034
+ setup(y) {
2035
+ const x = y, { t: d } = ye(), u = U(!1), g = () => {
2036
+ x.errors.length && (u.value = !u.value);
2037
+ };
2038
+ return (n, h) => {
2039
+ var w;
2040
+ const S = O("FmIcon"), V = O("FmTooltip");
2041
+ return b(), T("div", da, [
2042
+ t("div", {
2043
+ onClick: g,
2044
+ class: W({
2045
+ "cursor-pointer": n.errors.length
2046
+ })
2047
+ }, [
2048
+ t("div", ca, [
2049
+ t("div", ma, [
2050
+ t("div", {
2051
+ class: W({
2052
+ "text-fm-color-system-error-300": n.errors.length
2053
+ })
2054
+ }, [
2055
+ ke($(n.name) + " ", 1),
2056
+ n.type === "create" ? (b(), T("span", pa, "(" + $(e(d)("inventory.closing.template.import.new")) + ")", 1)) : K("", !0)
2057
+ ], 2),
2058
+ n.errors.length ? (b(), T("div", fa, [
2059
+ m(S, {
2060
+ name: "error",
2061
+ size: "sm",
2062
+ color: "system-error-300"
2063
+ })
2064
+ ])) : K("", !0)
2065
+ ]),
2066
+ h[0] || (h[0] = t("hr", { class: "my-2" }, null, -1)),
2067
+ t("div", va, [
2068
+ (w = n.items) != null && w.length ? (b(!0), T(re, { key: 0 }, fe(n.items, (v, i) => (b(), T("div", {
2069
+ key: i,
2070
+ class: "flex gap-4 mt-2 items-center"
2071
+ }, [
2072
+ t("div", ya, [
2073
+ m(V, {
2074
+ content: v.code,
2075
+ placement: "top",
2076
+ "z-index": 51
2077
+ }, {
2078
+ default: A(() => [
2079
+ t("span", ba, $(v.code), 1)
2080
+ ]),
2081
+ _: 2
2082
+ }, 1032, ["content"]),
2083
+ m(V, {
2084
+ content: v.name,
2085
+ placement: "top",
2086
+ "z-index": 51
2087
+ }, {
2088
+ default: A(() => [
2089
+ t("span", ga, $(v.name), 1)
2090
+ ]),
2091
+ _: 2
2092
+ }, 1032, ["content"])
2093
+ ]),
2094
+ t("div", null, [
2095
+ t("span", _a, $(e(bt).toFormatString({
2096
+ value: v.quantity
2097
+ })), 1),
2098
+ ke(" " + $(v.measurement ? v.measurement.abbrev : v.sku.unit.abbrev), 1)
2099
+ ])
2100
+ ]))), 128)) : K("", !0)
2101
+ ])
2102
+ ]),
2103
+ t("div", ha, [
2104
+ n.errors.length ? (b(), oe(S, {
2105
+ key: 0,
2106
+ name: u.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2107
+ size: "md"
2108
+ }, null, 8, ["name"])) : K("", !0)
2109
+ ])
2110
+ ], 2),
2111
+ u.value ? (b(), T("div", {
2112
+ key: 0,
2113
+ class: W(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
2114
+ "text-fm-color-typo-secondary": !n.errors.length,
2115
+ "text-fm-color-system-error-300": n.errors.length
2116
+ }])
2117
+ }, [
2118
+ n.errors.length ? (b(), T("div", xa, [
2119
+ t("ol", null, [
2120
+ (b(!0), T(re, null, fe(n.errors, (v, i) => (b(), T("li", { key: i }, $(v), 1))), 128))
2121
+ ])
2122
+ ])) : K("", !0)
2123
+ ], 2)) : K("", !0)
2124
+ ]);
2125
+ };
2126
+ }
2127
+ }), Ca = { class: "flex flex-col gap-24" }, wa = {
2128
+ key: 0,
2129
+ class: "flex items-center gap-8"
2130
+ }, Sa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "flex flex-col gap-8" }, $a = { class: "line-clamp-2 text-ellipsis break-all" }, Ia = {
2131
+ key: 2,
2132
+ class: "shrink-0"
2133
+ }, Da = {
2134
+ key: 0,
2135
+ class: "flex flex-col"
2136
+ }, Ta = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Va = {
2137
+ key: 0,
2138
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
2139
+ }, Pa = { class: "fm-typo-en-body-lg-600" }, pt = "Transfer note", Ra = /* @__PURE__ */ ne({
2140
+ __name: "XilnexImportForm",
2141
+ setup(y, { expose: x }) {
2142
+ const d = U(null), u = we(), g = U(!1), n = U(!1), h = ko(), S = U(!1), V = qe();
2143
+ U([]);
2144
+ const w = q({
2145
+ get() {
2146
+ var c;
2147
+ return ((c = h.supplier) == null ? void 0 : c.name) ?? "";
2148
+ },
2149
+ set(c) {
2150
+ c && (h.supplier = {
2151
+ name: c,
2152
+ registrationNumber: "",
2153
+ _id: "xilnex",
2154
+ internal: "restaurant",
2155
+ address: {
2156
+ line1: "",
2157
+ line2: "",
2158
+ city: "",
2159
+ state: "",
2160
+ country: "",
2161
+ postcode: ""
2162
+ }
2163
+ });
2164
+ }
2165
+ });
2166
+ He(async () => {
2167
+ const c = await V.getNetSuiteLocations();
2168
+ console.log(c), S.value = !0;
2169
+ });
2170
+ const v = q({
2171
+ get() {
2172
+ return "";
2173
+ },
2174
+ set(c) {
2175
+ if (c) {
2176
+ const f = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [D, M, Z] = c.split("-");
2177
+ f.setFullYear(parseInt(D)), f.setMonth(parseInt(M) - 1), f.setDate(parseInt(Z)), h.effectiveAt = f.toISOString();
2178
+ }
2179
+ }
2180
+ }), i = q({
2181
+ get() {
2182
+ return null;
2183
+ },
2184
+ set(c) {
2185
+ if (c) {
2186
+ const f = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [D, M] = c.split(":");
2187
+ f.setMinutes(parseInt(D)), f.setSeconds(parseInt(M)), h.effectiveAt = f.toISOString();
2188
+ }
2189
+ }
2190
+ }), o = U(new Array()), s = U([]), r = q(
2191
+ () => !!o.value.length || s.value.some((c) => c.errors.length)
2192
+ ), a = U();
2193
+ x({
2194
+ validateInputs: () => {
2195
+ var c, f;
2196
+ (f = (c = a.value) == null ? void 0 : c.validateInputs) == null || f.call(c);
2197
+ },
2198
+ resetInputsValidation: () => {
2199
+ var c, f;
2200
+ (f = (c = a.value) == null ? void 0 : c.resetInputsValidation) == null || f.call(c);
2201
+ },
2202
+ resetInputs: () => {
2203
+ var c, f;
2204
+ (f = (c = a.value) == null ? void 0 : c.resetInputs) == null || f.call(c);
2205
+ }
2206
+ });
2207
+ const { t: _ } = ye();
2208
+ async function F(c) {
2209
+ o.value = [], s.value = [];
2210
+ try {
2211
+ g.value = !0;
2212
+ const [f] = await Promise.all([
2213
+ ho(c),
2214
+ // fake buffer
2215
+ new Promise((M) => setTimeout(M, 1e3))
2216
+ ]), D = ua(f);
2217
+ if (D.invalidExcel) {
2218
+ o.value.push(
2219
+ D.invalidExcelMessage ?? _("inventory.ingredient.import.fileError.invalidExcel")
2220
+ );
2221
+ return;
2222
+ }
2223
+ if (s.value = D.importCreateResult, !s.value.length) {
2224
+ o.value.push(_("inventory.ingredient.import.fileError.noData"));
2225
+ return;
2226
+ }
2227
+ h.items = s.value.map((M) => M.poItems).flat();
2228
+ } catch (f) {
2229
+ u.open({
2230
+ title: _("inventory.ingredient.import.fileError.unableToRead"),
2231
+ message: f == null ? void 0 : f.message,
2232
+ type: "error"
2233
+ }), console.error("Error in reading file", f);
2234
+ } finally {
2235
+ o.value.length && u.open({
2236
+ title: _("inventory.ingredient.import.fileError.invalidExcel"),
2237
+ type: "error"
2238
+ }), g.value = !1;
2239
+ }
2240
+ }
2241
+ return he(d, (c) => {
2242
+ c && F(c);
2243
+ }), (c, f) => {
2244
+ const D = O("FmSelect"), M = O("FmDatePicker"), Z = O("FmTimePicker"), z = O("FmCircularProgress"), X = O("FmLabel"), N = O("FmIcon"), B = O("FmButton"), P = O("FmForm");
2245
+ return b(), oe(P, {
2246
+ ref_key: "formRef",
2247
+ ref: a
2248
+ }, {
2249
+ default: A(() => [
2250
+ t("div", Ca, [
2251
+ m(D, {
2252
+ modelValue: w.value,
2253
+ "onUpdate:modelValue": f[0] || (f[0] = (I) => w.value = I),
2254
+ label: "Transfer from",
2255
+ searchable: "",
2256
+ searchTarget: "label",
2257
+ items: [
2258
+ { label: "Object", value: null },
2259
+ { label: "Array", value: ["array", "1"] },
2260
+ { label: "Number", value: 3 },
2261
+ { label: "String", value: "4" },
2262
+ { label: "1", value: "5" },
2263
+ { label: "2", value: "6" }
2264
+ ],
2265
+ "helper-text": "Helper",
2266
+ rules: [e(De)()]
2267
+ }, null, 8, ["modelValue", "rules"]),
2268
+ m(M, {
2269
+ modelValue: v.value,
2270
+ "onUpdate:modelValue": f[1] || (f[1] = (I) => v.value = I),
2271
+ label: "Transfer date",
2272
+ rules: [e(De)()]
2273
+ }, null, 8, ["modelValue", "rules"]),
2274
+ m(Z, {
2275
+ modelValue: i.value,
2276
+ "onUpdate:modelValue": f[2] || (f[2] = (I) => i.value = I),
2277
+ label: "Transfer time",
2278
+ rules: [e(De)()]
2279
+ }, null, 8, ["modelValue", "rules"]),
2280
+ n.value ? (b(), T("div", wa, [
2281
+ t("div", null, [
2282
+ m(z, {
2283
+ size: "md",
2284
+ color: "neutral-gray-200"
2285
+ })
2286
+ ]),
2287
+ t("div", Sa, $(e(_)("inventory.formField.loading")), 1)
2288
+ ])) : (b(), T(re, { key: 1 }, [
2289
+ m(xo, {
2290
+ "max-file-size": 5,
2291
+ class: W({
2292
+ "w-full": !0,
2293
+ "h-[200px]": !d.value
2294
+ }),
2295
+ accept: ".xlsx,.xls",
2296
+ label: pt,
2297
+ onFileUpload: f[3] || (f[3] = (I) => d.value = I),
2298
+ "button-label": e(_)("inventory.ingredient.import.selectFile")
2299
+ }, Pt({ _: 2 }, [
2300
+ d.value ? {
2301
+ name: "default",
2302
+ fn: A(({ openFileDialog: I }) => [
2303
+ m(X, null, {
2304
+ default: A(() => [
2305
+ ke($(pt))
2306
+ ]),
2307
+ _: 1
2308
+ }),
2309
+ t("div", Fa, [
2310
+ t("div", {
2311
+ class: W([
2312
+ "fm-corner-radius-md p-16 flex items-center gap-16",
2313
+ {
2314
+ "border border-fm-color-neutral-gray-100": g.value,
2315
+ "border border-fm-color-neutral-gray-200": !g.value && !r.value,
2316
+ "border border-fm-color-system-error-200": r.value
2317
+ }
2318
+ ])
2319
+ }, [
2320
+ g.value ? (b(), oe(z, {
2321
+ key: 0,
2322
+ size: "md",
2323
+ color: "neutral-gray-200"
2324
+ })) : (b(), oe(N, {
2325
+ key: 1,
2326
+ name: r.value ? "error" : "attach_file",
2327
+ outline: "",
2328
+ color: r.value ? "system-error-300" : void 0
2329
+ }, null, 8, ["name", "color"])),
2330
+ t("div", {
2331
+ class: W([
2332
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2333
+ {
2334
+ "text-fm-color-typo-disabled": g.value,
2335
+ "text-fm-color-typo-primary": !g.value
2336
+ }
2337
+ ])
2338
+ }, [
2339
+ t("div", $a, $(d.value.name), 1)
2340
+ ], 2),
2341
+ g.value ? K("", !0) : (b(), T("div", Ia, [
2342
+ m(B, {
2343
+ label: e(_)("inventory.ingredient.import.replaceFile"),
2344
+ variant: r.value ? "destructive" : "secondary",
2345
+ "prepend-icon": r.value ? void 0 : "autorenew",
2346
+ onClick: I
2347
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2348
+ ]))
2349
+ ], 2),
2350
+ o.value.length ? (b(), T("div", Da, [
2351
+ (b(!0), T(re, null, fe(o.value, (E, L) => (b(), T("div", {
2352
+ key: L,
2353
+ class: "flex gap-8 items-center"
2354
+ }, [
2355
+ m(N, {
2356
+ name: "error",
2357
+ size: "sm",
2358
+ color: "system-error-300"
2359
+ }),
2360
+ t("div", Ta, $(E), 1)
2361
+ ]))), 128))
2362
+ ])) : K("", !0)
2363
+ ])
2364
+ ]),
2365
+ key: "0"
2366
+ } : void 0
2367
+ ]), 1032, ["class", "button-label"]),
2368
+ d.value ? (b(), T("div", Va, [
2369
+ t("div", Pa, $(e(_)("inventory.ingredient.import.summary")), 1),
2370
+ (b(!0), T(re, null, fe(s.value, (I, E) => (b(), oe(ka, {
2371
+ key: E,
2372
+ name: `Transfer Note ${E + 1}`,
2373
+ items: I.poItems,
2374
+ errors: I.errors,
2375
+ type: "create"
2376
+ }, null, 8, ["name", "items", "errors"]))), 128))
2377
+ ])) : K("", !0)
2378
+ ], 64))
2379
+ ])
2380
+ ]),
2381
+ _: 1
2382
+ }, 512);
2383
+ };
2384
+ }
2385
+ }), Oa = { class: "w-[480px]" }, Aa = /* @__PURE__ */ ne({
2386
+ __name: "XilnexImportDialog",
2387
+ props: {
2388
+ show: { type: Boolean }
2389
+ },
2390
+ emits: ["update:show", "submitted"],
2391
+ setup(y, { expose: x, emit: d }) {
2392
+ const u = d, n = _t(y, "show"), h = we(), S = We(), V = U(!1), w = U(), v = U();
2393
+ x({
2394
+ validateInputs: () => {
2395
+ var s, r;
2396
+ (r = (s = w.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
2397
+ },
2398
+ resetInputsValidation: () => {
2399
+ var s, r;
2400
+ (r = (s = w.value) == null ? void 0 : s.resetInputsValidation) == null || r.call(s);
2401
+ },
2402
+ resetInputs: () => {
2403
+ var s, r;
2404
+ (r = (s = w.value) == null ? void 0 : s.resetInputs) == null || r.call(s);
2405
+ }
2406
+ });
2407
+ function i() {
2408
+ var s, r;
2409
+ (r = (s = w.value) == null ? void 0 : s.validateInputs) == null || r.call(s);
2410
+ }
2411
+ async function o() {
2412
+ var r, a, _, F, c;
2413
+ if (!((a = (r = v.value) == null ? void 0 : r.supplier) != null && a.name)) {
2414
+ h.open({
2415
+ title: "Upload failed",
2416
+ message: "Location is required",
2417
+ type: "error"
2418
+ });
2419
+ return;
2420
+ }
2421
+ if (!((_ = v.value) != null && _.items) || ((c = (F = v.value) == null ? void 0 : F.items) == null ? void 0 : c.length) === 0) {
2422
+ h.open({
2423
+ title: "Upload failed",
2424
+ message: "No data to upload",
2425
+ type: "error"
2426
+ });
2427
+ return;
2428
+ }
2429
+ const s = v.value.effectiveAt ? new Date(v.value.effectiveAt) : null;
2430
+ if (!s) {
2431
+ h.open({
2432
+ title: "Invalid date",
2433
+ message: "Transfer date is required",
2434
+ type: "error"
2435
+ });
2436
+ return;
2437
+ }
2438
+ if (s.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2439
+ h.open({
2440
+ title: "Invalid date",
2441
+ message: "Transfer date cannot be in the future",
2442
+ type: "error"
2443
+ });
2444
+ return;
2445
+ }
2446
+ V.value = !0;
2447
+ try {
2448
+ await S.importFromXilnex(v.value), u("update:show", !1);
2449
+ } catch (f) {
2450
+ await new Promise((D) => setTimeout(D, 1e3)), h.open({
2451
+ title: "Upload failed",
2452
+ message: f == null ? void 0 : f.message,
2453
+ type: "error"
2454
+ });
2455
+ } finally {
2456
+ V.value = !1;
2457
+ }
2458
+ }
2459
+ return (s, r) => {
2460
+ const a = O("FmSpacer"), _ = O("FmButton"), F = O("FmDialog");
2461
+ return b(), oe(F, {
2462
+ modelValue: e(n),
2463
+ "onUpdate:modelValue": r[2] || (r[2] = (c) => ge(n) ? n.value = c : null),
2464
+ overlay: !0,
2465
+ "close-button": !1
2466
+ }, {
2467
+ "dialog-header": A(() => r[3] || (r[3] = [
2468
+ t("div", null, "Xilnex transfer order", -1)
2469
+ ])),
2470
+ "dialog-footer": A(() => [
2471
+ m(a, { class: "sm:hidden xs:hidden" }),
2472
+ m(_, {
2473
+ disabled: V.value,
2474
+ class: "sm:w-full xs:w-full",
2475
+ label: "Cancel",
2476
+ size: "md",
2477
+ variant: "tertiary",
2478
+ onClick: r[1] || (r[1] = (c) => u("update:show", !1))
2479
+ }, null, 8, ["disabled"]),
2480
+ m(_, {
2481
+ disabled: V.value,
2482
+ loading: V.value,
2483
+ class: "sm:w-full xs:w-full",
2484
+ label: "Upload",
2485
+ size: "md",
2486
+ variant: "primary",
2487
+ onClick: i
2488
+ }, null, 8, ["disabled", "loading"])
2489
+ ]),
2490
+ default: A(() => [
2491
+ t("div", Oa, [
2492
+ m(Ra, {
2493
+ ref_key: "formRef",
2494
+ ref: w,
2495
+ onValidationSuccess: o,
2496
+ modelValue: v.value,
2497
+ "onUpdate:modelValue": r[0] || (r[0] = (c) => v.value = c)
2498
+ }, null, 8, ["modelValue"])
2499
+ ])
2500
+ ]),
2501
+ _: 1
2502
+ }, 8, ["modelValue"]);
2503
+ };
2504
+ }
2505
+ }), Ma = { class: "flex flex-col py-8" }, Ea = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qa = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Na = {
2506
+ key: 0,
2507
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2508
+ }, Ba = { class: "pt-8" }, ft = "ReceiveRequestViewSearchCriteria", br = /* @__PURE__ */ ne({
2509
+ __name: "ReceiveRequestView",
2510
+ setup(y) {
2511
+ const { t: x } = ye(), d = we();
2512
+ Ae.object({
2513
+ name: Ae.string().optional().nullable(),
2514
+ startDate: Ae.string().optional().nullable(),
2515
+ endDate: Ae.string().optional().nullable()
2516
+ });
2517
+ const u = q(
2518
+ () => !o._currentLocation || v.loading.value
2519
+ ), g = Gt(), n = Xe(), h = qe();
2520
+ function S() {
2521
+ const N = {
2522
+ name: "",
2523
+ ...dt()
2524
+ }, B = g.getItem(ft);
2525
+ if (!B)
2526
+ return N;
2527
+ try {
2528
+ return JSON.parse(B);
2529
+ } catch {
2530
+ return N;
2531
+ }
2532
+ }
2533
+ function V() {
2534
+ g.setItem(ft, JSON.stringify(w.value));
2535
+ }
2536
+ const w = U(S()), v = Lt(
2537
+ Le.RECEIVE_REQUEST,
2538
+ w.value
2539
+ ), { columnDefs: i } = jt(
2540
+ Le.RECEIVE_REQUEST,
2541
+ v,
2542
+ v.shipments
2543
+ ), o = Qe();
2544
+ async function s() {
2545
+ const N = `inventory-record_${mt(w.value.startDate).format("DD-MM-YYYY_HH-mm")}-${mt(w.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, B = v.purchaseOrders.value.flatMap(
2546
+ (I) => I.items.map((E) => {
2547
+ var Q;
2548
+ const L = new Date(Wt(I._id) ?? ""), J = I.effectiveAt ? new Date(I.effectiveAt) : void 0, se = _e(
2549
+ Qt(E.sku, I.deliveryOrder || [])
2550
+ ), k = _e(E.quantity), C = ((Q = E == null ? void 0 : E.measurement) == null ? void 0 : Q.abbrev) || E.sku.unit.abbrev;
2551
+ return {
2552
+ "SKU code": E.code,
2553
+ "SKU name": E.name,
2554
+ "PO #": I.seqNumber,
2555
+ "Effective at": J,
2556
+ Date: L,
2557
+ Status: I.status,
2558
+ Reference: I.ref ?? "",
2559
+ "Received quantity": se,
2560
+ "Ordered quantity": k,
2561
+ Unit: C,
2562
+ "Total cost": E.totalCost ? Ce(E.totalCost) : null
2563
+ };
2564
+ })
2565
+ ), P = [
2566
+ "SKU code",
2567
+ "SKU name",
2568
+ "PO #",
2569
+ "Date",
2570
+ "Status",
2571
+ "Reference",
2572
+ "Received quantity",
2573
+ "Ordered quantity",
2574
+ "Unit"
2575
+ ];
2576
+ n.enableBackdatePo && P.insert("Effective at", 4), n.enableTotalCost && P.push("Total cost"), await Jt(
2577
+ [
2578
+ {
2579
+ name: "purchases",
2580
+ data: B,
2581
+ columns: P
2582
+ }
2583
+ ],
2584
+ N
2585
+ ), d.open({
2586
+ title: x("inventory.transfer.receiveRequest.export.success"),
2587
+ message: x("inventory.transfer.receiveRequest.export.message", [N]),
2588
+ type: "success"
2589
+ });
2590
+ }
2591
+ const r = U(dt()), a = U("");
2592
+ he([() => r.value], ([N]) => {
2593
+ !N.startDate || !N.endDate || (w.value.startDate = N.startDate, w.value.endDate = N.endDate, v.updateDateRange(
2594
+ w.value.startDate,
2595
+ w.value.endDate
2596
+ ), V());
2597
+ }), he([() => a.value], () => {
2598
+ V();
2599
+ });
2600
+ function _(N) {
2601
+ if (N === "create") {
2602
+ if (u.value) {
2603
+ d.open({
2604
+ title: "Loading data...",
2605
+ message: "Please wait.",
2606
+ type: "info"
2607
+ });
2608
+ return;
2609
+ }
2610
+ return v.promptCreateTransferDialog();
2611
+ }
2612
+ if (N === "upload" && n.enableXilnexTransferNote)
2613
+ return v.promptUploadTransferDialog();
2614
+ if (N === "refresh")
2615
+ return v.fetchData();
2616
+ if (N === "export")
2617
+ return s();
2618
+ }
2619
+ const { breakpoints: F } = Ke(), c = q(() => F.value.xs || F.value.sm), f = q(() => c.value ? 10 : 20), D = eo(), M = q(() => [
2620
+ {
2621
+ label: x("inventory.transfer.receiveRequest.actions.create"),
2622
+ value: "create",
2623
+ isPrimary: !0,
2624
+ prependIcon: "add"
2625
+ },
2626
+ ...n.enableXilnexTransferNote ? [
2627
+ {
2628
+ label: x("inventory.common.upload"),
2629
+ value: "upload"
2630
+ }
2631
+ ] : [],
2632
+ {
2633
+ label: x("inventory.common.refresh"),
2634
+ value: "refresh"
2635
+ },
2636
+ {
2637
+ label: x("inventory.common.export"),
2638
+ value: "export"
2639
+ }
2640
+ ]), Z = q(() => {
2641
+ const N = [
2642
+ {
2643
+ type: "string",
2644
+ key: "status",
2645
+ entity: "purchaseOrder",
2646
+ values: Array.from(
2647
+ new Set(v.purchaseOrders.value.map((P) => P.status))
2648
+ )
2649
+ }
2650
+ ], B = [
2651
+ {
2652
+ type: "string",
2653
+ key: "netsuiteTransactionNumber",
2654
+ entity: "purchaseOrder",
2655
+ values: v.purchaseOrders.value.map((P) => {
2656
+ var I, E;
2657
+ return (E = (I = P.netSuite) == null ? void 0 : I.additionalInfo) == null ? void 0 : E.transactionnumber;
2658
+ }).filter((P) => P != null)
2659
+ },
2660
+ {
2661
+ type: "string",
2662
+ key: "netsuiteOrderNo",
2663
+ entity: "purchaseOrder",
2664
+ values: v.purchaseOrders.value.map((P) => {
2665
+ var I;
2666
+ return (I = P.netSuite) == null ? void 0 : I.refNo;
2667
+ }).filter((P) => P != null)
2668
+ },
2669
+ {
2670
+ type: "string",
2671
+ key: "netsuiteOrderId",
2672
+ entity: "purchaseOrder",
2673
+ values: v.purchaseOrders.value.map((P) => {
2674
+ var I;
2675
+ return (I = P.netSuite) == null ? void 0 : I.id;
2676
+ }).filter((P) => P != null)
2677
+ }
2678
+ ];
2679
+ return [...N, ...h.isEnabled ? B : []];
2680
+ }), z = U(null), X = q(() => {
2681
+ if (!z.value)
2682
+ return v.purchaseOrders.value;
2683
+ const N = Co.build(z.value);
2684
+ return v.purchaseOrders.value.filter((B) => {
2685
+ var P, I, E, L;
2686
+ return wo(
2687
+ {
2688
+ netsuiteTransactionNumber: (I = (P = B.netSuite) == null ? void 0 : P.additionalInfo) == null ? void 0 : I.transactionnumber,
2689
+ netsuiteOrderNo: (E = B.netSuite) == null ? void 0 : E.refNo,
2690
+ netsuiteOrderId: (L = B.netSuite) == null ? void 0 : L.id,
2691
+ status: B.status
2692
+ },
2693
+ N
2694
+ );
2695
+ });
2696
+ });
2697
+ return (N, B) => {
2698
+ const P = O("FmTable");
2699
+ return b(), oe(to, {
2700
+ title: e(x)("inventory.transfer.receiveRequest.title2"),
2701
+ actions: M.value,
2702
+ "onClick:action": _
2703
+ }, {
2704
+ default: A(() => {
2705
+ var I, E;
2706
+ return [
2707
+ t("div", {
2708
+ class: W([
2709
+ "flex flex-col gap-8 max-h-full",
2710
+ {
2711
+ "p-0": c.value,
2712
+ "px-24 ": !c.value
2713
+ }
2714
+ ])
2715
+ }, [
2716
+ m(Bt, {
2717
+ "date-range-query": "",
2718
+ "date-range": r.value,
2719
+ "onUpdate:dateRange": B[0] || (B[0] = (L) => r.value = L),
2720
+ searchable: "",
2721
+ "change-location": "",
2722
+ search: a.value,
2723
+ "onUpdate:search": B[1] || (B[1] = (L) => a.value = L),
2724
+ filterable: "",
2725
+ "filter-attributes": Z.value,
2726
+ filter: z.value,
2727
+ "onUpdate:filter": B[2] || (B[2] = (L) => z.value = L)
2728
+ }, null, 8, ["date-range", "search", "filter-attributes", "filter"]),
2729
+ (b(), oe(P, {
2730
+ style: vt(e(D).tableHeight),
2731
+ "column-defs": e(i),
2732
+ "row-data": X.value,
2733
+ "search-value": a.value,
2734
+ loading: u.value,
2735
+ onRowClick: B[3] || (B[3] = (L) => e(v).promptShowTransferDetails(L.original)),
2736
+ key: (I = e(o)._currentLocation) == null ? void 0 : I.dbName,
2737
+ "page-size": f.value
2738
+ }, {
2739
+ "list-row": A((L) => [
2740
+ m(ht, {
2741
+ row: L,
2742
+ onRowClick: e(v).promptShowTransferDetails
2743
+ }, {
2744
+ default: A((J) => {
2745
+ var se, k, C, Q, le, ie, ee, be, ve, Te, Ve, Pe, Ue, xe, Se, Fe, Re, l, p, j;
2746
+ return [
2747
+ t("div", Ma, [
2748
+ t("div", Ea, [
2749
+ m(e(me), {
2750
+ render: (C = (k = (se = J._id) == null ? void 0 : se.column) == null ? void 0 : k.columnDef) == null ? void 0 : C.cell,
2751
+ props: (le = (Q = J._id) == null ? void 0 : Q.getContext) == null ? void 0 : le.call(Q)
2752
+ }, null, 8, ["render", "props"])
2753
+ ]),
2754
+ t("div", qa, [
2755
+ m(e(me), {
2756
+ render: (be = (ee = (ie = J.supplier_name) == null ? void 0 : ie.column) == null ? void 0 : ee.columnDef) == null ? void 0 : be.cell,
2757
+ props: (Te = (ve = J.supplier_name) == null ? void 0 : ve.getContext) == null ? void 0 : Te.call(ve)
2758
+ }, null, 8, ["render", "props"])
2759
+ ]),
2760
+ t("div", Ua, $(L.original.items.map((H) => `${H.name}`).join(", ")), 1),
2761
+ L.original.ref ? (b(), T("div", Na, [
2762
+ m(e(me), {
2763
+ render: (Ue = (Pe = (Ve = J.ref) == null ? void 0 : Ve.column) == null ? void 0 : Pe.columnDef) == null ? void 0 : Ue.cell,
2764
+ props: (Se = (xe = J.ref) == null ? void 0 : xe.getContext) == null ? void 0 : Se.call(xe)
2765
+ }, null, 8, ["render", "props"])
2766
+ ])) : K("", !0),
2767
+ t("div", Ba, [
2768
+ m(e(me), {
2769
+ render: (l = (Re = (Fe = J.status) == null ? void 0 : Fe.column) == null ? void 0 : Re.columnDef) == null ? void 0 : l.cell,
2770
+ props: (j = (p = J.status) == null ? void 0 : p.getContext) == null ? void 0 : j.call(p)
2771
+ }, null, 8, ["render", "props"])
2772
+ ])
2773
+ ])
2774
+ ];
2775
+ }),
2776
+ _: 2
2777
+ }, 1032, ["row", "onRowClick"])
2778
+ ]),
2779
+ _: 1
2780
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2781
+ ], 2),
2782
+ (b(), oe(Rt, { to: "body" }, [
2783
+ m(na, je(e(v).transferDialogProps.value, {
2784
+ onSubmitted: e(v).fetchData
2785
+ }), null, 16, ["onSubmitted"]),
2786
+ m(Ht, je({
2787
+ scope: e(Le).RECEIVE_REQUEST
2788
+ }, {
2789
+ ...e(v).transferDetailsProps.value,
2790
+ receivedMap: ((E = e(v).transferDetailsProps.value) == null ? void 0 : E.receivedMap) ?? {},
2791
+ shipments: e(v).shipments.value ?? []
2792
+ }, {
2793
+ onSubmitted: e(v).fetchData
2794
+ }), null, 16, ["scope", "onSubmitted"]),
2795
+ m(Aa, Ot(At(e(v).xilnexImportDialogProps.value)), null, 16)
2796
+ ]))
2797
+ ];
2798
+ }),
2799
+ _: 1
2800
+ }, 8, ["title", "actions"]);
2801
+ };
2802
+ }
2803
+ });
2804
+ export {
2805
+ br as default
2806
+ };