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