@feedmepos/mf-inventory-portal 0.0.25-dev.2 → 0.0.25-dev.21

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 (115) hide show
  1. package/dist/App-D6WBVERc.js +278 -0
  2. package/dist/ApprovalView-BIBoagE8.js +146 -0
  3. package/dist/{BindingsDialog-qeGh3ND8.js → BindingsDialog-DHRRkK1Z.js} +6 -6
  4. package/dist/{BindingsPicker-SfiA8fmD.js → BindingsPicker-DohvMDDF.js} +3 -3
  5. package/dist/{BindingsTable-BjW-eJr6.js → BindingsTable-C_JwU9ei.js} +6 -6
  6. package/dist/ClosingDraftView-BBebhUj-.js +1308 -0
  7. package/dist/ClosingTemplateView-CXRN19-D.js +1859 -0
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js +34 -0
  9. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BJufUQNE.js +215 -0
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-5rldKjyh.js → FmUnitInput.vue_vue_type_script_setup_true_lang-C5Xk19jY.js} +52 -52
  11. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-7HNI82u-.js +51 -0
  12. package/dist/{IngredientGroupView-CGyyFyvj.js → IngredientGroupView-l2bAc1Kj.js} +1 -1
  13. package/dist/{IngredientsView-BLKk-VxQ.js → IngredientsView-zDXt7KEx.js} +394 -382
  14. package/dist/{IntegrationView-C6gwvZ9b.js → IntegrationView-BYnlAPrP.js} +660 -623
  15. package/dist/{InventoryBindingForm-BB3ZN3Lx.js → InventoryBindingForm-BuweG4Vl.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-PT7Quw7j.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DgxN0U4N.js} +99 -99
  17. package/dist/{InventoryBindingSummary-yr0oie3c.js → InventoryBindingSummary-BpEo0JsK.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjJGUE9a.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CcjzkzCt.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-O1mYRa5W.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Ej20iSHA.js} +15 -15
  20. package/dist/PublishView-DCZ0zIaP.js +222 -0
  21. package/dist/{PurchaseOrderPrintPreview-Q_9-KVNj.js → PurchaseOrderPrintPreview-Cag7UEvz.js} +1 -1
  22. package/dist/ReceiveRequestView-ChIJGA98.js +2319 -0
  23. package/dist/{RecipeView-DBfugmRY.js → RecipeView-bBshe0eF.js} +32 -31
  24. package/dist/{index-CgspzSQi.js → StockView-D6-oKpAC.js} +3577 -1764
  25. package/dist/{SupplierView-BQViPyfj.js → SupplierView-dyIcGp9Q.js} +12 -11
  26. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C_7wbQow.js +1771 -0
  27. package/dist/TransferTemplateView-D2rxV0k_.js +1660 -0
  28. package/dist/{UnitView-CrbFeWaB.js → UnitView-DVS5Az5c.js} +14 -14
  29. package/dist/{WarehouseView-Dy5GljxY.js → WarehouseView-CR03TpnA.js} +332 -314
  30. package/dist/api/closing-draft.d.ts +1 -0
  31. package/dist/api/inventory.d.ts +9 -6
  32. package/dist/api/purchase-order.d.ts +2 -1
  33. package/dist/{app-D0O4wr2X.js → app-oV9ISfFL.js} +28343 -28141
  34. package/dist/app.js +1 -1
  35. package/dist/components/FmAutocompleteTextField.vue.d.ts +31 -0
  36. package/dist/components/FmCustomAttribute.vue.d.ts +3 -8
  37. package/dist/components/FmLockableField.vue.d.ts +3 -0
  38. package/dist/components/FmMultiselectDialog.d.ts +46 -0
  39. package/dist/components/FmMultiselectDialog.vue.d.ts +20 -3
  40. package/dist/components/FmMultiselectDialogProps.d.ts +2 -0
  41. package/dist/components/MountListener.vue.d.ts +15 -0
  42. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -1
  43. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -1
  44. package/dist/{decimal-CPGmj9BT.js → decimal-C7zgfr5G.js} +1 -1
  45. package/dist/feature-CDQQ-mV9.js +1003 -0
  46. package/dist/{format-unit-display-CMM6DZJj.js → format-unit-display-CVBzrNQ4.js} +334 -327
  47. package/dist/helper/fuzzy.d.ts +10 -0
  48. package/dist/index-0VS4cuk3.js +35546 -0
  49. package/dist/{stock-9nTT4Amy.js → stock-BIP_NIK_.js} +3 -3
  50. package/dist/stores/feature.d.ts +4 -7
  51. package/dist/stores/integration/netsuite.d.ts +5 -0
  52. package/dist/stores/inventory.d.ts +135 -8
  53. package/dist/stores/location.d.ts +100 -0
  54. package/dist/stores/warehouse.d.ts +1 -0
  55. package/dist/style.css +1 -1
  56. package/dist/{supplier-CH4EwBZM.js → supplier-DUQ2VSMg.js} +1 -1
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/use-ingredient-select-dialog-VkU5_Aaj.js +51 -0
  59. package/dist/{use-inventory-binding-dialog-Dli3xtq4.js → use-inventory-binding-dialog-BXp0z3v_.js} +1 -1
  60. package/dist/views/adjustment-template/wastage-template/actions.d.ts +24 -0
  61. package/dist/views/adjustment-template/wastage-template/table.d.ts +24 -0
  62. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +8 -4
  63. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +4 -1
  64. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +48 -24
  65. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +1 -1
  66. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  67. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +36 -12
  68. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -12
  69. package/dist/views/dev/components/AutocompleteTextField.vue.d.ts +2 -0
  70. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +3 -3
  71. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  72. package/dist/views/ingredients/composables/use-ingredient-select-dialog.d.ts +16 -0
  73. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  74. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +2 -0
  75. package/dist/views/receive-request/components/transfer-details/TransferDetails.vue.d.ts +1387 -0
  76. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +5 -1
  77. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +3 -0
  78. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -2
  79. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +48 -2
  80. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +490 -2
  81. package/dist/views/receive-request/components/transfer-form/components/TransferSubItemTable.vue.d.ts +72 -0
  82. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +25 -2
  83. package/dist/views/receive-request/components/transfer-form/helpers/calculate-sub-item-total.helper.d.ts +4 -0
  84. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +693 -35
  85. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +684 -35
  86. package/dist/views/receive-request/helper/po-to-po-template.util.d.ts +1 -0
  87. package/dist/views/receive-request/helper/print-po.d.ts +9 -2
  88. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  89. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +270 -2
  90. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +286 -0
  91. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItem.vue.d.ts +74 -0
  92. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateSubItemTable.vue.d.ts +92 -0
  93. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +8 -0
  94. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +1 -0
  95. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +36 -2
  96. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +456 -12
  97. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +456 -12
  98. package/dist/views/transfer-template/helpers/location-to-po-supplier.util.d.ts +75 -0
  99. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -0
  100. package/dist/{vue-i18n-BcYt8MNZ.js → vue-i18n-CCd5_SRR.js} +212 -212
  101. package/package.json +3 -3
  102. package/dist/App-oKNdl2la.js +0 -276
  103. package/dist/ApprovalView-hDGkcBDy.js +0 -138
  104. package/dist/ClosingDraftView-CEeeL7W4.js +0 -1225
  105. package/dist/ClosingTemplateView-CkS9e0MV.js +0 -1819
  106. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-CIBSvY0s.js +0 -142
  107. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Dg_7ELeT.js +0 -286
  108. package/dist/PublishView-ByXdmuJL.js +0 -192
  109. package/dist/ReceiveRequestView-CApg7LGM.js +0 -1876
  110. package/dist/StockView-D6o_oUlz.js +0 -1817
  111. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D2skLe2M.js +0 -1327
  112. package/dist/TransferTemplateView-DVesObTd.js +0 -1284
  113. package/dist/components/FmCustomAttribute2.vue.d.ts +0 -18
  114. package/dist/index-P5iEcRw3.js +0 -29202
  115. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +0 -2628
