@feedmepos/mf-inventory-portal 0.0.19-dev.10 → 0.0.19-dev.11

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 (43) hide show
  1. package/dist/{ApprovalView-BgTTFiOw.js → ApprovalView-BtgtZgDY.js} +5 -5
  2. package/dist/{BindingsDialog-BROnpXEI.js → BindingsDialog-DDqu7p2z.js} +1 -1
  3. package/dist/{BindingsPicker-aQHfS_vY.js → BindingsPicker-BDhn5Do7.js} +1 -1
  4. package/dist/{BindingsTable-DvtIQMFk.js → BindingsTable-C5R7orsB.js} +1 -1
  5. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DR9YAhaJ.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D0sbKAX9.js} +1 -1
  6. package/dist/{IngredientsView-BgAQCCD-.js → IngredientsView-Ac52Wd12.js} +5 -5
  7. package/dist/{IntegrationView-DEBb_X5K.js → IntegrationView-6mJtJK-d.js} +2 -2
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VF3PDSzP.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-C2BFaTg-.js} +1 -1
  9. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BIRzNfFN.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CL0RBLOF.js} +1 -1
  10. package/dist/{PurchaseOrderPrintPreview-D2zNGZhx.js → PurchaseOrderPrintPreview-UzrsJ0AN.js} +10 -10
  11. package/dist/{ReceiveRequestView-Dc5JlUMC.js → ReceiveRequestView-DW9u9TJZ.js} +7 -7
  12. package/dist/{RecipeView-C1DBn8pW.js → RecipeView-W15pCZKU.js} +5 -5
  13. package/dist/{StockView-6wi6BEOE.js → StockView-BqEe-OIX.js} +167 -167
  14. package/dist/{SupplierView-CS7YdL5Q.js → SupplierView-CGr2N-e7.js} +5 -5
  15. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DupNA58V.js +739 -0
  16. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-COVncBoC.js +1676 -0
  17. package/dist/TransferTemplateView-HgaSR8L8.js +1101 -0
  18. package/dist/{UnitView-BUdKTKch.js → UnitView-C07Yrynl.js} +6 -6
  19. package/dist/{WarehouseView-BbreEn79.js → WarehouseView-DL-8j9vX.js} +4 -4
  20. package/dist/{app-B3oV5Muh.js → app-B1MZZxUg.js} +97 -22
  21. package/dist/app.d.ts +74 -0
  22. package/dist/app.js +1 -1
  23. package/dist/components/row-action.enum.d.ts +3 -1
  24. package/dist/{decimal-DzjRPmPY.js → decimal-BXf_WdLk.js} +1 -1
  25. package/dist/{id-to-date-CG1QobkF.js → id-to-date-Dlovyec6.js} +1 -1
  26. package/dist/layout-BJjS48J5.js +151 -0
  27. package/dist/{purchase-order-transaction-type-D-GMrgDp.js → purchase-order-transaction-type-CMIu0jrP.js} +92 -87
  28. package/dist/row-action.enum-PMKMRrZR.js +50 -0
  29. package/dist/{supplier-BE_AQA4h.js → supplier-IDQmZ4VM.js} +1 -1
  30. package/dist/tsconfig.app.tsbuildinfo +1 -1
  31. package/dist/views/stock/helper/stock-row-action.d.ts +2 -2
  32. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +20 -0
  33. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +9 -0
  34. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -0
  35. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +445 -1
  36. package/dist/{xlsx-BGXLmGtO.js → xlsx-CfdXcS72.js} +1 -1
  37. package/dist/{xlsx.util-DxU-P-ww.js → xlsx.util-C5Wx4IUs.js} +2 -2
  38. package/package.json +2 -2
  39. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CBbbXOhl.js +0 -745
  40. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CWEypKBc.js +0 -1662
  41. package/dist/TransferTemplateView-C1hmdeKM.js +0 -933
  42. package/dist/layout-qEWDq5Vs.js +0 -147
  43. package/dist/row-action.enum-7jVyol1k.js +0 -36
