@feedmepos/mf-inventory-portal 1.0.20 → 1.0.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 (57) hide show
  1. package/dist/{App-HCucbXT5.js → App-Dm1dub7v.js} +2 -2
  2. package/dist/{ApprovalView-CR8Ievmh.js → ApprovalView-DZK5guKS.js} +2 -2
  3. package/dist/{BindingsDialog-BsbaWyqP.js → BindingsDialog-BL2jOxN4.js} +2 -2
  4. package/dist/{BindingsPicker-ByFOp6B3.js → BindingsPicker-G1SdBXsq.js} +1 -1
  5. package/dist/{BindingsTable-BhGnyUQH.js → BindingsTable-Coy6_ryj.js} +1 -1
  6. package/dist/{ClosingDraftView-5Eem33MA.js → ClosingDraftView-RTjmn1uK.js} +2 -2
  7. package/dist/{ClosingTemplateView-CydMQc2L.js → ClosingTemplateView-DkX8edyP.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-Csbca_v0.js → DeliveryOrderPrintPreview-j-DgrDiv.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-LV2wLWWk.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BL8MG9yR.js} +3 -3
  10. package/dist/{FmMultiselectDialog-DISDKgZY.js → FmMultiselectDialog-C2FfQXZp.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-TSO_zgPu.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D4dnq4rA.js} +1 -1
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Cg8vkF_r.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DXbFhLpK.js} +1 -1
  13. package/dist/{IngredientGroupView-BONl2HNV.js → IngredientGroupView-DHbQCRy_.js} +2 -2
  14. package/dist/{IngredientsView-b-ztsnrh.js → IngredientsView-CF-wb-6-.js} +5 -5
  15. package/dist/IntegrationView-X5yvur-x.js +6007 -0
  16. package/dist/{InventoryBindingForm-BJvKlpQv.js → InventoryBindingForm-CeJZHDY0.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Cw_LyQCc.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-9hirHThb.js} +3 -3
  18. package/dist/{InventoryBindingSummary-o1qzcGiz.js → InventoryBindingSummary-CBg7KhPi.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-8ne5kKtT.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BSVs7T4a.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-D60Y07cG.js → PremiumBadge.vue_vue_type_script_setup_true_lang-ChZwsyJM.js} +1 -1
  21. package/dist/{PublishView-BAzw6iNq.js → PublishView-BjvKb7f-.js} +2 -2
  22. package/dist/{PurchaseOrderPrintPreview-DBaLVHMs.js → PurchaseOrderPrintPreview-CbAMXMPU.js} +1 -1
  23. package/dist/{ReceiveRequestView-CHwB-N1X.js → ReceiveRequestView-ihHtocTf.js} +10 -10
  24. package/dist/{RecipeView-CTNJ1Alw.js → RecipeView-BoR36rGq.js} +4 -4
  25. package/dist/{StockView-Dd0FpkBz.js → StockView-DcHopPZO.js} +7 -7
  26. package/dist/{SupplierView-C5tHBFjz.js → SupplierView-V67QXaLX.js} +482 -480
  27. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-eeL8-QuF.js +2181 -0
  28. package/dist/TransferTemplateView-DKDeo49Q.js +1432 -0
  29. package/dist/{UnitView-DIqdD9rK.js → UnitView-BRVRLheN.js} +3 -3
  30. package/dist/WarehouseView-tRg5Hn4L.js +1034 -0
  31. package/dist/api/netsuite.d.ts +1 -0
  32. package/dist/{app-D6VUced2.js → app-82JEull2.js} +43642 -39723
  33. package/dist/app.js +4 -4
  34. package/dist/{decimal-B-F4KR7a.js → decimal-D-zH_vXe.js} +1 -1
  35. package/dist/{feature-BXo8MNXq.js → feature-UG6T1t8f.js} +394 -387
  36. package/dist/{format-unit-display-CKfsmYU1.js → format-unit-display-CIPAWL-6.js} +2 -2
  37. package/dist/{index-Bx9GXnw-.js → index-B7w4ky-g.js} +2 -2
  38. package/dist/{index-DWWzKqnk.js → index-BDC93VCL.js} +1 -1
  39. package/dist/{stock-CKqcI427.js → stock-Bq9xHemt.js} +1 -1
  40. package/dist/stores/integration/netsuite.d.ts +31 -0
  41. package/dist/{supplier-DsBIy15T.js → supplier-BrZdgPMN.js} +2 -2
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/{use-ingredient-select-dialog-DVBnJIlK.js → use-ingredient-select-dialog-Dzy7PO1j.js} +1 -1
  44. package/dist/{use-inventory-binding-dialog-DgbGDAWk.js → use-inventory-binding-dialog-DT4t22Eb.js} +1 -1
  45. package/dist/views/receive-request/components/netsuite/NetSuiteLatestInfo.vue.d.ts +17 -0
  46. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +497 -12
  47. package/dist/views/transfer-template/components/transfer-template-form/TransferTemplateForm.vue.d.ts +5 -1
  48. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +172 -0
  49. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +2 -0
  50. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +3 -2
  51. package/dist/{vue-i18n-g4GUXOuk.js → vue-i18n-D5ETg5F3.js} +300 -300
  52. package/package.json +5 -3
  53. package/dist/IntegrationView-oRHoLLjT.js +0 -9671
  54. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CpngWNmz.js +0 -2095
  55. package/dist/TransferTemplateView-CP24Mv9n.js +0 -1421
  56. package/dist/WarehouseView-DCtBNHvx.js +0 -1032
  57. package/dist/views/transfer-template/composables/useTransferTemplateHelper.d.ts +0 -305