@@ -1,1327 +0,0 @@
1
- import { ref as K, computed as Y, h as oe, defineComponent as _e, unref as i, openBlock as g, createElementBlock as D, createElementVNode as e, toDisplayString as S, createCommentVNode as x, resolveComponent as Z, createVNode as U, createBlock as W, isRef as Ge, withCtx as de, Fragment as ne, normalizeClass as ye, createTextVNode as xe, renderList as pe } from "vue";
2
- import { X as He, u as be, aG as k, a2 as ze, a4 as Ye, a5 as Qe, ai as We, e as Te, f as Ie, ar as B, V as Fe, c as Be, aH as Ze, Z as Se, L as he, j as fe, aI as Me, a9 as ge, h as Pe, D as V, i as F, b as Ue, a3 as Je, ao as Ce, a1 as $e, ae as Ee } from "./app-D0O4wr2X.js";
3
- import { useDialog as we, useSnackbar as Re, useProxiedModel as Xe } from "@feedmepos/ui-library";
4
- import { b as et, u as tt, f as Le, P as ie } from "./format-unit-display-CMM6DZJj.js";
5
- import { F as rt } from "./decimal-CPGmj9BT.js";
6
- import { useI18n as je } from "@feedmepos/mf-common";
7
- import { E as st } from "./empty-placeholder-wf6-BWE8.js";
8
- const Ve = He((v, y) => {
9
- const b = be();
10
- return {
11
- async readRequests(r) {
12
- const O = r ?? b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-request`;
13
- return await y.get(c);
14
- },
15
- async getPurchaseOrders({
16
- start: r,
17
- end: O
18
- }) {
19
- const c = b.currentLocationDBName, R = `${v.inventoryBackendUrl}/${c}/purchase-order`;
20
- return await y.get(`${R}?start=${r}&end=${O}`);
21
- },
22
- async getPurchaseOrderById(r) {
23
- const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
24
- return await y.get(`${c}/${r}`);
25
- },
26
- async processPurchaseOrder(r, O) {
27
- const c = b.currentLocationDBName, R = O || c, l = `${v.inventoryBackendUrl}/${R}/purchase-order/run-operation`;
28
- return await y.put(l, r);
29
- },
30
- async createPurchaseOrder(r) {
31
- const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
32
- return await y.post(c, r);
33
- },
34
- async updatePurchaseOrder(r) {
35
- const O = b.currentLocationDBName, c = `${v.inventoryBackendUrl}/${O}/purchase-order`;
36
- return await y.put(c, r);
37
- }
38
- };
39
- }), Ke = {
40
- [k.enum.confirmDraft]: {
41
- primaryActions: {
42
- text: "Confirm draft",
43
- close: !0
44
- },
45
- title: "Confirm draft?",
46
- message: "Purchase order cannot be changed after confirm draft.",
47
- successMessage: "Purchase order draft has been confirmed"
48
- },
49
- [k.enum.cancelDraft]: {
50
- primaryActions: {
51
- text: "Cancel draft",
52
- close: !0,
53
- variant: "destructive"
54
- },
55
- title: "Cancel draft?",
56
- message: "Purchase order cannot be changed after cancelled draft.",
57
- successMessage: "Purchase order draft has been cancelled"
58
- },
59
- [k.enum.submitRequest]: {
60
- primaryActions: {
61
- text: "Submit request",
62
- close: !0
63
- },
64
- title: "Confirm draft?",
65
- message: "Purchase order cannot be changed after confirm draft.",
66
- successMessage: "Purchase order draft has been submitted"
67
- },
68
- [k.enum.completeReceive]: {
69
- primaryActions: {
70
- text: "Mark received",
71
- close: !0
72
- },
73
- title: "Mark as received",
74
- message: "Purchase order cannot be changed after it has complete receiving.",
75
- successMessage: "Purchase order has been marked as received"
76
- },
77
- [k.enum.approveRequest]: {
78
- primaryActions: {
79
- text: "Approve request",
80
- close: !0
81
- },
82
- title: "Approve request?",
83
- message: "Purchase order will be approved.",
84
- successMessage: "Purchase order has been approved"
85
- },
86
- [k.enum.rejectRequest]: {
87
- primaryActions: {
88
- text: "Reject request",
89
- close: !0,
90
- variant: "destructive"
91
- },
92
- title: "Reject request?",
93
- message: "Purchase order will be rejected.",
94
- successMessage: "Purchase order has been rejected"
95
- }
96
- }, ve = K();
97
- function Cr(v, y) {
98
- const b = we(), r = be(), O = Be(), c = et(), R = tt(), l = K(!1), h = Re(), o = Ve(), s = K(new Array()), u = K(
99
- y != null && y.startDate && (y != null && y.endDate) ? y : ze()
100
- ), m = Y(() => {
101
- const p = new Date(u.value.startDate), d = new Date(u.value.endDate);
102
- return {
103
- start: Ye(p).toISOString(),
104
- end: Qe(d).toISOString()
105
- };
106
- }), f = K(new Array()), C = We(), z = K(null);
107
- async function te(p) {
108
- function d(n) {
109
- const _ = {
110
- mode: Te.CREATE,
111
- modelValue: p || void 0,
112
- show: !0,
113
- "onUpdate:show"(w) {
114
- ve.value.show = w;
115
- },
116
- templateId: n,
117
- lastClosingDate: z.value
118
- };
119
- ve.value = _;
120
- }
121
- let A;
122
- O.mustUsePoTemplate && !(p != null && p.template) ? b.open({
123
- title: "Create transfer",
124
- message: "",
125
- primaryActions: {
126
- text: "Select a template",
127
- close: !0
128
- },
129
- secondaryActions: {
130
- text: "Outlet to Outlet",
131
- variant: "secondary",
132
- close: !0
133
- }
134
- }).onPrimary(async () => {
135
- A = await c.getTemplateId(), A && d(A);
136
- }).onSecondary(() => {
137
- d(void 0);
138
- }) : d(A);
139
- }
140
- function ce(p) {
141
- const d = {
142
- mode: Te.UPDATE,
143
- modelValue: Ie(p),
144
- show: !0,
145
- "onUpdate:show"(A) {
146
- ve.value.show = A;
147
- },
148
- lastClosingDate: z.value
149
- };
150
- ve.value = d;
151
- }
152
- async function G() {
153
- s.value = [], l.value = !0;
154
- try {
155
- s.value = await o.getPurchaseOrders(m.value).then((A) => A.sort((n, _) => _._id.localeCompare(n._id)));
156
- const p = await C.readLastClosing(!0), d = p == null ? void 0 : p._id;
157
- d && (z.value = Ze(d)), O.mustUsePoTemplate && await R.fetchTemplates();
158
- } catch {
159
- h.open({
160
- title: "Something went wrong",
161
- message: "Error at fetching purchase orders",
162
- type: "error"
163
- });
164
- } finally {
165
- l.value = !1;
166
- }
167
- }
168
- async function ue() {
169
- f.value = [], l.value = !0;
170
- try {
171
- f.value = await o.readRequests().then((p) => p.reverse());
172
- } catch {
173
- h.open({
174
- title: "Something went wrong",
175
- message: "Error at fetching purchase requests",
176
- type: "error"
177
- });
178
- } finally {
179
- l.value = !1;
180
- }
181
- }
182
- function J() {
183
- switch (v) {
184
- case "receive/request":
185
- return G();
186
- case "approval":
187
- return ue();
188
- }
189
- }
190
- function re(p, d) {
191
- u.value = {
192
- startDate: p,
193
- endDate: d
194
- }, J();
195
- }
196
- r.watchLocation(async (p) => {
197
- if (!p) {
198
- s.value = [];
199
- return;
200
- }
201
- await J();
202
- });
203
- const X = K(), t = K(Math.random().toString());
204
- async function a(p, d) {
205
- var w, $;
206
- const A = Math.random().toString();
207
- t.value = A;
208
- const n = v === "receive/request" ? r.currentLocation : d == null ? void 0 : d.to, _ = {
209
- poRequest: d,
210
- purchaseOrder: p,
211
- transferTo: n == null ? void 0 : n.name,
212
- transferToDbName: n == null ? void 0 : n.dbName,
213
- show: !0,
214
- canResubmit: !1,
215
- canApprove: v === "approval",
216
- "onUpdate:show"(T) {
217
- X.value.show = T;
218
- }
219
- };
220
- if (X.value = _, !(d || p.status !== B.enum.REQUESTING)) {
221
- try {
222
- d = (await o.readRequests(
223
- `${p.supplier.internal}_${p.supplier._id}`
224
- )).find((L) => L.purchaseOrderId === p._id);
225
- } catch {
226
- console.error("Error at fetching po request to check");
227
- }
228
- A === t.value && (X.value.canResubmit = !d, X.value.transferTo = (w = d == null ? void 0 : d.to) == null ? void 0 : w.name, X.value.transferToDbName = ($ = d == null ? void 0 : d.to) == null ? void 0 : $.dbName);
229
- }
230
- }
231
- async function P(p, d, A, n) {
232
- l.value = !0;
233
- try {
234
- await o.processPurchaseOrder(
235
- {
236
- operation: d,
237
- doc: p,
238
- options: (
239
- // auto receive for supplier to warehouse
240
- (d === k.enum.confirmDraft || // auto receive for warehouse to warehouse
241
- d === k.enum.completeReceive) && O.autoReceiveWarehouse ? {
242
- autoReceive: !0
243
- } : void 0
244
- )
245
- },
246
- n
247
- ), await new Promise(($) => setTimeout($, 1e3));
248
- const w = be().currentLocationDBName.startsWith("restaurant_");
249
- d === k.enum.confirmDraft && p.effectiveAt && w ? h.open({
250
- title: "Success",
251
- message: `${A}. The backdate will be reflected once your POS has received this change.`,
252
- type: "success"
253
- }) : h.open({
254
- title: "Success",
255
- message: A,
256
- type: "success"
257
- });
258
- } catch (_) {
259
- h.open({
260
- title: "Something went wrong",
261
- message: "Please try again.",
262
- type: "error"
263
- }), console.error("Error when submitting PO operation", d, p, _);
264
- } finally {
265
- l.value = !1, J();
266
- }
267
- }
268
- async function N(p, d, A) {
269
- const n = Ke[d];
270
- if (!n) {
271
- h.open({
272
- title: "Something went wrong",
273
- message: `Cannot process order: ${Fe(d)}`,
274
- type: "error"
275
- });
276
- return;
277
- }
278
- const { successMessage: _, ...w } = n;
279
- b.open({
280
- title: w.title,
281
- message: w.message,
282
- primaryActions: w.primaryActions
283
- }).onPrimary(() => {
284
- P(p, d, _, A);
285
- });
286
- }
287
- return {
288
- purchaseOrders: s,
289
- purchaseRequests: f,
290
- updateDateRange: re,
291
- fetchData: J,
292
- loading: l,
293
- transferDialogProps: ve,
294
- promptCreateTransferDialog: te,
295
- promptUpdateTransferDialog: ce,
296
- transferDetailsProps: X,
297
- promptShowTransferDetails: a,
298
- submitAction: N
299
- };
300
- }
301
- function at(v, y) {
302
- return y.reduce(
303
- (r, O) => {
304
- const c = O.received.find((R) => R.sku._id === v._id);
305
- return c && (r = Se(r, c.amount)), r;
306
- },
307
- rt.toPrecision(he(0), v.unit.precision)
308
- );
309
- }
310
- function nt(v, y) {
311
- const { name: b, address: r, regNo: O } = y.doc.profile, c = {
312
- name: b,
313
- registrationNumber: O,
314
- line1: r == null ? void 0 : r.line1,
315
- line2: r == null ? void 0 : r.line2,
316
- postcode: r == null ? void 0 : r.postcode,
317
- city: r == null ? void 0 : r.city,
318
- state: r == null ? void 0 : r.state,
319
- country: r == null ? void 0 : r.country
320
- }, R = {
321
- name: v.supplier.name,
322
- registrationNumber: v.supplier.registrationNumber,
323
- line1: v.supplier.address.line1,
324
- line2: v.supplier.address.line2,
325
- postcode: v.supplier.address.postcode,
326
- city: v.supplier.address.city,
327
- state: v.supplier.address.state,
328
- country: v.supplier.address.country
329
- }, l = v.items.map((u) => {
330
- const { sku: m, measurement: f } = u, C = fe(
331
- at(u.sku, v.deliveryOrder || []),
332
- !1
333
- );
334
- return {
335
- code: m.code,
336
- description: m.name,
337
- quantity: Le(u.quantity, m.unit, u.measurement),
338
- unit: (f == null ? void 0 : f.abbrev) || m.unit.abbrev,
339
- received: C
340
- };
341
- }), h = v.deliveryOrder.map((u) => ({
342
- createdAt: Me(new Date(u.createdAt)),
343
- ref: u.deliveryOrderNumber,
344
- remark: u.remark || "",
345
- items: u.received.map((m) => {
346
- var f;
347
- return {
348
- code: m.sku.code,
349
- description: m.sku.name,
350
- quantity: fe(m.amount),
351
- unit: ((f = m.measurement) == null ? void 0 : f.abbrev) || m.sku.unit.abbrev
352
- };
353
- })
354
- })), o = {
355
- orderNumber: v.seqNumber.toString(),
356
- createdAt: ge(v._id),
357
- ref: v.ref || "",
358
- remark: v.remark || "",
359
- buyer: c,
360
- supplier: R,
361
- items: l,
362
- status: v.status,
363
- deliveryOrders: h
364
- }, s = new URL(window.location.href);
365
- s.pathname = s.hostname.includes("inventory.feedme") ? "/receive-request/print-preview" : "/inventory/receive-request/print-preview", s.searchParams.append("data", JSON.stringify(o)), window.open(s.href, "_blank", "noreferrer");
366
- }
367
- const me = {
368
- submitRequest: {
369
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
370
- color: "text-fm-color-typo-primary",
371
- value: k.enum.submitRequest
372
- },
373
- confirmDraft: {
374
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
375
- color: "text-fm-color-typo-primary",
376
- value: k.enum.confirmDraft
377
- },
378
- cancelDraft: {
379
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
380
- color: "text-fm-color-typo-error",
381
- value: k.enum.cancelDraft
382
- },
383
- approveRequest: {
384
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
385
- color: "text-fm-color-typo-primary",
386
- value: k.enum.approveRequest
387
- },
388
- rejectRequest: {
389
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
390
- color: "text-fm-color-typo-error",
391
- value: k.enum.rejectRequest
392
- },
393
- processRequest: {
394
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
395
- color: "text-fm-color-typo-primary",
396
- value: k.enum.processRequest
397
- },
398
- receiveStock: {
399
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
400
- color: "text-fm-color-typo-primary",
401
- value: k.enum.receiveStock
402
- },
403
- completeReceive: {
404
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
405
- color: "text-fm-color-typo-primary",
406
- value: k.enum.completeReceive
407
- }
408
- };
409
- function $r(v, y) {
410
- const b = be(), { t: r } = je();
411
- function O(s) {
412
- switch (s.status) {
413
- case "DRAFT":
414
- return [
415
- V[F.Update],
416
- V[F.Details],
417
- s.supplier.internal === "restaurant" || s.supplier.internal === "warehouse" ? me[k.enum.submitRequest] : me[k.enum.confirmDraft],
418
- me[k.enum.cancelDraft],
419
- V[F.Print]
420
- ];
421
- case "RECEIVING":
422
- return [
423
- me[k.enum.completeReceive],
424
- V[F.Details],
425
- V[F.Print]
426
- ];
427
- case "REQUESTING":
428
- return v === "receive/request" ? [V[F.Details], V[F.Print]] : [
429
- me[k.enum.approveRequest],
430
- me[k.enum.rejectRequest],
431
- V[F.Details],
432
- V[F.Print]
433
- ];
434
- case "PROCESSING":
435
- return [V[F.Details], V[F.Print]];
436
- case "COMPLETE":
437
- case "CANCEL":
438
- default:
439
- return [V[F.Details], V[F.Print]];
440
- }
441
- }
442
- function c(s) {
443
- return Object.values(k.enum).includes(s);
444
- }
445
- async function R(s, u, m) {
446
- var C, z;
447
- const f = Ie(u);
448
- if (s === F.Print) {
449
- nt(f, b.currentLocation);
450
- return;
451
- }
452
- if (s === F.Details) {
453
- y.promptShowTransferDetails(f, m);
454
- return;
455
- }
456
- if (s === F.Update) {
457
- (C = y.promptUpdateTransferDialog) == null || C.call(y, f);
458
- return;
459
- }
460
- if (c(s)) {
461
- y.submitAction(u, s, (z = m == null ? void 0 : m.to) == null ? void 0 : z.dbName);
462
- return;
463
- }
464
- }
465
- function l() {
466
- return [
467
- {
468
- accessorKey: "seqNumber",
469
- header: () => r("inventory.transfer.table.seqNo"),
470
- enableSorting: !0,
471
- size: 80,
472
- sortUndefined: "last"
473
- },
474
- {
475
- accessorKey: "_id",
476
- header: () => r("inventory.transfer.table.createdAt"),
477
- cell(s) {
478
- return ge(`${s.getValue()}`);
479
- },
480
- enableSorting: !0
481
- },
482
- {
483
- accessorKey: "supplier.name",
484
- header: () => r("inventory.transfer.table.transferFrom"),
485
- enableSorting: !0,
486
- size: 200
487
- },
488
- {
489
- accessorKey: "items.length",
490
- header: () => r("inventory.transfer.table.noOfItems"),
491
- enableSorting: !1,
492
- meta: {
493
- width: "10rem"
494
- }
495
- },
496
- {
497
- accessorKey: "ref",
498
- header: () => r("inventory.transfer.table.reference"),
499
- enableSorting: !1,
500
- size: "auto"
501
- },
502
- {
503
- accessorKey: "status",
504
- header: () => r("inventory.transfer.table.status"),
505
- cell(s) {
506
- const u = r(`inventory.transfer.status.${s.getValue() ?? ""}`), m = `${s.getValue() ?? ""}`.toLocaleLowerCase("en-us");
507
- return oe(
508
- "div",
509
- {
510
- class: "flex"
511
- },
512
- oe(
513
- "div",
514
- {
515
- class: `fm-status-badge fm-status-badge-${m}`
516
- },
517
- u
518
- )
519
- );
520
- },
521
- enableSorting: !0,
522
- size: 200
523
- },
524
- {
525
- id: "action",
526
- cell(s) {
527
- const u = s.row.original, m = O(u);
528
- return Pe(m, (f) => R(f, u));
529
- },
530
- enableSorting: !1,
531
- size: 40,
532
- meta: {
533
- cellClass: "",
534
- headerClass: ""
535
- }
536
- }
537
- ];
538
- }
539
- function h() {
540
- return [
541
- {
542
- accessorKey: "purchaseOrder.seqNumber",
543
- header: () => r("inventory.transfer.table.seqNo"),
544
- enableSorting: !0,
545
- size: 80,
546
- sortUndefined: "last"
547
- },
548
- {
549
- accessorKey: "purchaseOrder._id",
550
- header: () => r("inventory.transfer.table.createdAt"),
551
- cell(s) {
552
- return ge(`${s.getValue()}`);
553
- },
554
- enableSorting: !0
555
- },
556
- {
557
- accessorKey: "to.name",
558
- header: () => r("inventory.transfer.table.transferTo"),
559
- enableSorting: !1,
560
- size: 200
561
- },
562
- {
563
- accessorKey: "purchaseOrder.items.length",
564
- header: () => r("inventory.transfer.table.noOfItems"),
565
- enableSorting: !1
566
- },
567
- {
568
- accessorKey: "purchaseOrder.ref",
569
- header: () => r("inventory.transfer.table.reference"),
570
- enableSorting: !1,
571
- size: "auto"
572
- },
573
- {
574
- accessorKey: "purchaseOrder.status",
575
- header: () => r("inventory.transfer.table.status"),
576
- cell(s) {
577
- const u = r(`inventory.transfer.status.${s.getValue() ?? ""}`), m = `${s.getValue() ?? ""}`.toLocaleLowerCase("en-us");
578
- return oe(
579
- "div",
580
- {
581
- class: "flex"
582
- },
583
- oe(
584
- "div",
585
- {
586
- class: `fm-status-badge fm-status-badge-${m}`
587
- },
588
- u
589
- )
590
- );
591
- },
592
- enableSorting: !0
593
- },
594
- {
595
- id: "action",
596
- cell(s) {
597
- const u = s.row.original, m = u.purchaseOrder ? O(u.purchaseOrder) : [];
598
- return Pe(
599
- m,
600
- (f) => u.purchaseOrder ? R(f, u.purchaseOrder, u) : void 0
601
- );
602
- },
603
- enableSorting: !1,
604
- size: 40,
605
- meta: {
606
- cellClass: "",
607
- headerClass: ""
608
- }
609
- }
610
- ];
611
- }
612
- const o = Y(() => v === "receive/request" ? l() : h());
613
- return {
614
- get columnDefs() {
615
- return o.value;
616
- }
617
- };
618
- }
619
- const ot = {
620
- key: 0,
621
- class: "flex flex-col gap-8"
622
- }, lt = { class: "flex flex-col gap-4" }, it = { class: "fm-typo-en-body-lg-600" }, ct = {
623
- key: 0,
624
- class: "flex flex-col gap-4"
625
- }, ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dt = { class: "fm-typo-en-body-lg-600" }, mt = {
626
- key: 1,
627
- class: "flex flex-col gap-4"
628
- }, ft = { class: "fm-typo-en-body-lg-600" }, pt = {
629
- key: 2,
630
- class: "flex flex-col gap-4"
631
- }, vt = { class: "fm-typo-en-body-lg-600" }, yt = /* @__PURE__ */ _e({
632
- __name: "NetSuiteInfo",
633
- props: {
634
- transferType: {},
635
- transferToDbName: {},
636
- poRequest: {},
637
- purchaseOrder: {},
638
- isTransferBetweenOutlets: { type: Boolean }
639
- },
640
- setup(v) {
641
- const y = v, b = Ue(), r = Y(
642
- () => {
643
- var c, R, l, h, o, s;
644
- return b.getLocationSubsidiary(
645
- ((l = (R = (c = y.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : R.subsidiary) == null ? void 0 : l.id) || ((s = (o = (h = y.poRequest) == null ? void 0 : h.netSuite) == null ? void 0 : o.subsidiary) == null ? void 0 : s.id)
646
- ).fullName;
647
- }
648
- ), O = Y(() => {
649
- var c, R, l, h, o, s;
650
- return (R = (c = y.purchaseOrder) == null ? void 0 : c.deliveryFullfillment) != null && R.length && ((h = (l = y.purchaseOrder) == null ? void 0 : l.deliveryFullfillment) == null ? void 0 : h.length) > 0 ? (s = (o = y.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) == null ? void 0 : s.map((u) => {
651
- var m;
652
- return (m = u.netSuite) == null ? void 0 : m.refNo;
653
- }).join(", ") : "-";
654
- });
655
- return (c, R) => {
656
- var l, h, o, s, u, m, f, C, z, te, ce, G, ue, J;
657
- return i(b).isEnabled ? (g(), D("div", ot, [
658
- e("div", lt, [
659
- R[0] || (R[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
660
- e("div", it, S(r.value || "-"), 1)
661
- ]),
662
- c.isTransferBetweenOutlets ? x("", !0) : (g(), D("div", ct, [
663
- e("div", ut, " NetSuite " + S(c.transferType === i(ie).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
664
- e("div", dt, S(c.poRequest ? (h = (l = c.poRequest) == null ? void 0 : l.netSuite) == null ? void 0 : h.refNo : (s = (o = c.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : s.refNo) + " (" + S(c.poRequest ? (m = (u = c.poRequest) == null ? void 0 : u.netSuite) == null ? void 0 : m.id : (C = (f = c.purchaseOrder) == null ? void 0 : f.netSuite) == null ? void 0 : C.id) + ") ", 1)
665
- ])),
666
- (ce = (te = (z = c.purchaseOrder) == null ? void 0 : z.netSuite) == null ? void 0 : te.additionalInfo) != null && ce.transactionnumber ? (g(), D("div", mt, [
667
- R[1] || (R[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
668
- e("div", ft, S((J = (ue = (G = c.purchaseOrder) == null ? void 0 : G.netSuite) == null ? void 0 : ue.additionalInfo) == null ? void 0 : J.transactionnumber), 1)
669
- ])) : x("", !0),
670
- i(b).isEnabled && c.transferType === i(ie).TRANSFER && !c.isTransferBetweenOutlets ? (g(), D("div", pt, [
671
- R[2] || (R[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
672
- e("div", vt, S(O.value), 1)
673
- ])) : x("", !0)
674
- ])) : x("", !0);
675
- };
676
- }
677
- }), ht = {
678
- key: 0,
679
- class: "flex flex-row-reverse"
680
- }, bt = /* @__PURE__ */ _e({
681
- __name: "NetSuiteSync",
682
- props: {
683
- poRequest: {},
684
- purchaseOrder: {},
685
- isTransferBetweenOutlets: { type: Boolean }
686
- },
687
- setup(v) {
688
- const y = v, b = Ue(), r = Re(), O = we(), c = K(!1), R = Y(() => {
689
- var u, m, f, C;
690
- let h = !0;
691
- b.isEnabled || (h = !1);
692
- const o = y.purchaseOrder, s = y.poRequest;
693
- return o && ((u = o == null ? void 0 : o.supplier) != null && u.internal ? (!s && o.status == B.enum.DRAFT && (h = !1), s && !((m = s == null ? void 0 : s.netSuite) != null && m.id) && (h = !1), y.isTransferBetweenOutlets && (h = !1)) : ((o == null ? void 0 : o.status) !== B.enum.REQUESTING && o.supplier.internal && (h = !1), !s && !((f = o == null ? void 0 : o.netSuite) != null && f.id) && (h = !1), !s && ((C = o == null ? void 0 : o.netSuite) != null && C.id) && (o == null ? void 0 : o.status) == B.enum.REQUESTING && (h = !1))), h;
694
- });
695
- async function l() {
696
- c.value || O.open({
697
- title: "Sync with NetSuite",
698
- contentComponent: oe("div", [
699
- oe("p", "Are you sure you want to sync now?"),
700
- oe("br"),
701
- oe(
702
- "p",
703
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
704
- "Please wait a moment before syncing manually to avoid unnecessary actions."
705
- )
706
- ]),
707
- primaryActions: {
708
- text: "Sync",
709
- close: !0,
710
- variant: "destructive"
711
- },
712
- secondaryActions: { text: "Not now", close: !0 }
713
- }).onPrimary(async () => {
714
- var h;
715
- try {
716
- c.value = !0;
717
- const o = y.purchaseOrder, s = y.poRequest;
718
- let u = "purchaseOrder";
719
- if ((h = o == null ? void 0 : o.supplier) != null && h.internal && (u = "purchaseOrderRequest"), !(o != null && o._id)) {
720
- r.open({
721
- title: "Error",
722
- message: "Invalid sync ID",
723
- type: "error"
724
- });
725
- return;
726
- }
727
- await b.syncTransferOrder(u, o == null ? void 0 : o._id, s == null ? void 0 : s._id), r.open({
728
- title: "Sync with NetSuite",
729
- message: "Requested to sync with NetSuite. Please wait a moment.",
730
- type: "success"
731
- });
732
- } catch {
733
- r.open({
734
- title: "Error",
735
- message: "Failed to sync with NetSuite",
736
- type: "error"
737
- });
738
- }
739
- setTimeout(() => {
740
- c.value = !1;
741
- }, 5e3);
742
- });
743
- }
744
- return (h, o) => {
745
- const s = Z("FmButton");
746
- return R.value ? (g(), D("div", ht, [
747
- U(s, {
748
- "prepend-icon": "sync",
749
- variant: "primary",
750
- label: "NetSuite",
751
- loading: c.value,
752
- onClick: l
753
- }, null, 8, ["loading"])
754
- ])) : x("", !0);
755
- };
756
- }
757
- }), gt = { class: "flex flex-col gap-16 w-full h-full" }, St = { class: "flex justify-between" }, _t = { class: "fm-typo-en-body-lg-600" }, wt = { class: "flex flex-col gap-8" }, Rt = { class: "flex flex-col gap-4" }, Ot = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dt = { class: "flex gap-1" }, kt = { class: "fm-typo-en-body-lg-600" }, At = {
758
- key: 0,
759
- class: "flex flex-col gap-4"
760
- }, qt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Nt = { class: "fm-typo-en-body-lg-600" }, xt = { class: "flex flex-col gap-4" }, Tt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "fm-typo-en-body-lg-600" }, Ct = {
761
- key: 1,
762
- class: "flex flex-col gap-4"
763
- }, $t = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Et = { class: "fm-typo-en-body-lg-600" }, It = {
764
- key: 2,
765
- class: "flex flex-col gap-4"
766
- }, Ft = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "fm-typo-en-body-lg-600" }, Mt = {
767
- key: 3,
768
- class: "flex flex-col gap-4"
769
- }, Ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lt = { class: "fm-typo-en-body-lg-600" }, jt = {
770
- key: 4,
771
- class: "flex flex-col gap-4"
772
- }, Vt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Kt = { class: "fm-typo-en-body-lg-600" }, Gt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ht = { class: "flex flex-col gap-8" }, zt = { class: "fm-typo-en-body-lg-600" }, Yt = { class: "flex gap-8" }, Qt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Wt = { class: "flex w-full gap-4" }, Zt = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, Jt = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, Xt = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, er = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, tr = {
773
- key: 0,
774
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
775
- }, rr = { class: "py-8" }, sr = { class: "flex justify-end gap-4 items-center" }, ar = { class: "fm-typo-en-body-lg-600" }, nr = {
776
- key: 1,
777
- class: "flex-1 xs:w-screen xs:max-w-full"
778
- }, or = {
779
- key: 0,
780
- class: "flex flex-col items-center gap-8 h-full"
781
- }, lr = ["src"], ir = { class: "fm-typo-en-body-lg-600" }, cr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, ur = {
782
- key: 1,
783
- class: "px-4 flex flex-col"
784
- }, dr = { class: "flex gap-12 content-stretch" }, mr = {
785
- class: "flex flex-col w-24",
786
- name: "circles"
787
- }, fr = { class: "flex-1 flex flex-col items-center" }, pr = { class: "flex-1 flex flex-col items-center" }, vr = {
788
- class: "py-12 flex flex-col gap-4",
789
- name: "received-at header"
790
- }, yr = { class: "fm-typo-en-body-lg-400" }, hr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, br = { class: "flex gap-12 content-stretch" }, gr = {
791
- class: "flex flex-col w-24",
792
- name: "circles"
793
- }, Sr = { class: "flex-1 flex flex-col items-center" }, _r = {
794
- class: "py-12 flex flex-col gap-4 flex-1",
795
- name: "delivery details"
796
- }, wr = { class: "flex flex-col gap-8" }, Rr = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Or = { class: "flex flex-col gap-4" }, Dr = { class: "flex gap-8 xs:flex-col" }, Er = /* @__PURE__ */ _e({
797
- __name: "TransferDetails",
798
- props: {
799
- poRequest: {},
800
- purchaseOrder: {},
801
- transferTo: {},
802
- transferToDbName: {},
803
- show: { type: Boolean },
804
- canResubmit: { type: Boolean },
805
- canApprove: { type: Boolean }
806
- },
807
- emits: ["update:show", "submitted"],
808
- setup(v, { emit: y }) {
809
- const b = v, r = y, O = we(), c = Re(), R = Be(), { t: l } = je(), h = Y(
810
- () => {
811
- var t, a, P, N;
812
- return ((a = (t = b.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : a.internal) === "restaurant" || ((N = (P = b.purchaseOrder) == null ? void 0 : P.supplier) == null ? void 0 : N.internal) === "warehouse" ? ie.TRANSFER : ie.PURCHASE;
813
- }
814
- ), o = Y(() => {
815
- var t, a, P;
816
- return h.value === ie.TRANSFER && ((t = b.transferToDbName) == null ? void 0 : t.startsWith("restaurant")) && ((P = (a = b.purchaseOrder) == null ? void 0 : a.supplier) == null ? void 0 : P.internal) === "restaurant";
817
- }), s = [
818
- {
819
- label: l("inventory.transfer.receiveRequest.details.overview"),
820
- value: "overview"
821
- },
822
- {
823
- label: l("inventory.transfer.receiveRequest.details.deliveryHistory"),
824
- value: "deliveryHistory"
825
- }
826
- ], u = K(s[0]), m = K(!1), f = K(""), C = K(!0), z = Ve(), te = Xe(b, "show");
827
- async function ce(t, a, P) {
828
- f.value = a, m.value = !0, C.value = !1;
829
- try {
830
- await z.processPurchaseOrder(
831
- {
832
- operation: a,
833
- doc: t,
834
- options: (
835
- // auto receive for supplier to warehouse
836
- (a === k.enum.confirmDraft || // auto receive for warehouse to warehouse
837
- a === k.enum.completeReceive) && R.autoReceiveWarehouse ? {
838
- autoReceive: !0
839
- } : void 0
840
- )
841
- },
842
- b.transferToDbName
843
- ), await new Promise((N) => setTimeout(N, 1e3)), c.open({
844
- title: "Success",
845
- message: P,
846
- type: "success"
847
- }), r("update:show", !1), r("submitted");
848
- } catch (N) {
849
- c.open({
850
- title: "Something went wrong",
851
- message: "Please try again.",
852
- type: "error"
853
- }), console.error("Error when submitting PO operation", a, t, N);
854
- } finally {
855
- f.value = "", m.value = !1, C.value = !0;
856
- }
857
- }
858
- async function G(t) {
859
- const a = Ke[t];
860
- if (!a) {
861
- c.open({
862
- title: "Something went wrong",
863
- message: `Cannot process order: ${Fe(t)}`,
864
- type: "error"
865
- });
866
- return;
867
- }
868
- const { successMessage: P, ...N } = a;
869
- O.open({
870
- title: N.title,
871
- message: N.message,
872
- primaryActions: N.primaryActions
873
- }).onPrimary(() => {
874
- b.purchaseOrder && ce(b.purchaseOrder, t, P);
875
- });
876
- }
877
- const ue = Y(() => {
878
- var t, a;
879
- return ((t = b.purchaseOrder) == null ? void 0 : t.status) === B.enum.RECEIVING || ((a = b.purchaseOrder) == null ? void 0 : a.status) === B.enum.COMPLETE;
880
- }), J = Y(() => {
881
- var d, A, n;
882
- const P = (((d = b.purchaseOrder) == null ? void 0 : d.deliveryOrder) ?? []).flatMap((_) => _.received ?? []).reduce(
883
- (_, w) => {
884
- const $ = _[w.sku._id] ?? [];
885
- return _[w.sku._id] = [...$, w], _;
886
- },
887
- {}
888
- ), N = Object.entries(P).reduce(
889
- (_, [w, $]) => {
890
- const T = $.reduce((L, j) => {
891
- const Q = Je(
892
- L,
893
- Math.max(L.precision, j.amount.precision)
894
- );
895
- return Se(Q, j.amount);
896
- }, he(0));
897
- return _[w] = T, _;
898
- },
899
- {}
900
- ), p = ((A = b.purchaseOrder) == null ? void 0 : A.items) ?? [];
901
- for (const _ of p)
902
- N[n = _.sku._id] ?? (N[n] = he(0));
903
- return N;
904
- }), re = Y(() => {
905
- var d, A;
906
- const t = ((d = b.purchaseOrder) == null ? void 0 : d.deliveryOrder) ?? [], a = ((A = b.purchaseOrder) == null ? void 0 : A.deliveryFullfillment) ?? [], P = [
907
- ...t.map((n) => ({
908
- createdAt: n.createdAt,
909
- type: "grn",
910
- doc: n
911
- })),
912
- ...a.map((n) => ({
913
- createdAt: n.createdAt,
914
- type: "fulfillment",
915
- doc: n
916
- }))
917
- ];
918
- P.reverse().sort((n, _) => n.createdAt.localeCompare(_.createdAt));
919
- function N(n) {
920
- var w, $, T, L, j, Q, se;
921
- const _ = a.findIndex((M) => M.id === n.fullfillmentId);
922
- return {
923
- header: "Received",
924
- date: Ee(new Date(n.createdAt)),
925
- info: [
926
- {
927
- label: "Received by",
928
- values: [(w = n.createdBy) == null ? void 0 : w.name]
929
- },
930
- {
931
- label: "Received items",
932
- values: n.received.map((M) => {
933
- var ae;
934
- return `(${M.sku.code}) ${M.sku.name}: ${fe(M.amount, !1)} ${((ae = M.measurement) == null ? void 0 : ae.abbrev) ?? M.sku.unit.abbrev}`;
935
- })
936
- },
937
- n.deliveryOrderNumber ? {
938
- label: "Delivery order no.",
939
- values: [n.deliveryOrderNumber]
940
- } : null,
941
- n.remark ? {
942
- label: "Remark",
943
- values: [n.remark]
944
- } : null,
945
- _ > -1 ? {
946
- label: "Fulfilment's sequence",
947
- values: [`${_ + 1}`]
948
- } : null,
949
- (T = ($ = a[_]) == null ? void 0 : $.netSuite) != null && T.refNo ? {
950
- label: "Fulfillment's ref no. (Netsuite)",
951
- values: [(j = (L = a[_]) == null ? void 0 : L.netSuite) == null ? void 0 : j.refNo]
952
- } : null,
953
- (Q = n == null ? void 0 : n.netSuite) != null && Q.refNo ? {
954
- label: "Item receipt (Netsuite)",
955
- values: [(se = n == null ? void 0 : n.netSuite) == null ? void 0 : se.refNo]
956
- } : null
957
- ].filter((M) => M)
958
- };
959
- }
960
- function p(n) {
961
- var w, $;
962
- const _ = a.findIndex((T) => T.id === n.id);
963
- return {
964
- header: "Fulfillment",
965
- date: Ee(new Date(n.createdAt)),
966
- info: [
967
- {
968
- label: "Sequence",
969
- values: [String(_ + 1)]
970
- },
971
- {
972
- label: "Receiveable items",
973
- values: n.items.map((T) => {
974
- var L;
975
- return `(${T.sku.code}) ${T.sku.name}: ${fe(T.amount, !1)} ${((L = T.measurement) == null ? void 0 : L.abbrev) ?? T.sku.unit.abbrev}`;
976
- })
977
- },
978
- (w = n.netSuite) != null && w.refNo ? {
979
- label: "Ref no. (Netsuite)",
980
- values: [($ = n.netSuite) == null ? void 0 : $.refNo]
981
- } : null
982
- ].filter((T) => T)
983
- };
984
- }
985
- return P.map((n) => {
986
- switch (n.type) {
987
- case "grn":
988
- return N(n.doc);
989
- case "fulfillment":
990
- return p(n.doc);
991
- }
992
- });
993
- }), X = Y(() => {
994
- var a;
995
- const t = {
996
- ...he(0),
997
- currency: Ce()
998
- };
999
- return ((a = b.purchaseOrder) == null ? void 0 : a.items.reduce((P, N) => ({
1000
- ...Se(P, N.totalCost ?? t),
1001
- currency: Ce()
1002
- }), t)) ?? t;
1003
- });
1004
- return (t, a) => {
1005
- var T, L;
1006
- const P = Z("FmButtonGroup"), N = Z("FmChip"), p = Z("FmMenuDivider"), d = Z("FmCard"), A = Z("FmIcon"), n = Z("FmTooltip"), _ = Z("FmSpacer"), w = Z("FmButton"), $ = Z("FmSideSheet");
1007
- return g(), W($, {
1008
- header: i(l)("inventory.transfer.receiveRequest.details.title") + ((T = t.purchaseOrder) != null && T.seqNumber ? ` #${(L = t.purchaseOrder) == null ? void 0 : L.seqNumber}` : ""),
1009
- modelValue: i(te),
1010
- "onUpdate:modelValue": a[9] || (a[9] = (j) => Ge(te) ? te.value = j : null),
1011
- "dismiss-away": C.value,
1012
- "close-button": "",
1013
- "max-width": 600
1014
- }, {
1015
- default: de(() => {
1016
- var j, Q, se, M, ae;
1017
- return [
1018
- e("div", gt, [
1019
- U(bt, {
1020
- "po-request": t.poRequest,
1021
- "purchase-order": t.purchaseOrder,
1022
- "is-transfer-between-outlets": o.value
1023
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets"]),
1024
- e("div", null, [
1025
- U(P, {
1026
- items: s,
1027
- modelValue: u.value,
1028
- "onUpdate:modelValue": a[0] || (a[0] = (q) => u.value = q)
1029
- }, null, 8, ["modelValue"])
1030
- ]),
1031
- u.value.value === "overview" ? (g(), D(ne, { key: 0 }, [
1032
- e("div", null, [
1033
- U(d, {
1034
- variant: "outlined",
1035
- class: "flex flex-col gap-8 px-12 py-16"
1036
- }, {
1037
- default: de(() => {
1038
- var q, E, I, ee, le, H, Oe, De, ke, Ae, qe, Ne;
1039
- return [
1040
- e("div", St, [
1041
- e("div", _t, S(i(l)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1042
- e("div", null, [
1043
- U(N, {
1044
- label: i(l)(`inventory.transfer.status.${(q = t.purchaseOrder) == null ? void 0 : q.status}`),
1045
- class: ye(`fm-status-badge fm-status-badge-${(I = (E = t.purchaseOrder) == null ? void 0 : E.status) == null ? void 0 : I.toLocaleLowerCase("en-us")}`),
1046
- compact: ""
1047
- }, null, 8, ["label", "class"])
1048
- ])
1049
- ]),
1050
- U(p),
1051
- e("div", wt, [
1052
- e("div", Rt, [
1053
- e("div", Ot, [
1054
- e("div", Dt, S(i(l)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1055
- ]),
1056
- e("div", kt, S(i(ge)(((ee = t.purchaseOrder) == null ? void 0 : ee._id) ?? "")), 1)
1057
- ]),
1058
- (le = t.purchaseOrder) != null && le.effectiveAt ? (g(), D("div", At, [
1059
- e("div", qt, S(i(l)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1060
- e("div", Nt, S(i(Me)(new Date((H = t.purchaseOrder) == null ? void 0 : H.effectiveAt))), 1)
1061
- ])) : x("", !0),
1062
- e("div", xt, [
1063
- e("div", Tt, S(i(l)("inventory.transfer.receiveRequest.details.type.title")), 1),
1064
- e("div", Pt, S(i(l)(
1065
- `inventory.transfer.receiveRequest.details.type.${h.value.toLocaleLowerCase("en-US")}`
1066
- )), 1)
1067
- ]),
1068
- (De = (Oe = t.purchaseOrder) == null ? void 0 : Oe.supplier) != null && De.name ? (g(), D("div", Ct, [
1069
- e("div", $t, S(i(l)("inventory.transfer.receiveRequest.details.from")), 1),
1070
- e("div", Et, S((Ae = (ke = t.purchaseOrder) == null ? void 0 : ke.supplier) == null ? void 0 : Ae.name), 1)
1071
- ])) : x("", !0),
1072
- t.transferTo ? (g(), D("div", It, [
1073
- e("div", Ft, S(i(l)("inventory.transfer.receiveRequest.details.to")), 1),
1074
- e("div", Bt, S(t.transferTo), 1)
1075
- ])) : x("", !0),
1076
- U(yt, {
1077
- "po-request": t.poRequest,
1078
- "purchase-order": t.purchaseOrder,
1079
- "transfer-type": h.value,
1080
- "transfer-to-db-name": t.transferToDbName,
1081
- "is-transfer-between-outlets": o.value
1082
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets"]),
1083
- (qe = t.purchaseOrder) != null && qe.ref ? (g(), D("div", Mt, [
1084
- e("div", Ut, S(i(l)("inventory.transfer.receiveRequest.details.reference")), 1),
1085
- e("div", Lt, S(t.purchaseOrder.ref), 1)
1086
- ])) : x("", !0),
1087
- (Ne = t.purchaseOrder) != null && Ne.remark ? (g(), D("div", jt, [
1088
- e("div", Vt, S(i(l)("inventory.transfer.receiveRequest.details.remark")), 1),
1089
- e("div", Kt, S(t.purchaseOrder.remark), 1)
1090
- ])) : x("", !0)
1091
- ])
1092
- ];
1093
- }),
1094
- _: 1
1095
- })
1096
- ]),
1097
- e("div", Gt, [
1098
- e("div", Ht, [
1099
- e("div", zt, [
1100
- e("div", Yt, [
1101
- xe(S(ue.value ? i(l)("inventory.transfer.receiveRequest.details.receivedItems") : i(l)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1102
- (Q = (j = t.purchaseOrder) == null ? void 0 : j.netSuite) != null && Q.missingItems && ((M = (se = t.purchaseOrder) == null ? void 0 : se.netSuite) == null ? void 0 : M.missingItems.length) > 0 ? (g(), W(n, {
1103
- key: 0,
1104
- variant: "rich",
1105
- placement: "top",
1106
- "z-index": 51
1107
- }, {
1108
- content: de(() => {
1109
- var q, E;
1110
- return [
1111
- e("div", Qt, [
1112
- (g(!0), D(ne, null, pe((E = (q = t.purchaseOrder) == null ? void 0 : q.netSuite) == null ? void 0 : E.missingItems, (I, ee) => (g(), D("div", {
1113
- class: "flex justify-center align-middle",
1114
- key: ee
1115
- }, [
1116
- U(A, {
1117
- name: "arrow_right",
1118
- size: "sm"
1119
- }),
1120
- xe(" " + S(`(${I.netSuiteId}) ${I.name}: ${I.reason}`), 1)
1121
- ]))), 128))
1122
- ])
1123
- ];
1124
- }),
1125
- default: de(() => [
1126
- U(A, {
1127
- name: "error",
1128
- color: "#ff2c2c",
1129
- size: "sm"
1130
- })
1131
- ]),
1132
- _: 1
1133
- })) : x("", !0)
1134
- ])
1135
- ]),
1136
- (g(!0), D(ne, null, pe(((ae = t.purchaseOrder) == null ? void 0 : ae.items) ?? [], (q) => (g(), D("div", {
1137
- key: q.code,
1138
- class: "flex flex-col"
1139
- }, [
1140
- e("div", Wt, [
1141
- e("div", Zt, S(q.name), 1),
1142
- e("div", Jt, S(i(fe)(J.value[q.sku._id], !1)) + "/" + S(i(Le)(q.quantity, q.sku.unit, q.measurement)), 1)
1143
- ]),
1144
- e("div", Xt, [
1145
- e("div", er, S(q.code), 1),
1146
- q.totalCost && i(R).enableTotalCost ? (g(), D("div", tr, " (" + S(i($e)(q.totalCost)) + ") ", 1)) : x("", !0)
1147
- ])
1148
- ]))), 128)),
1149
- +i(fe)(X.value) ? (g(), D(ne, { key: 0 }, [
1150
- e("div", rr, [
1151
- U(p)
1152
- ]),
1153
- e("div", sr, [
1154
- a[10] || (a[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1155
- e("div", ar, S(i($e)(X.value)), 1)
1156
- ])
1157
- ], 64)) : x("", !0)
1158
- ])
1159
- ])
1160
- ], 64)) : x("", !0),
1161
- u.value.value === "deliveryHistory" ? (g(), D("div", nr, [
1162
- re.value.length ? (g(), D("div", ur, [
1163
- (g(!0), D(ne, null, pe(re.value, (q, E) => (g(), D(ne, { key: E }, [
1164
- e("div", dr, [
1165
- e("div", mr, [
1166
- e("div", fr, [
1167
- e("div", {
1168
- class: ye([
1169
- {
1170
- "bg-fm-color-primary": E !== 0,
1171
- "bg-white": E === 0
1172
- },
1173
- "w-[2px] h-full"
1174
- ])
1175
- }, null, 2)
1176
- ]),
1177
- a[11] || (a[11] = e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1178
- e("div", pr, [
1179
- e("div", {
1180
- class: ye([
1181
- {
1182
- "bg-fm-color-primary": E < re.value.length - 1,
1183
- "bg-white": E >= re.value.length - 1
1184
- },
1185
- "w-[2px] h-full"
1186
- ])
1187
- }, null, 2)
1188
- ])
1189
- ]),
1190
- e("div", vr, [
1191
- e("div", yr, S(q.header), 1),
1192
- e("div", hr, S(q.date), 1)
1193
- ])
1194
- ]),
1195
- e("div", br, [
1196
- e("div", gr, [
1197
- e("div", Sr, [
1198
- e("div", {
1199
- class: ye([
1200
- {
1201
- "bg-fm-color-primary": E < re.value.length - 1,
1202
- "bg-white": E >= re.value.length - 1
1203
- },
1204
- "w-[2px] h-full"
1205
- ])
1206
- }, null, 2)
1207
- ])
1208
- ]),
1209
- e("div", _r, [
1210
- U(d, {
1211
- variant: "outlined",
1212
- class: "py-12 px-16"
1213
- }, {
1214
- default: de(() => [
1215
- e("div", wr, [
1216
- (g(!0), D(ne, null, pe(q.info, (I, ee) => (g(), D("div", {
1217
- key: ee,
1218
- class: "flex flex-col gap-4"
1219
- }, [
1220
- e("div", Rr, S(I == null ? void 0 : I.label), 1),
1221
- e("div", Or, [
1222
- (g(!0), D(ne, null, pe(I == null ? void 0 : I.values, (le, H) => (g(), D("div", {
1223
- key: H,
1224
- class: "fm-typo-en-body-lg-600"
1225
- }, S(le), 1))), 128))
1226
- ])
1227
- ]))), 128))
1228
- ])
1229
- ]),
1230
- _: 2
1231
- }, 1024)
1232
- ])
1233
- ])
1234
- ], 64))), 128))
1235
- ])) : (g(), D("div", or, [
1236
- U(_),
1237
- e("div", null, [
1238
- e("img", {
1239
- src: i(st),
1240
- alt: "List is empty"
1241
- }, null, 8, lr)
1242
- ]),
1243
- e("div", ir, S(i(l)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
1244
- e("div", cr, S(i(l)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
1245
- U(_),
1246
- U(_)
1247
- ]))
1248
- ])) : x("", !0)
1249
- ])
1250
- ];
1251
- }),
1252
- "side-sheet-footer": de(() => {
1253
- var j, Q, se, M, ae, q, E, I, ee, le;
1254
- return [
1255
- e("div", Dr, [
1256
- ((j = t.purchaseOrder) == null ? void 0 : j.status) === i(B).enum.DRAFT && h.value === i(ie).PURCHASE ? (g(), W(w, {
1257
- key: 0,
1258
- label: i(l)("inventory.transfer.receiveRequest.actions.confirmDraft"),
1259
- onClick: a[1] || (a[1] = (H) => G("confirmDraft")),
1260
- loading: f.value === "confirmDraft",
1261
- disabled: f.value !== "confirmDraft" && m.value
1262
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1263
- ((Q = t.purchaseOrder) == null ? void 0 : Q.status) === i(B).enum.DRAFT && h.value === i(ie).TRANSFER ? (g(), W(w, {
1264
- key: 1,
1265
- label: i(l)("inventory.transfer.receiveRequest.actions.submitRequest"),
1266
- onClick: a[2] || (a[2] = (H) => G("submitRequest")),
1267
- loading: f.value === "submitRequest",
1268
- disabled: f.value !== "submitRequest" && m.value
1269
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1270
- ((se = t.purchaseOrder) == null ? void 0 : se.status) === i(B).enum.DRAFT ? (g(), W(w, {
1271
- key: 2,
1272
- label: i(l)("inventory.transfer.receiveRequest.actions.cancelDraft"),
1273
- onClick: a[3] || (a[3] = (H) => G("cancelDraft")),
1274
- loading: f.value === "cancelDraft",
1275
- disabled: f.value !== "cancelDraft" && m.value,
1276
- variant: "destructive"
1277
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1278
- ((M = t.purchaseOrder) == null ? void 0 : M.status) === i(B).enum.RECEIVING ? (g(), W(w, {
1279
- key: 3,
1280
- label: i(l)("inventory.transfer.receiveRequest.actions.completeReceive"),
1281
- onClick: a[4] || (a[4] = (H) => G("completeReceive")),
1282
- loading: f.value === "completeReceive",
1283
- disabled: f.value !== "completeReceive" && m.value
1284
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1285
- t.canResubmit ? (g(), W(w, {
1286
- key: 4,
1287
- label: i(l)("inventory.transfer.receiveRequest.actions.resubmitRequest"),
1288
- onClick: a[5] || (a[5] = (H) => G("submitRequest")),
1289
- loading: f.value === "submitRequest",
1290
- disabled: f.value !== "submitRequest" && m.value
1291
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1292
- (((ae = t.purchaseOrder) == null ? void 0 : ae.status) === i(B).enum.REQUESTING || ((q = t.purchaseOrder) == null ? void 0 : q.status) === i(B).enum.PROCESSING) && t.canApprove ? (g(), W(w, {
1293
- key: 5,
1294
- label: i(l)("inventory.transfer.approval.actions.approveRequest"),
1295
- onClick: a[6] || (a[6] = (H) => G("approveRequest")),
1296
- loading: f.value === "approveRequest",
1297
- disabled: f.value !== "approveRequest" && m.value
1298
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1299
- ((E = t.purchaseOrder) == null ? void 0 : E.status) === i(B).enum.REQUESTING && t.canApprove ? (g(), W(w, {
1300
- key: 6,
1301
- label: i(l)("inventory.transfer.approval.actions.rejectRequest"),
1302
- onClick: a[7] || (a[7] = (H) => G("rejectRequest")),
1303
- loading: f.value === "rejectRequest",
1304
- disabled: f.value !== "rejectRequest" && m.value,
1305
- variant: "destructive"
1306
- }, null, 8, ["label", "loading", "disabled"])) : x("", !0),
1307
- ((I = t.purchaseOrder) == null ? void 0 : I.status) !== i(B).enum.COMPLETE && ((ee = t.purchaseOrder) == null ? void 0 : ee.status) !== i(B).enum.CANCEL && (((le = t.purchaseOrder) == null ? void 0 : le.status) !== i(B).enum.REQUESTING || t.canApprove) ? (g(), W(w, {
1308
- key: 7,
1309
- label: i(l)("common.close"),
1310
- variant: "tertiary",
1311
- onClick: a[8] || (a[8] = (H) => r("update:show", !1))
1312
- }, null, 8, ["label"])) : x("", !0)
1313
- ])
1314
- ];
1315
- }),
1316
- _: 1
1317
- }, 8, ["header", "modelValue", "dismiss-away"]);
1318
- };
1319
- }
1320
- });
1321
- export {
1322
- Er as _,
1323
- Cr as a,
1324
- $r as b,
1325
- at as g,
1326
- Ve as u
1327
- };