@feedmepos/mf-inventory-portal 1.2.13 → 1.2.14-dev.2

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 (76) hide show
  1. package/dist/App-BsAX8Df8.js +286 -0
  2. package/dist/{ApprovalView-BWX6xBQs.js → ApprovalView-BT-A6f4_.js} +26 -26
  3. package/dist/{BindingsDialog-CuwkcDKX.js → BindingsDialog-CNpvAGHr.js} +2 -2
  4. package/dist/{BindingsPicker-BibFsY0g.js → BindingsPicker-D-vmVplT.js} +10 -10
  5. package/dist/{BindingsTable-AdjKwSPH.js → BindingsTable-Z7PTxSy6.js} +1 -1
  6. package/dist/{ClosingDraftView-DWFHP9nE.js → ClosingDraftView-C_3P7kh0.js} +44 -44
  7. package/dist/{ClosingTemplateView-DOCF5f_u.js → ClosingTemplateView-CimxBGT-.js} +26 -26
  8. package/dist/{DeliveryOrderPrintPreview-DNDtL_Vo.js → DeliveryOrderPrintPreview-CMTO9y6R.js} +10 -10
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BWhINOE8.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DMK3P4pu.js} +15 -15
  10. package/dist/{FmMultiselectDialog-Dfo04ak5.js → FmMultiselectDialog-D6f0A92U.js} +4 -4
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DGVs4zLl.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CJvnR-aO.js} +54 -54
  12. package/dist/ImportView-CTYLH5Mz.js +1303 -0
  13. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BESx2u4Y.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BbmtJ6Ge.js} +1 -1
  14. package/dist/{IngredientGroupView-M9sXlnE0.js → IngredientGroupView-wygIXAKy.js} +19 -20
  15. package/dist/IngredientsView-Ct3eNIqS.js +2240 -0
  16. package/dist/{IntegrationView-BlUNz1yc.js → IntegrationView-CKA76Mi6.js} +3 -3
  17. package/dist/{InventoryBindingForm-CvQ5zh6v.js → InventoryBindingForm-CdK2Ujur.js} +1 -1
  18. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BEAEmPsU.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B-O0bjxU.js} +12 -12
  19. package/dist/{InventoryBindingSummary-CsJ-6G2P.js → InventoryBindingSummary-DN6sSW2u.js} +1 -1
  20. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjN_ktl1.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BK65pQy4.js} +1 -1
  21. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BN_e7k7U.js → PremiumBadge.vue_vue_type_script_setup_true_lang-DrFtLYGt.js} +1 -1
  22. package/dist/{PublishView-DZgCyLK2.js → PublishView-LJA3-Xmq.js} +25 -25
  23. package/dist/{PurchaseOrderPrintPreview-CB2xvQ33.js → PurchaseOrderPrintPreview-CpnoNRcV.js} +12 -12
  24. package/dist/{ReceiveRequestView-DgDHOS-Y.js → ReceiveRequestView-d7KmB_XN.js} +131 -132
  25. package/dist/RecipeView-B7PtWfJ-.js +636 -0
  26. package/dist/{StockView-eJOngk08.js → StockView-DoataAnD.js} +165 -166
  27. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BMFfegsk.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BZNMBDJ7.js} +1 -1
  28. package/dist/{SupplierView-BS8rBAKC.js → SupplierView-D9Kb7rAO.js} +4 -4
  29. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CfnN-1oC.js +3385 -0
  30. package/dist/{TransferTemplateView-By5Ci4Yg.js → TransferTemplateView-D9mrfBH5.js} +166 -166
  31. package/dist/UnitView-BP5IzLw2.js +674 -0
  32. package/dist/{WarehouseView-4ZLSJXYc.js → WarehouseView-B-qnAHv5.js} +32 -32
  33. package/dist/api/inventory.d.ts +306 -0
  34. package/dist/api/purchase-order.d.ts +1 -0
  35. package/dist/{app-D2lun71R.js → app-DDKw9H3a.js} +11730 -11115
  36. package/dist/app.d.ts +421 -0
  37. package/dist/app.js +1 -1
  38. package/dist/{closing-template-Cm1TtVzm.js → closing-template-BYCZ8etT.js} +1 -1
  39. package/dist/{decimal-eeicE4jp.js → decimal-DMb7zEqx.js} +1 -1
  40. package/dist/{format-unit-display-vHKazw0l.js → format-unit-display-BCTXGGeT.js} +24 -24
  41. package/dist/helper/number.d.ts +1 -0
  42. package/dist/import-export.helper-B4JVPOJK.js +243 -0
  43. package/dist/{index-DvX9cMJV.js → index-BZIogw8R.js} +1 -1
  44. package/dist/{index-C5s-1g7c.js → index-B__hxI_k.js} +1 -1
  45. package/dist/{purchase-order-template-uTs7bR89.js → purchase-order-template-Duc9oBWo.js} +1 -1
  46. package/dist/router/name.d.ts +1 -0
  47. package/dist/{stock-CL2LNdXp.js → stock-cFTv_nsm.js} +1 -1
  48. package/dist/stores/feature.d.ts +2 -0
  49. package/dist/stores/inventory.d.ts +26 -199
  50. package/dist/{supplier-CuzoW2k4.js → supplier-CESqvbEF.js} +1 -1
  51. package/dist/tsconfig.app.tsbuildinfo +1 -1
  52. package/dist/{use-ingredient-select-dialog-Cpg4lHHC.js → use-ingredient-select-dialog-DRJNoQTb.js} +4 -4
  53. package/dist/{use-inventory-binding-dialog-h4M4ICQK.js → use-inventory-binding-dialog-DTK5yRv9.js} +1 -1
  54. package/dist/views/import/ImportView.vue.d.ts +3 -0
  55. package/dist/views/import/components/ImportDialog.vue.d.ts +2 -0
  56. package/dist/views/import/helper/import-export.helper.d.ts +4 -0
  57. package/dist/views/ingredients/helper/import-export.helper.d.ts +3 -1
  58. package/dist/views/receive-request/components/delivery-order-form/SystemTrailDialog.vue.d.ts +17 -0
  59. package/dist/views/receive-request/components/netsuite/NetSuiteTransactionChangeLog.vue.d.ts +15 -0
  60. package/dist/views/recipe/RecipeView.vue.d.ts +1 -0
  61. package/dist/views/recipe/components/import-recipes/ImportRecipeItem.vue.d.ts +16 -0
  62. package/dist/views/recipe/components/import-recipes/ImportRecipes.vue.d.ts +2 -0
  63. package/dist/views/recipe/helper/import-recipe.d.ts +48 -0
  64. package/dist/views/unit/UnitView.vue.d.ts +1 -0
  65. package/dist/views/unit/components/import-units/ImportUnitItem.vue.d.ts +12 -0
  66. package/dist/views/unit/components/import-units/ImportUnitItemProps.d.ts +6 -0
  67. package/dist/views/unit/components/import-units/ImportUnits.vue.d.ts +9 -0
  68. package/dist/views/unit/components/import-units/ImportUnitsProps.d.ts +5 -0
  69. package/dist/views/unit/helper/import-export.helper.d.ts +40 -0
  70. package/package.json +3 -3
  71. package/dist/App-ZoXow3DD.js +0 -276
  72. package/dist/IngredientsView-DUwhH3j1.js +0 -2475
  73. package/dist/RecipeView-DQDfwCJd.js +0 -621
  74. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-w98ibfql.js +0 -3060
  75. package/dist/UnitView-DmuWMFlA.js +0 -667
  76. package/dist/array-Ca8T3f_G.js +0 -44