@@ -1,2095 +0,0 @@
1
- import { a2 as lt, u as de, aM as w, b as qe, a7 as ct, a9 as ut, aa as dt, aN as mt, d as We, e as Ze, $ as et, aO as ft, a4 as Le, Q as Ne, i as ie, aP as tt, ae as ke, f as Qe, h as H, D as ee, av as le, aQ as rt, aR as pt, a8 as yt, at as Ye, a6 as Oe, aj as Ce, aw as vt } from "./app-D6VUced2.js";
2
- import { ref as K, computed as W, h as D, defineComponent as be, reactive as ht, onMounted as st, resolveComponent as G, openBlock as _, createBlock as ne, withCtx as ce, createElementVNode as n, createVNode as B, unref as h, createElementBlock as q, toDisplayString as x, createCommentVNode as L, watch as bt, isRef as gt, Fragment as te, normalizeClass as xe, createTextVNode as Fe, renderList as ve, resolveDynamicComponent as _t } from "vue";
3
- import { F as St } from "./decimal-B-F4KR7a.js";
4
- import { b as wt, u as Rt, f as at, P as ue } from "./format-unit-display-CKfsmYU1.js";
5
- import { useCoreStore as De, useI18n as nt } from "@feedmepos/mf-common";
6
- import { E as Ot } from "./empty-placeholder-wf6-BWE8.js";
7
- import { useDialog as Ve, useSnackbar as Ae, components as Xe, FmButtonVariant as Z, useProxiedModel as xt } from "@feedmepos/ui-library";
8
- import { u as Te, F as Ie } from "./feature-BXo8MNXq.js";
9
- import { _ as Nt, F as kt, a as qt } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-TSO_zgPu.js";
10
- import { u as Dt, R as Je } from "./usePromise-CbVUCxhj.js";
11
- import { u as At } from "./index-Bx9GXnw-.js";
12
- const $e = lt((m, s) => {
13
- const a = de(), N = De();
14
- return {
15
- async readRequests(u, e, c) {
16
- const f = u ?? a.currentLocationDBName, r = `${m.inventoryBackendUrl}/${f}/purchase-request`;
17
- return e && c ? await s.get(`${r}?startDate=${e}&endDate=${c}`) : await s.get(r);
18
- },
19
- async readRequestById(u, e) {
20
- const c = e ?? a.currentLocationDBName, f = `${m.inventoryBackendUrl}/${c}/purchase-request/${u}`;
21
- return await s.get(f);
22
- },
23
- async readRequestByIds(u, e) {
24
- const c = e ?? a.currentLocationDBName, f = `${m.inventoryBackendUrl}/${c}/purchase-request/find`;
25
- return await s.post(f, { requestIds: u });
26
- },
27
- async getPurchaseOrders({
28
- start: u,
29
- end: e
30
- }) {
31
- const c = a.currentLocationDBName, f = `${m.inventoryBackendUrl}/${c}/purchase-order`;
32
- return await s.get(`${f}?start=${u}&end=${e}`);
33
- },
34
- async getLatestPurchaseOrderRequest(u) {
35
- const e = a.currentLocationDBName, c = `${m.inventoryBackendUrl}/${e}/purchase-request/find-by-purchase-order-id`;
36
- return await s.get(`${c}/${u}`);
37
- },
38
- async getPurchaseOrderById(u) {
39
- const e = a.currentLocationDBName, c = `${m.inventoryBackendUrl}/${e}/purchase-order`;
40
- return await s.get(`${c}/${u}`);
41
- },
42
- /**
43
- * @deprecated Use `processPurchaseOrderV2` instead.
44
- */
45
- async processPurchaseOrder(u, e) {
46
- const c = a.currentLocationDBName, f = e || c, r = `${m.inventoryBackendUrl}/${f}/purchase-order/run-operation`;
47
- return await s.put(r, u);
48
- },
49
- async createPurchaseOrder(u) {
50
- const e = a.currentLocationDBName, c = `${m.inventoryBackendUrl}/${e}/purchase-order`;
51
- return await s.post(c, u);
52
- },
53
- async updatePurchaseOrder(u) {
54
- const e = a.currentLocationDBName, c = `${m.inventoryBackendUrl}/${e}/purchase-order`;
55
- return await s.put(c, u);
56
- },
57
- async importFromXilnex(u) {
58
- const e = a.currentLocationDBName, c = `${m.inventoryBackendUrl}/${e}/purchase-order/import-from-xilnex`;
59
- return await s.post(c, u);
60
- },
61
- async processPurchaseOrderV2(u, e) {
62
- const c = a.currentLocationDBName, f = e || c, r = `${m.inventoryBackendUrl}/${f}/v2/purchase-order/run-operation`;
63
- return await s.put(r, u);
64
- },
65
- async getWorkflowConfig() {
66
- var f;
67
- const e = `business_${(f = N.currentBusiness.value) == null ? void 0 : f._id}`, c = `${m.inventoryBackendUrl}/${e}/v2/purchase-order/workflow-config`;
68
- return await s.get(c);
69
- }
70
- };
71
- }), ot = {
72
- [w.enum.confirmDraft]: {
73
- primaryActions: {
74
- text: "Confirm draft",
75
- close: !0
76
- },
77
- title: "Confirm draft?",
78
- message: "Purchase order cannot be changed after confirm draft.",
79
- successMessage: "Purchase order draft has been confirmed"
80
- },
81
- [w.enum.cancelDraft]: {
82
- primaryActions: {
83
- text: "Cancel draft",
84
- close: !0,
85
- variant: "destructive"
86
- },
87
- title: "Cancel draft?",
88
- message: "Purchase order cannot be changed after cancelled draft.",
89
- successMessage: "Purchase order draft has been cancelled"
90
- },
91
- [w.enum.submitRequest]: {
92
- primaryActions: {
93
- text: "Submit request",
94
- close: !0
95
- },
96
- title: "Confirm draft?",
97
- message: "Purchase order cannot be changed after confirm draft.",
98
- successMessage: "Purchase order draft has been submitted"
99
- },
100
- [w.enum.completeReceive]: {
101
- primaryActions: {
102
- text: "Mark received",
103
- close: !0
104
- },
105
- title: "Mark as received",
106
- message: "Purchase order cannot be changed after it has complete receiving.",
107
- successMessage: "Purchase order has been marked as received"
108
- },
109
- [w.enum.approveRequest]: {
110
- primaryActions: {
111
- text: "Accept request",
112
- close: !0
113
- },
114
- title: "Accept request?",
115
- message: "Transfer out request will be accepted.",
116
- successMessage: "Transfer out request has been approved"
117
- },
118
- [w.enum.rejectRequest]: {
119
- primaryActions: {
120
- text: "Reject request",
121
- close: !0,
122
- variant: "destructive"
123
- },
124
- title: "Reject request?",
125
- message: "Purchase order will be rejected.",
126
- successMessage: "Purchase order has been rejected"
127
- },
128
- [w.enum.processRequest]: {
129
- primaryActions: {
130
- text: "Process request",
131
- close: !0,
132
- variant: "destructive"
133
- },
134
- title: "Process request?",
135
- message: "Purchase order will be processed.",
136
- successMessage: "Purchase order has been processed"
137
- }
138
- };
139
- function it() {
140
- const m = de(), s = $e(), a = Te();
141
- async function N(e, c) {
142
- const f = m.currentLocationDBName;
143
- return e.doc.supplier.internal && e.operation === w.enum.confirmDraft && (e.operation = w.enum.submitRequest), await s.processPurchaseOrder(e, c || f);
144
- }
145
- async function u(e, c) {
146
- const f = m.currentLocationDBName;
147
- return await s.processPurchaseOrderV2(e, c || f);
148
- }
149
- return (e) => a.useOperatePurchaseOrderV2 ? u(e.operateV2, e.transferTo) : N(e.operate, e.transferTo);
150
- }
151
- var Ue = /* @__PURE__ */ ((m) => (m.RECEIVE_REQUEST = "receive/request", m.APPROVAL = "approval", m))(Ue || {});
152
- const we = K(), Ee = K();
153
- function Ds(m, s) {
154
- const a = Ve(), N = de(), u = Te();
155
- qe();
156
- const e = wt(), c = Rt(), f = K(!1), r = Ae(), b = $e(), R = K(new Array()), p = K(
157
- s != null && s.startDate && (s != null && s.endDate) ? s : ct()
158
- ), o = W(() => {
159
- const k = new Date(p.value.startDate), t = new Date(p.value.endDate);
160
- return {
161
- start: ut(k).toISOString(),
162
- end: dt(t).toISOString()
163
- };
164
- }), l = K(new Array()), i = mt(), y = K(null);
165
- async function O(k) {
166
- function t(S) {
167
- const g = {
168
- mode: We.CREATE,
169
- modelValue: k || void 0,
170
- show: !0,
171
- "onUpdate:show"(A) {
172
- we.value.show = A;
173
- },
174
- templateId: S,
175
- lastClosingDate: y.value
176
- };
177
- we.value = g;
178
- }
179
- let d;
180
- u.mustUsePoTemplate && !(k != null && k.template) ? a.open({
181
- title: "Create transfer",
182
- message: "",
183
- primaryActions: {
184
- text: "Select a template",
185
- close: !0
186
- },
187
- secondaryActions: {
188
- text: "Outlet to Outlet",
189
- variant: "secondary",
190
- close: !0
191
- }
192
- }).onPrimary(async () => {
193
- d = await e.getTemplateId(), d && t(d);
194
- }).onSecondary(() => {
195
- t(void 0);
196
- }) : t(d);
197
- }
198
- function T(k) {
199
- const t = {
200
- mode: We.UPDATE,
201
- modelValue: Ze(k),
202
- show: !0,
203
- "onUpdate:show"(d) {
204
- we.value.show = d;
205
- },
206
- lastClosingDate: y.value
207
- };
208
- we.value = t;
209
- }
210
- async function X() {
211
- R.value = [], f.value = !0;
212
- try {
213
- R.value = await b.getPurchaseOrders(o.value).then((S) => S.sort((g, A) => A._id.localeCompare(g._id)));
214
- const k = await i.readCurrentLocationLastClosing(!0), t = k == null ? void 0 : k._id;
215
- t && (y.value = ft(t)), await u.awaitFeatureLoaded(() => u.mustUsePoTemplate) && await c.fetchTemplates();
216
- const d = R.value.map((S) => {
217
- var g;
218
- return ((g = S.request) == null ? void 0 : g.id) ?? "";
219
- }).filter((S) => S);
220
- l.value = await b.readRequestByIds(d);
221
- } catch {
222
- r.open({
223
- title: "Something went wrong",
224
- message: "Error at fetching purchase orders",
225
- type: "error"
226
- });
227
- } finally {
228
- f.value = !1;
229
- }
230
- }
231
- async function Q() {
232
- l.value = [], f.value = !0;
233
- try {
234
- l.value = await b.readRequests(
235
- void 0,
236
- o.value.start,
237
- o.value.end
238
- ).then((k) => k.reverse());
239
- } catch {
240
- r.open({
241
- title: "Something went wrong",
242
- message: "Error at fetching purchase requests",
243
- type: "error"
244
- });
245
- } finally {
246
- f.value = !1;
247
- }
248
- }
249
- function Y() {
250
- switch (m) {
251
- case "receive/request":
252
- return X();
253
- case "approval":
254
- return Q();
255
- }
256
- }
257
- function re(k, t) {
258
- p.value = {
259
- startDate: k,
260
- endDate: t
261
- }, Y();
262
- }
263
- N.watchLocation(async (k) => {
264
- if (!k) {
265
- R.value = [];
266
- return;
267
- }
268
- await Y();
269
- });
270
- const J = K(), me = K(Math.random().toString());
271
- async function ae(k, t) {
272
- const d = Math.random().toString();
273
- me.value = d, t ?? (t = l.value.computeFirst(
274
- (A) => A.purchaseOrderId === k._id ? A : null
275
- ) ?? void 0);
276
- const S = m === "receive/request" ? N.currentLocation : t == null ? void 0 : t.to, g = {
277
- poRequest: t,
278
- purchaseOrder: k,
279
- transferTo: S == null ? void 0 : S.name,
280
- transferToDbName: S == null ? void 0 : S.dbName,
281
- show: !0,
282
- canResubmit: !1,
283
- canApprove: m === "approval",
284
- "onUpdate:show"(A) {
285
- J.value.show = A;
286
- },
287
- scope: m
288
- };
289
- J.value = g;
290
- }
291
- async function fe(k, t, d, S) {
292
- const g = it();
293
- f.value = !0;
294
- try {
295
- await g({
296
- operate: {
297
- operation: t,
298
- doc: k,
299
- options: (
300
- // auto receive for supplier to warehouse
301
- (t === w.enum.confirmDraft || // auto receive for warehouse to warehouse
302
- t === w.enum.completeReceive) && u.autoReceiveWarehouse ? {
303
- autoReceive: !0
304
- } : void 0
305
- )
306
- },
307
- operateV2: {
308
- _id: k._id,
309
- _rev: k._rev ?? "",
310
- action: t,
311
- payloads: []
312
- },
313
- transferTo: S
314
- }), await new Promise((j) => setTimeout(j, 1e3));
315
- const V = de().currentLocationDBName.startsWith("restaurant_");
316
- t === w.enum.confirmDraft && k.effectiveAt && V ? r.open({
317
- title: "Success",
318
- message: `${d}. The backdate will be reflected once your POS has received this change.`,
319
- type: "success"
320
- }) : r.open({
321
- title: "Success",
322
- message: d,
323
- type: "success"
324
- });
325
- } catch (A) {
326
- r.open({
327
- title: "Something went wrong",
328
- message: "Please try again.",
329
- type: "error"
330
- }), console.error("Error when submitting PO operation", t, k, A);
331
- } finally {
332
- f.value = !1, Y();
333
- }
334
- }
335
- async function Pe(k, t, d) {
336
- const S = ot[t];
337
- if (!S) {
338
- r.open({
339
- title: "Something went wrong",
340
- message: `Cannot process order: ${et(t)}`,
341
- type: "error"
342
- });
343
- return;
344
- }
345
- const { successMessage: g, ...A } = S;
346
- a.open({
347
- title: A.title,
348
- message: A.message,
349
- primaryActions: A.primaryActions
350
- }).onPrimary(() => {
351
- fe(k, t, g, d);
352
- });
353
- }
354
- async function oe() {
355
- a.open({
356
- title: "Upload Transfer",
357
- primaryActions: {
358
- text: "Xilnex transfer note",
359
- close: !0
360
- },
361
- secondaryActions: {
362
- text: "Cancel",
363
- close: !0
364
- }
365
- }).onPrimary(() => {
366
- const k = {
367
- show: !0,
368
- "onUpdate:show"(t) {
369
- Ee.value.show = t;
370
- }
371
- };
372
- Ee.value = k;
373
- });
374
- }
375
- return {
376
- purchaseOrders: R,
377
- purchaseRequests: l,
378
- updateDateRange: re,
379
- fetchData: Y,
380
- loading: f,
381
- transferDialogProps: we,
382
- promptCreateTransferDialog: O,
383
- promptUpdateTransferDialog: T,
384
- transferDetailsProps: J,
385
- promptShowTransferDetails: ae,
386
- submitAction: Pe,
387
- xilnexImportDialogProps: Ee,
388
- promptUploadTransferDialog: oe
389
- };
390
- }
391
- function Tt(m, s) {
392
- return s.reduce(
393
- (N, u) => {
394
- const e = u.received.find((c) => c.sku._id === m._id);
395
- return e && (N = Le(N, e.amount)), N;
396
- },
397
- St.toPrecision(Ne(0), m.unit.precision)
398
- );
399
- }
400
- function $t(m, s, a, N) {
401
- const { name: u, address: e, regNo: c } = s.doc.profile, f = {
402
- name: u,
403
- registrationNumber: c,
404
- line1: e == null ? void 0 : e.line1,
405
- line2: e == null ? void 0 : e.line2,
406
- postcode: e == null ? void 0 : e.postcode,
407
- city: e == null ? void 0 : e.city,
408
- state: e == null ? void 0 : e.state,
409
- country: e == null ? void 0 : e.country
410
- }, r = {
411
- name: m.supplier.name,
412
- phoneNumber: m.supplier.phoneNumber,
413
- registrationNumber: m.supplier.registrationNumber,
414
- line1: m.supplier.address.line1,
415
- line2: m.supplier.address.line2,
416
- postcode: m.supplier.address.postcode,
417
- city: m.supplier.address.city,
418
- state: m.supplier.address.state,
419
- country: m.supplier.address.country
420
- }, b = m.items.map((i) => {
421
- const { sku: y, measurement: O } = i, T = ie(
422
- Tt(i.sku, m.deliveryOrder || []),
423
- !1
424
- );
425
- return {
426
- code: y.code,
427
- description: y.name,
428
- quantity: at(i.quantity, y.unit, i.measurement),
429
- unit: (O == null ? void 0 : O.abbrev) || y.unit.abbrev,
430
- received: T
431
- };
432
- }), R = m.deliveryOrder.map((i) => ({
433
- createdAt: tt(new Date(i.createdAt)),
434
- ref: i.deliveryOrderNumber,
435
- remark: i.remark || "",
436
- items: i.received.map((y) => {
437
- var O;
438
- return {
439
- code: y.sku.code,
440
- description: y.sku.name,
441
- quantity: ie(y.amount),
442
- unit: ((O = y.measurement) == null ? void 0 : O.abbrev) || y.sku.unit.abbrev
443
- };
444
- })
445
- })), p = {
446
- businessName: a == null ? void 0 : a.name,
447
- logo: a == null ? void 0 : a.thumbnail,
448
- orderNumber: m.seqNumber.toString(),
449
- createdAt: ke(m._id),
450
- ref: m.ref || "",
451
- remark: m.remark || "",
452
- buyer: f,
453
- supplier: r,
454
- items: b,
455
- status: m.status,
456
- deliveryOrders: R
457
- }, o = new URL(window.location.href), l = N && (m.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
458
- o.pathname = o.hostname.includes("portal.feedme") ? `/inventory/${l}` : `/${l}`, o.searchParams.append("data", JSON.stringify(p)), window.open(o.href, "_blank", "noreferrer");
459
- }
460
- const he = {
461
- submitRequest: {
462
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
463
- color: "text-fm-color-typo-primary",
464
- value: w.enum.submitRequest
465
- },
466
- confirmDraft: {
467
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
468
- color: "text-fm-color-typo-primary",
469
- value: w.enum.confirmDraft
470
- },
471
- cancelDraft: {
472
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
473
- color: "text-fm-color-typo-error",
474
- value: w.enum.cancelDraft
475
- },
476
- approveRequest: {
477
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
478
- color: "text-fm-color-typo-primary",
479
- value: w.enum.approveRequest
480
- },
481
- rejectRequest: {
482
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
483
- color: "text-fm-color-typo-error",
484
- value: w.enum.rejectRequest
485
- },
486
- processRequest: {
487
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
488
- color: "text-fm-color-typo-primary",
489
- value: w.enum.processRequest
490
- },
491
- receiveStock: {
492
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
493
- color: "text-fm-color-typo-primary",
494
- value: w.enum.receiveStock
495
- },
496
- completeReceive: {
497
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
498
- color: "text-fm-color-typo-primary",
499
- value: w.enum.completeReceive
500
- },
501
- closeRequest: {
502
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
503
- color: "system-error-300",
504
- value: w.enum.closeRequest
505
- },
506
- approveDraft: {
507
- translationKey: "",
508
- color: "",
509
- value: void 0
510
- },
511
- rejectDraft: {
512
- translationKey: "",
513
- color: "",
514
- value: void 0
515
- },
516
- returnStock: {
517
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
518
- color: "text-fm-color-typo-primary",
519
- value: w.enum.returnStock
520
- }
521
- };
522
- function As(m, s) {
523
- const a = de(), N = qe(), u = De(), { t: e } = nt();
524
- function c(o) {
525
- switch (o.status) {
526
- case "DRAFT":
527
- return [
528
- ee[H.Update],
529
- ee[H.Details],
530
- o.supplier.internal === "restaurant" || o.supplier.internal === "warehouse" ? he[w.enum.submitRequest] : he[w.enum.confirmDraft],
531
- he[w.enum.cancelDraft]
532
- ];
533
- case "RECEIVING":
534
- return [
535
- he[w.enum.completeReceive],
536
- ee[H.Details],
537
- ee[H.Print]
538
- ];
539
- case "REQUESTING":
540
- return m === "receive/request" ? [ee[H.Details], ee[H.Print]] : [
541
- he[w.enum.approveRequest],
542
- he[w.enum.rejectRequest],
543
- ee[H.Details]
544
- // DefaultRowActions[RowActionEnum.Print]
545
- ];
546
- case "PROCESSING":
547
- return [ee[H.Details], ee[H.Print]];
548
- case "COMPLETE":
549
- case "CANCEL":
550
- default:
551
- return [ee[H.Details], ee[H.Print]];
552
- }
553
- }
554
- function f(o) {
555
- return Object.values(w.enum).includes(o);
556
- }
557
- async function r(o, l, i) {
558
- var O, T, X, Q;
559
- const y = Ze(l);
560
- if (o === H.Print) {
561
- const Y = (i == null ? void 0 : i.toInventoryLocation) ?? a.currentLocation;
562
- y.ref = [((O = i == null ? void 0 : i.netSuite) == null ? void 0 : O.refNo) || ((T = y.netSuite) == null ? void 0 : T.refNo)].filter((re) => re).join(" "), $t(y, Y, u.currentBusiness.value, m === "approval");
563
- return;
564
- }
565
- if (o === H.Details) {
566
- s.promptShowTransferDetails(y, i);
567
- return;
568
- }
569
- if (o === H.Update) {
570
- (X = s.promptUpdateTransferDialog) == null || X.call(s, y);
571
- return;
572
- }
573
- if (f(o)) {
574
- s.submitAction(l, o, (Q = i == null ? void 0 : i.to) == null ? void 0 : Q.dbName);
575
- return;
576
- }
577
- }
578
- function b() {
579
- const o = [
580
- {
581
- accessorKey: "seqNumber",
582
- header: () => e("inventory.transfer.table.seqNo"),
583
- enableSorting: !0,
584
- size: 80,
585
- sortUndefined: "last"
586
- },
587
- {
588
- accessorKey: "_id",
589
- header: () => e("inventory.transfer.table.createdAt"),
590
- cell(l) {
591
- return ke(`${l.getValue()}`);
592
- },
593
- enableSorting: !0
594
- },
595
- {
596
- accessorKey: "supplier.name",
597
- header: () => e("inventory.transfer.table.transferFrom"),
598
- enableSorting: !0,
599
- size: 200
600
- },
601
- {
602
- accessorKey: "items.length",
603
- header: () => e("inventory.transfer.table.noOfItems"),
604
- enableSorting: !1,
605
- meta: {
606
- width: "10rem"
607
- }
608
- },
609
- {
610
- accessorKey: "ref",
611
- header: () => e("inventory.transfer.table.reference"),
612
- enableSorting: !1,
613
- size: "auto"
614
- },
615
- {
616
- accessorKey: "status",
617
- header: () => e("inventory.transfer.table.status"),
618
- cell(l) {
619
- const i = e(`inventory.transfer.status.${l.getValue() ?? ""}`), y = `${l.getValue() ?? ""}`.toLocaleLowerCase("en-us");
620
- return D(
621
- "div",
622
- {
623
- class: "flex"
624
- },
625
- D(
626
- "div",
627
- {
628
- class: `fm-status-badge fm-status-badge-${y}`
629
- },
630
- i
631
- )
632
- );
633
- },
634
- enableSorting: !0,
635
- size: 200
636
- },
637
- {
638
- id: "action",
639
- cell(l) {
640
- const i = l.row.original, y = c(i);
641
- return Qe(y, (O) => r(O, i));
642
- },
643
- enableSorting: !1,
644
- size: 40,
645
- meta: {
646
- cellClass: "",
647
- headerClass: ""
648
- }
649
- }
650
- ];
651
- if (N.isEnabled) {
652
- const l = [
653
- {
654
- id: "netsuiteTransferOrder",
655
- header: () => "NetSuite Order (ID)",
656
- cell(i) {
657
- var O;
658
- const y = i.row.original;
659
- return (O = y.netSuite) != null && O.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
660
- },
661
- enableSorting: !1,
662
- size: 200,
663
- meta: {
664
- cellClass: "",
665
- headerClass: ""
666
- }
667
- },
668
- {
669
- id: "netsuiteTransactionNumber",
670
- header: () => "NetSuite Transaction No.",
671
- cell(i) {
672
- var O, T;
673
- return ((T = (O = i.row.original.netSuite) == null ? void 0 : O.additionalInfo) == null ? void 0 : T.transactionnumber) ?? "N/A";
674
- },
675
- enableSorting: !1,
676
- size: 200,
677
- meta: {
678
- cellClass: "",
679
- headerClass: ""
680
- }
681
- }
682
- ];
683
- o.splice(o.length - 2, 0, ...l);
684
- }
685
- return o;
686
- }
687
- function R() {
688
- const o = [
689
- {
690
- accessorKey: "purchaseOrder.seqNumber",
691
- header: () => e("inventory.transfer.table.seqNo"),
692
- enableSorting: !0,
693
- size: 80,
694
- sortUndefined: "last"
695
- },
696
- {
697
- accessorKey: "purchaseOrder._id",
698
- header: () => e("inventory.transfer.table.createdAt"),
699
- cell(l) {
700
- return ke(`${l.getValue()}`);
701
- },
702
- enableSorting: !0
703
- },
704
- {
705
- accessorKey: "to.name",
706
- header: () => e("inventory.transfer.table.transferTo"),
707
- enableSorting: !1,
708
- size: 200
709
- },
710
- {
711
- accessorKey: "purchaseOrder.items.length",
712
- header: () => e("inventory.transfer.table.noOfItems"),
713
- enableSorting: !1
714
- },
715
- {
716
- accessorKey: "purchaseOrder.ref",
717
- header: () => e("inventory.transfer.table.reference"),
718
- enableSorting: !1,
719
- size: "auto"
720
- },
721
- {
722
- accessorKey: "purchaseOrder.status",
723
- header: () => e("inventory.transfer.table.status"),
724
- cell(l) {
725
- const i = e(`inventory.transfer.status.${l.getValue() ?? ""}`), y = `${l.getValue() ?? ""}`.toLocaleLowerCase("en-us");
726
- return D(
727
- "div",
728
- {
729
- class: "flex"
730
- },
731
- D(
732
- "div",
733
- {
734
- class: `fm-status-badge fm-status-badge-${y}`
735
- },
736
- i
737
- )
738
- );
739
- },
740
- enableSorting: !0
741
- },
742
- {
743
- id: "action",
744
- cell(l) {
745
- const i = l.row.original, O = (i.purchaseOrder ? c(i.purchaseOrder) : []).map((T) => T.value === H.Print ? {
746
- ...T,
747
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
748
- } : T);
749
- return Qe(
750
- O,
751
- (T) => i.purchaseOrder ? r(T, i.purchaseOrder, i) : void 0
752
- );
753
- },
754
- enableSorting: !1,
755
- size: 40,
756
- meta: {
757
- cellClass: "",
758
- headerClass: ""
759
- }
760
- }
761
- ];
762
- if (N.isEnabled) {
763
- const l = [
764
- {
765
- id: "netsuiteTransferOrder",
766
- header: () => "NetSuite Order (ID)",
767
- cell(i) {
768
- var O;
769
- const y = i.row.original;
770
- return (O = y.netSuite) != null && O.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
771
- },
772
- enableSorting: !1,
773
- size: 200,
774
- meta: {
775
- cellClass: "",
776
- headerClass: ""
777
- }
778
- },
779
- {
780
- id: "netsuiteTransactionNumber",
781
- header: () => "NetSuite Transaction No.",
782
- cell(i) {
783
- var O, T;
784
- return ((T = (O = i.row.original.netSuite) == null ? void 0 : O.additionalInfo) == null ? void 0 : T.transactionnumber) ?? "N/A";
785
- },
786
- enableSorting: !1,
787
- size: 200,
788
- meta: {
789
- cellClass: "",
790
- headerClass: ""
791
- }
792
- }
793
- ];
794
- o.splice(o.length - 2, 0, ...l);
795
- }
796
- return o;
797
- }
798
- const p = W(() => m === "receive/request" ? b() : R());
799
- return {
800
- get columnDefs() {
801
- return p.value;
802
- }
803
- };
804
- }
805
- const Pt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Ct = { class: "flex flex-col gap-8" }, Ft = { class: "flex w-full justify-end gap-16" }, It = /* @__PURE__ */ be({
806
- __name: "FulfillmentForm",
807
- props: {
808
- purchaseOrder: {},
809
- confirm: { type: Function }
810
- },
811
- emits: ["update:show"],
812
- setup(m, { emit: s }) {
813
- const a = m, N = ht({
814
- id: "",
815
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
816
- items: []
817
- }), u = K(), e = s;
818
- return st(() => {
819
- a.purchaseOrder && (N.items = a.purchaseOrder.items.map((c) => ({
820
- id: c.id,
821
- sku: c.sku,
822
- measurement: c.measurement,
823
- amount: c.quantity ?? { amount: 1, precision: 0 }
824
- })));
825
- }), (c, f) => {
826
- const r = G("FmTable"), b = G("FmButton"), R = G("FmForm");
827
- return _(), ne(R, {
828
- ref_key: "formRef",
829
- ref: u,
830
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
831
- onValidationFailed: console.log,
832
- onValidationSuccess: f[1] || (f[1] = () => a.confirm(N))
833
- }, {
834
- default: ce(() => [
835
- f[2] || (f[2] = n("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
836
- n("div", Pt, [
837
- n("div", Ct, [
838
- B(r, {
839
- "column-defs": [
840
- {
841
- header: "Code",
842
- cell: (p) => {
843
- const o = a.purchaseOrder.items.find((l) => l.id === p.row.original.id || l.sku._id === p.row.original.sku._id);
844
- return D(
845
- h(Xe).FmTooltip,
846
- {
847
- content: o.code,
848
- placement: "top",
849
- variant: "plain",
850
- zIndex: 50
851
- },
852
- D(
853
- "span",
854
- {
855
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
856
- },
857
- o.code
858
- )
859
- );
860
- }
861
- },
862
- {
863
- header: "Name",
864
- cell: (p) => {
865
- const o = a.purchaseOrder.items.find((l) => l.id === p.row.original.id || l.sku._id === p.row.original.sku._id);
866
- return D(
867
- h(Xe).FmTooltip,
868
- {
869
- content: o.name,
870
- placement: "top",
871
- variant: "plain",
872
- zIndex: 50
873
- },
874
- D(
875
- "span",
876
- {
877
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
878
- },
879
- o.name
880
- )
881
- );
882
- }
883
- },
884
- {
885
- header: "Amount",
886
- cell: (p) => {
887
- const o = p.row.original, l = a.purchaseOrder.items.find((y) => y.id === o.id || y.sku._id === o.sku._id), i = o.amount ?? {
888
- amount: 1,
889
- precision: 0
890
- };
891
- return D(Nt, {
892
- style: {
893
- flex: "1 1 0%"
894
- },
895
- modelValue: {
896
- amount: i,
897
- measurement: o.measurement ?? null
898
- },
899
- key: o.id ?? o.sku._id,
900
- unit: o.sku.unit,
901
- "onUpdate:modelValue": (y) => {
902
- if (!y) return;
903
- const O = N.items.find((T) => T.id === o.id || T.sku._id === o.sku._id);
904
- O && (O.amount = y.amount);
905
- },
906
- disableUnit: !0,
907
- rules: [
908
- h(kt)(
909
- +h(ie)({ amount: 0, precision: 0 })
910
- ),
911
- h(qt)(+h(ie)(l.quantity))
912
- ],
913
- applyDefaultRules: !0
914
- });
915
- }
916
- }
917
- ],
918
- "row-data": N.items,
919
- "hide-footer": !0
920
- }, null, 8, ["column-defs", "row-data"])
921
- ])
922
- ]),
923
- n("div", Ft, [
924
- B(b, {
925
- class: "px-16",
926
- label: "Confirm",
927
- size: "md",
928
- variant: "primary",
929
- type: "submit"
930
- }),
931
- B(b, {
932
- class: "px-16",
933
- label: "Cancel",
934
- size: "md",
935
- variant: "secondary",
936
- onClick: f[0] || (f[0] = () => e("update:show", !1))
937
- })
938
- ])
939
- ]),
940
- _: 1
941
- }, 8, ["onValidationFailed"]);
942
- };
943
- }
944
- }), Be = {
945
- submitRequest: {
946
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
947
- color: "primary",
948
- buttonVariant: Z.Primary
949
- },
950
- confirmDraft: {
951
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
952
- color: "primary",
953
- buttonVariant: Z.Primary
954
- },
955
- cancelDraft: {
956
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
957
- color: "system-error-300",
958
- buttonVariant: Z.Destructive
959
- },
960
- approveDraft: {
961
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
962
- color: "primary",
963
- buttonVariant: Z.Primary
964
- },
965
- rejectDraft: {
966
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
967
- color: "system-error-300",
968
- buttonVariant: Z.Destructive
969
- },
970
- approveRequest: {
971
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
972
- color: "primary",
973
- buttonVariant: Z.Primary
974
- },
975
- processRequest: {
976
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
977
- color: "primary",
978
- buttonVariant: Z.Primary
979
- },
980
- receiveStock: {
981
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
982
- color: "primary",
983
- buttonVariant: Z.Primary,
984
- available: !1
985
- },
986
- completeReceive: {
987
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
988
- color: "primary",
989
- buttonVariant: Z.Plain
990
- },
991
- rejectRequest: {
992
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
993
- color: "system-error-300",
994
- buttonVariant: Z.Destructive
995
- },
996
- closeRequest: {
997
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
998
- color: "system-error-300",
999
- buttonVariant: Z.Destructive,
1000
- available: !1
1001
- },
1002
- returnStock: {
1003
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1004
- color: "primary",
1005
- buttonVariant: Z.Primary,
1006
- available: !1
1007
- }
1008
- };
1009
- function Et() {
1010
- const m = Te();
1011
- return {
1012
- ableToMarkReceived(s) {
1013
- if (!s || s.status !== le.enum.RECEIVING)
1014
- return !1;
1015
- const N = de().currentLocationDBName;
1016
- return `${s.supplier.internal}_${s.supplier._id}` !== N;
1017
- },
1018
- ableToMarkApproved(s) {
1019
- return !(!s || (s == null ? void 0 : s.status) !== le.enum.REQUESTING);
1020
- },
1021
- ableToCreateFulfillment(s, a) {
1022
- var e, c;
1023
- if (!m.acceptRequireFulfillment || !s || !a || s.status !== le.enum.PROCESSING || !a.processedAt)
1024
- return !1;
1025
- const N = (e = a == null ? void 0 : a.from) == null ? void 0 : e.dbName, u = (c = a == null ? void 0 : a.to) == null ? void 0 : c.dbName;
1026
- return !(N.startsWith("restaurant_") && u.startsWith("restaurant_"));
1027
- }
1028
- };
1029
- }
1030
- const Bt = { class: "flex flex-row-reverse" }, Lt = /* @__PURE__ */ be({
1031
- __name: "NetSuiteSync",
1032
- props: {
1033
- poRequest: {},
1034
- purchaseOrder: {},
1035
- isTransferBetweenOutlets: { type: Boolean },
1036
- scope: {}
1037
- },
1038
- setup(m) {
1039
- const s = m, a = qe(), N = Ae(), u = Ve(), e = K(!1);
1040
- W(() => {
1041
- var R, p, o, l;
1042
- let f = !0;
1043
- a.isEnabled || (f = !1);
1044
- const r = s.purchaseOrder, b = s.poRequest;
1045
- return r && ((R = r == null ? void 0 : r.supplier) != null && R.internal ? (!b && r.status == le.enum.DRAFT && (f = !1), b && !((p = b == null ? void 0 : b.netSuite) != null && p.id) && (f = !1), s.isTransferBetweenOutlets && (f = !1)) : ((r == null ? void 0 : r.status) !== le.enum.REQUESTING && r.supplier.internal && (f = !1), !b && !((o = r == null ? void 0 : r.netSuite) != null && o.id) && (f = !1), !b && ((l = r == null ? void 0 : r.netSuite) != null && l.id) && (r == null ? void 0 : r.status) == le.enum.REQUESTING && (f = !1))), f;
1046
- });
1047
- async function c() {
1048
- e.value || u.open({
1049
- title: "Sync with NetSuite",
1050
- contentComponent: D("div", [
1051
- D("p", "Are you sure you want to sync now?"),
1052
- D("br"),
1053
- D(
1054
- "p",
1055
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1056
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1057
- )
1058
- ]),
1059
- primaryActions: {
1060
- text: "Sync",
1061
- close: !0,
1062
- variant: "destructive"
1063
- },
1064
- secondaryActions: { text: "Not now", close: !0 }
1065
- }).onPrimary(async () => {
1066
- var f, r, b;
1067
- try {
1068
- e.value = !0;
1069
- const R = ((f = s.purchaseOrder) == null ? void 0 : f._id) || ((r = s.poRequest) == null ? void 0 : r.purchaseOrderId) || "", p = (b = s.poRequest) == null ? void 0 : b.to.dbName;
1070
- await a.syncPurchaseOrder(
1071
- R,
1072
- s.scope === "approval" ? p : void 0
1073
- ), N.open({
1074
- title: "Sync with NetSuite",
1075
- message: "Requested to sync with NetSuite. Please wait a moment.",
1076
- type: "success"
1077
- }), await new Promise((o) => setTimeout(o, 5e3)), e.value = !1;
1078
- } catch {
1079
- N.open({
1080
- title: "Error",
1081
- message: "Failed to sync with NetSuite",
1082
- type: "error"
1083
- }), e.value = !1;
1084
- }
1085
- });
1086
- }
1087
- return (f, r) => {
1088
- const b = G("FmButton");
1089
- return _(), q("div", Bt, [
1090
- B(b, {
1091
- "prepend-icon": "sync",
1092
- variant: "secondary",
1093
- label: "Sync",
1094
- loading: e.value,
1095
- onClick: c,
1096
- "text-color": "primary",
1097
- "bg-color": "transparent",
1098
- "border-color": "primary"
1099
- }, null, 8, ["loading"])
1100
- ]);
1101
- };
1102
- }
1103
- }), Ut = {
1104
- key: 0,
1105
- class: "flex flex-col gap-8"
1106
- }, Vt = { class: "flex flex-col gap-4" }, Mt = { class: "fm-typo-en-body-lg-600" }, Kt = {
1107
- key: 0,
1108
- class: "flex flex-col gap-4"
1109
- }, jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-lg-600" }, Ht = { key: 0 }, Gt = { key: 1 }, Wt = {
1110
- key: 1,
1111
- class: "flex flex-col gap-4"
1112
- }, Qt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yt = { class: "fm-typo-en-body-lg-600" }, Xt = { key: 0 }, Jt = { key: 1 }, Zt = {
1113
- key: 2,
1114
- class: "flex flex-col gap-4"
1115
- }, er = { class: "fm-typo-en-body-lg-600" }, tr = {
1116
- key: 3,
1117
- class: "flex flex-col gap-4"
1118
- }, rr = { class: "fm-typo-en-body-lg-600" }, sr = /* @__PURE__ */ be({
1119
- __name: "NetSuiteInfo",
1120
- props: {
1121
- transferType: {},
1122
- transferToDbName: {},
1123
- poRequest: {},
1124
- purchaseOrder: {},
1125
- isTransferBetweenOutlets: { type: Boolean },
1126
- scope: {}
1127
- },
1128
- setup(m) {
1129
- const s = m, a = qe(), N = $e(), u = K(s.poRequest);
1130
- st(async () => {
1131
- var r;
1132
- if (!s.poRequest && ((r = s.purchaseOrder) != null && r._id)) {
1133
- const b = await N.getLatestPurchaseOrderRequest(s.purchaseOrder._id);
1134
- u.value = b;
1135
- }
1136
- });
1137
- const e = W(
1138
- () => {
1139
- var r, b, R, p, o, l;
1140
- return a.getSubsidiaryFullName(
1141
- ((R = (b = (r = s.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : b.subsidiary) == null ? void 0 : R.id) || ((l = (o = (p = s.poRequest) == null ? void 0 : p.netSuite) == null ? void 0 : o.subsidiary) == null ? void 0 : l.id)
1142
- ).fullName;
1143
- }
1144
- ), c = W(() => {
1145
- var r, b, R, p, o, l, i, y, O, T, X, Q;
1146
- return (R = (b = (r = s.purchaseOrder) == null ? void 0 : r.netSuite) == null ? void 0 : b.additionalInfo) != null && R.transactionnumber ? (l = (o = (p = s.purchaseOrder) == null ? void 0 : p.netSuite) == null ? void 0 : o.additionalInfo) == null ? void 0 : l.transactionnumber : (O = (y = (i = u.value) == null ? void 0 : i.netSuite) == null ? void 0 : y.additionalInfo) != null && O.transactionnumber ? (Q = (X = (T = u.value) == null ? void 0 : T.netSuite) == null ? void 0 : X.additionalInfo) == null ? void 0 : Q.transactionnumber : null;
1147
- }), f = W(() => {
1148
- var r, b, R, p, o, l;
1149
- return (b = (r = s.purchaseOrder) == null ? void 0 : r.deliveryFullfillment) != null && b.length && ((p = (R = s.purchaseOrder) == null ? void 0 : R.deliveryFullfillment) == null ? void 0 : p.length) > 0 ? (l = (o = s.purchaseOrder) == null ? void 0 : o.deliveryFullfillment) == null ? void 0 : l.map((i) => {
1150
- var y;
1151
- return (y = i.netSuite) == null ? void 0 : y.refNo;
1152
- }).join(", ") : "N/A";
1153
- });
1154
- return (r, b) => {
1155
- var R, p, o, l, i, y, O, T, X, Q, Y, re, J, me, ae, fe;
1156
- return h(a).isEnabled ? (_(), q("div", Ut, [
1157
- n("div", Vt, [
1158
- b[0] || (b[0] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1159
- n("div", Mt, x(e.value || "N/A"), 1)
1160
- ]),
1161
- !r.isTransferBetweenOutlets && r.scope === h(Ue).RECEIVE_REQUEST ? (_(), q("div", Kt, [
1162
- n("div", jt, " NetSuite " + x((p = (R = r.purchaseOrder) == null ? void 0 : R.netSuite) != null && p.recordType ? h(rt)((l = (o = r.purchaseOrder) == null ? void 0 : o.netSuite) == null ? void 0 : l.recordType) : r.transferType === h(ue).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1163
- n("div", zt, [
1164
- (y = (i = r.purchaseOrder) == null ? void 0 : i.netSuite) != null && y.id ? (_(), q("span", Ht, x((T = (O = r.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : T.refNo) + " (" + x((Q = (X = r.purchaseOrder) == null ? void 0 : X.netSuite) == null ? void 0 : Q.id) + ") ", 1)) : (_(), q("span", Gt, "N/A"))
1165
- ])
1166
- ])) : L("", !0),
1167
- !r.isTransferBetweenOutlets && u.value || r.scope === h(Ue).APPROVAL ? (_(), q("div", Wt, [
1168
- n("div", Qt, " (Request) NetSuite " + x(r.transferType === h(ue).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1169
- n("div", Yt, [
1170
- (re = (Y = u.value) == null ? void 0 : Y.netSuite) != null && re.id ? (_(), q("span", Xt, x((me = (J = u.value) == null ? void 0 : J.netSuite) == null ? void 0 : me.refNo) + " (" + x((fe = (ae = u.value) == null ? void 0 : ae.netSuite) == null ? void 0 : fe.id) + ") ", 1)) : (_(), q("span", Jt, "N/A"))
1171
- ])
1172
- ])) : L("", !0),
1173
- c.value ? (_(), q("div", Zt, [
1174
- b[1] || (b[1] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1175
- n("div", er, x(c.value), 1)
1176
- ])) : L("", !0),
1177
- h(a).isEnabled && r.transferType === h(ue).TRANSFER && !r.isTransferBetweenOutlets ? (_(), q("div", tr, [
1178
- b[2] || (b[2] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1179
- n("div", rr, x(f.value), 1)
1180
- ])) : L("", !0)
1181
- ])) : L("", !0);
1182
- };
1183
- }
1184
- }), ar = { class: "flex flex-row-reverse" }, nr = /* @__PURE__ */ be({
1185
- __name: "NetSuiteLog",
1186
- props: {
1187
- netsuiteId: {},
1188
- purchaseOrderId: {}
1189
- },
1190
- setup(m) {
1191
- const s = Ae(), a = pt();
1192
- async function N(u, e) {
1193
- let c = `attributes.pod:netsuite* AND body.message:*${u}*`;
1194
- if (e) {
1195
- const r = e.replace(/:/g, "\\:");
1196
- c = `attributes.pod:netsuite* AND (body.message:*${u}* OR ${r})`;
1197
- }
1198
- const { url: f } = await a.getLogs(c);
1199
- s.open(
1200
- {
1201
- message: "Opening NetSuite logs...",
1202
- type: "info"
1203
- },
1204
- 800
1205
- ), await new Promise((r) => setTimeout(r, 800)), window.open(f, "_blank");
1206
- }
1207
- return (u, e) => {
1208
- const c = G("FmButton");
1209
- return _(), q("div", ar, [
1210
- B(c, {
1211
- "prepend-icon": "history",
1212
- variant: "secondary",
1213
- label: "Logs",
1214
- onClick: e[0] || (e[0] = (f) => N(u.netsuiteId, u.purchaseOrderId)),
1215
- "text-color": "primary",
1216
- "bg-color": "transparent",
1217
- "border-color": "primary"
1218
- })
1219
- ]);
1220
- };
1221
- }
1222
- }), or = {
1223
- key: 0,
1224
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1225
- }, ir = { class: "flex gap-8 items-center" }, lr = { class: "ml-auto" }, cr = { class: "flex gap-4" }, ur = /* @__PURE__ */ be({
1226
- __name: "NetSuitePanel",
1227
- props: {
1228
- poRequest: {},
1229
- purchaseOrder: {},
1230
- transferType: {},
1231
- transferToDbName: {},
1232
- scope: {}
1233
- },
1234
- setup(m) {
1235
- const s = m, a = At(), N = De(), u = W(() => {
1236
- var r, b, R, p, o, l, i;
1237
- const e = ((r = s.transferToDbName) == null ? void 0 : r.startsWith("restaurant")) && ((R = (b = s.purchaseOrder) == null ? void 0 : b.supplier) == null ? void 0 : R.internal) === "restaurant", c = s.transferType === ue.PURCHASE, f = s.transferType === ue.TRANSFER;
1238
- return c || f && !e || ((o = (p = s.purchaseOrder) == null ? void 0 : p.netSuite) == null ? void 0 : o.id) || ((i = (l = s.poRequest) == null ? void 0 : l.netSuite) == null ? void 0 : i.id);
1239
- });
1240
- return (e, c) => {
1241
- var r, b, R, p, o, l;
1242
- const f = G("FmMenuDivider");
1243
- return h(a).isNetSuiteEnabled && u.value ? (_(), q("div", or, [
1244
- n("div", ir, [
1245
- c[0] || (c[0] = n("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1246
- n("div", lr, [
1247
- n("div", cr, [
1248
- (r = h(N).sessionUser.value) != null && r.role.isAdmin && ((R = (b = s.purchaseOrder) == null ? void 0 : b.netSuite) != null && R.id) ? (_(), ne(nr, {
1249
- key: 0,
1250
- "netsuite-id": (o = (p = e.purchaseOrder) == null ? void 0 : p.netSuite) == null ? void 0 : o.id,
1251
- "purchase-order-id": (l = e.purchaseOrder) == null ? void 0 : l._id
1252
- }, null, 8, ["netsuite-id", "purchase-order-id"])) : L("", !0),
1253
- B(Lt, {
1254
- "po-request": e.poRequest,
1255
- "purchase-order": e.purchaseOrder,
1256
- "is-transfer-between-outlets": !u.value,
1257
- scope: e.scope
1258
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1259
- ])
1260
- ])
1261
- ]),
1262
- B(f),
1263
- B(sr, {
1264
- "po-request": e.poRequest,
1265
- "purchase-order": e.purchaseOrder,
1266
- "transfer-type": e.transferType,
1267
- "transfer-to-db-name": e.transferToDbName,
1268
- "is-transfer-between-outlets": !u.value,
1269
- scope: e.scope
1270
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1271
- ])) : L("", !0);
1272
- };
1273
- }
1274
- }), dr = { class: "flex flex-col gap-16 w-full h-full" }, mr = { class: "flex justify-between" }, fr = { class: "fm-typo-en-body-lg-600" }, pr = { class: "flex flex-col gap-8" }, yr = { class: "flex flex-col gap-4" }, vr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, hr = { class: "flex gap-1" }, br = { class: "fm-typo-en-body-lg-600" }, gr = {
1275
- key: 0,
1276
- class: "flex flex-col gap-4"
1277
- }, _r = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Sr = { class: "fm-typo-en-body-lg-600" }, wr = { class: "flex flex-col gap-4" }, Rr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Or = { class: "fm-typo-en-body-lg-600" }, xr = {
1278
- key: 1,
1279
- class: "flex flex-col gap-4"
1280
- }, Nr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, kr = { class: "fm-typo-en-body-lg-600" }, qr = {
1281
- key: 2,
1282
- class: "flex flex-col gap-4"
1283
- }, Dr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ar = { class: "fm-typo-en-body-lg-600" }, Tr = {
1284
- key: 3,
1285
- class: "flex flex-col gap-4"
1286
- }, $r = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pr = { class: "fm-typo-en-body-lg-600" }, Cr = {
1287
- key: 4,
1288
- class: "flex flex-col gap-4"
1289
- }, Fr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ir = { class: "fm-typo-en-body-lg-600" }, Er = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Br = { class: "flex flex-col gap-8" }, Lr = { class: "flex gap-8 items-center" }, Ur = { class: "flex-1 fm-typo-en-body-lg-600" }, Vr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Mr = { class: "flex w-full gap-4" }, Kr = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2" }, jr = { class: "fm-typo-en-body-lg-600 line-clamp-2" }, zr = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, Hr = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Gr = {
1290
- key: 0,
1291
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1292
- }, Wr = { class: "py-8" }, Qr = { class: "flex justify-end gap-4 items-center" }, Yr = { class: "fm-typo-en-body-lg-600" }, Xr = {
1293
- key: 1,
1294
- class: "flex-1 xs:w-screen xs:max-w-full"
1295
- }, Jr = {
1296
- key: 0,
1297
- class: "flex flex-col items-center gap-8 h-full"
1298
- }, Zr = ["src"], es = { class: "fm-typo-en-body-lg-600" }, ts = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, rs = {
1299
- key: 1,
1300
- class: "px-4 flex flex-col"
1301
- }, ss = { class: "flex gap-12 content-stretch" }, as = {
1302
- class: "flex flex-col w-24",
1303
- name: "circles"
1304
- }, ns = { class: "flex-1 flex flex-col items-center" }, os = { class: "flex-1 flex flex-col items-center" }, is = {
1305
- class: "py-12 flex flex-col gap-4",
1306
- name: "received-at header"
1307
- }, ls = { class: "fm-typo-en-body-lg-400" }, cs = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, us = { class: "flex gap-12 content-stretch" }, ds = {
1308
- class: "flex flex-col w-24",
1309
- name: "circles"
1310
- }, ms = { class: "flex-1 flex flex-col items-center" }, fs = {
1311
- class: "py-12 flex flex-col gap-4 flex-1",
1312
- name: "delivery details"
1313
- }, ps = { class: "flex flex-col gap-8" }, ys = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, vs = { class: "flex flex-col gap-4" }, hs = { class: "flex gap-8 xs:flex-col" }, Ts = /* @__PURE__ */ be({
1314
- __name: "TransferDetails",
1315
- props: {
1316
- poRequest: {},
1317
- purchaseOrder: {},
1318
- transferTo: {},
1319
- transferToDbName: {},
1320
- show: { type: Boolean },
1321
- canResubmit: { type: Boolean },
1322
- canApprove: { type: Boolean },
1323
- scope: {}
1324
- },
1325
- emits: ["update:show", "submitted"],
1326
- setup(m, { emit: s }) {
1327
- const a = m, N = s, u = Ve(), e = Ae(), c = Te(), f = de(), r = De(), b = W(
1328
- () => {
1329
- var t, d;
1330
- return {
1331
- id: ((t = r.sessionUser.value) == null ? void 0 : t.id) ?? "",
1332
- name: ((d = r.sessionUser.value) == null ? void 0 : d.displayName) ?? ""
1333
- };
1334
- }
1335
- ), R = Et(), { t: p } = nt(), o = W(
1336
- () => {
1337
- var t, d, S, g;
1338
- return ((d = (t = a.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : d.internal) === "restaurant" || ((g = (S = a.purchaseOrder) == null ? void 0 : S.supplier) == null ? void 0 : g.internal) === "warehouse" ? ue.TRANSFER : ue.PURCHASE;
1339
- }
1340
- ), l = K(!1), i = K(""), y = K(!0), O = $e(), T = Dt(O.getWorkflowConfig), X = it(), Q = W(() => {
1341
- if (!a.purchaseOrder)
1342
- return [];
1343
- const t = T.result.value;
1344
- if (t.state === Je.loading)
1345
- return [];
1346
- const d = {
1347
- user: b.value,
1348
- executedAt: f.locations.computeFirst(
1349
- (g) => {
1350
- var A;
1351
- return g.dbName === ((A = f._currentLocation) == null ? void 0 : A.dbName) ? g : null;
1352
- }
1353
- ),
1354
- purchaseOrderRequest: a.poRequest,
1355
- purchaseOrder: a.purchaseOrder
1356
- };
1357
- let S = [];
1358
- try {
1359
- t.state === Je.error ? (console.error("Error fetching workflow config:", t.error), S = Ie.getAvailableActions({
1360
- ...d,
1361
- orderConfig: Ie.getDefaultConfig()
1362
- }).actions.filter(
1363
- (g) => (
1364
- // TODO: create receiveStock & processRequest dialog
1365
- // to create their payload
1366
- g !== w.enum.receiveStock && g !== w.enum.processRequest && g !== w.enum.closeRequest
1367
- )
1368
- )) : S = Ie.getAvailableActions({
1369
- ...d,
1370
- orderConfig: t.data
1371
- }).actions.filter(
1372
- (g) => g !== w.enum.receiveStock && g !== w.enum.processRequest && g !== w.enum.closeRequest
1373
- );
1374
- } catch (g) {
1375
- console.error("Error getting available actions:", g);
1376
- }
1377
- return a.scope === "approval" && (S = S.filter((g) => g !== w.enum.completeReceive)), S;
1378
- }), Y = xt(a, "show"), re = W(() => [
1379
- {
1380
- label: p("inventory.transfer.receiveRequest.details.overview"),
1381
- value: "overview"
1382
- },
1383
- {
1384
- label: p("inventory.transfer.receiveRequest.details.deliveryHistory"),
1385
- value: "deliveryHistory"
1386
- }
1387
- ]), J = K(re.value[0]);
1388
- bt(
1389
- () => a.show,
1390
- (t) => {
1391
- t && (J.value = re.value[0]);
1392
- }
1393
- );
1394
- async function me(t, d, S, g, A) {
1395
- return new Promise((V, j) => {
1396
- u.open({
1397
- closeButton: !1,
1398
- title: g.title,
1399
- message: g.message,
1400
- primaryActions: g.primaryActions,
1401
- secondaryActions: { text: "No", close: !1 }
1402
- }).onPrimary(async () => {
1403
- var $, C, U, F;
1404
- const v = [];
1405
- S === w.enum.approveRequest ? (v.push({
1406
- action: "approveRequest",
1407
- payload: null
1408
- }), d.fulfillment && v.push({
1409
- action: "processRequest",
1410
- payload: {
1411
- fulfillmentId: "",
1412
- deliveryOrderNumber: "",
1413
- deliveryRemark: null,
1414
- items: d.fulfillment.items,
1415
- createdBy: b.value
1416
- }
1417
- })) : S === w.enum.processRequest && d.fulfillment && v.push({
1418
- action: "processRequest",
1419
- payload: {
1420
- fulfillmentId: "",
1421
- deliveryOrderNumber: "",
1422
- deliveryRemark: null,
1423
- items: d.fulfillment.items,
1424
- createdBy: b.value
1425
- }
1426
- });
1427
- try {
1428
- await X({
1429
- operate: {
1430
- operation: S,
1431
- doc: t,
1432
- options: d
1433
- },
1434
- operateV2: {
1435
- _id: (($ = a.purchaseOrder) == null ? void 0 : $._id) ?? "",
1436
- _rev: ((C = a.purchaseOrder) == null ? void 0 : C._rev) ?? "",
1437
- action: S,
1438
- payloads: v
1439
- // add payload if action is receiveStock or processRequest
1440
- },
1441
- transferTo: (F = (U = a.poRequest) == null ? void 0 : U.to) == null ? void 0 : F.dbName
1442
- }).delayed(1e3), V("submitted");
1443
- } catch (z) {
1444
- j(z);
1445
- }
1446
- }).onSecondary(() => {
1447
- V("cancelled");
1448
- for (let v = 0; v < A + 2; v++)
1449
- u.close();
1450
- }).onClose(() => {
1451
- });
1452
- });
1453
- }
1454
- async function ae(t) {
1455
- var g, A, V, j;
1456
- if (t === w.enum.receiveStock)
1457
- return;
1458
- const d = ot[t];
1459
- if (!d) {
1460
- e.open({
1461
- title: "Something went wrong",
1462
- message: `Cannot process order: ${et(t)}`,
1463
- type: "error"
1464
- });
1465
- return;
1466
- }
1467
- const { successMessage: S } = d;
1468
- if (a.purchaseOrder) {
1469
- i.value = `${t}`, l.value = !0, y.value = !1;
1470
- const v = {};
1471
- let $ = 0;
1472
- if ((t === w.enum.confirmDraft || // auto receive for warehouse to warehouse
1473
- t === w.enum.completeReceive) && c.autoReceiveWarehouse)
1474
- v.autoReceive = !0;
1475
- else if ((t === w.enum.approveRequest || t === w.enum.processRequest) && c.acceptRequireFulfillment) {
1476
- const C = (A = (g = a.poRequest) == null ? void 0 : g.from) == null ? void 0 : A.dbName, U = (j = (V = a.poRequest) == null ? void 0 : V.to) == null ? void 0 : j.dbName;
1477
- if (C && U && (C.startsWith("warehouse_") || U.startsWith("warehouse_"))) {
1478
- const F = await new Promise((z, I) => {
1479
- u.open({
1480
- closeButton: !1,
1481
- title: "Confirm transfer amount",
1482
- dialogComponent: It,
1483
- dialogComponentProps: {
1484
- purchaseOrder: a.purchaseOrder,
1485
- confirm: z,
1486
- "onUpdate:show": (se) => {
1487
- se || (i.value = "", l.value = !1, y.value = !0, $++, u.close()), I("cancelled");
1488
- }
1489
- }
1490
- });
1491
- });
1492
- v.fulfillment = F;
1493
- }
1494
- }
1495
- try {
1496
- await me(
1497
- a.purchaseOrder,
1498
- v,
1499
- t,
1500
- d,
1501
- $
1502
- ) === "submitted" && (e.open({
1503
- title: "Success",
1504
- message: S,
1505
- type: "success"
1506
- }), N("update:show", !1), N("submitted"));
1507
- } catch (C) {
1508
- e.open({
1509
- title: "Something went wrong",
1510
- message: "Please try again.",
1511
- type: "error"
1512
- }), console.error("Error when submitting PO operation", t, a.purchaseOrder, C);
1513
- } finally {
1514
- i.value = "", l.value = !1, y.value = !0;
1515
- }
1516
- }
1517
- }
1518
- const fe = W(() => {
1519
- var t, d;
1520
- return ((t = a.purchaseOrder) == null ? void 0 : t.status) === le.enum.RECEIVING || ((d = a.purchaseOrder) == null ? void 0 : d.status) === le.enum.COMPLETE;
1521
- }), Pe = W(() => {
1522
- var V, j, v;
1523
- const S = (((V = a.purchaseOrder) == null ? void 0 : V.deliveryOrder) ?? []).flatMap(($) => $.received ?? []).reduce(
1524
- ($, C) => {
1525
- const U = $[C.sku._id] ?? [];
1526
- return $[C.sku._id] = [...U, C], $;
1527
- },
1528
- {}
1529
- ), g = Object.entries(S).reduce(
1530
- ($, [C, U]) => {
1531
- const F = U.reduce((z, I) => {
1532
- const se = yt(
1533
- z,
1534
- Math.max(z.precision, I.amount.precision)
1535
- );
1536
- return Le(se, I.amount);
1537
- }, Ne(0));
1538
- return $[C] = F, $;
1539
- },
1540
- {}
1541
- ), A = ((j = a.purchaseOrder) == null ? void 0 : j.items) ?? [];
1542
- for (const $ of A)
1543
- g[v = $.sku._id] ?? (g[v] = Ne(0));
1544
- return g;
1545
- }), oe = W(() => {
1546
- var V, j;
1547
- const t = ((V = a.purchaseOrder) == null ? void 0 : V.deliveryOrder) ?? [], d = ((j = a.purchaseOrder) == null ? void 0 : j.deliveryFullfillment) ?? [], S = [
1548
- ...t.map((v) => ({
1549
- createdAt: v.createdAt,
1550
- type: "grn",
1551
- doc: v
1552
- })),
1553
- ...d.map((v) => ({
1554
- createdAt: v.createdAt,
1555
- type: "fulfillment",
1556
- doc: v
1557
- }))
1558
- ];
1559
- S.reverse().sort((v, $) => v.createdAt.localeCompare($.createdAt));
1560
- function g(v) {
1561
- var U, F, z, I, se, ge, _e, Se, E;
1562
- const $ = d.findIndex((P) => P.id === v.fullfillmentId), C = [
1563
- (F = (U = d[$]) == null ? void 0 : U.netSuite) != null && F.refNo ? {
1564
- label: "Fulfillment's ref no. (Netsuite)",
1565
- values: [(I = (z = d[$]) == null ? void 0 : z.netSuite) == null ? void 0 : I.refNo]
1566
- } : null,
1567
- (se = v == null ? void 0 : v.netSuite) != null && se.refNo ? {
1568
- label: "Netsuite ref no.",
1569
- values: [(ge = v == null ? void 0 : v.netSuite) == null ? void 0 : ge.refNo]
1570
- } : null,
1571
- (_e = v == null ? void 0 : v.netSuite) != null && _e.recordType ? {
1572
- label: "Netsuite Type",
1573
- values: [rt((Se = v == null ? void 0 : v.netSuite) == null ? void 0 : Se.recordType)]
1574
- } : null
1575
- ];
1576
- return {
1577
- header: "Received",
1578
- date: Ce(new Date(v.createdAt)),
1579
- info: [
1580
- {
1581
- label: "Adjustment date",
1582
- values: [
1583
- v.adjustment ? Ce(new Date(vt(v.adjustment))) : "-"
1584
- ]
1585
- },
1586
- {
1587
- label: "Received by",
1588
- values: [(E = v.createdBy) == null ? void 0 : E.name]
1589
- },
1590
- {
1591
- label: "Received items",
1592
- values: v.received.map((P) => {
1593
- var M;
1594
- return D("div", [
1595
- D(
1596
- "div",
1597
- {
1598
- class: "flex gap-4"
1599
- },
1600
- [
1601
- D(
1602
- "div",
1603
- {
1604
- class: "flex flex-col"
1605
- },
1606
- [
1607
- D(
1608
- "span",
1609
- {
1610
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1611
- },
1612
- `${P.sku.name}`
1613
- ),
1614
- D(
1615
- "span",
1616
- {
1617
- class: "fm-typo-en-body-md-400"
1618
- },
1619
- `${P.sku.code} `
1620
- )
1621
- ]
1622
- ),
1623
- D(
1624
- "div",
1625
- {
1626
- class: "ml-auto flex flex-col"
1627
- },
1628
- [
1629
- D(
1630
- "div",
1631
- {
1632
- class: "ml-auto flex gap-1"
1633
- },
1634
- [
1635
- D(
1636
- "span",
1637
- {
1638
- class: "fm-typo-en-body-lg-600 self-end"
1639
- },
1640
- ie(P.amount, !1)
1641
- ),
1642
- D(
1643
- "span",
1644
- {
1645
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1646
- },
1647
- ((M = P.measurement) == null ? void 0 : M.abbrev) ?? P.sku.unit.abbrev
1648
- )
1649
- ]
1650
- ),
1651
- D(
1652
- "div",
1653
- {
1654
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1655
- },
1656
- `${P.cost ? `(${Oe(P.cost)})` : ""}`
1657
- )
1658
- ]
1659
- )
1660
- ]
1661
- )
1662
- ]);
1663
- })
1664
- },
1665
- v.deliveryOrderNumber ? {
1666
- label: "Delivery order no.",
1667
- values: [v.deliveryOrderNumber]
1668
- } : null,
1669
- v.remark ? {
1670
- label: "Remark",
1671
- values: [v.remark]
1672
- } : null,
1673
- $ > -1 ? {
1674
- label: "Fulfilment's sequence",
1675
- values: [`${$ + 1}`]
1676
- } : null,
1677
- ...C
1678
- ].filter((P) => P)
1679
- };
1680
- }
1681
- function A(v) {
1682
- var C, U;
1683
- const $ = d.findIndex((F) => F.id === v.id);
1684
- return {
1685
- header: "Fulfillment",
1686
- date: Ce(new Date(v.createdAt)),
1687
- info: [
1688
- {
1689
- label: "Sequence",
1690
- values: [String($ + 1)]
1691
- },
1692
- {
1693
- label: "Receiveable items",
1694
- values: v.items.map((F) => {
1695
- var z;
1696
- return D("div", [
1697
- D(
1698
- "div",
1699
- {
1700
- class: "flex gap-4"
1701
- },
1702
- [
1703
- D(
1704
- "div",
1705
- {
1706
- class: "flex flex-col"
1707
- },
1708
- [
1709
- D(
1710
- "span",
1711
- {
1712
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
1713
- },
1714
- `${F.sku.name}`
1715
- ),
1716
- D(
1717
- "span",
1718
- {
1719
- class: "fm-typo-en-body-md-400"
1720
- },
1721
- `${F.sku.code} `
1722
- )
1723
- ]
1724
- ),
1725
- D(
1726
- "div",
1727
- {
1728
- class: "ml-auto flex flex-col"
1729
- },
1730
- [
1731
- D(
1732
- "div",
1733
- {
1734
- class: "ml-auto flex gap-1"
1735
- },
1736
- [
1737
- D(
1738
- "span",
1739
- {
1740
- class: "fm-typo-en-body-lg-600 self-end"
1741
- },
1742
- ie(F.amount, !1)
1743
- ),
1744
- D(
1745
- "span",
1746
- {
1747
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
1748
- },
1749
- ((z = F.measurement) == null ? void 0 : z.abbrev) ?? F.sku.unit.abbrev
1750
- )
1751
- ]
1752
- ),
1753
- D(
1754
- "div",
1755
- {
1756
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1757
- },
1758
- `${F.cost ? `(${Oe(F.cost)})` : ""}`
1759
- )
1760
- ]
1761
- )
1762
- ]
1763
- )
1764
- ]);
1765
- })
1766
- },
1767
- (C = v.netSuite) != null && C.refNo ? {
1768
- label: "Ref no. (Netsuite)",
1769
- values: [(U = v.netSuite) == null ? void 0 : U.refNo]
1770
- } : null
1771
- ].filter((F) => F)
1772
- };
1773
- }
1774
- return S.map((v) => {
1775
- switch (v.type) {
1776
- case "grn":
1777
- return g(v.doc);
1778
- case "fulfillment":
1779
- return A(v.doc);
1780
- }
1781
- });
1782
- }), k = W(() => {
1783
- var d;
1784
- const t = {
1785
- ...Ne(0),
1786
- currency: Ye()
1787
- };
1788
- return ((d = a.purchaseOrder) == null ? void 0 : d.items.reduce((S, g) => ({
1789
- ...Le(S, g.totalCost ?? t),
1790
- currency: Ye()
1791
- }), t)) ?? t;
1792
- });
1793
- return (t, d) => {
1794
- var F, z;
1795
- const S = G("FmButtonGroup"), g = G("FmChip"), A = G("FmMenuDivider"), V = G("FmCard"), j = G("FmIcon"), v = G("FmTooltip"), $ = G("FmSpacer"), C = G("FmButton"), U = G("FmSideSheet");
1796
- return _(), ne(U, {
1797
- header: h(p)("inventory.transfer.receiveRequest.details.title") + ((F = t.purchaseOrder) != null && F.seqNumber ? ` #${(z = t.purchaseOrder) == null ? void 0 : z.seqNumber}` : ""),
1798
- modelValue: h(Y),
1799
- "onUpdate:modelValue": d[5] || (d[5] = (I) => gt(Y) ? Y.value = I : null),
1800
- "dismiss-away": y.value,
1801
- "close-button": "",
1802
- "max-width": 600
1803
- }, {
1804
- default: ce(() => {
1805
- var I, se, ge, _e, Se;
1806
- return [
1807
- n("div", dr, [
1808
- n("div", null, [
1809
- B(S, {
1810
- items: re.value,
1811
- modelValue: J.value,
1812
- "onUpdate:modelValue": d[0] || (d[0] = (E) => J.value = E)
1813
- }, null, 8, ["items", "modelValue"])
1814
- ]),
1815
- J.value.value === "overview" ? (_(), q(te, { key: 0 }, [
1816
- n("div", null, [
1817
- B(V, {
1818
- variant: "outlined",
1819
- class: "flex flex-col gap-8 px-12 py-16"
1820
- }, {
1821
- default: ce(() => {
1822
- var E, P, M, pe, ye, Re, Me, Ke, je, ze, He, Ge;
1823
- return [
1824
- n("div", mr, [
1825
- n("div", fr, x(h(p)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
1826
- n("div", null, [
1827
- B(g, {
1828
- label: h(p)(`inventory.transfer.status.${(E = t.purchaseOrder) == null ? void 0 : E.status}`),
1829
- class: xe(`fm-status-badge fm-status-badge-${(M = (P = t.purchaseOrder) == null ? void 0 : P.status) == null ? void 0 : M.toLocaleLowerCase("en-us")}`),
1830
- compact: ""
1831
- }, null, 8, ["label", "class"])
1832
- ])
1833
- ]),
1834
- B(A),
1835
- n("div", pr, [
1836
- n("div", yr, [
1837
- n("div", vr, [
1838
- n("div", hr, x(h(p)("inventory.transfer.receiveRequest.details.createdAt")), 1)
1839
- ]),
1840
- n("div", br, x(h(ke)(((pe = t.purchaseOrder) == null ? void 0 : pe._id) ?? "")), 1)
1841
- ]),
1842
- (ye = t.purchaseOrder) != null && ye.effectiveAt ? (_(), q("div", gr, [
1843
- n("div", _r, x(h(p)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
1844
- n("div", Sr, x(h(tt)(new Date((Re = t.purchaseOrder) == null ? void 0 : Re.effectiveAt))), 1)
1845
- ])) : L("", !0),
1846
- n("div", wr, [
1847
- n("div", Rr, x(h(p)("inventory.transfer.receiveRequest.details.type.title")), 1),
1848
- n("div", Or, x(h(p)(
1849
- `inventory.transfer.receiveRequest.details.type.${o.value.toLocaleLowerCase("en-US")}`
1850
- )), 1)
1851
- ]),
1852
- (Ke = (Me = t.purchaseOrder) == null ? void 0 : Me.supplier) != null && Ke.name ? (_(), q("div", xr, [
1853
- n("div", Nr, x(h(p)("inventory.transfer.receiveRequest.details.from")), 1),
1854
- n("div", kr, x((ze = (je = t.purchaseOrder) == null ? void 0 : je.supplier) == null ? void 0 : ze.name), 1)
1855
- ])) : L("", !0),
1856
- t.transferTo ? (_(), q("div", qr, [
1857
- n("div", Dr, x(h(p)("inventory.transfer.receiveRequest.details.to")), 1),
1858
- n("div", Ar, x(t.transferTo), 1)
1859
- ])) : L("", !0),
1860
- (He = t.purchaseOrder) != null && He.ref ? (_(), q("div", Tr, [
1861
- n("div", $r, x(h(p)("inventory.transfer.receiveRequest.details.reference")), 1),
1862
- n("div", Pr, x(t.purchaseOrder.ref), 1)
1863
- ])) : L("", !0),
1864
- (Ge = t.purchaseOrder) != null && Ge.remark ? (_(), q("div", Cr, [
1865
- n("div", Fr, x(h(p)("inventory.transfer.receiveRequest.details.remark")), 1),
1866
- n("div", Ir, x(t.purchaseOrder.remark), 1)
1867
- ])) : L("", !0)
1868
- ])
1869
- ];
1870
- }),
1871
- _: 1
1872
- })
1873
- ]),
1874
- B(ur, {
1875
- "po-request": t.poRequest,
1876
- purchaseOrder: t.purchaseOrder,
1877
- transferType: o.value,
1878
- transferToDbName: t.transferToDbName,
1879
- scope: t.scope
1880
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
1881
- n("div", Er, [
1882
- n("div", Br, [
1883
- n("div", Lr, [
1884
- n("span", Ur, [
1885
- Fe(x(fe.value ? h(p)("inventory.transfer.receiveRequest.details.receivedItems") : h(p)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
1886
- (se = (I = t.purchaseOrder) == null ? void 0 : I.netSuite) != null && se.missingItems && ((_e = (ge = t.purchaseOrder) == null ? void 0 : ge.netSuite) == null ? void 0 : _e.missingItems.length) > 0 ? (_(), ne(v, {
1887
- key: 0,
1888
- variant: "rich",
1889
- placement: "top",
1890
- "z-index": 51
1891
- }, {
1892
- content: ce(() => {
1893
- var E, P;
1894
- return [
1895
- n("div", Vr, [
1896
- (_(!0), q(te, null, ve((P = (E = t.purchaseOrder) == null ? void 0 : E.netSuite) == null ? void 0 : P.missingItems, (M, pe) => (_(), q("div", {
1897
- class: "flex justify-center align-middle",
1898
- key: pe
1899
- }, [
1900
- B(j, {
1901
- name: "arrow_right",
1902
- size: "sm"
1903
- }),
1904
- Fe(" " + x(`(${M.netSuiteId}) ${M.name}: ${M.reason}`), 1)
1905
- ]))), 128))
1906
- ])
1907
- ];
1908
- }),
1909
- default: ce(() => [
1910
- B(j, {
1911
- name: "error",
1912
- color: "#ff2c2c",
1913
- size: "sm"
1914
- })
1915
- ]),
1916
- _: 1
1917
- })) : L("", !0)
1918
- ])
1919
- ]),
1920
- B(A),
1921
- (_(!0), q(te, null, ve(((Se = t.purchaseOrder) == null ? void 0 : Se.items) ?? [], (E) => {
1922
- var P;
1923
- return _(), q("div", {
1924
- key: E.code,
1925
- class: "flex flex-col"
1926
- }, [
1927
- n("div", Mr, [
1928
- n("div", Kr, x(E.name), 1),
1929
- n("div", jr, x(h(ie)(Pe.value[E.sku._id], !1)) + "/" + x(h(at)(E.quantity, E.sku.unit, E.measurement)), 1)
1930
- ]),
1931
- n("div", zr, [
1932
- n("div", Hr, x(E.code), 1),
1933
- (P = E.totalCost) != null && P.amount && h(c).enableTotalCost ? (_(), q("div", Gr, " (" + x(h(Oe)(E.totalCost)) + ") ", 1)) : L("", !0)
1934
- ])
1935
- ]);
1936
- }), 128)),
1937
- +h(ie)(k.value) ? (_(), q(te, { key: 0 }, [
1938
- n("div", Wr, [
1939
- B(A)
1940
- ]),
1941
- n("div", Qr, [
1942
- d[6] || (d[6] = n("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
1943
- n("div", Yr, x(h(Oe)(k.value)), 1)
1944
- ])
1945
- ], 64)) : L("", !0)
1946
- ])
1947
- ])
1948
- ], 64)) : J.value.value === "deliveryHistory" ? (_(), q("div", Xr, [
1949
- oe.value.length ? (_(), q("div", rs, [
1950
- (_(!0), q(te, null, ve(oe.value, (E, P) => (_(), q(te, { key: P }, [
1951
- n("div", ss, [
1952
- n("div", as, [
1953
- n("div", ns, [
1954
- n("div", {
1955
- class: xe([
1956
- {
1957
- "bg-fm-color-primary": P !== 0,
1958
- "bg-white": P === 0
1959
- },
1960
- "w-[2px] h-full"
1961
- ])
1962
- }, null, 2)
1963
- ]),
1964
- d[7] || (d[7] = n("div", { class: "h-24 w-24 bg-fm-color-primary rounded-full" }, null, -1)),
1965
- n("div", os, [
1966
- n("div", {
1967
- class: xe([
1968
- {
1969
- "bg-fm-color-primary": P < oe.value.length - 1,
1970
- "bg-white": P >= oe.value.length - 1
1971
- },
1972
- "w-[2px] h-full"
1973
- ])
1974
- }, null, 2)
1975
- ])
1976
- ]),
1977
- n("div", is, [
1978
- n("div", ls, x(E.header), 1),
1979
- n("div", cs, x(E.date), 1)
1980
- ])
1981
- ]),
1982
- n("div", us, [
1983
- n("div", ds, [
1984
- n("div", ms, [
1985
- n("div", {
1986
- class: xe([
1987
- {
1988
- "bg-fm-color-primary": P < oe.value.length - 1,
1989
- "bg-white": P >= oe.value.length - 1
1990
- },
1991
- "w-[2px] h-full"
1992
- ])
1993
- }, null, 2)
1994
- ])
1995
- ]),
1996
- n("div", fs, [
1997
- B(V, {
1998
- variant: "outlined",
1999
- class: "py-12 px-16"
2000
- }, {
2001
- default: ce(() => [
2002
- n("div", ps, [
2003
- (_(!0), q(te, null, ve(E.info, (M, pe) => (_(), q("div", {
2004
- key: pe,
2005
- class: "flex flex-col gap-4"
2006
- }, [
2007
- n("div", ys, x(M == null ? void 0 : M.label), 1),
2008
- n("div", vs, [
2009
- (_(!0), q(te, null, ve(M == null ? void 0 : M.values, (ye, Re) => (_(), q("div", {
2010
- key: Re,
2011
- class: "fm-typo-en-body-lg-600"
2012
- }, [
2013
- typeof ye == "string" ? (_(), q(te, { key: 0 }, [
2014
- Fe(x(ye), 1)
2015
- ], 64)) : (_(), ne(_t(ye), { key: 1 }))
2016
- ]))), 128))
2017
- ])
2018
- ]))), 128))
2019
- ])
2020
- ]),
2021
- _: 2
2022
- }, 1024)
2023
- ])
2024
- ])
2025
- ], 64))), 128))
2026
- ])) : (_(), q("div", Jr, [
2027
- B($),
2028
- n("div", null, [
2029
- n("img", {
2030
- src: h(Ot),
2031
- alt: "List is empty"
2032
- }, null, 8, Zr)
2033
- ]),
2034
- n("div", es, x(h(p)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
2035
- n("div", ts, x(h(p)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
2036
- B($),
2037
- B($)
2038
- ]))
2039
- ])) : L("", !0)
2040
- ])
2041
- ];
2042
- }),
2043
- "side-sheet-footer": ce(() => [
2044
- n("div", hs, [
2045
- (_(!0), q(te, null, ve(Q.value, (I) => (_(), q(te, null, [
2046
- h(Be)[I].available != !1 ? (_(), ne(C, {
2047
- key: I,
2048
- label: h(p)(h(Be)[I].translationKey),
2049
- onClick: (se) => ae(I),
2050
- loading: i.value === I,
2051
- disabled: i.value !== I && l.value,
2052
- variant: h(Be)[I].buttonVariant
2053
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : L("", !0)
2054
- ], 64))), 256)),
2055
- h(R).ableToMarkReceived(t.purchaseOrder) && !Q.value.includes("completeReceive") ? (_(), ne(C, {
2056
- key: 0,
2057
- label: h(p)("inventory.transfer.receiveRequest.actions.completeReceive"),
2058
- onClick: d[1] || (d[1] = (I) => ae("completeReceive")),
2059
- loading: i.value === "completeReceive",
2060
- disabled: i.value !== "completeReceive" && l.value
2061
- }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
2062
- h(R).ableToMarkApproved(t.purchaseOrder) && t.canApprove && !Q.value.includes("approveRequest") ? (_(), ne(C, {
2063
- key: 1,
2064
- label: h(p)("inventory.transfer.approval.actions.approveRequest"),
2065
- onClick: d[2] || (d[2] = (I) => ae("approveRequest")),
2066
- loading: i.value === "approveRequest",
2067
- disabled: i.value !== "approveRequest" && l.value
2068
- }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
2069
- h(R).ableToCreateFulfillment(t.purchaseOrder, t.poRequest) ? (_(), ne(C, {
2070
- key: 2,
2071
- label: h(p)("inventory.transfer.receiveRequest.actions.processRequest"),
2072
- onClick: d[3] || (d[3] = (I) => ae("processRequest")),
2073
- loading: i.value === "processRequest",
2074
- disabled: i.value !== "processRequest" && l.value
2075
- }, null, 8, ["label", "loading", "disabled"])) : L("", !0),
2076
- B(C, {
2077
- label: h(p)("common.close"),
2078
- variant: "tertiary",
2079
- onClick: d[4] || (d[4] = (I) => N("update:show", !1))
2080
- }, null, 8, ["label"])
2081
- ])
2082
- ]),
2083
- _: 1
2084
- }, 8, ["header", "modelValue", "dismiss-away"]);
2085
- };
2086
- }
2087
- });
2088
- export {
2089
- Ue as P,
2090
- Ts as _,
2091
- Ds as a,
2092
- As as b,
2093
- Tt as g,
2094
- $e as u
2095
- };