@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.40

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