@@ -0,0 +1,739 @@
1
+ import { a as le, f as ae, P as Z, b as xe, d as De } from "./purchase-order-transaction-type-CMIu0jrP.js";
2
+ import { computed as re, h as be, defineComponent as Se, ref as ee, resolveComponent as K, openBlock as d, createBlock as P, unref as s, isRef as Ce, withCtx as te, createElementVNode as e, createVNode as I, createElementBlock as h, Fragment as X, toDisplayString as l, normalizeClass as se, createCommentVNode as f, renderList as oe } from "vue";
3
+ import { c as ge } from "./layout-BJjS48J5.js";
4
+ import { D as g, R as v } from "./row-action.enum-PMKMRrZR.js";
5
+ import { B as Re, l as ie, a as ce, a4 as ue, ad as b, c as Ae, j as Ee, aa as q, H as Pe, G as Te, E as Ne, b as Fe, w as je } from "./app-B1MZZxUg.js";
6
+ import { F as Ie } from "./decimal-BXf_WdLk.js";
7
+ import { components as _e, useDialog as Ue, useSnackbar as Me, useProxiedModel as $e } from "@feedmepos/ui-library";
8
+ import { useI18n as Oe } from "@feedmepos/mf-common";
9
+ import { E as Ke } from "./empty-placeholder-wf6-BWE8.js";
10
+ function Le(m, k) {
11
+ return k.reduce(
12
+ (r, T) => {
13
+ const D = T.received.find((A) => A.sku._id === m._id);
14
+ return D && (r = Re(r, D.amount)), r;
15
+ },
16
+ Ie.toPrecision(ie(0), m.unit.precision)
17
+ );
18
+ }
19
+ function Ve(m, k) {
20
+ const { name: _, address: r, regNo: T } = k.doc.profile, D = {
21
+ name: _,
22
+ registrationNumber: T,
23
+ line1: r == null ? void 0 : r.line1,
24
+ line2: r == null ? void 0 : r.line2,
25
+ postcode: r == null ? void 0 : r.postcode,
26
+ city: r == null ? void 0 : r.city,
27
+ state: r == null ? void 0 : r.state,
28
+ country: r == null ? void 0 : r.country
29
+ }, A = {
30
+ name: m.supplier.name,
31
+ registrationNumber: m.supplier.registrationNumber,
32
+ line1: m.supplier.address.line1,
33
+ line2: m.supplier.address.line2,
34
+ postcode: m.supplier.address.postcode,
35
+ city: m.supplier.address.city,
36
+ state: m.supplier.address.state,
37
+ country: m.supplier.address.country
38
+ }, i = m.items.map((n) => {
39
+ const { sku: a, measurement: p } = n, V = ce(
40
+ Le(n.sku, m.deliveryOrder || []),
41
+ !1
42
+ );
43
+ return {
44
+ code: a.code,
45
+ description: a.name,
46
+ quantity: le(n.quantity, a.unit, n.measurement),
47
+ unit: (p == null ? void 0 : p.abbrev) || a.unit.abbrev,
48
+ received: V
49
+ };
50
+ }), U = m.deliveryOrder.map((n) => ({
51
+ createdAt: ue(new Date(n.createdAt)),
52
+ ref: n.deliveryOrderNumber,
53
+ remark: n.remark || "",
54
+ items: n.received.map((a) => {
55
+ var p;
56
+ return {
57
+ code: a.sku.code,
58
+ description: a.sku.name,
59
+ quantity: ce(a.amount),
60
+ unit: ((p = a.measurement) == null ? void 0 : p.abbrev) || a.sku.unit.abbrev
61
+ };
62
+ })
63
+ })), L = {
64
+ orderNumber: m.seqNumber.toString(),
65
+ createdAt: ae(m._id),
66
+ ref: m.ref || "",
67
+ remark: m.remark || "",
68
+ buyer: D,
69
+ supplier: A,
70
+ items: i,
71
+ status: m.status,
72
+ deliveryOrders: U
73
+ }, c = new URL(window.location.href);
74
+ c.pathname = "/receive-request/print-preview", c.searchParams.append("data", JSON.stringify(L)), window.open(c.href, "_blank", "noreferrer");
75
+ }
76
+ const z = {
77
+ submitRequest: {
78
+ translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
79
+ color: "text-fm-color-typo-primary",
80
+ value: b.enum.submitRequest
81
+ },
82
+ confirmDraft: {
83
+ translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
84
+ color: "text-fm-color-typo-primary",
85
+ value: b.enum.confirmDraft
86
+ },
87
+ cancelDraft: {
88
+ translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
89
+ color: "text-fm-color-typo-error",
90
+ value: b.enum.cancelDraft
91
+ },
92
+ approveRequest: {
93
+ translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
94
+ color: "text-fm-color-typo-primary",
95
+ value: b.enum.approveRequest
96
+ },
97
+ rejectRequest: {
98
+ translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
99
+ color: "text-fm-color-typo-error",
100
+ value: b.enum.rejectRequest
101
+ },
102
+ processRequest: {
103
+ translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
104
+ color: "text-fm-color-typo-primary",
105
+ value: b.enum.processRequest
106
+ },
107
+ receiveStock: {
108
+ translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
109
+ color: "text-fm-color-typo-primary",
110
+ value: b.enum.receiveStock
111
+ },
112
+ completeReceive: {
113
+ translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
114
+ color: "text-fm-color-typo-primary",
115
+ value: b.enum.completeReceive
116
+ }
117
+ };
118
+ function ms(m, k) {
119
+ const _ = Ee(), { t: r } = Oe();
120
+ function T(c) {
121
+ switch (c.status) {
122
+ case "DRAFT":
123
+ return [
124
+ c.supplier.internal === "restaurant" || c.supplier.internal === "warehouse" ? z[b.enum.submitRequest] : z[b.enum.confirmDraft],
125
+ z[b.enum.cancelDraft],
126
+ g[v.Update],
127
+ g[v.Details],
128
+ g[v.Print]
129
+ ];
130
+ case "RECEIVING":
131
+ return [
132
+ z[b.enum.completeReceive],
133
+ g[v.Update],
134
+ g[v.Details],
135
+ g[v.Print]
136
+ ];
137
+ case "REQUESTING":
138
+ return m === "receive/request" ? [
139
+ g[v.Update],
140
+ g[v.Details],
141
+ g[v.Print]
142
+ ] : [
143
+ z[b.enum.approveRequest],
144
+ z[b.enum.rejectRequest],
145
+ g[v.Details],
146
+ g[v.Print]
147
+ ];
148
+ case "PROCESSING":
149
+ return [g[v.Details], g[v.Print]];
150
+ case "COMPLETE":
151
+ case "CANCEL":
152
+ default:
153
+ return [
154
+ g[v.Update],
155
+ g[v.Details],
156
+ g[v.Print]
157
+ ];
158
+ }
159
+ }
160
+ function D(c) {
161
+ return Object.values(b.enum).includes(c);
162
+ }
163
+ async function A(c, n, a) {
164
+ var V, B;
165
+ const p = Ae(n);
166
+ if (c === v.Print) {
167
+ Ve(p, _.currentLocation);
168
+ return;
169
+ }
170
+ if (c === v.Details) {
171
+ k.promptShowTransferDetails(p, a);
172
+ return;
173
+ }
174
+ if (c === v.Update) {
175
+ (V = k.promptUpdateTransferDialog) == null || V.call(k, p);
176
+ return;
177
+ }
178
+ if (D(c)) {
179
+ k.submitAction(n, c, (B = a == null ? void 0 : a.to) == null ? void 0 : B.dbName);
180
+ return;
181
+ }
182
+ }
183
+ function i() {
184
+ return [
185
+ {
186
+ accessorKey: "seqNumber",
187
+ header: () => r("inventory.transfer.table.seqNo"),
188
+ enableSorting: !0,
189
+ size: 80,
190
+ sortUndefined: "last"
191
+ },
192
+ {
193
+ accessorKey: "_id",
194
+ header: () => r("inventory.transfer.table.createdAt"),
195
+ cell(c) {
196
+ return ae(`${c.getValue()}`);
197
+ },
198
+ enableSorting: !0
199
+ },
200
+ {
201
+ accessorKey: "supplier.name",
202
+ header: () => r("inventory.transfer.table.transferFrom"),
203
+ enableSorting: !0,
204
+ size: 200
205
+ },
206
+ {
207
+ accessorKey: "items.length",
208
+ header: () => r("inventory.transfer.table.noOfItems"),
209
+ enableSorting: !1,
210
+ meta: {
211
+ width: "10rem"
212
+ }
213
+ },
214
+ {
215
+ accessorKey: "ref",
216
+ header: () => r("inventory.transfer.table.reference"),
217
+ enableSorting: !1,
218
+ size: "auto"
219
+ },
220
+ {
221
+ accessorKey: "status",
222
+ header: () => r("inventory.transfer.table.status"),
223
+ cell(c) {
224
+ const n = r(`inventory.transfer.status.${c.getValue() ?? ""}`), a = `${c.getValue() ?? ""}`.toLocaleLowerCase("en-us");
225
+ return be(_e.FmChip, {
226
+ label: n,
227
+ class: `fm-status-badge fm-status-badge-${a}`,
228
+ compact: !0
229
+ });
230
+ },
231
+ enableSorting: !0,
232
+ size: 200
233
+ },
234
+ {
235
+ id: "action",
236
+ cell(c) {
237
+ const n = c.row.original, a = T(n);
238
+ return ge(a, (p) => A(p, n));
239
+ },
240
+ enableSorting: !1,
241
+ size: 40,
242
+ meta: {
243
+ cellClass: "",
244
+ headerClass: ""
245
+ }
246
+ }
247
+ ];
248
+ }
249
+ function U() {
250
+ return [
251
+ {
252
+ accessorKey: "purchaseOrder.seqNumber",
253
+ header: () => r("inventory.transfer.table.seqNo"),
254
+ enableSorting: !0,
255
+ size: 80,
256
+ sortUndefined: "last"
257
+ },
258
+ {
259
+ accessorKey: "purchaseOrder._id",
260
+ header: () => r("inventory.transfer.table.createdAt"),
261
+ cell(c) {
262
+ return ae(`${c.getValue()}`);
263
+ },
264
+ enableSorting: !0
265
+ },
266
+ {
267
+ accessorKey: "to.name",
268
+ header: () => r("inventory.transfer.table.transferTo"),
269
+ enableSorting: !1,
270
+ size: 200
271
+ },
272
+ {
273
+ accessorKey: "purchaseOrder.items.length",
274
+ header: () => r("inventory.transfer.table.noOfItems"),
275
+ enableSorting: !1
276
+ },
277
+ {
278
+ accessorKey: "purchaseOrder.ref",
279
+ header: () => r("inventory.transfer.table.reference"),
280
+ enableSorting: !1,
281
+ size: "auto"
282
+ },
283
+ {
284
+ accessorKey: "purchaseOrder.status",
285
+ header: () => r("inventory.transfer.table.status"),
286
+ cell(c) {
287
+ const n = r(`inventory.transfer.status.${c.getValue() ?? ""}`), a = `${c.getValue() ?? ""}`.toLocaleLowerCase("en-us");
288
+ return be(_e.FmChip, {
289
+ label: n,
290
+ class: `fm-status-badge fm-status-badge-${a}`,
291
+ compact: !0
292
+ });
293
+ },
294
+ enableSorting: !0
295
+ },
296
+ {
297
+ id: "action",
298
+ cell(c) {
299
+ const n = c.row.original, a = n.purchaseOrder ? T(n.purchaseOrder) : [];
300
+ return ge(
301
+ a,
302
+ (p) => n.purchaseOrder ? A(p, n.purchaseOrder, n) : void 0
303
+ );
304
+ },
305
+ enableSorting: !1,
306
+ size: 40,
307
+ meta: {
308
+ cellClass: "",
309
+ headerClass: ""
310
+ }
311
+ }
312
+ ];
313
+ }
314
+ const L = re(() => m === "receive/request" ? i() : U());
315
+ return {
316
+ get columnDefs() {
317
+ return L.value;
318
+ }
319
+ };
320
+ }
321
+ const Be = { class: "flex flex-col gap-16 w-full h-full" }, Ge = { class: "flex justify-between" }, He = { class: "fm-typo-en-body-lg-600" }, ze = { class: "flex flex-col gap-8" }, Qe = { class: "flex flex-col gap-4" }, Ye = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Je = { class: "flex gap-1" }, We = { class: "fm-typo-en-body-lg-600" }, Xe = {
322
+ key: 0,
323
+ class: "flex flex-col gap-4"
324
+ }, Ze = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, et = { class: "fm-typo-en-body-lg-600" }, tt = { class: "flex flex-col gap-4" }, st = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rt = { class: "fm-typo-en-body-lg-600" }, at = {
325
+ key: 1,
326
+ class: "flex flex-col gap-4"
327
+ }, nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ot = { class: "fm-typo-en-body-lg-600" }, lt = {
328
+ key: 2,
329
+ class: "flex flex-col gap-4"
330
+ }, it = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ct = { class: "fm-typo-en-body-lg-600" }, ut = {
331
+ key: 3,
332
+ class: "flex flex-col gap-4"
333
+ }, dt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, mt = { class: "fm-typo-en-body-lg-600" }, ft = {
334
+ key: 4,
335
+ class: "flex flex-col gap-4"
336
+ }, vt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pt = { class: "fm-typo-en-body-lg-600" }, yt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, ht = { class: "flex flex-col gap-8" }, bt = { class: "fm-typo-en-body-lg-600" }, gt = { class: "flex w-full gap-4" }, _t = { class: "grow fm-typo-en-body-lg-400 line-clamp-2" }, Rt = /* @__PURE__ */ e("div", { class: "flex-1 min-w-32" }, null, -1), Ot = { class: "fm-typo-en-body-lg-600 shrink-0" }, qt = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, kt = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, wt = {
337
+ key: 0,
338
+ class: "shrink-0 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
339
+ }, xt = {
340
+ key: 1,
341
+ class: "flex-1 xs:w-screen xs:max-w-full"
342
+ }, Dt = {
343
+ key: 0,
344
+ class: "flex flex-col items-center gap-8 h-full"
345
+ }, St = ["src"], Ct = { class: "fm-typo-en-body-lg-600" }, At = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Et = {
346
+ key: 1,
347
+ class: "px-4 flex flex-col"
348
+ }, Pt = { class: "flex gap-12 content-stretch" }, Tt = {
349
+ class: "flex flex-col w-24",
350
+ name: "circles"
351
+ }, Nt = { class: "flex-1 flex flex-col items-center" }, Ft = /* @__PURE__ */ e("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1), jt = { class: "flex-1 flex flex-col items-center" }, It = {
352
+ class: "py-12 flex flex-col gap-4",
353
+ name: "received-at header"
354
+ }, Ut = { class: "fm-typo-en-body-lg-400" }, Mt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, $t = { class: "flex gap-12 content-stretch" }, Kt = {
355
+ class: "flex flex-col w-24",
356
+ name: "circles"
357
+ }, Lt = { class: "flex-1 flex flex-col items-center" }, Vt = {
358
+ class: "py-12 flex flex-col gap-4 flex-1",
359
+ name: "delivery details"
360
+ }, Bt = { class: "flex flex-col gap-8" }, Gt = { class: "flex flex-col gap-4" }, Ht = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-lg-600" }, Qt = { class: "flex flex-col gap-4" }, Yt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Jt = { class: "flex flex-col gap-4" }, Wt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Xt = { class: "fm-typo-en-body-lg-600" }, Zt = { class: "flex flex-col gap-4" }, es = {
361
+ key: 0,
362
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
363
+ }, ts = { class: "fm-typo-en-body-lg-600" }, ss = { class: "flex gap-8 xs:flex-col" }, fs = /* @__PURE__ */ Se({
364
+ __name: "TransferDetails",
365
+ props: {
366
+ purchaseOrder: {},
367
+ transferTo: {},
368
+ transferToDbName: {},
369
+ show: { type: Boolean },
370
+ canResubmit: { type: Boolean },
371
+ canApprove: { type: Boolean }
372
+ },
373
+ emits: ["update:show", "submitted"],
374
+ setup(m, { emit: k }) {
375
+ const _ = m, r = k, T = Ue(), D = Me(), A = Fe(), { t: i } = Oe(), U = re(
376
+ () => {
377
+ var t, o, S, y;
378
+ return ((o = (t = _.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : o.internal) === "restaurant" || ((y = (S = _.purchaseOrder) == null ? void 0 : S.supplier) == null ? void 0 : y.internal) === "warehouse" ? Z.TRANSFER : Z.PURCHASE;
379
+ }
380
+ ), L = [
381
+ {
382
+ label: i("inventory.transfer.receiveRequest.details.overview"),
383
+ value: "overview"
384
+ },
385
+ {
386
+ label: i("inventory.transfer.receiveRequest.details.deliveryHistory"),
387
+ value: "deliveryHistory"
388
+ }
389
+ ], c = ee(L[0]), n = ee(!1), a = ee(""), p = ee(!0), V = xe(), B = $e(_, "show");
390
+ async function qe(t, o, S) {
391
+ a.value = o, n.value = !0, p.value = !1;
392
+ try {
393
+ await V.processPurchaseOrder(
394
+ {
395
+ operation: o,
396
+ doc: t,
397
+ options: (
398
+ // auto receive for supplier to warehouse
399
+ (o === b.enum.confirmDraft || // auto receive for warehouse to warehouse
400
+ o === b.enum.completeReceive) && A.autoReceiveWarehouse ? {
401
+ autoReceive: !0
402
+ } : void 0
403
+ )
404
+ },
405
+ _.transferToDbName
406
+ ), await new Promise((y) => setTimeout(y, 1e3)), D.open({
407
+ title: "Success",
408
+ message: S,
409
+ type: "success"
410
+ }), r("update:show", !1), r("submitted");
411
+ } catch (y) {
412
+ D.open({
413
+ title: "Something went wrong",
414
+ message: "Please try again.",
415
+ type: "error"
416
+ }), console.error("Error when submitting PO operation", o, t, y);
417
+ } finally {
418
+ a.value = "", n.value = !1, p.value = !0;
419
+ }
420
+ }
421
+ async function M(t) {
422
+ const o = De[t];
423
+ if (!o) {
424
+ D.open({
425
+ title: "Something went wrong",
426
+ message: `Cannot process order: ${je(t)}`,
427
+ type: "error"
428
+ });
429
+ return;
430
+ }
431
+ const { successMessage: S, ...y } = o;
432
+ T.open({
433
+ title: y.title,
434
+ message: y.message,
435
+ primaryActions: y.primaryActions
436
+ }).onPrimary(() => {
437
+ _.purchaseOrder && qe(_.purchaseOrder, t, S);
438
+ });
439
+ }
440
+ const ke = re(() => {
441
+ var t, o;
442
+ return ((t = _.purchaseOrder) == null ? void 0 : t.status) === q.enum.RECEIVING || ((o = _.purchaseOrder) == null ? void 0 : o.status) === q.enum.COMPLETE;
443
+ }), we = re(() => {
444
+ var Q, G, w;
445
+ const S = (((Q = _.purchaseOrder) == null ? void 0 : Q.deliveryOrder) ?? []).flatMap((O) => O.received ?? []).reduce(
446
+ (O, N) => {
447
+ const H = O[N.sku._id] ?? [];
448
+ return O[N.sku._id] = [...H, N], O;
449
+ },
450
+ {}
451
+ ), y = Object.entries(S).reduce(
452
+ (O, [N, H]) => {
453
+ const E = H.reduce((F, j) => {
454
+ const $ = Pe(
455
+ F,
456
+ Math.max(F.precision, j.amount.precision)
457
+ );
458
+ return Re($, j.amount);
459
+ }, ie(0));
460
+ return O[N] = E, O;
461
+ },
462
+ {}
463
+ ), ne = ((G = _.purchaseOrder) == null ? void 0 : G.items) ?? [];
464
+ for (const O of ne)
465
+ y[w = O.sku._id] ?? (y[w] = ie(0));
466
+ return y;
467
+ });
468
+ return (t, o) => {
469
+ var N, H;
470
+ const S = K("FmButtonGroup"), y = K("FmChip"), ne = K("FmMenuDivider"), Q = K("FmCard"), G = K("FmSpacer"), w = K("FmButton"), O = K("FmSideSheet");
471
+ return d(), P(O, {
472
+ header: s(i)("inventory.transfer.receiveRequest.details.title") + ((N = t.purchaseOrder) != null && N.seqNumber ? ` #${(H = t.purchaseOrder) == null ? void 0 : H.seqNumber}` : ""),
473
+ modelValue: s(B),
474
+ "onUpdate:modelValue": o[9] || (o[9] = (E) => Ce(B) ? B.value = E : null),
475
+ "dismiss-away": p.value,
476
+ "close-button": "",
477
+ "max-width": 500
478
+ }, {
479
+ default: te(() => {
480
+ var E, F, j, $, Y, J;
481
+ return [
482
+ e("div", Be, [
483
+ e("div", null, [
484
+ I(S, {
485
+ items: L,
486
+ modelValue: c.value,
487
+ "onUpdate:modelValue": o[0] || (o[0] = (u) => c.value = u)
488
+ }, null, 8, ["modelValue"])
489
+ ]),
490
+ c.value.value === "overview" ? (d(), h(X, { key: 0 }, [
491
+ I(Q, {
492
+ variant: "outlined",
493
+ class: "flex flex-col gap-8 px-12 py-16"
494
+ }, {
495
+ default: te(() => {
496
+ var u, R, x, W, C, de, me, fe, ve, pe, ye, he;
497
+ return [
498
+ e("div", Ge, [
499
+ e("div", He, l(s(i)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
500
+ e("div", null, [
501
+ I(y, {
502
+ label: s(i)(`inventory.transfer.status.${(u = t.purchaseOrder) == null ? void 0 : u.status}`),
503
+ class: se(`fm-status-badge fm-status-badge-${(x = (R = t.purchaseOrder) == null ? void 0 : R.status) == null ? void 0 : x.toLocaleLowerCase("en-us")}`),
504
+ compact: ""
505
+ }, null, 8, ["label", "class"])
506
+ ])
507
+ ]),
508
+ I(ne),
509
+ e("div", ze, [
510
+ e("div", Qe, [
511
+ e("div", Ye, [
512
+ e("div", Je, l(s(i)("inventory.transfer.receiveRequest.details.createdAt")), 1)
513
+ ]),
514
+ e("div", We, l(s(ae)(((W = t.purchaseOrder) == null ? void 0 : W._id) ?? "")), 1)
515
+ ]),
516
+ (C = t.purchaseOrder) != null && C.effectiveAt ? (d(), h("div", Xe, [
517
+ e("div", Ze, l(s(i)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
518
+ e("div", et, l(s(ue)(new Date((de = t.purchaseOrder) == null ? void 0 : de.effectiveAt))), 1)
519
+ ])) : f("", !0),
520
+ e("div", tt, [
521
+ e("div", st, l(s(i)("inventory.transfer.receiveRequest.details.type.title")), 1),
522
+ e("div", rt, l(s(i)(
523
+ `inventory.transfer.receiveRequest.details.type.${U.value.toLocaleLowerCase("en-US")}`
524
+ )), 1)
525
+ ]),
526
+ (fe = (me = t.purchaseOrder) == null ? void 0 : me.supplier) != null && fe.name ? (d(), h("div", at, [
527
+ e("div", nt, l(s(i)("inventory.transfer.receiveRequest.details.from")), 1),
528
+ e("div", ot, l((pe = (ve = t.purchaseOrder) == null ? void 0 : ve.supplier) == null ? void 0 : pe.name), 1)
529
+ ])) : f("", !0),
530
+ t.transferTo ? (d(), h("div", lt, [
531
+ e("div", it, l(s(i)("inventory.transfer.receiveRequest.details.to")), 1),
532
+ e("div", ct, l(t.transferTo), 1)
533
+ ])) : f("", !0),
534
+ (ye = t.purchaseOrder) != null && ye.ref ? (d(), h("div", ut, [
535
+ e("div", dt, l(s(i)("inventory.transfer.receiveRequest.details.reference")), 1),
536
+ e("div", mt, l(t.purchaseOrder.ref), 1)
537
+ ])) : f("", !0),
538
+ (he = t.purchaseOrder) != null && he.remark ? (d(), h("div", ft, [
539
+ e("div", vt, l(s(i)("inventory.transfer.receiveRequest.details.remark")), 1),
540
+ e("div", pt, l(t.purchaseOrder.remark), 1)
541
+ ])) : f("", !0)
542
+ ])
543
+ ];
544
+ }),
545
+ _: 1
546
+ }),
547
+ e("div", yt, [
548
+ e("div", ht, [
549
+ e("div", bt, l(ke.value ? s(i)("inventory.transfer.receiveRequest.details.receivedItems") : s(i)("inventory.transfer.receiveRequest.details.requestedItems")), 1),
550
+ (d(!0), h(X, null, oe(((E = t.purchaseOrder) == null ? void 0 : E.items) ?? [], (u) => (d(), h("div", {
551
+ key: u.code,
552
+ class: "flex flex-col"
553
+ }, [
554
+ e("div", gt, [
555
+ e("div", _t, l(u.name), 1),
556
+ Rt,
557
+ e("div", Ot, l(s(ce)(we.value[u.sku._id], !1)) + "/" + l(s(le)(u.quantity, u.sku.unit, u.measurement)), 1)
558
+ ]),
559
+ e("div", qt, [
560
+ e("div", kt, l(u.code), 1),
561
+ u.totalCost && s(A).enableTotalCost ? (d(), h("div", wt, " (" + l(s(Te)(u.totalCost)) + ") ", 1)) : f("", !0)
562
+ ])
563
+ ]))), 128))
564
+ ])
565
+ ])
566
+ ], 64)) : f("", !0),
567
+ c.value.value === "deliveryHistory" ? (d(), h("div", xt, [
568
+ ((j = (F = t.purchaseOrder) == null ? void 0 : F.deliveryOrder) == null ? void 0 : j.length) === 0 ? (d(), h("div", Dt, [
569
+ I(G),
570
+ e("div", null, [
571
+ e("img", {
572
+ src: s(Ke),
573
+ alt: "List is empty"
574
+ }, null, 8, St)
575
+ ]),
576
+ e("div", Ct, l(s(i)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
577
+ e("div", At, l(s(i)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
578
+ I(G),
579
+ I(G)
580
+ ])) : f("", !0),
581
+ ($ = t.purchaseOrder) != null && $.deliveryOrder && ((Y = t.purchaseOrder) == null ? void 0 : Y.deliveryOrder.length) > 0 ? (d(), h("div", Et, [
582
+ (d(!0), h(X, null, oe((J = t.purchaseOrder) == null ? void 0 : J.deliveryOrder, (u, R) => (d(), h(X, { key: R }, [
583
+ e("div", Pt, [
584
+ e("div", Tt, [
585
+ e("div", Nt, [
586
+ e("div", {
587
+ class: se([
588
+ {
589
+ "bg-fm-color-primary": R !== 0,
590
+ "bg-white": R === 0
591
+ },
592
+ "w-[2px] h-full"
593
+ ])
594
+ }, null, 2)
595
+ ]),
596
+ Ft,
597
+ e("div", jt, [
598
+ e("div", {
599
+ class: se([
600
+ {
601
+ "bg-fm-color-primary": R < t.purchaseOrder.deliveryOrder.length - 1,
602
+ "bg-white": R >= t.purchaseOrder.deliveryOrder.length - 1
603
+ },
604
+ "w-[2px] h-full"
605
+ ])
606
+ }, null, 2)
607
+ ])
608
+ ]),
609
+ e("div", It, [
610
+ e("div", Ut, l(s(i)("inventory.transfer.receiveRequest.details.received")), 1),
611
+ e("div", Mt, l(s(ue)(new Date(u.createdAt))) + ", " + l(s(Ne)(new Date(u.createdAt))), 1)
612
+ ])
613
+ ]),
614
+ e("div", $t, [
615
+ e("div", Kt, [
616
+ e("div", Lt, [
617
+ e("div", {
618
+ class: se([
619
+ {
620
+ "bg-fm-color-primary": R < t.purchaseOrder.deliveryOrder.length - 1,
621
+ "bg-white": R >= t.purchaseOrder.deliveryOrder.length - 1
622
+ },
623
+ "w-[2px] h-full"
624
+ ])
625
+ }, null, 2)
626
+ ])
627
+ ]),
628
+ e("div", Vt, [
629
+ I(Q, {
630
+ variant: "outlined",
631
+ class: "py-12 px-16"
632
+ }, {
633
+ default: te(() => [
634
+ e("div", Bt, [
635
+ e("div", Gt, [
636
+ e("div", Ht, l(s(i)("inventory.transfer.receiveRequest.details.receivedBy")), 1),
637
+ e("div", zt, l(u.createdBy.name), 1)
638
+ ]),
639
+ e("div", Qt, [
640
+ e("div", Yt, l(s(i)("inventory.transfer.receiveRequest.details.receivedItems")), 1),
641
+ (d(!0), h(X, null, oe(u.received, (x) => (d(), h("div", {
642
+ class: "fm-typo-en-body-lg-600",
643
+ key: x.sku._id
644
+ }, l(x.sku.name) + " " + l(s(le)(x.amount, x.sku.unit, x.measurement)), 1))), 128))
645
+ ]),
646
+ e("div", Jt, [
647
+ e("div", Wt, l(s(i)("inventory.transfer.receiveRequest.details.deliveryOrderNo")), 1),
648
+ e("div", Xt, l(u.deliveryOrderNumber.trim().length ? u.deliveryOrderNumber : "-"), 1)
649
+ ]),
650
+ e("div", Zt, [
651
+ u.remark ? (d(), h("div", es, l(s(i)("inventory.transfer.receiveRequest.details.deliveryRemark")), 1)) : f("", !0),
652
+ e("div", ts, l(u.remark), 1)
653
+ ])
654
+ ])
655
+ ]),
656
+ _: 2
657
+ }, 1024)
658
+ ])
659
+ ])
660
+ ], 64))), 128))
661
+ ])) : f("", !0)
662
+ ])) : f("", !0)
663
+ ])
664
+ ];
665
+ }),
666
+ "side-sheet-footer": te(() => {
667
+ var E, F, j, $, Y, J, u, R, x, W;
668
+ return [
669
+ e("div", ss, [
670
+ ((E = t.purchaseOrder) == null ? void 0 : E.status) === s(q).enum.DRAFT && U.value === s(Z).PURCHASE ? (d(), P(w, {
671
+ key: 0,
672
+ label: s(i)("inventory.transfer.receiveRequest.actions.confirmDraft"),
673
+ onClick: o[1] || (o[1] = (C) => M("confirmDraft")),
674
+ loading: a.value === "confirmDraft",
675
+ disabled: a.value !== "confirmDraft" && n.value
676
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
677
+ ((F = t.purchaseOrder) == null ? void 0 : F.status) === s(q).enum.DRAFT && U.value === s(Z).TRANSFER ? (d(), P(w, {
678
+ key: 1,
679
+ label: s(i)("inventory.transfer.receiveRequest.actions.submitRequest"),
680
+ onClick: o[2] || (o[2] = (C) => M("submitRequest")),
681
+ loading: a.value === "submitRequest",
682
+ disabled: a.value !== "submitRequest" && n.value
683
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
684
+ ((j = t.purchaseOrder) == null ? void 0 : j.status) === s(q).enum.DRAFT ? (d(), P(w, {
685
+ key: 2,
686
+ label: s(i)("inventory.transfer.receiveRequest.actions.cancelDraft"),
687
+ onClick: o[3] || (o[3] = (C) => M("cancelDraft")),
688
+ loading: a.value === "cancelDraft",
689
+ disabled: a.value !== "cancelDraft" && n.value,
690
+ variant: "destructive"
691
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
692
+ (($ = t.purchaseOrder) == null ? void 0 : $.status) === s(q).enum.RECEIVING ? (d(), P(w, {
693
+ key: 3,
694
+ label: s(i)("inventory.transfer.receiveRequest.actions.completeReceive"),
695
+ onClick: o[4] || (o[4] = (C) => M("completeReceive")),
696
+ loading: a.value === "completeReceive",
697
+ disabled: a.value !== "completeReceive" && n.value
698
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
699
+ t.canResubmit ? (d(), P(w, {
700
+ key: 4,
701
+ label: s(i)("inventory.transfer.receiveRequest.actions.resubmitRequest"),
702
+ onClick: o[5] || (o[5] = (C) => M("submitRequest")),
703
+ loading: a.value === "submitRequest",
704
+ disabled: a.value !== "submitRequest" && n.value
705
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
706
+ (((Y = t.purchaseOrder) == null ? void 0 : Y.status) === s(q).enum.REQUESTING || ((J = t.purchaseOrder) == null ? void 0 : J.status) === s(q).enum.PROCESSING) && t.canApprove ? (d(), P(w, {
707
+ key: 5,
708
+ label: s(i)("inventory.transfer.approval.actions.approveRequest"),
709
+ onClick: o[6] || (o[6] = (C) => M("approveRequest")),
710
+ loading: a.value === "approveRequest",
711
+ disabled: a.value !== "approveRequest" && n.value
712
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
713
+ ((u = t.purchaseOrder) == null ? void 0 : u.status) === s(q).enum.REQUESTING && t.canApprove ? (d(), P(w, {
714
+ key: 6,
715
+ label: s(i)("inventory.transfer.approval.actions.rejectRequest"),
716
+ onClick: o[7] || (o[7] = (C) => M("rejectRequest")),
717
+ loading: a.value === "rejectRequest",
718
+ disabled: a.value !== "rejectRequest" && n.value,
719
+ variant: "destructive"
720
+ }, null, 8, ["label", "loading", "disabled"])) : f("", !0),
721
+ ((R = t.purchaseOrder) == null ? void 0 : R.status) !== s(q).enum.COMPLETE && ((x = t.purchaseOrder) == null ? void 0 : x.status) !== s(q).enum.CANCEL && (((W = t.purchaseOrder) == null ? void 0 : W.status) !== s(q).enum.REQUESTING || t.canApprove) ? (d(), P(w, {
722
+ key: 7,
723
+ label: s(i)("common.close"),
724
+ variant: "tertiary",
725
+ onClick: o[8] || (o[8] = (C) => r("update:show", !1))
726
+ }, null, 8, ["label"])) : f("", !0)
727
+ ])
728
+ ];
729
+ }),
730
+ _: 1
731
+ }, 8, ["header", "modelValue", "dismiss-away"]);
732
+ };
733
+ }
734
+ });
735
+ export {
736
+ fs as _,
737
+ Le as g,
738
+ ms as u
739
+ };