@@ -1,3060 +0,0 @@
1
- import { a8 as mt, u as _e, aW as P, aX as Ge, aG as Q, c as Pe, b as We, ag as xt, ai as wt, aj as $t, aY as Rt, e as it, f as pt, a6 as rt, aZ as kt, ad as ft, a1 as yt, l as ye, ab as Dt, a_ as vt, an as je, h as Fe, i as ct, j as me, D as ve, a$ as ht, b0 as bt, b1 as Ee, X as gt, a9 as Ue, aa as ze, af as Ve, a0 as De, t as ut, aE as Te, b2 as Qe, b3 as ke } from "./app-D2lun71R.js";
2
- import { ref as Y, computed as H, h as q, defineComponent as Se, reactive as Nt, onMounted as _t, resolveComponent as G, openBlock as f, createBlock as le, withCtx as X, createElementVNode as e, createVNode as I, unref as h, createElementBlock as x, toDisplayString as _, createCommentVNode as M, Fragment as ue, renderList as be, createTextVNode as Ne, normalizeClass as Be, watch as Ct, isRef as At, resolveDynamicComponent as Tt } from "vue";
3
- import { F as Ft } from "./decimal-eeicE4jp.js";
4
- import { useCoreStore as Me, useI18n as st } from "@feedmepos/mf-common";
5
- import { useDialog as Ye, useSnackbar as qe, components as Ke, FmButtonVariant as fe, useProxiedModel as Pt } from "@feedmepos/ui-library";
6
- import { a as qt, u as It, P as Ce, f as Et } from "./format-unit-display-vHKazw0l.js";
7
- import { E as Lt } from "./empty-placeholder-wf6-BWE8.js";
8
- import { _ as Vt, F as Bt, a as Ut } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DGVs4zLl.js";
9
- import { u as Mt, R as dt } from "./usePromise-CbVUCxhj.js";
10
- import { u as jt } from "./index-DvX9cMJV.js";
11
- const Ie = mt((g, r) => {
12
- const o = _e(), p = Me();
13
- return {
14
- async readRequests(l, n, a) {
15
- const s = l ?? o.currentLocationDBName, i = `${g.inventoryBackendUrl}/${s}/purchase-request`;
16
- return n && a ? await r.get(`${i}?startDate=${n}&endDate=${a}`) : await r.get(i);
17
- },
18
- async readRequestById(l, n) {
19
- const a = n ?? o.currentLocationDBName, s = `${g.inventoryBackendUrl}/${a}/purchase-request/${l}`;
20
- return await r.get(s);
21
- },
22
- async readRequestByIds(l, n) {
23
- const a = n ?? o.currentLocationDBName, s = `${g.inventoryBackendUrl}/${a}/purchase-request/find`;
24
- return await r.post(s, { requestIds: l });
25
- },
26
- async getPurchaseOrders({
27
- start: l,
28
- end: n
29
- }) {
30
- const a = o.currentLocationDBName, s = `${g.inventoryBackendUrl}/${a}/purchase-order`;
31
- return await r.get(`${s}?start=${l}&end=${n}`);
32
- },
33
- async getLatestPurchaseOrderRequest(l) {
34
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/purchase-request/find-by-purchase-order-id`;
35
- return await r.get(`${a}/${l}`);
36
- },
37
- async getPurchaseOrderById(l) {
38
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/purchase-order`;
39
- return await r.get(`${a}/${l}`);
40
- },
41
- /**
42
- * @deprecated Use `processPurchaseOrderV2` instead.
43
- */
44
- async processPurchaseOrder(l, n) {
45
- const a = o.currentLocationDBName, s = n || a, i = `${g.inventoryBackendUrl}/${s}/purchase-order/run-operation`;
46
- return await r.put(i, l);
47
- },
48
- async createPurchaseOrder(l) {
49
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/purchase-order`;
50
- return await r.post(a, l);
51
- },
52
- async updatePurchaseOrder(l) {
53
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/purchase-order`;
54
- return await r.put(a, l);
55
- },
56
- async importFromXilnex(l) {
57
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/purchase-order/import-from-xilnex`;
58
- return await r.post(a, l);
59
- },
60
- async processPurchaseOrderV2(l, n) {
61
- const a = o.currentLocationDBName, s = n || a, i = `${g.inventoryBackendUrl}/${s}/v2/purchase-order/run-operation`;
62
- return await r.put(i, l);
63
- },
64
- async getWorkflowConfig() {
65
- var s;
66
- const n = `business_${(s = p.currentBusiness.value) == null ? void 0 : s._id}`, a = `${g.inventoryBackendUrl}/${n}/v2/purchase-order/workflow-config`;
67
- return await r.get(a);
68
- },
69
- async updateDeliveryOrder(l) {
70
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/delivery-order`;
71
- return await r.put(a, l);
72
- },
73
- async createDeliveryOrder(l) {
74
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/delivery-order`;
75
- return await r.post(a, l);
76
- }
77
- };
78
- }), zt = mt((g, r) => {
79
- const o = _e();
80
- return {
81
- async getShipments({
82
- start: p,
83
- end: l
84
- }) {
85
- const n = o.currentLocationDBName, a = `${g.inventoryBackendUrl}/${n}/shipments`;
86
- return await r.get(`${a}?start=${p}&end=${l}`);
87
- },
88
- async getShipmentsByIds(p) {
89
- if (p.length === 0)
90
- return [];
91
- const l = o.currentLocationDBName, n = `${g.inventoryBackendUrl}/${l}/shipments/get`;
92
- return await r.post(n, { shipmentIds: p });
93
- }
94
- };
95
- }), St = {
96
- [P.enum.confirmDraft]: {
97
- primaryActions: {
98
- text: "Confirm draft",
99
- close: !0
100
- },
101
- title: "Confirm draft?",
102
- message: "Purchase order cannot be changed after confirm draft.",
103
- successMessage: "Purchase order draft has been confirmed"
104
- },
105
- [P.enum.cancelDraft]: {
106
- primaryActions: {
107
- text: "Cancel draft",
108
- close: !0,
109
- variant: "destructive"
110
- },
111
- title: "Cancel draft?",
112
- message: "Purchase order cannot be changed after cancelled draft.",
113
- successMessage: "Purchase order draft has been cancelled"
114
- },
115
- [P.enum.submitRequest]: {
116
- primaryActions: {
117
- text: "Submit request",
118
- close: !0
119
- },
120
- title: "Confirm draft?",
121
- message: "Purchase order cannot be changed after confirm draft.",
122
- successMessage: "Purchase order draft has been submitted"
123
- },
124
- [P.enum.completeReceive]: {
125
- primaryActions: {
126
- text: "Mark received",
127
- close: !0
128
- },
129
- title: "Mark as received",
130
- message: "Purchase order cannot be changed after it has complete receiving.",
131
- successMessage: "Purchase order has been marked as received"
132
- },
133
- [P.enum.approveRequest]: {
134
- primaryActions: {
135
- text: "Accept request",
136
- close: !0
137
- },
138
- title: "Accept request?",
139
- message: "Transfer out request will be accepted.",
140
- successMessage: "Transfer out request has been approved"
141
- },
142
- [P.enum.rejectRequest]: {
143
- primaryActions: {
144
- text: "Reject request",
145
- close: !0,
146
- variant: "destructive"
147
- },
148
- title: "Reject request?",
149
- message: "Purchase order will be rejected.",
150
- successMessage: "Purchase order has been rejected"
151
- },
152
- [P.enum.processRequest]: {
153
- primaryActions: {
154
- text: "Process request",
155
- close: !0,
156
- variant: "destructive"
157
- },
158
- title: "Process request?",
159
- message: "Purchase order will be processed.",
160
- successMessage: "Purchase order has been processed"
161
- }
162
- };
163
- function He(g) {
164
- return Ge.generatedPOReceivedMap({
165
- purchaseOrder: g
166
- });
167
- }
168
- function Kt(g) {
169
- return Ge.validatePOItemReceivedStatus({
170
- dto: g
171
- });
172
- }
173
- function Ze(g) {
174
- return Ge.validatePOReceivedStatus({
175
- receivedMap: g
176
- });
177
- }
178
- function et(g, r, o) {
179
- if (!Q.safeParse(g).success)
180
- throw new Error(`Invalid purchase order status: ${g}`);
181
- const p = Q.parse(g);
182
- return Ge.orderStatusCombination({
183
- status: p,
184
- isPOPartialReceive: r,
185
- isPOOverReceive: o
186
- });
187
- }
188
- function Ot() {
189
- const g = _e(), r = Ie(), o = Pe();
190
- async function p(n, a) {
191
- const s = g.currentLocationDBName;
192
- return n.doc.supplier.internal && n.operation === P.enum.confirmDraft && (n.operation = P.enum.submitRequest), await r.processPurchaseOrder(n, a || s);
193
- }
194
- async function l(n, a) {
195
- const s = g.currentLocationDBName;
196
- return await r.processPurchaseOrderV2(n, a || s);
197
- }
198
- return (n) => o.useOperatePurchaseOrderV2 ? l(n.operateV2, n.transferTo) : p(n.operate, n.transferTo);
199
- }
200
- var tt = /* @__PURE__ */ ((g) => (g.RECEIVE_REQUEST = "receive/request", g.APPROVAL = "approval", g))(tt || {});
201
- const Le = Y(), Je = Y();
202
- function bn(g, r) {
203
- const o = Ye(), p = _e(), l = Pe();
204
- We();
205
- const n = qt(), a = It(), s = Y(!1), i = qe(), O = Ie(), $ = zt(), b = Y(new Array()), F = Y(new Array()), u = Y(
206
- r != null && r.startDate && (r != null && r.endDate) ? r : xt()
207
- ), N = H(() => {
208
- const V = new Date(u.value.startDate), B = new Date(u.value.endDate);
209
- return {
210
- start: wt(V).toISOString(),
211
- end: $t(B).toISOString()
212
- };
213
- }), d = Y(new Array()), c = Rt(), y = Y(null);
214
- async function R(V) {
215
- function B(D) {
216
- const S = {
217
- mode: it.CREATE,
218
- modelValue: V || void 0,
219
- show: !0,
220
- "onUpdate:show"(T) {
221
- Le.value.show = T;
222
- },
223
- templateId: D,
224
- lastClosingDate: y.value
225
- };
226
- Le.value = S;
227
- }
228
- let se;
229
- l.mustUsePoTemplate && !(V != null && V.template) ? o.open({
230
- title: "Create transfer",
231
- message: "",
232
- primaryActions: {
233
- text: "Select a template",
234
- close: !0
235
- },
236
- secondaryActions: {
237
- text: "Outlet to Outlet",
238
- variant: "secondary",
239
- close: !0
240
- }
241
- }).onPrimary(async () => {
242
- se = await n.getTemplateId(), se && B(se);
243
- }).onSecondary(() => {
244
- B(void 0);
245
- }) : B(se);
246
- }
247
- function k(V) {
248
- const B = {
249
- mode: it.UPDATE,
250
- modelValue: pt(V),
251
- show: !0,
252
- "onUpdate:show"(se) {
253
- Le.value.show = se;
254
- },
255
- lastClosingDate: y.value
256
- };
257
- Le.value = B;
258
- }
259
- async function z() {
260
- b.value = [], F.value = [], s.value = !0;
261
- try {
262
- const V = await O.getPurchaseOrders(N.value);
263
- b.value = V.sort((t, m) => m._id.localeCompare(t._id));
264
- const B = V.flatMap((t) => t.shipmentIds || []).filter(Boolean), se = B.length > 0 ? await $.getShipmentsByIds(B) : [];
265
- F.value = se;
266
- const D = await c.readCurrentLocationLastClosing(!0), S = D == null ? void 0 : D._id;
267
- S && (y.value = kt(S)), await l.awaitFeatureLoaded(() => l.mustUsePoTemplate) && await a.fetchTemplates();
268
- const T = b.value.map((t) => {
269
- var m;
270
- return ((m = t.request) == null ? void 0 : m.id) ?? "";
271
- }).filter((t) => t);
272
- d.value = await O.readRequestByIds(T);
273
- } catch {
274
- i.open({
275
- title: "Something went wrong",
276
- message: "Error at fetching purchase orders",
277
- type: "error"
278
- });
279
- } finally {
280
- s.value = !1;
281
- }
282
- }
283
- async function A() {
284
- d.value = [], s.value = !0;
285
- try {
286
- d.value = await O.readRequests(
287
- void 0,
288
- N.value.start,
289
- N.value.end
290
- ).then((V) => V.reverse());
291
- } catch {
292
- i.open({
293
- title: "Something went wrong",
294
- message: "Error at fetching purchase requests",
295
- type: "error"
296
- });
297
- } finally {
298
- s.value = !1;
299
- }
300
- }
301
- function K() {
302
- switch (g) {
303
- case "receive/request":
304
- return z();
305
- case "approval":
306
- return A();
307
- }
308
- }
309
- function Z(V, B) {
310
- u.value = {
311
- startDate: V,
312
- endDate: B
313
- }, K();
314
- }
315
- p.watchLocation(async (V) => {
316
- if (!V) {
317
- b.value = [];
318
- return;
319
- }
320
- await K();
321
- });
322
- const oe = Y(), ce = Y(Math.random().toString());
323
- async function Oe(V, B) {
324
- const se = Math.random().toString();
325
- ce.value = se, B ?? (B = d.value.computeFirst(
326
- (t) => t.purchaseOrderId === V._id ? t : null
327
- ) ?? void 0);
328
- const D = g === "receive/request" ? p.currentLocation : B == null ? void 0 : B.to, S = g === "approval", T = {
329
- poRequest: B,
330
- purchaseOrder: {
331
- ...V,
332
- status: S && (B != null && B.rejectedAt) ? Q.Enum.REJECT : V.status
333
- },
334
- transferTo: D == null ? void 0 : D.name,
335
- transferToDbName: D == null ? void 0 : D.dbName,
336
- show: !0,
337
- canResubmit: !1,
338
- canApprove: S,
339
- "onUpdate:show"(t) {
340
- oe.value.show = t;
341
- },
342
- scope: g,
343
- receivedMap: He(V) ?? {},
344
- shipments: F.value
345
- };
346
- oe.value = T;
347
- }
348
- async function ge(V, B, se, D) {
349
- const S = Ot();
350
- s.value = !0;
351
- try {
352
- await S({
353
- operate: {
354
- operation: B,
355
- doc: V,
356
- options: (
357
- // auto receive for supplier to warehouse
358
- (B === P.enum.confirmDraft || // auto receive for warehouse to warehouse
359
- B === P.enum.completeReceive) && l.autoReceiveWarehouse ? {
360
- autoReceive: !0
361
- } : void 0
362
- )
363
- },
364
- operateV2: {
365
- _id: V._id,
366
- _rev: V._rev ?? "",
367
- action: B,
368
- payloads: []
369
- },
370
- transferTo: D
371
- }), await new Promise((m) => setTimeout(m, 1e3));
372
- const t = _e().currentLocationDBName.startsWith("restaurant_");
373
- B === P.enum.confirmDraft && V.effectiveAt && t ? i.open({
374
- title: "Success",
375
- message: `${se}. The backdate will be reflected once your POS has received this change.`,
376
- type: "success"
377
- }) : i.open({
378
- title: "Success",
379
- message: se,
380
- type: "success"
381
- });
382
- } catch (T) {
383
- i.open({
384
- title: "Something went wrong",
385
- message: "Please try again.",
386
- type: "error"
387
- }), console.error("Error when submitting PO operation", B, V, T);
388
- } finally {
389
- s.value = !1, K();
390
- }
391
- }
392
- async function xe(V, B, se) {
393
- const D = St[B];
394
- if (!D) {
395
- i.open({
396
- title: "Something went wrong",
397
- message: `Cannot process order: ${rt(B)}`,
398
- type: "error"
399
- });
400
- return;
401
- }
402
- const { successMessage: S, ...T } = D;
403
- o.open({
404
- title: T.title,
405
- message: T.message,
406
- primaryActions: T.primaryActions
407
- }).onPrimary(() => {
408
- ge(V, B, S, se);
409
- });
410
- }
411
- async function he() {
412
- o.open({
413
- title: "Upload Transfer",
414
- primaryActions: {
415
- text: "Xilnex transfer note",
416
- close: !0
417
- },
418
- secondaryActions: {
419
- text: "Cancel",
420
- close: !0
421
- }
422
- }).onPrimary(() => {
423
- const V = {
424
- show: !0,
425
- "onUpdate:show"(B) {
426
- Je.value.show = B;
427
- }
428
- };
429
- Je.value = V;
430
- });
431
- }
432
- return {
433
- purchaseOrders: b,
434
- shipments: F,
435
- purchaseRequests: d,
436
- updateDateRange: Z,
437
- fetchData: K,
438
- loading: s,
439
- transferDialogProps: Le,
440
- promptCreateTransferDialog: R,
441
- promptUpdateTransferDialog: k,
442
- transferDetailsProps: oe,
443
- promptShowTransferDetails: Oe,
444
- submitAction: xe,
445
- xilnexImportDialogProps: Je,
446
- promptUploadTransferDialog: he
447
- };
448
- }
449
- function Ht(g, r) {
450
- return r.reduce(
451
- (p, l) => {
452
- const n = l.received.find((a) => a.sku._id === g._id);
453
- return n && (p = ft(p, n.amount)), p;
454
- },
455
- Ft.toPrecision(yt(0), g.unit.precision)
456
- );
457
- }
458
- function Gt(g) {
459
- const { po: r, currentLocation: o, business: p, fulfilling: l, por: n } = g, { name: a, address: s, regNo: i } = o.doc.profile, O = {
460
- name: a,
461
- registrationNumber: i,
462
- line1: s == null ? void 0 : s.line1,
463
- line2: s == null ? void 0 : s.line2,
464
- postcode: s == null ? void 0 : s.postcode,
465
- city: s == null ? void 0 : s.city,
466
- state: s == null ? void 0 : s.state,
467
- country: s == null ? void 0 : s.country
468
- }, $ = {
469
- name: r.supplier.name,
470
- phoneNumber: r.supplier.phoneNumber,
471
- registrationNumber: r.supplier.registrationNumber,
472
- line1: r.supplier.address.line1,
473
- line2: r.supplier.address.line2,
474
- postcode: r.supplier.address.postcode,
475
- city: r.supplier.address.city,
476
- state: r.supplier.address.state,
477
- country: r.supplier.address.country
478
- }, b = r.items.map((k) => {
479
- const { sku: z, measurement: A } = k, K = ye(
480
- Ht(k.sku, r.deliveryOrder || []),
481
- !1
482
- );
483
- return {
484
- code: z.code,
485
- description: z.name,
486
- quantity: ye(k.quantity, !1),
487
- unit: (A == null ? void 0 : A.abbrev) || z.unit.abbrev,
488
- received: K,
489
- cost: k.totalCost ? `${k.totalCost.currency} ${Dt.toFormatString({
490
- value: k.totalCost
491
- })}` : void 0
492
- };
493
- }), F = r.deliveryOrder.map((k) => ({
494
- createdAt: vt(new Date(k.createdAt)),
495
- ref: k.deliveryOrderNumber,
496
- remark: k.remark || "",
497
- items: k.received.map((z) => {
498
- var A;
499
- return {
500
- code: z.sku.code,
501
- description: z.sku.name,
502
- quantity: ye(z.amount),
503
- unit: ((A = z.measurement) == null ? void 0 : A.abbrev) || z.sku.unit.abbrev
504
- };
505
- })
506
- })), u = [
507
- // Production
508
- "67ca5d2c80bd0e001c5bf5bc",
509
- // Dev
510
- "6880b36a3054c5001db19218"
511
- ];
512
- let N = "Inventory Receive Note";
513
- if (r.supplier.internal ? (N = "Inventory Transfer Note", u.includes((p == null ? void 0 : p._id) || "") && (N = "Stock Request")) : N = "Purchase Order", n) {
514
- const k = n.from.dbName;
515
- o.dbName === k || (N = "Inventory Receive Note");
516
- }
517
- const c = {
518
- title: N,
519
- businessName: p == null ? void 0 : p.name,
520
- logo: p == null ? void 0 : p.thumbnail,
521
- orderNumber: r.seqNumber.toString(),
522
- createdAt: je(r._id),
523
- ref: r.ref || "",
524
- remark: r.remark || "",
525
- buyer: O,
526
- supplier: $,
527
- items: b,
528
- status: r.status,
529
- deliveryOrders: F
530
- }, y = new URL(window.location.href), R = l && (r.deliveryFullfillment || []).length > 0 ? "receive-request/delivery-print-preview" : "receive-request/print-preview";
531
- y.pathname = y.hostname.includes("portal.feedme") ? `/inventory/${R}` : `/${R}`, y.searchParams.append("data", JSON.stringify(c)), window.open(y.href, "_blank", "noreferrer");
532
- }
533
- const Ae = {
534
- submitRequest: {
535
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
536
- color: "text-fm-color-typo-primary",
537
- value: P.enum.submitRequest
538
- },
539
- confirmDraft: {
540
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
541
- color: "text-fm-color-typo-primary",
542
- value: P.enum.confirmDraft
543
- },
544
- cancelDraft: {
545
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
546
- color: "text-fm-color-typo-error",
547
- value: P.enum.cancelDraft
548
- },
549
- approveRequest: {
550
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
551
- color: "text-fm-color-typo-primary",
552
- value: P.enum.approveRequest
553
- },
554
- rejectRequest: {
555
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
556
- color: "text-fm-color-typo-error",
557
- value: P.enum.rejectRequest
558
- },
559
- processRequest: {
560
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
561
- color: "text-fm-color-typo-primary",
562
- value: P.enum.processRequest
563
- },
564
- receiveStock: {
565
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
566
- color: "text-fm-color-typo-primary",
567
- value: P.enum.receiveStock
568
- },
569
- completeReceive: {
570
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
571
- color: "text-fm-color-typo-primary",
572
- value: P.enum.completeReceive
573
- },
574
- closeRequest: {
575
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
576
- color: "system-error-300",
577
- value: P.enum.closeRequest
578
- },
579
- approveDraft: {
580
- translationKey: "",
581
- color: "",
582
- value: void 0
583
- },
584
- rejectDraft: {
585
- translationKey: "",
586
- color: "",
587
- value: void 0
588
- },
589
- returnStock: {
590
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
591
- color: "text-fm-color-typo-primary",
592
- value: P.enum.returnStock
593
- }
594
- };
595
- function gn(g, r, o) {
596
- const p = _e(), l = We(), n = Me(), { t: a } = st();
597
- function s(u) {
598
- switch (u.status) {
599
- case "DRAFT":
600
- return [
601
- ve[me.Update],
602
- ve[me.Details],
603
- u.supplier.internal === "restaurant" || u.supplier.internal === "warehouse" ? Ae[P.enum.submitRequest] : Ae[P.enum.confirmDraft],
604
- Ae[P.enum.cancelDraft]
605
- ];
606
- case "RECEIVING":
607
- return [
608
- Ae[P.enum.completeReceive],
609
- ve[me.Details],
610
- ve[me.Print]
611
- ];
612
- case "REQUESTING":
613
- return g === "receive/request" ? [ve[me.Details], ve[me.Print]] : [
614
- Ae[P.enum.approveRequest],
615
- Ae[P.enum.rejectRequest],
616
- ve[me.Details]
617
- // DefaultRowActions[RowActionEnum.Print]
618
- ];
619
- case "PROCESSING":
620
- return [ve[me.Details], ve[me.Print]];
621
- case "COMPLETE":
622
- case "CANCEL":
623
- default:
624
- return [ve[me.Details], ve[me.Print]];
625
- }
626
- }
627
- function i(u) {
628
- return Object.values(P.enum).includes(u);
629
- }
630
- async function O(u, N, d) {
631
- var y, R, k, z, A, K;
632
- const c = pt(N);
633
- if (u === me.Print) {
634
- const Z = (d == null ? void 0 : d.toInventoryLocation) ?? p.currentLocation;
635
- ((y = d == null ? void 0 : d.netSuite) != null && y.refNo || (R = c.netSuite) != null && R.refNo) && (c.ref = [((k = d == null ? void 0 : d.netSuite) == null ? void 0 : k.refNo) || ((z = c.netSuite) == null ? void 0 : z.refNo)].filter((oe) => oe).join(" ")), Gt({
636
- po: c,
637
- currentLocation: Z,
638
- business: n.currentBusiness.value,
639
- fulfilling: g === "approval",
640
- por: d
641
- });
642
- return;
643
- }
644
- if (u === me.Details) {
645
- r.promptShowTransferDetails(c, d);
646
- return;
647
- }
648
- if (u === me.Update) {
649
- (A = r.promptUpdateTransferDialog) == null || A.call(r, c);
650
- return;
651
- }
652
- if (i(u)) {
653
- r.submitAction(N, u, (K = d == null ? void 0 : d.to) == null ? void 0 : K.dbName);
654
- return;
655
- }
656
- }
657
- function $() {
658
- var N;
659
- const u = [
660
- {
661
- accessorKey: "seqNumber",
662
- header: () => a("inventory.transfer.table.seqNo"),
663
- enableSorting: !0,
664
- size: 80,
665
- sortUndefined: "last"
666
- },
667
- {
668
- accessorKey: "_id",
669
- header: () => a("inventory.transfer.table.createdAt"),
670
- cell(d) {
671
- return je(`${d.getValue()}`);
672
- },
673
- enableSorting: !0
674
- },
675
- {
676
- accessorKey: "supplier.name",
677
- header: () => a("inventory.transfer.table.transferFrom"),
678
- enableSorting: !0,
679
- size: 200
680
- },
681
- {
682
- accessorKey: "items.length",
683
- header: () => a("inventory.transfer.table.noOfItems"),
684
- cell: (d) => {
685
- const c = d.row.original.version || "1", y = d.getValue();
686
- return q("div", { class: "flex items-center gap-2" }, [
687
- y,
688
- c !== "1" ? q(
689
- "div",
690
- { class: "py-3" },
691
- q(
692
- Fe,
693
- q(
694
- "div",
695
- {
696
- class: ["fm-status-badge", "fm-status-badge-draft"].join(" ")
697
- },
698
- `v${c}`
699
- )
700
- )
701
- ) : null
702
- ]);
703
- },
704
- enableSorting: !1,
705
- meta: {
706
- width: "10rem"
707
- }
708
- },
709
- {
710
- accessorKey: "ref",
711
- header: () => a("inventory.transfer.table.reference"),
712
- enableSorting: !1,
713
- size: "auto"
714
- },
715
- ...(N = n.sessionUser.value) != null && N.role.isAdmin ? [
716
- {
717
- id: "statusForAdmin",
718
- header: () => q(Fe, {}, () => `${a("inventory.transfer.table.status")}`),
719
- cell(d) {
720
- return d.row.original.status;
721
- },
722
- enableSorting: !0,
723
- size: 200
724
- }
725
- ] : [],
726
- {
727
- accessorKey: "status",
728
- header: () => a("inventory.transfer.table.status"),
729
- cell(d) {
730
- const c = d.getValue(), y = He(d.row.original), { partial: R, over: k } = Ze(y), z = et(c ?? "", R, k);
731
- let A = a(`inventory.transfer.status.${z}`), K = `${c ?? ""}`.toLocaleLowerCase("en-us");
732
- z === Q.enum.CLOSE && (A = `${a(`inventory.transfer.status.${Q.enum.COMPLETE}`)}`), z === "PARTIAL_RECEIVED" && K === Q.enum.PROCESSING.toLocaleLowerCase("en-us") && (K = Q.enum.RECEIVING.toLocaleLowerCase("en-us"));
733
- let Z = null;
734
- const oe = o.value.find((ce) => ce.ref === d.row.original._id);
735
- if (oe != null && oe.milestones && oe.milestones.length > 0) {
736
- const ce = oe.milestones[oe.milestones.length - 1];
737
- if (ce.estimatedTime) {
738
- const Oe = new Date(ce.estimatedTime), ge = Oe.getDate().toString().padStart(2, "0");
739
- Z = `${Oe.toLocaleString("en-US", { month: "short" })} ${ge}`;
740
- }
741
- }
742
- return q(
743
- "div",
744
- {
745
- class: "flex"
746
- },
747
- [
748
- q(
749
- "div",
750
- { class: "flex items-center" },
751
- q(
752
- "div",
753
- {
754
- class: [
755
- "fm-status-badge",
756
- `fm-status-badge-${K}`,
757
- k && "fm-status-badge-error"
758
- ].filter(Boolean).join(" ")
759
- },
760
- `${A}`
761
- )
762
- ),
763
- ...Z ? [
764
- q(
765
- "div",
766
- {
767
- class: "flex items-center gap-1 ml-2"
768
- },
769
- [
770
- q(Ke.FmIcon, {
771
- name: "local_shipping",
772
- size: "md",
773
- color: "neutral-gray-400"
774
- }),
775
- q(
776
- "span",
777
- { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" },
778
- Z
779
- )
780
- ]
781
- )
782
- ] : []
783
- ]
784
- );
785
- },
786
- enableSorting: !0,
787
- size: 150
788
- },
789
- {
790
- id: "action",
791
- cell(d) {
792
- const c = d.row.original, y = s(c);
793
- return ct(y, (R) => O(R, c));
794
- },
795
- enableSorting: !1,
796
- size: 40,
797
- meta: {
798
- cellClass: "",
799
- headerClass: ""
800
- }
801
- }
802
- ];
803
- if (l.isEnabled) {
804
- const d = [
805
- {
806
- id: "netsuiteTransferOrder",
807
- accessorFn: (c) => {
808
- var y;
809
- return (y = c.netSuite) != null && y.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
810
- },
811
- header: () => "NetSuite Order (ID)",
812
- cell(c) {
813
- var R;
814
- const y = c.row.original;
815
- return (R = y.netSuite) != null && R.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
816
- },
817
- enableSorting: !1,
818
- size: 200,
819
- meta: {
820
- cellClass: "",
821
- headerClass: ""
822
- }
823
- },
824
- {
825
- id: "netsuiteTransactionNumber",
826
- accessorFn: (c) => {
827
- var y, R;
828
- return ((R = (y = c.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : R.transactionnumber) ?? "N/A";
829
- },
830
- header: () => "NetSuite Transaction No.",
831
- cell(c) {
832
- var R, k;
833
- return ((k = (R = c.row.original.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : k.transactionnumber) ?? "N/A";
834
- },
835
- enableSorting: !1,
836
- size: 200,
837
- meta: {
838
- cellClass: "",
839
- headerClass: ""
840
- }
841
- }
842
- ];
843
- u.splice(u.length - 1, 0, ...d);
844
- }
845
- return u;
846
- }
847
- function b() {
848
- var N;
849
- const u = [
850
- {
851
- accessorKey: "purchaseOrder.seqNumber",
852
- header: () => a("inventory.transfer.table.seqNo"),
853
- enableSorting: !0,
854
- size: 80,
855
- sortUndefined: "last"
856
- },
857
- {
858
- accessorKey: "purchaseOrder._id",
859
- header: () => a("inventory.transfer.table.createdAt"),
860
- cell(d) {
861
- return je(`${d.getValue()}`);
862
- },
863
- enableSorting: !0
864
- },
865
- {
866
- accessorKey: "to.name",
867
- header: () => a("inventory.transfer.table.transferTo"),
868
- enableSorting: !1,
869
- size: 200
870
- },
871
- {
872
- accessorKey: "purchaseOrder.items.length",
873
- header: () => a("inventory.transfer.table.noOfItems"),
874
- enableSorting: !1
875
- },
876
- {
877
- accessorKey: "purchaseOrder.ref",
878
- header: () => a("inventory.transfer.table.reference"),
879
- enableSorting: !1,
880
- size: "auto"
881
- },
882
- ...(N = n.sessionUser.value) != null && N.role.isAdmin ? [
883
- {
884
- id: "statusForAdmin",
885
- header: () => q(Fe, {}, () => `${a("inventory.transfer.table.status")}`),
886
- cell(d) {
887
- return d.row.original.status;
888
- },
889
- enableSorting: !0,
890
- size: 200
891
- }
892
- ] : [],
893
- {
894
- accessorKey: "purchaseOrder.status",
895
- header: () => a("inventory.transfer.table.status"),
896
- cell(d) {
897
- const c = d.row.original, y = d.getValue();
898
- if (!c.purchaseOrder)
899
- return q(Ke.FmChip, {
900
- label: "N/A",
901
- compact: !0
902
- });
903
- const R = He(c.purchaseOrder), { partial: k, over: z } = Ze(R), A = et(y ?? "", k, z);
904
- let K = a(`inventory.transfer.status.${A}`), Z = `${y ?? ""}`.toLocaleLowerCase("en-us");
905
- return A === Q.enum.CLOSE && (K = `${a(`inventory.transfer.status.${Q.enum.COMPLETE}`)}`), A === "PARTIAL_RECEIVED" && Z === Q.enum.PROCESSING.toLocaleLowerCase("en-us") && (Z = Q.enum.RECEIVING.toLocaleLowerCase("en-us")), c.rejectedAt && (K = a("inventory.transfer.status.REJECT"), Z = Q.enum.REJECT.toLocaleLowerCase("en-us")), q(
906
- "div",
907
- {
908
- class: "flex"
909
- },
910
- q(
911
- "div",
912
- {
913
- class: [
914
- "fm-status-badge",
915
- `fm-status-badge-${Z}`,
916
- z && "fm-status-badge-error"
917
- ].filter(Boolean).join(" ")
918
- },
919
- `${K}`
920
- )
921
- );
922
- },
923
- enableSorting: !0
924
- },
925
- {
926
- id: "action",
927
- cell(d) {
928
- const c = d.row.original, R = (c.purchaseOrder ? s(c.purchaseOrder) : []).map((k) => k.value === me.Print ? {
929
- ...k,
930
- translationKey: "inventory.transfer.receiveRequest.details.printDeliveryOrder"
931
- } : k);
932
- return ct(
933
- R,
934
- (k) => c.purchaseOrder ? O(k, c.purchaseOrder, c) : void 0
935
- );
936
- },
937
- enableSorting: !1,
938
- size: 40,
939
- meta: {
940
- cellClass: "",
941
- headerClass: ""
942
- }
943
- }
944
- ];
945
- if (l.isEnabled) {
946
- const d = [
947
- {
948
- id: "netsuiteTransferOrder",
949
- accessorFn: (c) => {
950
- var y;
951
- return (y = c.netSuite) != null && y.id ? `${c.netSuite.refNo} (${c.netSuite.id})` : "N/A";
952
- },
953
- header: () => "NetSuite Order (ID)",
954
- cell(c) {
955
- var R;
956
- const y = c.row.original;
957
- return (R = y.netSuite) != null && R.id ? `${y.netSuite.refNo} (${y.netSuite.id})` : "N/A";
958
- },
959
- enableSorting: !1,
960
- size: 200,
961
- meta: {
962
- cellClass: "",
963
- headerClass: ""
964
- }
965
- },
966
- {
967
- id: "netsuiteTransactionNumber",
968
- accessorFn: (c) => {
969
- var y, R;
970
- return ((R = (y = c.netSuite) == null ? void 0 : y.additionalInfo) == null ? void 0 : R.transactionnumber) ?? "N/A";
971
- },
972
- header: () => "NetSuite Transaction No.",
973
- cell(c) {
974
- var R, k;
975
- return ((k = (R = c.row.original.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : k.transactionnumber) ?? "N/A";
976
- },
977
- enableSorting: !1,
978
- size: 200,
979
- meta: {
980
- cellClass: "",
981
- headerClass: ""
982
- }
983
- }
984
- ];
985
- u.splice(u.length - 2, 0, ...d);
986
- }
987
- return u;
988
- }
989
- return {
990
- columnDefs: H(() => g === "receive/request" ? $() : b())
991
- };
992
- }
993
- const Wt = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Yt = { class: "flex flex-col gap-8" }, Qt = { class: "flex w-full justify-end gap-16" }, Jt = /* @__PURE__ */ Se({
994
- __name: "FulfillmentForm",
995
- props: {
996
- purchaseOrder: {},
997
- confirm: { type: Function }
998
- },
999
- emits: ["update:show"],
1000
- setup(g, { emit: r }) {
1001
- const o = g, p = Nt({
1002
- id: "",
1003
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1004
- items: []
1005
- }), l = Y(), n = r;
1006
- _t(() => {
1007
- o.purchaseOrder && (p.items = o.purchaseOrder.items.map((s) => ({
1008
- id: s.id,
1009
- sku: s.sku,
1010
- measurement: s.measurement,
1011
- amount: s.quantity ?? { amount: 1, precision: 0 }
1012
- })));
1013
- });
1014
- const a = H(() => p.items.length <= 10);
1015
- return (s, i) => {
1016
- const O = G("FmTable"), $ = G("FmButton"), b = G("FmForm");
1017
- return f(), le(b, {
1018
- ref_key: "formRef",
1019
- ref: l,
1020
- class: "bg-white flex flex-col gap-32 rounded-3xl p-24 w-[800px]",
1021
- onValidationFailed: console.log,
1022
- onValidationSuccess: i[1] || (i[1] = () => o.confirm(p))
1023
- }, {
1024
- default: X(() => [
1025
- i[2] || (i[2] = e("div", { class: "fm-typo-en-title-sm-600" }, "Confirm the transfer amount", -1)),
1026
- e("div", Wt, [
1027
- e("div", Yt, [
1028
- I(O, {
1029
- "column-defs": [
1030
- {
1031
- header: "Code",
1032
- cell: (F) => {
1033
- const u = o.purchaseOrder.items.find((N) => N.id === F.row.original.id || N.sku._id === F.row.original.sku._id);
1034
- return q(
1035
- h(Ke).FmTooltip,
1036
- {
1037
- content: u.code,
1038
- placement: "top",
1039
- variant: "plain",
1040
- zIndex: 50
1041
- },
1042
- q(
1043
- "span",
1044
- {
1045
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1046
- },
1047
- u.code
1048
- )
1049
- );
1050
- }
1051
- },
1052
- {
1053
- header: "Name",
1054
- cell: (F) => {
1055
- const u = o.purchaseOrder.items.find((N) => N.id === F.row.original.id || N.sku._id === F.row.original.sku._id);
1056
- return q(
1057
- h(Ke).FmTooltip,
1058
- {
1059
- content: u.name,
1060
- placement: "top",
1061
- variant: "plain",
1062
- zIndex: 50
1063
- },
1064
- q(
1065
- "span",
1066
- {
1067
- class: "flex-auto line-clamp-2 text-ellipsis break-all"
1068
- },
1069
- u.name
1070
- )
1071
- );
1072
- }
1073
- },
1074
- {
1075
- header: "Amount",
1076
- cell: (F) => {
1077
- const u = F.row.original, N = o.purchaseOrder.items.find((c) => c.id === u.id || c.sku._id === u.sku._id), d = u.amount ?? {
1078
- amount: 1,
1079
- precision: 0
1080
- };
1081
- return q(Vt, {
1082
- style: {
1083
- flex: "1 1 0%"
1084
- },
1085
- modelValue: {
1086
- amount: d,
1087
- measurement: u.measurement ?? null
1088
- },
1089
- key: u.id ?? u.sku._id,
1090
- unit: u.sku.unit,
1091
- "onUpdate:modelValue": (c) => {
1092
- if (!c) return;
1093
- const y = p.items.find((R) => R.id === u.id || R.sku._id === u.sku._id);
1094
- y && (y.amount = c.amount);
1095
- },
1096
- disableUnit: !0,
1097
- rules: [
1098
- h(Bt)(
1099
- +h(ye)({ amount: 0, precision: 0 })
1100
- ),
1101
- h(Ut)(+h(ye)(N.quantity))
1102
- ],
1103
- applyDefaultRules: !0
1104
- });
1105
- }
1106
- }
1107
- ],
1108
- "row-data": p.items,
1109
- "hide-footer": a.value
1110
- }, null, 8, ["column-defs", "row-data", "hide-footer"])
1111
- ])
1112
- ]),
1113
- e("div", Qt, [
1114
- I($, {
1115
- class: "px-16",
1116
- label: "Confirm",
1117
- size: "md",
1118
- variant: "primary",
1119
- type: "submit"
1120
- }),
1121
- I($, {
1122
- class: "px-16",
1123
- label: "Cancel",
1124
- size: "md",
1125
- variant: "secondary",
1126
- onClick: i[0] || (i[0] = () => n("update:show", !1))
1127
- })
1128
- ])
1129
- ]),
1130
- _: 1
1131
- }, 8, ["onValidationFailed"]);
1132
- };
1133
- }
1134
- }), Xe = {
1135
- submitRequest: {
1136
- translationKey: "inventory.transfer.receiveRequest.actions.submitRequest",
1137
- color: "primary",
1138
- buttonVariant: fe.Primary
1139
- },
1140
- confirmDraft: {
1141
- translationKey: "inventory.transfer.receiveRequest.actions.confirmDraft",
1142
- color: "primary",
1143
- buttonVariant: fe.Primary
1144
- },
1145
- cancelDraft: {
1146
- translationKey: "inventory.transfer.receiveRequest.actions.cancelDraft",
1147
- color: "system-error-300",
1148
- buttonVariant: fe.Destructive
1149
- },
1150
- approveDraft: {
1151
- translationKey: "inventory.transfer.receiveRequest.actions.approveDraft",
1152
- color: "primary",
1153
- buttonVariant: fe.Primary
1154
- },
1155
- rejectDraft: {
1156
- translationKey: "inventory.transfer.receiveRequest.actions.rejectDraft",
1157
- color: "system-error-300",
1158
- buttonVariant: fe.Destructive
1159
- },
1160
- approveRequest: {
1161
- translationKey: "inventory.transfer.receiveRequest.actions.approveRequest",
1162
- color: "primary",
1163
- buttonVariant: fe.Primary
1164
- },
1165
- processRequest: {
1166
- translationKey: "inventory.transfer.receiveRequest.actions.processRequest",
1167
- color: "primary",
1168
- buttonVariant: fe.Primary
1169
- },
1170
- receiveStock: {
1171
- translationKey: "inventory.transfer.receiveRequest.actions.receiveStock",
1172
- color: "primary",
1173
- buttonVariant: fe.Primary,
1174
- available: !1
1175
- },
1176
- completeReceive: {
1177
- translationKey: "inventory.transfer.receiveRequest.actions.completeReceive",
1178
- color: "primary",
1179
- buttonVariant: fe.Plain
1180
- },
1181
- rejectRequest: {
1182
- translationKey: "inventory.transfer.receiveRequest.actions.rejectRequest",
1183
- color: "system-error-300",
1184
- buttonVariant: fe.Destructive
1185
- },
1186
- closeRequest: {
1187
- translationKey: "inventory.transfer.receiveRequest.actions.closeRequest",
1188
- color: "system-error-300",
1189
- buttonVariant: fe.Destructive,
1190
- available: !1
1191
- },
1192
- returnStock: {
1193
- translationKey: "inventory.transfer.receiveRequest.actions.returnStock",
1194
- color: "primary",
1195
- buttonVariant: fe.Primary,
1196
- available: !1
1197
- }
1198
- };
1199
- function Xt() {
1200
- const g = Pe();
1201
- return {
1202
- ableToMarkReceived(r) {
1203
- if (!r || r.status !== Q.enum.RECEIVING)
1204
- return !1;
1205
- const p = _e().currentLocationDBName;
1206
- return `${r.supplier.internal}_${r.supplier._id}` !== p;
1207
- },
1208
- ableToMarkApproved(r) {
1209
- return !(!r || (r == null ? void 0 : r.status) !== Q.enum.REQUESTING);
1210
- },
1211
- ableToCreateFulfillment(r, o) {
1212
- var n, a;
1213
- if (!g.acceptRequireFulfillment || !r || !o || r.status !== Q.enum.PROCESSING || !o.processedAt)
1214
- return !1;
1215
- const p = (n = o == null ? void 0 : o.from) == null ? void 0 : n.dbName, l = (a = o == null ? void 0 : o.to) == null ? void 0 : a.dbName;
1216
- return !(p.startsWith("restaurant_") && l.startsWith("restaurant_"));
1217
- }
1218
- };
1219
- }
1220
- const Zt = { class: "flex flex-row-reverse" }, er = /* @__PURE__ */ Se({
1221
- __name: "NetSuiteSync",
1222
- props: {
1223
- poRequest: {},
1224
- purchaseOrder: {},
1225
- isTransferBetweenOutlets: { type: Boolean },
1226
- scope: {}
1227
- },
1228
- setup(g) {
1229
- const r = g, o = We(), p = qe(), l = Ye(), n = Y(!1);
1230
- H(() => {
1231
- var $, b, F, u;
1232
- let s = !0;
1233
- o.isEnabled || (s = !1);
1234
- const i = r.purchaseOrder, O = r.poRequest;
1235
- return i && (($ = i == null ? void 0 : i.supplier) != null && $.internal ? (!O && i.status == Q.enum.DRAFT && (s = !1), O && !((b = O == null ? void 0 : O.netSuite) != null && b.id) && (s = !1), r.isTransferBetweenOutlets && (s = !1)) : ((i == null ? void 0 : i.status) !== Q.enum.REQUESTING && i.supplier.internal && (s = !1), !O && !((F = i == null ? void 0 : i.netSuite) != null && F.id) && (s = !1), !O && ((u = i == null ? void 0 : i.netSuite) != null && u.id) && (i == null ? void 0 : i.status) == Q.enum.REQUESTING && (s = !1))), s;
1236
- });
1237
- async function a() {
1238
- n.value || l.open({
1239
- title: "Sync with NetSuite",
1240
- contentComponent: q("div", [
1241
- q("p", "Are you sure you want to sync now?"),
1242
- q("br"),
1243
- q(
1244
- "p",
1245
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" },
1246
- "Please wait a moment before syncing manually to avoid unnecessary actions."
1247
- )
1248
- ]),
1249
- primaryActions: {
1250
- text: "Sync",
1251
- close: !0,
1252
- variant: "destructive"
1253
- },
1254
- secondaryActions: { text: "Not now", close: !0 }
1255
- }).onPrimary(async () => {
1256
- var s, i, O;
1257
- try {
1258
- n.value = !0;
1259
- const $ = ((s = r.purchaseOrder) == null ? void 0 : s._id) || ((i = r.poRequest) == null ? void 0 : i.purchaseOrderId) || "", b = (O = r.poRequest) == null ? void 0 : O.to.dbName;
1260
- await o.syncPurchaseOrder(
1261
- $,
1262
- r.scope === "approval" ? b : void 0
1263
- ), p.open({
1264
- title: "Sync with NetSuite",
1265
- message: "Requested to sync with NetSuite. Please wait a moment.",
1266
- type: "success"
1267
- }), await new Promise((F) => setTimeout(F, 5e3)), n.value = !1;
1268
- } catch {
1269
- p.open({
1270
- title: "Error",
1271
- message: "Failed to sync with NetSuite",
1272
- type: "error"
1273
- }), n.value = !1;
1274
- }
1275
- });
1276
- }
1277
- return (s, i) => {
1278
- const O = G("FmButton");
1279
- return f(), x("div", Zt, [
1280
- I(O, {
1281
- "prepend-icon": "sync",
1282
- variant: "secondary",
1283
- label: "Sync",
1284
- loading: n.value,
1285
- onClick: a,
1286
- "text-color": "primary",
1287
- "bg-color": "transparent",
1288
- "border-color": "primary"
1289
- }, null, 8, ["loading"])
1290
- ]);
1291
- };
1292
- }
1293
- }), tr = {
1294
- key: 0,
1295
- class: "flex flex-col gap-8"
1296
- }, rr = { class: "flex flex-col gap-4" }, sr = { class: "fm-typo-en-body-lg-600" }, or = {
1297
- key: 0,
1298
- class: "flex flex-col gap-4"
1299
- }, nr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ar = { class: "fm-typo-en-body-lg-600" }, lr = { key: 0 }, ir = { key: 1 }, cr = {
1300
- key: 1,
1301
- class: "flex flex-col gap-4"
1302
- }, ur = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dr = { class: "fm-typo-en-body-lg-600" }, mr = { key: 0 }, pr = { key: 1 }, fr = {
1303
- key: 2,
1304
- class: "flex flex-col gap-4"
1305
- }, yr = { class: "fm-typo-en-body-lg-600" }, vr = {
1306
- key: 3,
1307
- class: "flex flex-col gap-4"
1308
- }, hr = { class: "fm-typo-en-body-lg-600" }, br = /* @__PURE__ */ Se({
1309
- __name: "NetSuiteInfo",
1310
- props: {
1311
- transferType: {},
1312
- transferToDbName: {},
1313
- poRequest: {},
1314
- purchaseOrder: {},
1315
- isTransferBetweenOutlets: { type: Boolean },
1316
- scope: {}
1317
- },
1318
- setup(g) {
1319
- const r = g, o = We(), p = Ie(), l = Y(r.poRequest);
1320
- _t(async () => {
1321
- var i;
1322
- if (!r.poRequest && ((i = r.purchaseOrder) != null && i._id)) {
1323
- const O = await p.getLatestPurchaseOrderRequest(r.purchaseOrder._id);
1324
- l.value = O;
1325
- }
1326
- });
1327
- const n = H(
1328
- () => {
1329
- var i, O, $, b, F, u;
1330
- return o.getSubsidiaryFullName(
1331
- (($ = (O = (i = r.purchaseOrder) == null ? void 0 : i.netSuite) == null ? void 0 : O.subsidiary) == null ? void 0 : $.id) || ((u = (F = (b = r.poRequest) == null ? void 0 : b.netSuite) == null ? void 0 : F.subsidiary) == null ? void 0 : u.id)
1332
- ).fullName;
1333
- }
1334
- ), a = H(() => {
1335
- var i, O, $, b, F, u, N, d, c, y, R, k;
1336
- return ($ = (O = (i = r.purchaseOrder) == null ? void 0 : i.netSuite) == null ? void 0 : O.additionalInfo) != null && $.transactionnumber ? (u = (F = (b = r.purchaseOrder) == null ? void 0 : b.netSuite) == null ? void 0 : F.additionalInfo) == null ? void 0 : u.transactionnumber : (c = (d = (N = l.value) == null ? void 0 : N.netSuite) == null ? void 0 : d.additionalInfo) != null && c.transactionnumber ? (k = (R = (y = l.value) == null ? void 0 : y.netSuite) == null ? void 0 : R.additionalInfo) == null ? void 0 : k.transactionnumber : null;
1337
- }), s = H(() => {
1338
- var i, O, $, b, F, u;
1339
- return (O = (i = r.purchaseOrder) == null ? void 0 : i.deliveryFullfillment) != null && O.length && ((b = ($ = r.purchaseOrder) == null ? void 0 : $.deliveryFullfillment) == null ? void 0 : b.length) > 0 ? (u = (F = r.purchaseOrder) == null ? void 0 : F.deliveryFullfillment) == null ? void 0 : u.map((N) => {
1340
- var d;
1341
- return (d = N.netSuite) == null ? void 0 : d.refNo;
1342
- }).join(", ") : "N/A";
1343
- });
1344
- return (i, O) => {
1345
- var $, b, F, u, N, d, c, y, R, k, z, A, K, Z, oe, ce;
1346
- return h(o).isEnabled ? (f(), x("div", tr, [
1347
- e("div", rr, [
1348
- O[0] || (O[0] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "NetSuite subsidiary", -1)),
1349
- e("div", sr, _(n.value || "N/A"), 1)
1350
- ]),
1351
- !i.isTransferBetweenOutlets && i.scope === h(tt).RECEIVE_REQUEST ? (f(), x("div", or, [
1352
- e("div", nr, " NetSuite " + _((b = ($ = i.purchaseOrder) == null ? void 0 : $.netSuite) != null && b.recordType ? h(ht)((u = (F = i.purchaseOrder) == null ? void 0 : F.netSuite) == null ? void 0 : u.recordType) : i.transferType === h(Ce).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1353
- e("div", ar, [
1354
- (d = (N = i.purchaseOrder) == null ? void 0 : N.netSuite) != null && d.id ? (f(), x("span", lr, _((y = (c = i.purchaseOrder) == null ? void 0 : c.netSuite) == null ? void 0 : y.refNo) + " (" + _((k = (R = i.purchaseOrder) == null ? void 0 : R.netSuite) == null ? void 0 : k.id) + ") ", 1)) : (f(), x("span", ir, "N/A"))
1355
- ])
1356
- ])) : M("", !0),
1357
- !i.isTransferBetweenOutlets && l.value || i.scope === h(tt).APPROVAL ? (f(), x("div", cr, [
1358
- e("div", ur, " (Request) NetSuite " + _(i.transferType === h(Ce).PURCHASE ? "Purchase Order" : "Transfer Order") + " (ID) ", 1),
1359
- e("div", dr, [
1360
- (A = (z = l.value) == null ? void 0 : z.netSuite) != null && A.id ? (f(), x("span", mr, _((Z = (K = l.value) == null ? void 0 : K.netSuite) == null ? void 0 : Z.refNo) + " (" + _((ce = (oe = l.value) == null ? void 0 : oe.netSuite) == null ? void 0 : ce.id) + ") ", 1)) : (f(), x("span", pr, "N/A"))
1361
- ])
1362
- ])) : M("", !0),
1363
- a.value ? (f(), x("div", fr, [
1364
- O[1] || (O[1] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite Transaction Number ", -1)),
1365
- e("div", yr, _(a.value), 1)
1366
- ])) : M("", !0),
1367
- h(o).isEnabled && i.transferType === h(Ce).TRANSFER && !i.isTransferBetweenOutlets ? (f(), x("div", vr, [
1368
- O[2] || (O[2] = e("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " NetSuite fulfillment IDs ", -1)),
1369
- e("div", hr, _(s.value), 1)
1370
- ])) : M("", !0)
1371
- ])) : M("", !0);
1372
- };
1373
- }
1374
- }), gr = { class: "flex flex-row-reverse" }, _r = /* @__PURE__ */ Se({
1375
- __name: "NetSuiteLog",
1376
- props: {
1377
- netsuiteId: {},
1378
- purchaseOrderId: {}
1379
- },
1380
- setup(g) {
1381
- const r = qe(), o = bt();
1382
- async function p(l, n) {
1383
- const a = [];
1384
- if (l && a.push(`body.message:*${l}*`), n) {
1385
- const $ = n.replace(/:/g, "\\:");
1386
- a.push(`${$}`);
1387
- }
1388
- if (a.length === 0) {
1389
- r.open({
1390
- message: "Cannot open logs without valid filters.",
1391
- type: "error"
1392
- });
1393
- return;
1394
- }
1395
- const i = `attributes.pod:netsuite* AND (${a.join(" OR ")})`, { url: O } = await o.getSyncLogs(i);
1396
- r.open(
1397
- {
1398
- message: "Opening NetSuite logs...",
1399
- type: "info"
1400
- },
1401
- 800
1402
- ), await new Promise(($) => setTimeout($, 800)), window.open(O, "_blank");
1403
- }
1404
- return (l, n) => {
1405
- const a = G("FmButton");
1406
- return f(), x("div", gr, [
1407
- I(a, {
1408
- "prepend-icon": "history",
1409
- variant: "secondary",
1410
- label: "Logs",
1411
- onClick: n[0] || (n[0] = (s) => p(l.netsuiteId, l.purchaseOrderId)),
1412
- "text-color": "primary",
1413
- "bg-color": "transparent",
1414
- "border-color": "primary"
1415
- })
1416
- ]);
1417
- };
1418
- }
1419
- }), Sr = { class: "flex flex-row-reverse" }, Or = { key: 0 }, xr = { key: 1 }, wr = { class: "mb-6" }, $r = { class: "fm-typo-en-body-md-400" }, Rr = { key: 0 }, kr = { key: 1 }, Dr = { key: 0 }, Nr = {
1420
- key: 1,
1421
- class: "border-t pt-6"
1422
- }, Cr = { class: "fm-typo-en-body-lg-600 mb-4 flex items-center gap-2" }, Ar = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg overflow-y-auto" }, Tr = { class: "w-full" }, Fr = {
1423
- class: "p-3 fm-typo-en-body-sm-600",
1424
- style: { "min-width": "130px" }
1425
- }, Pr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ir = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Er = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Lr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Vr = { class: "p-3 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Br = { class: "p-3 fm-typo-en-body-sm-600" }, Ur = { key: 2 }, Mr = { key: 1 }, jr = /* @__PURE__ */ Se({
1426
- __name: "NetSuiteLatestInfo",
1427
- props: {
1428
- netsuiteId: {},
1429
- purchaseOrderId: {}
1430
- },
1431
- setup(g) {
1432
- const r = g, o = bt(), p = Y(!1), l = _e(), n = Y(!0), a = Y(!1), s = Y(!1), i = Y(!1), O = Y(null), $ = Y([]);
1433
- async function b() {
1434
- if (!O.value) {
1435
- p.value = !0;
1436
- try {
1437
- n.value = !0;
1438
- const d = await o.getMoreInfo(
1439
- l.currentLocation.dbName,
1440
- r.purchaseOrderId
1441
- );
1442
- O.value = d, a.value = !1;
1443
- } catch {
1444
- a.value = !0;
1445
- } finally {
1446
- n.value = !1;
1447
- }
1448
- await F();
1449
- }
1450
- }
1451
- async function F() {
1452
- if (!($.value.length > 0))
1453
- try {
1454
- s.value = !0;
1455
- const d = await o.getChangeLogs(r.netsuiteId);
1456
- $.value = d, i.value = !1;
1457
- } catch {
1458
- i.value = !0;
1459
- } finally {
1460
- s.value = !1;
1461
- }
1462
- }
1463
- function u(d) {
1464
- switch (d) {
1465
- case Ee.Create:
1466
- return "text-green-600 bg-green-100";
1467
- case Ee.Set:
1468
- return "text-blue-600 bg-blue-100";
1469
- case Ee.Change:
1470
- return "text-yellow-600 bg-yellow-100";
1471
- case Ee.Unset:
1472
- return "text-red-600 bg-red-100";
1473
- default:
1474
- return "text-gray-600 bg-gray-100";
1475
- }
1476
- }
1477
- function N(d) {
1478
- return new Date(d).toLocaleDateString("en-US", {
1479
- year: "numeric",
1480
- month: "short",
1481
- day: "numeric",
1482
- hour: "2-digit",
1483
- minute: "2-digit"
1484
- });
1485
- }
1486
- return (d, c) => {
1487
- const y = G("FmButton"), R = G("FmLabel"), k = G("FmIcon"), z = G("FmDialog");
1488
- return f(), x("div", Sr, [
1489
- I(z, {
1490
- modelValue: p.value,
1491
- "onUpdate:modelValue": c[2] || (c[2] = (A) => p.value = A),
1492
- overlay: !0,
1493
- "max-width": 800
1494
- }, {
1495
- "dialog-button": X(() => [
1496
- I(y, {
1497
- "prepend-icon": "info",
1498
- variant: "secondary",
1499
- label: "Latest Info",
1500
- onClick: c[0] || (c[0] = (A) => b()),
1501
- "text-color": "primary",
1502
- "bg-color": "transparent",
1503
- "border-color": "primary"
1504
- })
1505
- ]),
1506
- "dialog-header": X(() => c[3] || (c[3] = [
1507
- e("div", null, "NetSuite latest info", -1)
1508
- ])),
1509
- default: X(() => [
1510
- n.value ? (f(), x("div", Or, "Loading...")) : (f(), x("div", xr, [
1511
- a.value ? (f(), x("p", Mr, "Something went wrong.")) : (f(), x(ue, { key: 0 }, [
1512
- e("div", wr, [
1513
- c[4] || (c[4] = e("h3", { class: "fm-typo-en-body-lg-600 mb-4" }, "NetSuite Order Details", -1)),
1514
- (f(!0), x(ue, null, be(O.value, (A, K) => (f(), x("div", {
1515
- key: K,
1516
- class: "mb-2"
1517
- }, [
1518
- e("div", null, [
1519
- I(R, {
1520
- label: h(rt)(K)
1521
- }, null, 8, ["label"]),
1522
- e("div", $r, [
1523
- Array.isArray(A) ? (f(), x("span", Rr, _(A.length > 0 ? A.join(", ") : "N/A"), 1)) : (f(), x("span", kr, _(A), 1))
1524
- ])
1525
- ])
1526
- ]))), 128))
1527
- ]),
1528
- s.value ? (f(), x("div", Dr, "Change Log Loading...")) : M("", !0),
1529
- !s.value && $.value.length > 0 ? (f(), x("div", Nr, [
1530
- e("h3", Cr, [
1531
- I(k, {
1532
- name: "error",
1533
- color: "#ff9500",
1534
- size: "sm"
1535
- }),
1536
- c[5] || (c[5] = Ne(" Change Logs "))
1537
- ]),
1538
- e("div", Ar, [
1539
- e("table", Tr, [
1540
- c[6] || (c[6] = e("thead", { class: "bg-fm-color-neutral-gray-50" }, [
1541
- e("tr", { class: "border-b border-fm-color-neutral-gray-200" }, [
1542
- e("th", {
1543
- class: "text-left p-3 fm-typo-en-body-md-600",
1544
- style: { "min-width": "130px" }
1545
- }, " Date "),
1546
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Role"),
1547
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Name"),
1548
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Context"),
1549
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Type"),
1550
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Line ID"),
1551
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Field"),
1552
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "Old Value"),
1553
- e("th", { class: "text-left p-3 fm-typo-en-body-md-600" }, "New Value")
1554
- ])
1555
- ], -1)),
1556
- e("tbody", null, [
1557
- (f(!0), x(ue, null, be($.value, (A, K) => (f(), x("tr", {
1558
- key: K,
1559
- class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1560
- }, [
1561
- e("td", Fr, _(N(A._dateiso8601)), 1),
1562
- e("td", Pr, _(A._rolename), 1),
1563
- e("td", qr, _(A._employeename), 1),
1564
- e("td", Ir, _(A._contextname), 1),
1565
- e("td", {
1566
- class: Be(`p-3 fm-typo-en-body-sm-600 ${u(Number(A.type) - 1)}`)
1567
- }, _(h(Ee)[Number(A.type) - 1]), 3),
1568
- e("td", Er, _(A.lineid || ""), 1),
1569
- e("td", Lr, _(A._fieldname), 1),
1570
- e("td", Vr, _(A.oldvalue || ""), 1),
1571
- e("td", Br, _(A.newvalue || ""), 1)
1572
- ]))), 128))
1573
- ])
1574
- ])
1575
- ])
1576
- ])) : (f(), x("div", Ur, c[7] || (c[7] = [
1577
- e("p", null, "No change logs available.", -1)
1578
- ])))
1579
- ], 64))
1580
- ]))
1581
- ]),
1582
- "dialog-footer": X(() => [
1583
- I(y, {
1584
- class: "ml-auto sm:w-full xs:w-full",
1585
- label: "Close",
1586
- size: "md",
1587
- variant: "primary",
1588
- onClick: c[1] || (c[1] = (A) => p.value = !1)
1589
- })
1590
- ]),
1591
- _: 1
1592
- }, 8, ["modelValue"])
1593
- ]);
1594
- };
1595
- }
1596
- }), zr = {
1597
- key: 0,
1598
- class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16 flex flex-col gap-8"
1599
- }, Kr = { class: "flex gap-8 items-center" }, Hr = { class: "ml-auto" }, Gr = { class: "flex gap-3" }, Wr = /* @__PURE__ */ Se({
1600
- __name: "NetSuitePanel",
1601
- props: {
1602
- poRequest: {},
1603
- purchaseOrder: {},
1604
- transferType: {},
1605
- transferToDbName: {},
1606
- scope: {}
1607
- },
1608
- setup(g) {
1609
- const r = g, o = jt();
1610
- Me();
1611
- const p = H(() => {
1612
- var s, i, O, $, b, F, u;
1613
- const l = ((s = r.transferToDbName) == null ? void 0 : s.startsWith("restaurant")) && ((O = (i = r.purchaseOrder) == null ? void 0 : i.supplier) == null ? void 0 : O.internal) === "restaurant", n = r.transferType === Ce.PURCHASE, a = r.transferType === Ce.TRANSFER;
1614
- return n || a && !l || ((b = ($ = r.purchaseOrder) == null ? void 0 : $.netSuite) == null ? void 0 : b.id) || ((u = (F = r.poRequest) == null ? void 0 : F.netSuite) == null ? void 0 : u.id);
1615
- });
1616
- return (l, n) => {
1617
- var s, i;
1618
- const a = G("FmMenuDivider");
1619
- return h(o).isNetSuiteEnabled && p.value ? (f(), x("div", zr, [
1620
- e("div", Kr, [
1621
- n[0] || (n[0] = e("span", { class: "flex-1 fm-typo-en-body-lg-600" }, "NetSuite Info", -1)),
1622
- e("div", Hr, [
1623
- e("div", Gr, [
1624
- (i = (s = r.purchaseOrder) == null ? void 0 : s.netSuite) != null && i.id ? (f(), le(Fe, { key: 0 }, {
1625
- default: X(() => {
1626
- var O, $, b;
1627
- return [
1628
- I(jr, {
1629
- "netsuite-id": ($ = (O = l.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : $.id,
1630
- "purchase-order-id": (b = l.purchaseOrder) == null ? void 0 : b._id
1631
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1632
- ];
1633
- }),
1634
- _: 1
1635
- })) : M("", !0),
1636
- I(Fe, null, {
1637
- default: X(() => {
1638
- var O, $, b;
1639
- return [
1640
- I(_r, {
1641
- "netsuite-id": ($ = (O = l.purchaseOrder) == null ? void 0 : O.netSuite) == null ? void 0 : $.id,
1642
- "purchase-order-id": (b = l.purchaseOrder) == null ? void 0 : b._id
1643
- }, null, 8, ["netsuite-id", "purchase-order-id"])
1644
- ];
1645
- }),
1646
- _: 1
1647
- }),
1648
- I(er, {
1649
- "po-request": l.poRequest,
1650
- "purchase-order": l.purchaseOrder,
1651
- "is-transfer-between-outlets": !p.value,
1652
- scope: l.scope
1653
- }, null, 8, ["po-request", "purchase-order", "is-transfer-between-outlets", "scope"])
1654
- ])
1655
- ])
1656
- ]),
1657
- I(a),
1658
- I(br, {
1659
- "po-request": l.poRequest,
1660
- "purchase-order": l.purchaseOrder,
1661
- "transfer-type": l.transferType,
1662
- "transfer-to-db-name": l.transferToDbName,
1663
- "is-transfer-between-outlets": !p.value,
1664
- scope: l.scope
1665
- }, null, 8, ["po-request", "purchase-order", "transfer-type", "transfer-to-db-name", "is-transfer-between-outlets", "scope"])
1666
- ])) : M("", !0);
1667
- };
1668
- }
1669
- }), Yr = { class: "flex flex-col gap-3" }, Qr = { class: "flex flex-col gap-4" }, Jr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Xr = { class: "flex flex-col gap-4" }, Zr = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, es = { class: "flex flex-col gap-4" }, ts = { class: "flex gap-4" }, rs = { class: "flex flex-col" }, ss = { class: "fm-typo-en-body-lg-600 basis-1/2 shrink-0 grow" }, os = { class: "fm-typo-en-body-md-400" }, ns = { class: "ml-auto flex flex-col" }, as = { class: "ml-auto flex gap-1" }, ls = { class: "fm-typo-en-body-lg-600 self-end" }, is = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, cs = { class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, us = { class: "flex flex-col gap-4" }, ds = { class: "flex flex-col gap-4" }, ms = { class: "flex flex-col gap-4" }, ps = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, fs = {
1670
- key: 0,
1671
- class: "flex flex-col gap-4"
1672
- }, ys = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, vs = /* @__PURE__ */ Se({
1673
- __name: "EditForm",
1674
- props: {
1675
- purchaseOrder: {},
1676
- deliveryOrder: {}
1677
- },
1678
- emits: ["submitted"],
1679
- setup(g, { emit: r }) {
1680
- const o = Y(!1), p = g, l = r, n = gt("deliveryOrder"), a = Ie(), s = H(
1681
- () => {
1682
- var F;
1683
- return ((F = p.purchaseOrder.deliveryFullfillment) == null ? void 0 : F.findIndex(
1684
- (u) => p.deliveryOrder.fullfillmentId && u.id === p.deliveryOrder.fullfillmentId
1685
- )) ?? -1;
1686
- }
1687
- ), O = Pe().enablePortalDeliveryOrderWrite, $ = qe();
1688
- function b() {
1689
- a.updateDeliveryOrder({
1690
- deliveryOrder: {
1691
- ...p.deliveryOrder,
1692
- deliveryOrderNumber: n.deliveryOrderNumber || ""
1693
- },
1694
- purchaseOrderId: p.purchaseOrder._id,
1695
- purchaseOrderRev: p.purchaseOrder._rev
1696
- }).then(() => {
1697
- $.open(
1698
- {
1699
- title: "Success",
1700
- message: `PO# ${p.purchaseOrder.seqNumber} Changes have been saved`,
1701
- type: "success"
1702
- },
1703
- 1e4
1704
- ), o.value = !1, l("submitted");
1705
- });
1706
- }
1707
- return (F, u) => {
1708
- const N = G("FmButton"), d = G("FmTextField"), c = G("FmDialog");
1709
- return f(), le(c, {
1710
- modelValue: o.value,
1711
- "onUpdate:modelValue": u[1] || (u[1] = (y) => o.value = y),
1712
- overlay: !0
1713
- }, {
1714
- "dialog-button": X(() => [
1715
- h(O) ? (f(), le(N, {
1716
- key: 0,
1717
- variant: "plain",
1718
- label: "Edit",
1719
- size: "md",
1720
- "prepend-icon": "edit"
1721
- })) : M("", !0)
1722
- ]),
1723
- "dialog-header": X(() => [
1724
- e("div", null, "Received on " + _(h(Ue)(p.deliveryOrder.createdAt)), 1)
1725
- ]),
1726
- "dialog-footer": X(() => [
1727
- I(N, {
1728
- class: "ml-auto",
1729
- label: "Apply changes",
1730
- size: "md",
1731
- variant: "destructive",
1732
- onClick: b
1733
- })
1734
- ]),
1735
- default: X(() => [
1736
- e("div", null, [
1737
- e("div", Yr, [
1738
- e("div", Qr, [
1739
- u[2] || (u[2] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Adjustment date", -1)),
1740
- e("div", Jr, _(p.deliveryOrder.adjustment ? h(Ue)(new Date(h(ze)(p.deliveryOrder.adjustment))) : "-"), 1)
1741
- ]),
1742
- e("div", Xr, [
1743
- u[3] || (u[3] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
1744
- e("div", Zr, _(p.deliveryOrder.createdBy.name), 1)
1745
- ]),
1746
- e("div", es, [
1747
- u[4] || (u[4] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received items", -1)),
1748
- (f(!0), x(ue, null, be(p.deliveryOrder.received, (y, R) => {
1749
- var k;
1750
- return f(), x("div", { key: R }, [
1751
- e("div", ts, [
1752
- e("div", rs, [
1753
- e("span", ss, _(y.sku.name), 1),
1754
- e("span", os, _(y.sku.code), 1)
1755
- ]),
1756
- e("div", ns, [
1757
- e("div", as, [
1758
- e("span", ls, _(h(ye)(y.amount, !1)), 1),
1759
- e("span", is, _(((k = y.measurement) == null ? void 0 : k.abbrev) ?? y.sku.unit.abbrev), 1)
1760
- ]),
1761
- e("div", cs, _(`${y.cost ? `(${h(Ve)(y.cost)})` : ""}`), 1)
1762
- ])
1763
- ])
1764
- ]);
1765
- }), 128))
1766
- ]),
1767
- e("div", us, [
1768
- u[5] || (u[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
1769
- e("div", ds, [
1770
- I(d, {
1771
- modelValue: h(n).deliveryOrderNumber,
1772
- "onUpdate:modelValue": u[0] || (u[0] = (y) => h(n).deliveryOrderNumber = y),
1773
- size: "md",
1774
- placeholder: p.deliveryOrder.deliveryOrderNumber
1775
- }, null, 8, ["modelValue", "placeholder"])
1776
- ])
1777
- ]),
1778
- e("div", ms, [
1779
- u[6] || (u[6] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
1780
- e("div", ps, _(p.deliveryOrder.remark || "N/A"), 1)
1781
- ]),
1782
- s.value >= 0 ? (f(), x("div", fs, [
1783
- u[7] || (u[7] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Fulfilment's sequence ", -1)),
1784
- e("div", ys, _(s.value + 1), 1)
1785
- ])) : M("", !0)
1786
- ])
1787
- ])
1788
- ]),
1789
- _: 1
1790
- }, 8, ["modelValue"]);
1791
- };
1792
- }
1793
- }), hs = { class: "flex flex-col gap-3" }, bs = { class: "flex flex-col gap-4" }, gs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, _s = {
1794
- key: 0,
1795
- class: "flex flex-col gap-4"
1796
- }, Ss = { class: "flex items-center justify-between" }, Os = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, xs = {
1797
- key: 0,
1798
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1799
- }, ws = { class: "flex gap-4" }, $s = { class: "flex-1" }, Rs = { class: "flex-1" }, ks = {
1800
- key: 0,
1801
- class: "flex items-center text-fm-color-system-error-300"
1802
- }, Ds = { class: "fm-typo-en-body-md-400" }, Ns = { class: "flex flex-col gap-4" }, Cs = { class: "flex justify-between items-center py-1 gap-4" }, As = { class: "flex flex-col" }, Ts = { class: "fm-typo-en-body-lg-600" }, Fs = { class: "fm-typo-en-body-md-400" }, Ps = { class: "flex flex-col gap-2 items-end" }, qs = {
1803
- key: 0,
1804
- class: "flex items-center gap-2"
1805
- }, Is = {
1806
- key: 0,
1807
- class: "border-b border-fm-color-stroke-secondary"
1808
- }, Es = { class: "flex flex-col gap-4" }, Ls = { class: "flex flex-col gap-4" }, Vs = { class: "flex flex-col gap-4" }, Bs = { class: "flex flex-col gap-4 fm-typo-en-body-lg-600" }, Us = /* @__PURE__ */ Se({
1809
- __name: "CreateForm",
1810
- props: {
1811
- purchaseOrder: {},
1812
- receivedInfoMap: {}
1813
- },
1814
- emits: ["submitted"],
1815
- setup(g, { emit: r }) {
1816
- var V, B, se;
1817
- const { t: o } = st(), p = Y(!1), l = Me(), n = g, a = r, s = gt("", {
1818
- default: {
1819
- deliveryOrderNumber: "",
1820
- remark: "",
1821
- received: n.purchaseOrder.items.map((D) => ({
1822
- sku: D.sku,
1823
- amount: De.fromNumber(0),
1824
- measurement: D.measurement
1825
- })),
1826
- createdBy: {
1827
- id: ((V = l.sessionUser.value) == null ? void 0 : V.id) || "",
1828
- name: ((B = l.sessionUser.value) == null ? void 0 : B.displayName) || ""
1829
- },
1830
- createdAt: ""
1831
- }
1832
- }), i = Ie(), O = Ye(), $ = Pe(), b = ((se = n.purchaseOrder) == null ? void 0 : se.supplier.internal) != null, F = b && $.enablePOSTransferRequireFulfillment, u = $.enablePortalDeliveryOrderWrite && (n.purchaseOrder.status === Q.Enum.RECEIVING || n.purchaseOrder.status === Q.Enum.COMPLETE) && (b ? !F : !0), N = $.enablePurchaseOrderReceiveWithCustomCost, d = $.enableBackdateReceive, c = Y({}), y = qe(), R = H({
1833
- get() {
1834
- if (!s.createdAt) return "";
1835
- const D = new Date(s.createdAt), S = D.getFullYear(), T = String(D.getMonth() + 1).padStart(2, "0"), t = String(D.getDate()).padStart(2, "0");
1836
- return `${S}-${T}-${t}`;
1837
- },
1838
- set(D) {
1839
- if (D) {
1840
- const S = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [T, t, m] = D.split("-");
1841
- S.setFullYear(parseInt(T)), S.setMonth(parseInt(t) - 1), S.setDate(parseInt(m)), s.createdAt = S.toISOString();
1842
- }
1843
- }
1844
- }), k = H({
1845
- get() {
1846
- if (!s.createdAt) return "";
1847
- const D = new Date(s.createdAt), S = String(D.getHours()).padStart(2, "0"), T = String(D.getMinutes()).padStart(2, "0");
1848
- return `${S}:${T}`;
1849
- },
1850
- set(D) {
1851
- if (D) {
1852
- const S = s.createdAt ? new Date(s.createdAt) : /* @__PURE__ */ new Date(), [T, t] = D.split(":");
1853
- S.setHours(parseInt(T)), S.setMinutes(parseInt(t)), s.createdAt = S.toISOString();
1854
- }
1855
- }
1856
- }), z = H(() => {
1857
- const D = ze(n.purchaseOrder._id);
1858
- if (!D) return "";
1859
- const S = new Date(D), T = S.getFullYear(), t = String(S.getMonth() + 1).padStart(2, "0"), m = String(S.getDate()).padStart(2, "0");
1860
- return `${T}-${t}-${m}`;
1861
- }), A = H(() => {
1862
- const D = ze(n.purchaseOrder._id);
1863
- return D ? new Date(D) : null;
1864
- }), K = H(() => {
1865
- if (!R.value || !k.value || !A.value) return null;
1866
- if (/* @__PURE__ */ new Date(`${R.value}T${k.value}:00`) < A.value) {
1867
- const S = z.value, T = A.value.getHours(), t = A.value.getMinutes(), m = T >= 12 ? "PM" : "AM", C = T % 12 || 12, w = `${String(C).padStart(2, "0")}:${String(t).padStart(2, "0")} ${m}`;
1868
- return `Delivery date & time cannot be earlier than order creation (${S} ${w})`;
1869
- }
1870
- return null;
1871
- }), Z = H(() => K.value ? !1 : s.received.some((S) => {
1872
- const T = S.amount;
1873
- return T ? +ye(T) > 0 : !1;
1874
- }));
1875
- function oe() {
1876
- s.createdAt = "";
1877
- }
1878
- const ce = H(() => n.purchaseOrder.items.map((D, S) => H({
1879
- get: () => {
1880
- var t;
1881
- const T = (t = s.received[S]) == null ? void 0 : t.amount;
1882
- return T ? +ye(T) : 0;
1883
- },
1884
- set: (T) => {
1885
- s.received[S].amount = ut(T, 2);
1886
- }
1887
- })));
1888
- function Oe(D) {
1889
- const S = !c.value[D];
1890
- if (c.value[D] = S, S) {
1891
- const T = n.purchaseOrder.items[D];
1892
- T.totalCost ? s.received[D].cost = {
1893
- currency: T.totalCost.currency,
1894
- amount: T.totalCost.amount,
1895
- precision: 4
1896
- // Standardize to 4 decimals
1897
- } : s.received[D].cost = {
1898
- currency: Te(),
1899
- amount: 0,
1900
- precision: 4
1901
- };
1902
- } else
1903
- delete s.received[D].cost;
1904
- }
1905
- const ge = H(() => n.purchaseOrder.items.map((D, S) => H({
1906
- get: () => {
1907
- var t;
1908
- const T = (t = s.received[S]) == null ? void 0 : t.cost;
1909
- return T ? +ye(T) : 0;
1910
- },
1911
- set: (T) => {
1912
- s.received[S].cost = {
1913
- currency: Te(),
1914
- ...ut(T, 4)
1915
- };
1916
- }
1917
- })));
1918
- function xe() {
1919
- O.open({
1920
- title: "Confirm Create Delivery Order",
1921
- message: `Are you sure you want to create delivery order for PO# ${n.purchaseOrder.seqNumber}?`,
1922
- primaryActions: {
1923
- text: "Create",
1924
- close: !0,
1925
- variant: "primary"
1926
- },
1927
- secondaryActions: {
1928
- text: "Cancel",
1929
- close: !0
1930
- }
1931
- }).onPrimary(() => he());
1932
- }
1933
- function he() {
1934
- i.createDeliveryOrder({
1935
- deliveryOrder: s,
1936
- purchaseOrderId: n.purchaseOrder._id,
1937
- purchaseOrderRev: n.purchaseOrder._rev,
1938
- currency: Te()
1939
- }).then(() => {
1940
- y.open(
1941
- {
1942
- title: "Success",
1943
- message: `New delivery order created for PO# ${n.purchaseOrder.seqNumber}`,
1944
- type: "success"
1945
- },
1946
- 1e4
1947
- ), p.value = !1, a("submitted");
1948
- });
1949
- }
1950
- return (D, S) => {
1951
- const T = G("FmButton"), t = G("FmDatePicker"), m = G("FmTimePicker"), C = G("FmIcon"), w = G("FmStepperField"), j = G("FmSwitch"), U = G("FmTextField"), ee = G("FmDialog");
1952
- return f(), le(ee, {
1953
- modelValue: p.value,
1954
- "onUpdate:modelValue": S[4] || (S[4] = (v) => p.value = v),
1955
- overlay: !0,
1956
- "min-width": 800
1957
- }, {
1958
- "dialog-button": X(() => [
1959
- h(u) ? (f(), le(T, {
1960
- key: 0,
1961
- variant: "primary",
1962
- label: "Create",
1963
- size: "md",
1964
- "prepend-icon": "add",
1965
- class: "w-full"
1966
- })) : M("", !0)
1967
- ]),
1968
- "dialog-header": X(() => [
1969
- e("div", null, "Order #" + _(n.purchaseOrder.seqNumber) + " (New Delivery Order)", 1)
1970
- ]),
1971
- "dialog-footer": X(() => [
1972
- I(T, {
1973
- class: "ml-auto",
1974
- label: "Create",
1975
- size: "md",
1976
- variant: "destructive",
1977
- disabled: !Z.value,
1978
- onClick: xe
1979
- }, null, 8, ["disabled"])
1980
- ]),
1981
- default: X(() => {
1982
- var v;
1983
- return [
1984
- e("div", hs, [
1985
- e("div", bs, [
1986
- S[5] || (S[5] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Received by", -1)),
1987
- e("div", gs, _((v = h(l).sessionUser.value) == null ? void 0 : v.displayName), 1)
1988
- ]),
1989
- h(d) ? (f(), x("div", _s, [
1990
- e("div", Ss, [
1991
- e("div", Os, [
1992
- S[6] || (S[6] = Ne(" Delivery Date & Time ")),
1993
- !R.value && !k.value ? (f(), x("div", xs, " Leave blank to use current date & time ")) : M("", !0)
1994
- ]),
1995
- R.value || k.value ? (f(), le(T, {
1996
- key: 0,
1997
- variant: "tertiary",
1998
- label: "Clear",
1999
- "prepend-icon": "close",
2000
- onClick: oe
2001
- })) : M("", !0)
2002
- ]),
2003
- e("div", ws, [
2004
- e("div", $s, [
2005
- I(t, {
2006
- modelValue: R.value,
2007
- "onUpdate:modelValue": S[0] || (S[0] = (L) => R.value = L)
2008
- }, null, 8, ["modelValue"])
2009
- ]),
2010
- e("div", Rs, [
2011
- I(m, {
2012
- modelValue: k.value,
2013
- "onUpdate:modelValue": S[1] || (S[1] = (L) => k.value = L)
2014
- }, null, 8, ["modelValue"])
2015
- ])
2016
- ]),
2017
- K.value ? (f(), x("div", ks, [
2018
- I(C, {
2019
- name: "error",
2020
- class: "inline-block mr-1",
2021
- size: "sm"
2022
- }),
2023
- e("div", Ds, _(K.value), 1)
2024
- ])) : M("", !0)
2025
- ])) : M("", !0),
2026
- e("div", Ns, [
2027
- S[8] || (S[8] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Items going to receive ", -1)),
2028
- (f(!0), x(ue, null, be(n.purchaseOrder.items, (L, W) => {
2029
- var te, E, ne;
2030
- return f(), x("div", { key: W }, [
2031
- e("div", Cs, [
2032
- e("div", As, [
2033
- e("span", Ts, _(L.sku.name), 1),
2034
- e("span", Fs, _(L.sku.code), 1)
2035
- ]),
2036
- e("div", Ps, [
2037
- I(w, {
2038
- label: "Receive Quantity",
2039
- modelValue: ce.value[W].value,
2040
- "onUpdate:modelValue": (de) => ce.value[W].value = de,
2041
- "helper-text": `${h(o)("inventory.transfer.receiveRequest.details.received")} ${h(De).toFormatString(
2042
- {
2043
- value: (te = D.receivedInfoMap[L.sku._id]) == null ? void 0 : te.received
2044
- }
2045
- )} ${((E = L.measurement) == null ? void 0 : E.abbrev) ?? L.sku.unit.abbrev}`,
2046
- min: 0,
2047
- "append-text": ((ne = L.measurement) == null ? void 0 : ne.abbrev) ?? L.sku.unit.abbrev
2048
- }, null, 8, ["modelValue", "onUpdate:modelValue", "helper-text", "append-text"]),
2049
- h(N) ? (f(), x("div", qs, [
2050
- I(j, {
2051
- "model-value": c.value[W],
2052
- "onUpdate:modelValue": (de) => Oe(W),
2053
- size: "sm"
2054
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
2055
- S[7] || (S[7] = e("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Override cost ", -1))
2056
- ])) : M("", !0),
2057
- h(N) && c.value[W] ? (f(), le(w, {
2058
- key: 1,
2059
- modelValue: ge.value[W].value,
2060
- "onUpdate:modelValue": (de) => ge.value[W].value = de,
2061
- label: "Total Cost",
2062
- step: 1e-4,
2063
- min: 0,
2064
- placeholder: "0.0000",
2065
- size: "sm",
2066
- "append-text": h(Te)()
2067
- }, null, 8, ["modelValue", "onUpdate:modelValue", "append-text"])) : M("", !0)
2068
- ])
2069
- ]),
2070
- W < n.purchaseOrder.items.length - 1 ? (f(), x("div", Is)) : M("", !0)
2071
- ]);
2072
- }), 128))
2073
- ]),
2074
- e("div", Es, [
2075
- S[9] || (S[9] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Delivery order no.", -1)),
2076
- e("div", Ls, [
2077
- I(U, {
2078
- modelValue: h(s).deliveryOrderNumber,
2079
- "onUpdate:modelValue": S[2] || (S[2] = (L) => h(s).deliveryOrderNumber = L),
2080
- size: "md"
2081
- }, null, 8, ["modelValue"])
2082
- ])
2083
- ]),
2084
- e("div", Vs, [
2085
- S[10] || (S[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Remark", -1)),
2086
- e("div", Bs, [
2087
- I(U, {
2088
- modelValue: h(s).remark,
2089
- "onUpdate:modelValue": S[3] || (S[3] = (L) => h(s).remark = L),
2090
- size: "md"
2091
- }, null, 8, ["modelValue"])
2092
- ])
2093
- ])
2094
- ])
2095
- ];
2096
- }),
2097
- _: 1
2098
- }, 8, ["modelValue"]);
2099
- };
2100
- }
2101
- }), Ms = { class: "flex flex-col w-full gap-3" }, js = { class: "flex" }, zs = { class: "fm-typo-en-title-md-600 text-fm-color-typo-primary" }, Ks = { class: "flex flex-col gap-16 w-full h-full" }, Hs = { class: "flex justify-between" }, Gs = { class: "fm-typo-en-body-lg-600" }, Ws = { class: "flex gap-2" }, Ys = {
2102
- key: 0,
2103
- class: "flex items-center gap-1"
2104
- }, Qs = { class: "fm-typo-en-body-md-400" }, Js = { class: "flex flex-col gap-8" }, Xs = { class: "flex flex-col gap-4" }, Zs = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, eo = { class: "flex gap-1" }, to = { class: "fm-typo-en-body-lg-600" }, ro = {
2105
- key: 0,
2106
- class: "flex flex-col gap-4"
2107
- }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, oo = { class: "fm-typo-en-body-lg-600" }, no = { class: "flex flex-col gap-4" }, ao = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lo = { class: "fm-typo-en-body-lg-600" }, io = {
2108
- key: 1,
2109
- class: "flex flex-col gap-4"
2110
- }, co = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, uo = { class: "fm-typo-en-body-lg-600" }, mo = {
2111
- key: 2,
2112
- class: "flex flex-col gap-4"
2113
- }, po = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, fo = { class: "fm-typo-en-body-lg-600" }, yo = {
2114
- key: 3,
2115
- class: "flex flex-col gap-4"
2116
- }, vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ho = { class: "fm-typo-en-body-lg-600" }, bo = {
2117
- key: 4,
2118
- class: "flex flex-col gap-4"
2119
- }, go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _o = { class: "fm-typo-en-body-lg-600" }, So = { class: "border border-fm-color-neutral-gray-200 fm-corner-radius-lg p-16" }, Oo = { class: "flex flex-col gap-8" }, xo = { class: "flex gap-8 items-center" }, wo = { class: "flex-1 fm-typo-en-body-lg-600" }, $o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-4" }, Ro = { class: "flex w-full gap-4" }, ko = { class: "basis-1/2 shrink-0 grow fm-typo-en-body-lg-400 line-clamp-2 flex items-center gap-2" }, Do = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary flex flex-col gap-2" }, No = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Co = ["innerHTML"], Ao = { class: "flex w-full gap-4 fm-typo-en-body-sm-400" }, To = { class: "grow fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-1" }, Fo = {
2120
- key: 0,
2121
- class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2122
- }, Po = { class: "py-8" }, qo = { class: "flex justify-end gap-4 items-center" }, Io = { class: "fm-typo-en-body-lg-600" }, Eo = {
2123
- key: 1,
2124
- class: "flex-1 xs:w-screen xs:max-w-full"
2125
- }, Lo = {
2126
- key: 0,
2127
- class: "flex flex-col items-center gap-8 h-full"
2128
- }, Vo = ["src"], Bo = { class: "fm-typo-en-body-lg-600" }, Uo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary px-16" }, Mo = {
2129
- key: 1,
2130
- class: "px-4 flex flex-col"
2131
- }, jo = { class: "flex gap-12 content-stretch" }, zo = {
2132
- class: "flex flex-col w-40",
2133
- name: "circles"
2134
- }, Ko = { class: "flex-1 flex flex-col items-center" }, Ho = { class: "h-40 w-40 bg-fm-color-primary rounded-full flex items-center justify-center" }, Go = { class: "flex-1 flex flex-col items-center" }, Wo = { class: "flex w-full items-center gap-4" }, Yo = {
2135
- class: "py-12 flex flex-col gap-4",
2136
- name: "received-at header"
2137
- }, Qo = { class: "fm-typo-en-body-lg-400" }, Jo = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Xo = { class: "ml-auto" }, Zo = { class: "flex gap-12 content-stretch" }, en = {
2138
- class: "flex flex-col w-40",
2139
- name: "circles"
2140
- }, tn = { class: "flex-1 flex flex-col items-center" }, rn = {
2141
- class: "py-12 flex flex-col gap-4 flex-1",
2142
- name: "delivery details"
2143
- }, sn = { class: "flex flex-col gap-8" }, on = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, nn = { class: "flex flex-col gap-4" }, an = { class: "flex gap-8 xs:flex-col" }, _n = /* @__PURE__ */ Se({
2144
- __name: "TransferDetails",
2145
- props: {
2146
- poRequest: {},
2147
- purchaseOrder: {},
2148
- transferTo: {},
2149
- transferToDbName: {},
2150
- show: { type: Boolean },
2151
- canResubmit: { type: Boolean },
2152
- canApprove: { type: Boolean },
2153
- scope: {},
2154
- receivedMap: {},
2155
- shipments: {}
2156
- },
2157
- emits: ["update:show", "submitted"],
2158
- setup(g, { emit: r }) {
2159
- const o = g, p = r, l = Ye(), n = qe(), a = Pe(), s = _e(), i = Me(), O = H(
2160
- () => {
2161
- var t, m;
2162
- return {
2163
- id: ((t = i.sessionUser.value) == null ? void 0 : t.id) ?? "",
2164
- name: ((m = i.sessionUser.value) == null ? void 0 : m.displayName) ?? ""
2165
- };
2166
- }
2167
- ), $ = Xt(), { t: b } = st(), F = H(
2168
- () => {
2169
- var t, m, C, w;
2170
- return ((m = (t = o.purchaseOrder) == null ? void 0 : t.supplier) == null ? void 0 : m.internal) === "restaurant" || ((w = (C = o.purchaseOrder) == null ? void 0 : C.supplier) == null ? void 0 : w.internal) === "warehouse" ? Ce.TRANSFER : Ce.PURCHASE;
2171
- }
2172
- ), u = H(() => {
2173
- var C;
2174
- const t = (C = o.shipments) == null ? void 0 : C.find((w) => {
2175
- var j;
2176
- return w.ref === ((j = o.purchaseOrder) == null ? void 0 : j._id);
2177
- });
2178
- let m = null;
2179
- if (t != null && t.milestones && t.milestones.length > 0) {
2180
- const w = t.milestones[t.milestones.length - 1];
2181
- if (w.estimatedTime) {
2182
- const j = new Date(w.estimatedTime), U = j.getDate().toString().padStart(2, "0");
2183
- m = `${j.toLocaleString("en-US", { month: "short" })} ${U}`;
2184
- }
2185
- }
2186
- return m;
2187
- }), N = Y(!1), d = Y(""), c = Y(!0), y = Ie(), R = Mt(y.getWorkflowConfig), k = Ot(), z = H(() => {
2188
- if (!o.purchaseOrder)
2189
- return [];
2190
- const t = R.result.value;
2191
- if (t.state === dt.loading)
2192
- return [];
2193
- const m = {
2194
- user: O.value,
2195
- executedAt: s.locations.computeFirst(
2196
- (w) => {
2197
- var j;
2198
- return w.dbName === ((j = s._currentLocation) == null ? void 0 : j.dbName) ? w : null;
2199
- }
2200
- ),
2201
- purchaseOrderRequest: o.poRequest,
2202
- purchaseOrder: o.purchaseOrder
2203
- };
2204
- let C = [];
2205
- try {
2206
- t.state === dt.error ? (console.error("Error fetching workflow config:", t.error), C = Qe.getAvailableActions({
2207
- ...m,
2208
- orderConfig: Qe.getDefaultConfig()
2209
- }).actions.filter(
2210
- (w) => (
2211
- // TODO: create receiveStock & processRequest dialog
2212
- // to create their payload
2213
- w !== P.enum.receiveStock && w !== P.enum.processRequest && w !== P.enum.closeRequest
2214
- )
2215
- )) : C = Qe.getAvailableActions({
2216
- ...m,
2217
- orderConfig: t.data
2218
- }).actions.filter(
2219
- (w) => w !== P.enum.receiveStock && w !== P.enum.processRequest && w !== P.enum.closeRequest
2220
- );
2221
- } catch (w) {
2222
- console.error("Error getting available actions:", w);
2223
- }
2224
- return o.scope === "approval" && (C = C.filter((w) => w !== P.enum.completeReceive)), C;
2225
- }), A = Pt(o, "show"), K = H(() => [
2226
- {
2227
- label: b("inventory.transfer.receiveRequest.details.overview"),
2228
- value: "overview"
2229
- },
2230
- {
2231
- label: b("inventory.transfer.receiveRequest.details.deliveryHistory"),
2232
- value: "deliveryHistory"
2233
- }
2234
- ]), Z = Y(K.value[0]);
2235
- Ct(
2236
- () => o.show,
2237
- (t) => {
2238
- t && (Z.value = K.value[0]);
2239
- }
2240
- );
2241
- async function oe(t, m, C, w, j) {
2242
- return new Promise((U, ee) => {
2243
- l.open({
2244
- closeButton: !1,
2245
- title: w.title,
2246
- message: w.message,
2247
- primaryActions: w.primaryActions,
2248
- secondaryActions: { text: "No", close: !1 }
2249
- }).onPrimary(async () => {
2250
- var L, W, te, E;
2251
- const v = [];
2252
- C === P.enum.approveRequest ? (v.push({
2253
- action: "approveRequest",
2254
- payload: null
2255
- }), m.fulfillment && v.push({
2256
- action: "processRequest",
2257
- payload: {
2258
- fulfillmentId: "",
2259
- deliveryOrderNumber: "",
2260
- deliveryRemark: null,
2261
- items: m.fulfillment.items,
2262
- createdBy: O.value
2263
- }
2264
- })) : C === P.enum.processRequest ? m.fulfillment && v.push({
2265
- action: "processRequest",
2266
- payload: {
2267
- fulfillmentId: "",
2268
- deliveryOrderNumber: "",
2269
- deliveryRemark: null,
2270
- items: m.fulfillment.items,
2271
- createdBy: O.value
2272
- }
2273
- }) : C === P.enum.rejectRequest ? v.push({
2274
- action: "rejectRequest",
2275
- payload: null
2276
- }) : C === P.enum.closeRequest && v.push({
2277
- action: "closeRequest",
2278
- payload: null
2279
- });
2280
- try {
2281
- await k({
2282
- operate: {
2283
- operation: C,
2284
- doc: t,
2285
- options: m
2286
- },
2287
- operateV2: {
2288
- _id: ((L = o.purchaseOrder) == null ? void 0 : L._id) ?? "",
2289
- _rev: ((W = o.purchaseOrder) == null ? void 0 : W._rev) ?? "",
2290
- action: C,
2291
- payloads: v
2292
- // add payload if action is receiveStock or processRequest
2293
- },
2294
- transferTo: (E = (te = o.poRequest) == null ? void 0 : te.to) == null ? void 0 : E.dbName
2295
- }).delayed(1e3), U("submitted");
2296
- } catch (ne) {
2297
- ee(ne);
2298
- }
2299
- }).onSecondary(() => {
2300
- U("cancelled");
2301
- for (let v = 0; v < j + 2; v++)
2302
- l.close();
2303
- }).onClose(() => {
2304
- });
2305
- });
2306
- }
2307
- async function ce(t) {
2308
- var j, U, ee, v;
2309
- if (t === P.enum.receiveStock)
2310
- return;
2311
- const m = St[t];
2312
- if (!m) {
2313
- n.open({
2314
- title: "Something went wrong",
2315
- message: `Cannot process order: ${rt(t)}`,
2316
- type: "error"
2317
- });
2318
- return;
2319
- }
2320
- const { successMessage: C, ...w } = m;
2321
- if (o.purchaseOrder) {
2322
- d.value = `${t}`, N.value = !0, c.value = !1;
2323
- const L = {};
2324
- let W = 0;
2325
- if ((t === P.enum.confirmDraft || // auto receive for warehouse to warehouse
2326
- t === P.enum.completeReceive) && a.autoReceiveWarehouse)
2327
- L.autoReceive = !0;
2328
- else if ((t === P.enum.approveRequest || t === P.enum.processRequest) && a.acceptRequireFulfillment) {
2329
- const te = (U = (j = o.poRequest) == null ? void 0 : j.from) == null ? void 0 : U.dbName, E = (v = (ee = o.poRequest) == null ? void 0 : ee.to) == null ? void 0 : v.dbName;
2330
- if (te && E && (te.startsWith("warehouse_") || E.startsWith("warehouse_"))) {
2331
- const ne = await new Promise((de, we) => {
2332
- l.open({
2333
- closeButton: !1,
2334
- title: "Confirm transfer amount",
2335
- dialogComponent: Jt,
2336
- dialogComponentProps: {
2337
- purchaseOrder: o.purchaseOrder,
2338
- confirm: de,
2339
- "onUpdate:show": ($e) => {
2340
- $e || (d.value = "", N.value = !1, c.value = !0, W++, l.close()), we("cancelled");
2341
- }
2342
- }
2343
- });
2344
- });
2345
- L.fulfillment = ne;
2346
- }
2347
- }
2348
- try {
2349
- await oe(
2350
- o.purchaseOrder,
2351
- L,
2352
- t,
2353
- m,
2354
- W
2355
- ) === "submitted" && (n.open({
2356
- title: "Success",
2357
- message: C,
2358
- type: "success"
2359
- }), p("update:show", !1), p("submitted"));
2360
- } catch (te) {
2361
- n.open({
2362
- title: "Something went wrong",
2363
- message: "Please try again.",
2364
- type: "error"
2365
- }), console.error("Error when submitting PO operation", t, o.purchaseOrder, te);
2366
- } finally {
2367
- d.value = "", N.value = !1, c.value = !0;
2368
- }
2369
- }
2370
- }
2371
- const Oe = H(() => {
2372
- var t, m;
2373
- return ((t = o.purchaseOrder) == null ? void 0 : t.status) === Q.enum.RECEIVING || ((m = o.purchaseOrder) == null ? void 0 : m.status) === Q.enum.COMPLETE;
2374
- }), ge = H(() => o.purchaseOrder ? He(o.purchaseOrder) : {}), xe = H(() => {
2375
- const t = o.purchaseOrder;
2376
- if (!t) return { status: "", statusClass: "" };
2377
- const { partial: m, over: C } = Ze(ge.value), w = et(t.status, m, C);
2378
- let j = b(`inventory.transfer.status.${w}`), U = `${t.status}`.toLocaleLowerCase("en-us");
2379
- return w === Q.enum.CLOSE && (j = `${b(`inventory.transfer.status.${Q.enum.COMPLETE}`)}`), w === "PARTIAL_RECEIVED" && U === Q.enum.PROCESSING.toLocaleLowerCase("en-us") && (U = Q.enum.RECEIVING.toLocaleLowerCase("en-us")), {
2380
- status: j,
2381
- statusClass: `fm-status-badge fm-status-badge-${U}`
2382
- };
2383
- }), he = H(() => {
2384
- var U, ee;
2385
- const t = ((U = o.purchaseOrder) == null ? void 0 : U.deliveryOrder) ?? [], m = ((ee = o.purchaseOrder) == null ? void 0 : ee.deliveryFullfillment) ?? [], C = [
2386
- ...t.map((v) => ({
2387
- createdAt: v.createdAt,
2388
- type: "grn",
2389
- doc: v
2390
- })),
2391
- ...m.map((v) => ({
2392
- createdAt: v.createdAt,
2393
- type: "fulfillment",
2394
- doc: v
2395
- }))
2396
- ];
2397
- C.reverse().sort((v, L) => v.createdAt.localeCompare(L.createdAt));
2398
- function w(v) {
2399
- var te, E, ne, de, we, $e, J, ie, ae, pe;
2400
- const L = m.findIndex((re) => re.id === v.fullfillmentId), W = [
2401
- (E = (te = m[L]) == null ? void 0 : te.netSuite) != null && E.refNo ? {
2402
- label: "Fulfillment's ref no. (Netsuite)",
2403
- values: [(de = (ne = m[L]) == null ? void 0 : ne.netSuite) == null ? void 0 : de.refNo]
2404
- } : null,
2405
- (we = v == null ? void 0 : v.netSuite) != null && we.refNo ? {
2406
- label: "Netsuite ref no.",
2407
- values: [`${($e = v == null ? void 0 : v.netSuite) == null ? void 0 : $e.refNo} (${((J = v == null ? void 0 : v.netSuite) == null ? void 0 : J.id) ?? "-"})`]
2408
- } : null,
2409
- (ie = v == null ? void 0 : v.netSuite) != null && ie.recordType ? {
2410
- label: "Netsuite Type",
2411
- values: [ht((ae = v == null ? void 0 : v.netSuite) == null ? void 0 : ae.recordType)]
2412
- } : null
2413
- ];
2414
- return {
2415
- header: "Received",
2416
- deliveryOrder: v,
2417
- date: Ue(new Date(v.createdAt)),
2418
- info: [
2419
- {
2420
- label: "Adjustment date",
2421
- values: [
2422
- v.adjustment ? Ue(new Date(ze(v.adjustment))) : "-"
2423
- ]
2424
- },
2425
- {
2426
- label: "Received by",
2427
- values: [(pe = v.createdBy) == null ? void 0 : pe.name]
2428
- },
2429
- {
2430
- label: "Received items",
2431
- values: v.received.map((re) => {
2432
- var Re;
2433
- return q("div", [
2434
- q(
2435
- "div",
2436
- {
2437
- class: "flex gap-4"
2438
- },
2439
- [
2440
- q(
2441
- "div",
2442
- {
2443
- class: "flex flex-col"
2444
- },
2445
- [
2446
- q(
2447
- "span",
2448
- {
2449
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2450
- },
2451
- `${re.sku.name}`
2452
- ),
2453
- q(
2454
- "span",
2455
- {
2456
- class: "fm-typo-en-body-md-400"
2457
- },
2458
- `${re.sku.code} `
2459
- )
2460
- ]
2461
- ),
2462
- q(
2463
- "div",
2464
- {
2465
- class: "ml-auto flex flex-col"
2466
- },
2467
- [
2468
- q(
2469
- "div",
2470
- {
2471
- class: "ml-auto flex gap-1"
2472
- },
2473
- [
2474
- q(
2475
- "span",
2476
- {
2477
- class: "fm-typo-en-body-lg-600 self-end"
2478
- },
2479
- ye(re.amount, !1)
2480
- ),
2481
- q(
2482
- "span",
2483
- {
2484
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2485
- },
2486
- ((Re = re.measurement) == null ? void 0 : Re.abbrev) ?? re.sku.unit.abbrev
2487
- )
2488
- ]
2489
- ),
2490
- q(
2491
- "div",
2492
- {
2493
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2494
- },
2495
- `${re.cost ? `(${Ve(re.cost)})` : ""}`
2496
- )
2497
- ]
2498
- )
2499
- ]
2500
- )
2501
- ]);
2502
- })
2503
- },
2504
- {
2505
- label: "Delivery order no.",
2506
- values: [v.deliveryOrderNumber || "N/A"]
2507
- },
2508
- {
2509
- label: "Remark",
2510
- values: [v.remark || "N/A"]
2511
- },
2512
- L > -1 ? {
2513
- label: "Fulfilment's sequence",
2514
- values: [`${L + 1}`]
2515
- } : null,
2516
- ...W
2517
- ].filter((re) => !!re)
2518
- };
2519
- }
2520
- function j(v) {
2521
- var W, te;
2522
- const L = m.findIndex((E) => E.id === v.id);
2523
- return {
2524
- header: "Fulfillment",
2525
- date: Ue(new Date(v.createdAt)),
2526
- info: [
2527
- {
2528
- label: "Sequence",
2529
- values: [String(L + 1)]
2530
- },
2531
- {
2532
- label: "Receiveable items",
2533
- values: v.items.map((E) => {
2534
- var ne;
2535
- return q("div", [
2536
- q(
2537
- "div",
2538
- {
2539
- class: "flex gap-4"
2540
- },
2541
- [
2542
- q(
2543
- "div",
2544
- {
2545
- class: "flex flex-col"
2546
- },
2547
- [
2548
- q(
2549
- "span",
2550
- {
2551
- class: "fm-typo-en-body-lg-800 basis-1/2 shrink-0 grow"
2552
- },
2553
- `${E.sku.name}`
2554
- ),
2555
- q(
2556
- "span",
2557
- {
2558
- class: "fm-typo-en-body-md-400"
2559
- },
2560
- `${E.sku.code} `
2561
- )
2562
- ]
2563
- ),
2564
- q(
2565
- "div",
2566
- {
2567
- class: "ml-auto flex flex-col"
2568
- },
2569
- [
2570
- q(
2571
- "div",
2572
- {
2573
- class: "ml-auto flex gap-1"
2574
- },
2575
- [
2576
- q(
2577
- "span",
2578
- {
2579
- class: "fm-typo-en-body-lg-600 self-end"
2580
- },
2581
- ye(E.amount, !1)
2582
- ),
2583
- q(
2584
- "span",
2585
- {
2586
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary"
2587
- },
2588
- ((ne = E.measurement) == null ? void 0 : ne.abbrev) ?? E.sku.unit.abbrev
2589
- )
2590
- ]
2591
- ),
2592
- q(
2593
- "div",
2594
- {
2595
- class: "flex self-end fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2596
- },
2597
- `${E.cost ? `(${Ve(E.cost)})` : ""}`
2598
- )
2599
- ]
2600
- )
2601
- ]
2602
- )
2603
- ]);
2604
- })
2605
- },
2606
- (W = v.netSuite) != null && W.refNo ? {
2607
- label: "Ref no. (Netsuite)",
2608
- values: [(te = v.netSuite) == null ? void 0 : te.refNo]
2609
- } : null
2610
- ].filter((E) => !!E)
2611
- };
2612
- }
2613
- return C.map((v) => {
2614
- switch (v.type) {
2615
- case "grn":
2616
- return w(v.doc);
2617
- case "fulfillment":
2618
- return j(v.doc);
2619
- }
2620
- });
2621
- }), V = H(() => {
2622
- var m;
2623
- const t = {
2624
- ...yt(0),
2625
- currency: Te()
2626
- };
2627
- return ((m = o.purchaseOrder) == null ? void 0 : m.items.reduce((C, w) => ({
2628
- ...ft(C, w.totalCost ?? t),
2629
- currency: Te()
2630
- }), t)) ?? t;
2631
- });
2632
- function B(t) {
2633
- var U;
2634
- const C = (((U = o.purchaseOrder) == null ? void 0 : U.version) ?? ke.enum[1]) === ke.enum[2] ? t.id : t.sku._id, w = o.receivedMap[C];
2635
- return `<span class="${se(t)} fm-typo-en-body-lg-600">${De.toFormatString({ value: w.received })}</span>/${Et(t.quantity, t.sku.unit, t.measurement)}`;
2636
- }
2637
- function se(t) {
2638
- var L;
2639
- const C = (((L = o.purchaseOrder) == null ? void 0 : L.version) ?? ke.enum[1]) === ke.enum[2] ? t.id : t.sku._id, w = o.receivedMap[C], { isPartialReceive: j, isNoReceive: U, isOverReceive: ee, isFullReceive: v } = Kt(w);
2640
- return U ? "text-fm-color-typo-tertiary" : j ? "text-fm-color-system-warning-300" : ee ? "text-fm-color-system-error-300" : v ? "text-fm-color-system-success-300" : "";
2641
- }
2642
- const D = H(() => {
2643
- var t, m, C;
2644
- return (t = o.purchaseOrder) != null && t.itemsAtSubmission ? ((m = o.purchaseOrder) == null ? void 0 : m.version) === ke.enum[2] ? o.purchaseOrder.items.reduce((w, j) => {
2645
- var ee, v;
2646
- const U = (v = (ee = o.purchaseOrder) == null ? void 0 : ee.itemsAtSubmission) == null ? void 0 : v.find(
2647
- (L) => L.id === j.id
2648
- );
2649
- return U && U.quantity !== j.quantity && w.set(j.sku.code, {
2650
- originalAmount: Number(De.toFormatString({ value: U.quantity })),
2651
- newAmount: Number(De.toFormatString({ value: j.quantity }))
2652
- }), w;
2653
- }, /* @__PURE__ */ new Map()) : (C = o.purchaseOrder) == null ? void 0 : C.items.reduce((w, j) => {
2654
- var L, W;
2655
- const U = (W = (L = o.purchaseOrder) == null ? void 0 : L.itemsAtSubmission) == null ? void 0 : W.find(
2656
- (te) => te.sku._id === j.sku._id
2657
- ), ee = U ? Number(De.toFormatString({ value: U.quantity })) : 0, v = Number(De.toFormatString({ value: j.quantity }));
2658
- return U && ee !== v && w.set(j.sku.code, {
2659
- originalAmount: ee,
2660
- newAmount: v
2661
- }), w;
2662
- }, /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2663
- }), S = (t) => {
2664
- var C, w;
2665
- const m = D.value;
2666
- return ((C = o.purchaseOrder) == null ? void 0 : C.version) === ke.enum[2] ? m.has(t.id) : m.has((w = t.sku) == null ? void 0 : w.code);
2667
- }, T = (t) => {
2668
- var C, w;
2669
- const m = D.value;
2670
- return ((C = o.purchaseOrder) == null ? void 0 : C.version) === ke.enum[2] ? m.get(t.id) : m.get((w = t.sku) == null ? void 0 : w.code);
2671
- };
2672
- return (t, m) => {
2673
- const C = G("FmButton"), w = G("FmButtonGroup"), j = G("FmChip"), U = G("FmIcon"), ee = G("FmMenuDivider"), v = G("FmCard"), L = G("FmTooltip"), W = G("FmSpacer"), te = G("FmSideSheet");
2674
- return f(), le(te, {
2675
- modelValue: h(A),
2676
- "onUpdate:modelValue": m[8] || (m[8] = (E) => At(A) ? A.value = E : null),
2677
- "dismiss-away": c.value,
2678
- "max-width": 600,
2679
- "close-button": !1
2680
- }, {
2681
- "side-sheet-header": X(() => {
2682
- var E, ne;
2683
- return [
2684
- e("div", Ms, [
2685
- e("div", js, [
2686
- e("div", zs, _(h(b)("inventory.transfer.receiveRequest.details.title") + ((E = t.purchaseOrder) != null && E.seqNumber ? ` #${(ne = t.purchaseOrder) == null ? void 0 : ne.seqNumber}` : "")), 1),
2687
- I(C, {
2688
- class: "ml-auto -m-2",
2689
- variant: "tertiary",
2690
- "prepend-icon": "close",
2691
- onClick: m[0] || (m[0] = (de) => p("update:show", !1))
2692
- })
2693
- ]),
2694
- I(w, {
2695
- items: K.value,
2696
- modelValue: Z.value,
2697
- "onUpdate:modelValue": m[1] || (m[1] = (de) => Z.value = de)
2698
- }, null, 8, ["items", "modelValue"]),
2699
- t.purchaseOrder && Z.value.value === "deliveryHistory" ? (f(), le(Us, {
2700
- key: 0,
2701
- "purchase-order": t.purchaseOrder,
2702
- "received-info-map": ge.value,
2703
- onSubmitted: m[2] || (m[2] = () => {
2704
- p("update:show", !1), p("submitted");
2705
- })
2706
- }, null, 8, ["purchase-order", "received-info-map"])) : M("", !0)
2707
- ])
2708
- ];
2709
- }),
2710
- default: X(() => {
2711
- var E, ne, de, we, $e;
2712
- return [
2713
- e("div", Ks, [
2714
- Z.value.value === "overview" ? (f(), x(ue, { key: 0 }, [
2715
- e("div", null, [
2716
- I(v, {
2717
- variant: "outlined",
2718
- class: "flex flex-col gap-8 px-12 py-16"
2719
- }, {
2720
- default: X(() => {
2721
- var J, ie, ae, pe, re, Re, ot, nt, at;
2722
- return [
2723
- e("div", Hs, [
2724
- e("div", Gs, _(h(b)("inventory.transfer.receiveRequest.details.requestSummary")), 1),
2725
- e("div", Ws, [
2726
- I(Fe, null, {
2727
- default: X(() => {
2728
- var lt;
2729
- return [
2730
- Ne(_((lt = o.purchaseOrder) == null ? void 0 : lt.status), 1)
2731
- ];
2732
- }),
2733
- _: 1
2734
- }),
2735
- I(j, {
2736
- label: xe.value.status,
2737
- class: Be(xe.value.statusClass),
2738
- compact: ""
2739
- }, null, 8, ["label", "class"]),
2740
- u.value ? (f(), x("div", Ys, [
2741
- I(U, {
2742
- name: "local_shipping",
2743
- color: "#666666"
2744
- }),
2745
- e("span", Qs, _(u.value), 1)
2746
- ])) : M("", !0)
2747
- ])
2748
- ]),
2749
- I(ee),
2750
- e("div", Js, [
2751
- e("div", Xs, [
2752
- e("div", Zs, [
2753
- e("div", eo, _(h(b)("inventory.transfer.receiveRequest.details.createdAt")), 1)
2754
- ]),
2755
- e("div", to, _(h(je)(((J = t.purchaseOrder) == null ? void 0 : J._id) ?? "")), 1)
2756
- ]),
2757
- (ie = t.purchaseOrder) != null && ie.effectiveAt ? (f(), x("div", ro, [
2758
- e("div", so, _(h(b)("inventory.transfer.receiveRequest.details.backdatedTo")), 1),
2759
- e("div", oo, _(h(vt)(new Date((ae = t.purchaseOrder) == null ? void 0 : ae.effectiveAt))), 1)
2760
- ])) : M("", !0),
2761
- e("div", no, [
2762
- e("div", ao, _(h(b)("inventory.transfer.receiveRequest.details.type.title")), 1),
2763
- e("div", lo, _(h(b)(
2764
- `inventory.transfer.receiveRequest.details.type.${F.value.toLocaleLowerCase("en-US")}`
2765
- )), 1)
2766
- ]),
2767
- (re = (pe = t.purchaseOrder) == null ? void 0 : pe.supplier) != null && re.name ? (f(), x("div", io, [
2768
- e("div", co, _(h(b)("inventory.transfer.receiveRequest.details.from")), 1),
2769
- e("div", uo, _((ot = (Re = t.purchaseOrder) == null ? void 0 : Re.supplier) == null ? void 0 : ot.name), 1)
2770
- ])) : M("", !0),
2771
- t.transferTo ? (f(), x("div", mo, [
2772
- e("div", po, _(h(b)("inventory.transfer.receiveRequest.details.to")), 1),
2773
- e("div", fo, _(t.transferTo), 1)
2774
- ])) : M("", !0),
2775
- (nt = t.purchaseOrder) != null && nt.ref ? (f(), x("div", yo, [
2776
- e("div", vo, _(h(b)("inventory.transfer.receiveRequest.details.reference")), 1),
2777
- e("div", ho, _(t.purchaseOrder.ref), 1)
2778
- ])) : M("", !0),
2779
- (at = t.purchaseOrder) != null && at.remark ? (f(), x("div", bo, [
2780
- e("div", go, _(h(b)("inventory.transfer.receiveRequest.details.remark")), 1),
2781
- e("div", _o, _(t.purchaseOrder.remark), 1)
2782
- ])) : M("", !0)
2783
- ])
2784
- ];
2785
- }),
2786
- _: 1
2787
- })
2788
- ]),
2789
- I(Wr, {
2790
- "po-request": t.poRequest,
2791
- purchaseOrder: t.purchaseOrder,
2792
- transferType: F.value,
2793
- transferToDbName: t.transferToDbName,
2794
- scope: t.scope
2795
- }, null, 8, ["po-request", "purchaseOrder", "transferType", "transferToDbName", "scope"]),
2796
- e("div", So, [
2797
- e("div", Oo, [
2798
- e("div", xo, [
2799
- e("span", wo, [
2800
- Ne(_(Oe.value ? h(b)("inventory.transfer.receiveRequest.details.receivedItems") : h(b)("inventory.transfer.receiveRequest.details.requestedItems")) + " ", 1),
2801
- (ne = (E = t.purchaseOrder) == null ? void 0 : E.netSuite) != null && ne.missingItems && ((we = (de = t.purchaseOrder) == null ? void 0 : de.netSuite) == null ? void 0 : we.missingItems.length) > 0 ? (f(), le(L, {
2802
- key: 0,
2803
- variant: "rich",
2804
- placement: "top",
2805
- "z-index": 51
2806
- }, {
2807
- content: X(() => {
2808
- var J, ie;
2809
- return [
2810
- e("div", $o, [
2811
- (f(!0), x(ue, null, be((ie = (J = t.purchaseOrder) == null ? void 0 : J.netSuite) == null ? void 0 : ie.missingItems, (ae, pe) => (f(), x("div", {
2812
- class: "flex justify-center align-middle",
2813
- key: pe
2814
- }, [
2815
- I(U, {
2816
- name: "arrow_right",
2817
- size: "sm"
2818
- }),
2819
- Ne(" " + _(`(${ae.netSuiteId}) ${ae.name}: ${ae.reason}`), 1)
2820
- ]))), 128))
2821
- ])
2822
- ];
2823
- }),
2824
- default: X(() => [
2825
- I(U, {
2826
- name: "error",
2827
- color: "#ff2c2c",
2828
- size: "sm"
2829
- })
2830
- ]),
2831
- _: 1
2832
- })) : M("", !0)
2833
- ])
2834
- ]),
2835
- I(ee),
2836
- (f(!0), x(ue, null, be((($e = t.purchaseOrder) == null ? void 0 : $e.items) ?? [], (J, ie) => {
2837
- var ae;
2838
- return f(), x("div", {
2839
- key: ie,
2840
- class: "flex flex-col"
2841
- }, [
2842
- e("div", Ro, [
2843
- e("div", ko, [
2844
- Ne(_(J.name) + " ", 1),
2845
- S(J) ? (f(), le(L, {
2846
- key: 0,
2847
- variant: "rich",
2848
- placement: "top",
2849
- "z-index": 51
2850
- }, {
2851
- content: X(() => {
2852
- var pe, re;
2853
- return [
2854
- e("div", Do, [
2855
- m[9] || (m[9] = e("div", { class: "font-semibold" }, "Submission changes", -1)),
2856
- e("div", null, "Original Amount: " + _((pe = T(J)) == null ? void 0 : pe.originalAmount), 1),
2857
- e("div", null, " New Amount: " + _((re = T(J)) == null ? void 0 : re.newAmount), 1)
2858
- ])
2859
- ];
2860
- }),
2861
- default: X(() => [
2862
- I(U, {
2863
- name: "error",
2864
- color: "#ff9500",
2865
- size: "sm"
2866
- })
2867
- ]),
2868
- _: 2
2869
- }, 1024)) : M("", !0)
2870
- ]),
2871
- e("div", No, [
2872
- e("span", {
2873
- innerHTML: B(J)
2874
- }, null, 8, Co)
2875
- ])
2876
- ]),
2877
- e("div", Ao, [
2878
- e("div", To, _(J.code), 1),
2879
- (ae = J.totalCost) != null && ae.amount && h(a).enableTotalCost ? (f(), x("div", Fo, " (" + _(h(Ve)(J.totalCost)) + ") ", 1)) : M("", !0)
2880
- ])
2881
- ]);
2882
- }), 128)),
2883
- +h(ye)(V.value) ? (f(), x(ue, { key: 0 }, [
2884
- e("div", Po, [
2885
- I(ee)
2886
- ]),
2887
- e("div", qo, [
2888
- m[10] || (m[10] = e("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, "Total:", -1)),
2889
- e("div", Io, _(h(Ve)(V.value)), 1)
2890
- ])
2891
- ], 64)) : M("", !0)
2892
- ])
2893
- ])
2894
- ], 64)) : Z.value.value === "deliveryHistory" ? (f(), x("div", Eo, [
2895
- he.value.length ? (f(), x("div", Mo, [
2896
- (f(!0), x(ue, null, be(he.value, (J, ie) => (f(), x(ue, { key: ie }, [
2897
- e("div", jo, [
2898
- e("div", zo, [
2899
- e("div", Ko, [
2900
- e("div", {
2901
- class: Be([
2902
- {
2903
- "bg-fm-color-primary": ie !== 0,
2904
- "bg-white": ie === 0
2905
- },
2906
- "w-[2px] h-full"
2907
- ])
2908
- }, null, 2)
2909
- ]),
2910
- e("div", Ho, [
2911
- J.header === "Received" ? (f(), le(U, {
2912
- key: 0,
2913
- name: "local_shipping",
2914
- outline: "",
2915
- color: "#ffffff"
2916
- })) : M("", !0)
2917
- ]),
2918
- e("div", Go, [
2919
- e("div", {
2920
- class: Be([
2921
- {
2922
- "bg-fm-color-primary": ie < he.value.length - 1,
2923
- "bg-white": ie >= he.value.length - 1
2924
- },
2925
- "w-[2px] h-full"
2926
- ])
2927
- }, null, 2)
2928
- ])
2929
- ]),
2930
- e("div", Wo, [
2931
- e("div", Yo, [
2932
- e("div", Qo, _(J.header), 1),
2933
- e("div", Jo, _(J.date), 1)
2934
- ]),
2935
- e("div", Xo, [
2936
- J.header === "Received" && J.deliveryOrder && t.purchaseOrder ? (f(), le(vs, {
2937
- key: 0,
2938
- deliveryOrder: J.deliveryOrder,
2939
- purchaseOrder: t.purchaseOrder,
2940
- onSubmitted: m[3] || (m[3] = () => {
2941
- p("update:show", !1), p("submitted");
2942
- })
2943
- }, null, 8, ["deliveryOrder", "purchaseOrder"])) : M("", !0)
2944
- ])
2945
- ])
2946
- ]),
2947
- e("div", Zo, [
2948
- e("div", en, [
2949
- e("div", tn, [
2950
- e("div", {
2951
- class: Be([
2952
- {
2953
- "bg-fm-color-primary": ie < he.value.length - 1,
2954
- "bg-white": ie >= he.value.length - 1
2955
- },
2956
- "w-[2px] h-full"
2957
- ])
2958
- }, null, 2)
2959
- ])
2960
- ]),
2961
- e("div", rn, [
2962
- I(v, {
2963
- variant: "outlined",
2964
- class: "py-12 px-16"
2965
- }, {
2966
- default: X(() => [
2967
- e("div", sn, [
2968
- (f(!0), x(ue, null, be(J.info, (ae, pe) => (f(), x("div", {
2969
- key: pe,
2970
- class: "flex flex-col gap-4"
2971
- }, [
2972
- e("div", on, _(ae == null ? void 0 : ae.label), 1),
2973
- e("div", nn, [
2974
- (f(!0), x(ue, null, be(ae == null ? void 0 : ae.values, (re, Re) => (f(), x("div", {
2975
- key: Re,
2976
- class: "fm-typo-en-body-lg-600"
2977
- }, [
2978
- typeof re == "string" ? (f(), x(ue, { key: 0 }, [
2979
- Ne(_(re), 1)
2980
- ], 64)) : (f(), le(Tt(re), { key: 1 }))
2981
- ]))), 128))
2982
- ])
2983
- ]))), 128))
2984
- ])
2985
- ]),
2986
- _: 2
2987
- }, 1024)
2988
- ])
2989
- ])
2990
- ], 64))), 128))
2991
- ])) : (f(), x("div", Lo, [
2992
- I(W),
2993
- e("div", null, [
2994
- e("img", {
2995
- src: h(Lt),
2996
- alt: "List is empty"
2997
- }, null, 8, Vo)
2998
- ]),
2999
- e("div", Bo, _(h(b)("inventory.transfer.receiveRequest.details.noRecordsFound")), 1),
3000
- e("div", Uo, _(h(b)("inventory.transfer.receiveRequest.details.trackDeliveryMessage")), 1),
3001
- I(W),
3002
- I(W)
3003
- ]))
3004
- ])) : M("", !0)
3005
- ])
3006
- ];
3007
- }),
3008
- "side-sheet-footer": X(() => [
3009
- e("div", an, [
3010
- (f(!0), x(ue, null, be(z.value, (E) => (f(), x(ue, null, [
3011
- h(Xe)[E].available != !1 ? (f(), le(C, {
3012
- key: E,
3013
- label: h(b)(h(Xe)[E].translationKey),
3014
- onClick: (ne) => ce(E),
3015
- loading: d.value === E,
3016
- disabled: d.value !== E && N.value,
3017
- variant: h(Xe)[E].buttonVariant
3018
- }, null, 8, ["label", "onClick", "loading", "disabled", "variant"])) : M("", !0)
3019
- ], 64))), 256)),
3020
- h($).ableToMarkReceived(t.purchaseOrder) && !z.value.includes("completeReceive") ? (f(), le(C, {
3021
- key: 0,
3022
- label: h(b)("inventory.transfer.receiveRequest.actions.completeReceive"),
3023
- onClick: m[4] || (m[4] = (E) => ce("completeReceive")),
3024
- loading: d.value === "completeReceive",
3025
- disabled: d.value !== "completeReceive" && N.value
3026
- }, null, 8, ["label", "loading", "disabled"])) : M("", !0),
3027
- h($).ableToMarkApproved(t.purchaseOrder) && t.canApprove && !z.value.includes("approveRequest") ? (f(), le(C, {
3028
- key: 1,
3029
- label: h(b)("inventory.transfer.approval.actions.approveRequest"),
3030
- onClick: m[5] || (m[5] = (E) => ce("approveRequest")),
3031
- loading: d.value === "approveRequest",
3032
- disabled: d.value !== "approveRequest" && N.value
3033
- }, null, 8, ["label", "loading", "disabled"])) : M("", !0),
3034
- h($).ableToCreateFulfillment(t.purchaseOrder, t.poRequest) && o.scope === "approval" ? (f(), le(C, {
3035
- key: 2,
3036
- label: h(b)("inventory.transfer.receiveRequest.actions.processRequest"),
3037
- onClick: m[6] || (m[6] = (E) => ce("processRequest")),
3038
- loading: d.value === "processRequest",
3039
- disabled: d.value !== "processRequest" && N.value
3040
- }, null, 8, ["label", "loading", "disabled"])) : M("", !0),
3041
- I(C, {
3042
- label: h(b)("common.close"),
3043
- variant: "tertiary",
3044
- onClick: m[7] || (m[7] = (E) => p("update:show", !1))
3045
- }, null, 8, ["label"])
3046
- ])
3047
- ]),
3048
- _: 1
3049
- }, 8, ["modelValue", "dismiss-away"]);
3050
- };
3051
- }
3052
- });
3053
- export {
3054
- tt as P,
3055
- _n as _,
3056
- bn as a,
3057
- gn as b,
3058
- Ht as g,
3059
- Ie as u
3060
- };