@feedmepos/mf-inventory-portal 1.3.7-dev.2 → 1.3.7

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 (135) hide show
  1. package/dist/{App-Bt9_9LW3.js → App-D1-fT3jF.js} +3 -3
  2. package/dist/ApprovalView-0FbsslVD.js +226 -0
  3. package/dist/{BindingsDialog-lLNdP2RG.js → BindingsDialog-DeavyPY-.js} +5 -5
  4. package/dist/{BindingsPicker-BwxdoHu-.js → BindingsPicker-BGzhKq8G.js} +3 -3
  5. package/dist/{BindingsTable-C8cf9nV_.js → BindingsTable-Dr9hWkE1.js} +5 -5
  6. package/dist/{ClosingDraftView-CHB815at.js → ClosingDraftView-6gwWEWWB.js} +57 -57
  7. package/dist/{ClosingHistoryView-BQS52wLi.js → ClosingHistoryView-D4rNnlsq.js} +4 -4
  8. package/dist/{ClosingTemplateView-7o5xDvYi.js → ClosingTemplateView-DxCLH1GH.js} +16 -16
  9. package/dist/{DeliveryOrderPrintPreview-DBWYDmhP.js → DeliveryOrderPrintPreview-D-XeZX-z.js} +17 -17
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-hX9rZGHP.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DeoaPLQm.js} +14 -14
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DLo83JRe.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js} +2 -2
  12. package/dist/{FmMultiselectDialog-CX6Q05kY.js → FmMultiselectDialog-BQZmTWDb.js} +2 -2
  13. package/dist/{FmMultiselectDialog-eZLmEoMJ.js → FmMultiselectDialog-DJFi54mG.js} +1 -1
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CNP7o7p-.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js} +4 -4
  15. package/dist/{ImportView-5F1k_NOx.js → ImportView-DPQY0ELT.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-COyKYsPf.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeVYXEzb.js} +1 -1
  17. package/dist/{IngredientGroupView-1kwOZDub.js → IngredientGroupView-5AuPbMDz.js} +7 -7
  18. package/dist/{IngredientsView-L50oDR5B.js → IngredientsView-qMotWYnL.js} +17 -17
  19. package/dist/{IntegrationView-CwBluyeW.js → IntegrationView-CVdwhNTA.js} +13 -13
  20. package/dist/{InventoryBindingForm-28KU0Y69.js → InventoryBindingForm-B5KUYKIu.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-DAxmcGtJ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-pbyMU879.js} +5 -5
  22. package/dist/{InventoryBindingSummary-hjZLd6je.js → InventoryBindingSummary-Bm3A2kmC.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-GqT3S9zo.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NnoVkA8W.js} +1 -1
  24. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-6jv1aHW-.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Dp4gFbs5.js} +1 -1
  25. package/dist/PublishView-DOIiAeDK.js +208 -0
  26. package/dist/{PurchaseOrderPrintPreview-C_AaZuFs.js → PurchaseOrderPrintPreview-BE-8EJFv.js} +12 -12
  27. package/dist/ReceiveRequestView-ur3OeHuv.js +2802 -0
  28. package/dist/{RecipeView-B39YtOhH.js → RecipeView-CM-BrVSe.js} +21 -22
  29. package/dist/{StockView-DGO3Xf6j.js → StockView-DDqlms0m.js} +20 -21
  30. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-b6jr57r-.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CcQ6bBWG.js} +1 -1
  31. package/dist/{SupplierView-Bfo4AYFs.js → SupplierView-CM2PrtHi.js} +14 -14
  32. package/dist/{SurchargeView-CPuDx3I8.js → SurchargeView-q2NfASMH.js} +8 -8
  33. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-EmbaZT8X.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js} +2 -2
  34. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CMWRgrTV.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bp3joqMK.js} +67 -60
  35. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-GhRFdMoW.js +3521 -0
  36. package/dist/{TransferTemplateView-DH1BkbUP.js → TransferTemplateView-B26H_T9Q.js} +19 -20
  37. package/dist/{UnitCostHistoryView-DonGH8na.js → UnitCostHistoryView-BzumRVdx.js} +4 -4
  38. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CW3kofME.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CfWpv2Mv.js} +4 -4
  39. package/dist/{UnitView-CFBdZjSP.js → UnitView-Cxfg--TU.js} +9 -9
  40. package/dist/{WarehouseView-gdd1ou_Y.js → WarehouseView-CvoafTrd.js} +7 -7
  41. package/dist/{WastageTemplateView-BoMqb-zR.js → WastageTemplateView-Bqd4Wp3d.js} +16 -16
  42. package/dist/{app-QEDlYnlN.js → app-CrrDFeMj.js} +4557 -4711
  43. package/dist/app.d.ts +0 -32
  44. package/dist/app.js +2 -2
  45. package/dist/{closing-template-CbHN15AQ.js → closing-template-Ew74NLQj.js} +1 -1
  46. package/dist/{component-kqxARxvM.js → component-DpCUABT3.js} +21 -30
  47. package/dist/components/row-action.enum.d.ts +0 -3
  48. package/dist/{date2-Z-I7Kd_W.js → date2-Bklbk2g-.js} +4 -4
  49. package/dist/{dayjs.min-D4CmdyEZ.js → dayjs.min-B463GIlc.js} +1 -1
  50. package/dist/{decimal-C-T875Hm.js → decimal-Dm2vbfDq.js} +2 -2
  51. package/dist/defineDeepModel-SD5OUepJ.js +19 -0
  52. package/dist/{duplicate-template-CmTg7BGs.js → duplicate-template-CR79OmLy.js} +1 -1
  53. package/dist/{export-B1VAPZRx.js → export-CQJcxfPC.js} +1 -1
  54. package/dist/{inventory-core-dart.default-ugZJdof5.js → feature-CZHvliez.js} +1395 -322
  55. package/dist/{format-time-from-id-DZ_PAFci.js → format-time-from-id-61ydd8RS.js} +1 -1
  56. package/dist/{format-unit-display-DlODRa7k.js → format-unit-display-BLtW28yU.js} +13 -13
  57. package/dist/{import-export.helper-DVCiPtHv.js → import-export.helper-uhFwjH6X.js} +6 -6
  58. package/dist/{index-rghVMuZK.js → index-CouegIcG.js} +1 -1
  59. package/dist/{index-BHqcJDf6.js → index-Dx5HvWR_.js} +1 -1
  60. package/dist/{index-BZxwdVW1.js → index-uA6bkf1x.js} +3 -3
  61. package/dist/{lodash-CgDY9U7s.js → lodash-CjyamSgJ.js} +1 -1
  62. package/dist/{lz-string-DNoTxtCy.js → lz-string-BbZdMrTL.js} +1 -1
  63. package/dist/{netsuite-B64xGIt5.js → netsuite-2v3F8ILe.js} +9 -60
  64. package/dist/{number-Bqy4-9rV.js → number-BYbxsJHr.js} +3 -3
  65. package/dist/{purchase-order-template-BxowjjVQ.js → purchase-order-template-s1AiueV_.js} +1 -1
  66. package/dist/router/name.d.ts +0 -2
  67. package/dist/{row-action.enum-Co_O4qD9.js → row-action.enum-BcW_L_nE.js} +3 -11
  68. package/dist/{rules-BkK6oJzC.js → rules-C7L-LFOd.js} +2 -2
  69. package/dist/{stock-lXNLY2TO.js → stock-CvYOcgWb.js} +3 -3
  70. package/dist/{stock-CedueOcQ.js → stock-D2s88pz1.js} +1 -1
  71. package/dist/stores/feature.d.ts +0 -2
  72. package/dist/stores/integration/netsuite.d.ts +1 -1
  73. package/dist/style.css +1 -1
  74. package/dist/{supplier-BxEW6DYL.js → supplier-DmobM7mD.js} +2 -2
  75. package/dist/{surcharge-_zxlHhpJ.js → surcharge-BdZOVfi0.js} +1 -1
  76. package/dist/tsconfig.app.tsbuildinfo +1 -1
  77. package/dist/{use-ingredient-select-dialog-BQFTqO6q.js → use-ingredient-select-dialog-BUCJBHjV.js} +2 -2
  78. package/dist/{use-inventory-binding-dialog-BnJKIhqC.js → use-inventory-binding-dialog-DiN1hBIm.js} +2 -2
  79. package/dist/{use-template-enabled-locations-2-Ch5vC3Ux.js → use-template-enabled-locations-CmH6I2cy.js} +33 -21
  80. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +21 -21
  81. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +21 -21
  82. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +129 -129
  83. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +150 -154
  84. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +7 -93
  85. package/dist/vue-i18n-D0Q6LFcu.js +2365 -0
  86. package/dist/{xlsx-BlvEsbYy.js → xlsx-D4PML26z.js} +398 -398
  87. package/dist/{xlsx.util-B4ae3AUU.js → xlsx.util-BWLcCmO_.js} +1 -1
  88. package/package.json +3 -8
  89. package/dist/ApprovalView-BAFatrEE.js +0 -241
  90. package/dist/IntegrationExplorerView-BVJ3qSYS.js +0 -22254
  91. package/dist/PublishView-kBqlO98G.js +0 -234
  92. package/dist/ReceiveRequestView-sebwwuaH.js +0 -2817
  93. package/dist/SettingsView-CFoKuaMo.js +0 -695
  94. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-_5fogvJl.js +0 -3790
  95. package/dist/api/integration-sync-log.d.ts +0 -47
  96. package/dist/api/netsuite-explorer.d.ts +0 -51
  97. package/dist/defineDeepModel-Ds_lq_kg.js +0 -19
  98. package/dist/feature-_WJViVjR.js +0 -1081
  99. package/dist/modules/print-template/api/print-template.d.ts +0 -29
  100. package/dist/modules/print-template/components/BlockConfigPanel.vue.d.ts +0 -19
  101. package/dist/modules/print-template/components/CustomPrintTemplatePreview.vue.d.ts +0 -25
  102. package/dist/modules/print-template/components/PrintTemplateEditorDialog.vue.d.ts +0 -45
  103. package/dist/modules/print-template/components/TemplatePreview.vue.d.ts +0 -22
  104. package/dist/modules/print-template/composables/print-po-with-template.d.ts +0 -25
  105. package/dist/modules/print-template/definitions/block-definitions.d.ts +0 -88
  106. package/dist/modules/print-template/definitions/predefined-templates.d.ts +0 -22
  107. package/dist/modules/print-template/definitions/template-renderer.d.ts +0 -17
  108. package/dist/modules/print-template/index.d.ts +0 -11
  109. package/dist/modules/print-template/store/print-template.d.ts +0 -170
  110. package/dist/modules/print-template/types/print-data.d.ts +0 -52
  111. package/dist/modules/print-template/utils/sanitize-html.d.ts +0 -32
  112. package/dist/predefined-templates-B5qmOdnZ.js +0 -4542
  113. package/dist/views/integration/components/IntegrationSyncLogTab.vue.d.ts +0 -15
  114. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
  115. package/dist/views/integration-explorer/IntegrationExplorerView.vue.d.ts +0 -2
  116. package/dist/views/integration-explorer/composables/use-explorer-tab.d.ts +0 -126
  117. package/dist/views/integration-explorer/netsuite/ExplorerRecordSyncLog.vue.d.ts +0 -17
  118. package/dist/views/integration-explorer/netsuite/ExplorerRecordToolbar.vue.d.ts +0 -201
  119. package/dist/views/integration-explorer/netsuite/ExplorerSystemNote.vue.d.ts +0 -15
  120. package/dist/views/integration-explorer/netsuite/JsonViewer.vue.d.ts +0 -15
  121. package/dist/views/integration-explorer/netsuite/NetSuiteExplorerView.vue.d.ts +0 -2
  122. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferSideSheet.vue.d.ts +0 -7
  123. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferView.vue.d.ts +0 -39
  124. package/dist/views/integration-explorer/netsuite/items/AssemblyItemSideSheet.vue.d.ts +0 -7
  125. package/dist/views/integration-explorer/netsuite/items/InventoryItemSideSheet.vue.d.ts +0 -7
  126. package/dist/views/integration-explorer/netsuite/items/ItemsView.vue.d.ts +0 -2
  127. package/dist/views/integration-explorer/netsuite/items/ServiceItemSideSheet.vue.d.ts +0 -7
  128. package/dist/views/integration-explorer/netsuite/orders/ExplorerOrderDetailSideSheet.vue.d.ts +0 -7
  129. package/dist/views/integration-explorer/netsuite/orders/OrdersView.vue.d.ts +0 -39
  130. package/dist/views/integration-explorer/netsuite/orders/PurchaseOrderSideSheet.vue.d.ts +0 -7
  131. package/dist/views/integration-explorer/netsuite/orders/SyncNetsuiteButton.vue.d.ts +0 -29
  132. package/dist/views/integration-explorer/netsuite/orders/TransferOrderSideSheet.vue.d.ts +0 -7
  133. package/dist/views/settings/SettingsView.vue.d.ts +0 -2
  134. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +0 -13
  135. package/dist/vue-i18n-taYcBeKI.js +0 -2365
@@ -0,0 +1,2802 @@
1
+ import { computed as q, h as Q, defineComponent as ne, openBlock as b, createElementBlock as T, Fragment as ae, renderList as fe, createElementVNode as t, toDisplayString as $, unref as e, resolveComponent as O, createVNode as m, withCtx as M, createCommentVNode as Y, ref as U, createBlock as oe, watch as he, normalizeClass as W, normalizeStyle as vt, onMounted as He, createTextVNode as ke, reactive as Vt, mergeProps as je, isRef as ge, createSlots as Pt, Teleport as Rt, normalizeProps as Ot, guardReactiveProps as At } from "vue";
2
+ import { t as ue, s as de, f as yt, O as Mt, D as Et, u as Qe, a as Ye, P as qt, Q as Ut, v as Nt, y as bt, m as Ae } from "./app-CrrDFeMj.js";
3
+ import { i as dt, _ as Bt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js";
4
+ import { u as zt, a as Lt, P as Le, b as jt, _ as Ht, g as Qt } from "./TransferDetails.vue_vue_type_script_setup_true_lang-GhRFdMoW.js";
5
+ import { a as _e, d as Ce, c as Yt } from "./number-BYbxsJHr.js";
6
+ import { _ as gt, u as Kt, i as Xt } from "./PremiumBadge.vue_vue_type_script_setup_true_lang-Dp4gFbs5.js";
7
+ import { d as ct } from "./dayjs.min-B463GIlc.js";
8
+ import { e as Zt } from "./export-CQJcxfPC.js";
9
+ import { u as Wt } from "./useTabStorage-BkIVScW_.js";
10
+ import { u as Jt, _ as Gt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CkPuJQWF.js";
11
+ import { useBreakpoints as Ke, components as pe, FmButtonVariant as eo, useSnackbar as we, useDialog as to, useProxiedModel as _t } from "@feedmepos/ui-library";
12
+ import { F as Ie } from "./form-mode.enum-BKiNVH6A.js";
13
+ import { R as De, A as Ee, M as oo, c as mt, B as so } from "./rules-C7L-LFOd.js";
14
+ import { _ as ao, a as ro, b as lo, F as no } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js";
15
+ import { F as Me, u as Xe, P as io } from "./feature-CZHvliez.js";
16
+ import { u as qe } from "./netsuite-2v3F8ILe.js";
17
+ import { useI18n as ye } from "@feedmepos/mf-common";
18
+ import { u as uo } from "./surcharge-BdZOVfi0.js";
19
+ import { a as co } from "./FmMultiselectDialog-BQZmTWDb.js";
20
+ import { F as ce, _ as ht } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
21
+ import { u as xt } from "./supplier-DmobM7mD.js";
22
+ import { d as Ze, e as mo, g as po, b as fo } from "./date2-Bklbk2g-.js";
23
+ import { u as vo, _ as yo } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DeoaPLQm.js";
24
+ import { _ as bo } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
25
+ import { a as kt } from "./format-unit-display-BLtW28yU.js";
26
+ import { u as We } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js";
27
+ import { u as go } from "./vue-i18n-D0Q6LFcu.js";
28
+ import { s as _o, r as ho } from "./xlsx.util-BWLcCmO_.js";
29
+ import { F as xo } from "./FmDroppableField-J0xUsOTV.js";
30
+ import { d as ko } from "./defineDeepModel-SD5OUepJ.js";
31
+ import { P as Co, J as wo } from "./app-DiX-EfV6.js";
32
+ var te = /* @__PURE__ */ ((y) => (y.Code = "Code", y.Name = "Name", y.TemplateName = "TemplateName", y.Amount = "Amount", y.Cost = "Cost", y.TotalCost = "TotalCost", y.Delete = "Delete", y))(te || {});
33
+ const So = () => Q(
34
+ gt,
35
+ {
36
+ zIndex: 50,
37
+ class: "whitespace-nowrap"
38
+ },
39
+ `Total (${yt()})`
40
+ );
41
+ function Fo(y) {
42
+ const { t: x } = ye(), { breakpoints: d } = Ke(), u = Xe(), g = qe();
43
+ function n(i) {
44
+ const o = y.formController.getAllPurchaseOrderItems().find((a) => a.item.sku._id === i);
45
+ return (o == null ? void 0 : o.isCustomCost) ?? !1;
46
+ }
47
+ function h(i) {
48
+ var s, _, F, c, f, I, A;
49
+ const o = (f = (c = (F = (_ = (s = y.supplier) == null ? void 0 : s.supplyItems) == null ? void 0 : _.find(
50
+ (X) => X.skuId === i._id
51
+ )) == null ? void 0 : F.defaultCost) == null ? void 0 : c.costPerUnit) == null ? void 0 : f.amount;
52
+ return (((A = (I = i.defaultCost) == null ? void 0 : I.costPerUnit) == null ? void 0 : A.amount) ?? o) != null;
53
+ }
54
+ function S(i) {
55
+ if (!n(i.sku._id) && h(i.sku)) {
56
+ const { cost: o, supplierOverrideCost: a } = Me.calculateDefaultCost({
57
+ item: i.sku,
58
+ amount: i.quantity,
59
+ measurement: i.measurement,
60
+ overrides: {
61
+ supplier: y.supplier
62
+ },
63
+ defaultCurrency: de()
64
+ });
65
+ return { cost: o, supplierOverrideCost: a };
66
+ } else
67
+ return {
68
+ cost: i.totalCost ?? { amount: 0, precision: 0, currency: de() }
69
+ };
70
+ }
71
+ const V = [
72
+ {
73
+ id: "Code",
74
+ header: () => x("inventory.transfer.form.items.table.Code"),
75
+ accessorKey: "code",
76
+ size: 200,
77
+ cell(i) {
78
+ const o = i.row.original;
79
+ return g.isEnabled ? Q(
80
+ pe.FmTooltip,
81
+ {
82
+ content: o.code,
83
+ placement: "top",
84
+ variant: "plain",
85
+ zIndex: 50
86
+ },
87
+ Q(
88
+ "span",
89
+ {
90
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
91
+ },
92
+ o.code
93
+ )
94
+ ) : Q(pe.FmTextField, {
95
+ modelValue: o.code,
96
+ "onUpdate:modelValue": (a) => {
97
+ y.updateItem({
98
+ ...o,
99
+ code: a
100
+ });
101
+ },
102
+ key: o.sku._id,
103
+ rules: [De()],
104
+ labelMark: "required"
105
+ });
106
+ },
107
+ enableSorting: !1
108
+ },
109
+ {
110
+ id: "Name",
111
+ header: () => x("inventory.transfer.form.items.table.Name"),
112
+ minSize: 300,
113
+ cell(i) {
114
+ const o = i.row.original;
115
+ return g.isEnabled ? Q(
116
+ pe.FmTooltip,
117
+ {
118
+ content: o.name,
119
+ placement: "top",
120
+ variant: "plain",
121
+ zIndex: 50
122
+ },
123
+ Q(
124
+ "span",
125
+ {
126
+ class: "flex-auto line-clamp-2 text-ellipsis break-all"
127
+ },
128
+ o.name
129
+ )
130
+ ) : Q(pe.FmTextField, {
131
+ modelValue: o.name,
132
+ "onUpdate:modelValue": (a) => {
133
+ y.updateItem({
134
+ ...o,
135
+ name: a
136
+ });
137
+ },
138
+ key: o.sku._id,
139
+ rules: [De()],
140
+ labelMark: "required"
141
+ });
142
+ },
143
+ enableSorting: !1
144
+ },
145
+ {
146
+ id: "TemplateName",
147
+ header: () => x("inventory.transfer.form.items.table.Name"),
148
+ minSize: 300,
149
+ enableSorting: !1,
150
+ cell(i) {
151
+ const o = i.row.original, a = o.code, r = o.name;
152
+ return Q(
153
+ pe.FmTooltip,
154
+ { zIndex: 50 },
155
+ {
156
+ default() {
157
+ return Q("div", { class: "flex flex-col w-full" }, [
158
+ Q(
159
+ "div",
160
+ { class: "line-clamp-1 fm-typo-en-body-lg-400 text-fm-color-typo-primary" },
161
+ r
162
+ ),
163
+ Q(
164
+ "div",
165
+ {
166
+ class: "line-clamp-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
167
+ },
168
+ a
169
+ )
170
+ ]);
171
+ },
172
+ content() {
173
+ return r;
174
+ }
175
+ }
176
+ );
177
+ }
178
+ },
179
+ {
180
+ id: "Amount",
181
+ header: () => x("inventory.transfer.form.items.table.Amount"),
182
+ minSize: 200,
183
+ cell(i) {
184
+ var _, F, c, f, I;
185
+ const o = i.row.original, a = (_ = y.forecastAmounts) == null ? void 0 : _.find((A) => A.skuId === o.sku._id), r = a ? a.helperState === "error" ? `Predicted: ${a.amount} (out of range)` : `Predicted: ${a.amount}` : void 0, s = (f = (c = (F = y.template) == null ? void 0 : F.purchaseOrder) == null ? void 0 : c.items) == null ? void 0 : f.find(
186
+ (A) => A.sku._id === o.sku._id
187
+ );
188
+ return Q(ao, {
189
+ style: {
190
+ flex: "1 1 0%"
191
+ },
192
+ modelValue: {
193
+ amount: o.quantity ?? { amount: 1, precision: 0 },
194
+ measurement: o.measurement ?? null
195
+ },
196
+ key: o.sku._id,
197
+ unit: o.sku.unit,
198
+ helperText: r,
199
+ helperState: a == null ? void 0 : a.helperState,
200
+ "onUpdate:modelValue": (A) => {
201
+ if (!A) return;
202
+ const X = {
203
+ ...o,
204
+ quantity: A.amount,
205
+ measurement: A.measurement
206
+ };
207
+ y.updateItem(X);
208
+ },
209
+ stepper: s == null ? void 0 : s.quantityStep,
210
+ disableUnit: !!s,
211
+ disabled: y.disabled,
212
+ rules: [
213
+ ro(
214
+ +_e(
215
+ ((I = o.quantity) == null ? void 0 : I.amount) === 0 ? { amount: 0, precision: 0 } : (s == null ? void 0 : s.minimumQuantity) ?? { amount: 0, precision: 0 }
216
+ )
217
+ ),
218
+ lo(
219
+ s != null && s.maximumQuantity ? +_e(s == null ? void 0 : s.maximumQuantity) : 1 / 0
220
+ ),
221
+ ...s != null && s.quantityStep ? [no(s.quantityStep)] : []
222
+ ],
223
+ applyDefaultRules: !0
224
+ });
225
+ },
226
+ enableSorting: !1
227
+ },
228
+ {
229
+ id: "Cost",
230
+ header: So,
231
+ size: 180,
232
+ cell(i) {
233
+ const o = i.row.original, a = h(o.sku), r = d.value.xs || d.value.sm;
234
+ if (!n(o.sku._id) && a) {
235
+ const { cost: s, supplierOverrideCost: _ } = y.formController.getItemCost(
236
+ o,
237
+ de()
238
+ );
239
+ return Q(
240
+ "div",
241
+ {
242
+ class: [
243
+ "flex gap-4 fm-typo-en-body-md-400 items-center",
244
+ y.disabled ? "text-fm-color-typo-disabled" : ""
245
+ ],
246
+ key: o.sku._id
247
+ },
248
+ [
249
+ u.enablePurchaseOrderCostEdit ? Q(pe.FmButton, {
250
+ prependIcon: "edit",
251
+ variant: eo.Tertiary,
252
+ disabled: y.disabled,
253
+ onClick() {
254
+ y.updateItem({
255
+ ...o,
256
+ totalCost: s,
257
+ isCustomCost: !0
258
+ });
259
+ }
260
+ }) : null,
261
+ Q(
262
+ "div",
263
+ {
264
+ class: "flex flex-col"
265
+ },
266
+ [
267
+ Q(
268
+ "span",
269
+ r ? Ce(s) : _e(s)
270
+ ),
271
+ Q(
272
+ "span",
273
+ {
274
+ class: [
275
+ "fm-typo-en-body-sm-400",
276
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
277
+ ]
278
+ },
279
+ x("inventory.transfer.form.items.autoCalculated")
280
+ ),
281
+ _ ? Q(
282
+ "span",
283
+ {
284
+ class: [
285
+ "fm-typo-en-body-sm-400",
286
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-neutral-gray-400"
287
+ ]
288
+ },
289
+ [
290
+ Ce(_.costPerUnit),
291
+ "/",
292
+ _.measurement ? Q(
293
+ "span",
294
+ { class: "text-blue-500 font-semibold" },
295
+ _.measurement.abbrev
296
+ ) : Q("span", { class: "text-green-500 font-bold" }, o.sku.unit.abbrev)
297
+ // base unit style
298
+ ]
299
+ ) : null
300
+ ]
301
+ )
302
+ ]
303
+ );
304
+ }
305
+ return Q(
306
+ pe.FmTextField,
307
+ {
308
+ disabled: y.disabled || !u.enablePurchaseOrderCostEdit,
309
+ modelValue: _e(o.totalCost ?? { amount: 0, precision: 0 }),
310
+ key: o.sku._id,
311
+ "onUpdate:modelValue": (s) => {
312
+ u.enablePurchaseOrderCostEdit && y.updateItem({
313
+ ...o,
314
+ totalCost: {
315
+ ...Yt(+s),
316
+ currency: de()
317
+ },
318
+ isCustomCost: !0
319
+ });
320
+ },
321
+ rules: [Ee(0), oo(2)]
322
+ },
323
+ {
324
+ prepend() {
325
+ return r ? Q(
326
+ "div",
327
+ {
328
+ class: [
329
+ "text-fm-typo-en-body-lg-400",
330
+ y.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
331
+ ]
332
+ },
333
+ yt()
334
+ ) : null;
335
+ },
336
+ append() {
337
+ return !a || !u.enablePurchaseOrderCostEdit ? null : Q(pe.FmButton, {
338
+ prependIcon: "close",
339
+ variant: "tertiary",
340
+ disabled: y.disabled,
341
+ onClick() {
342
+ const { cost: s } = Me.calculateDefaultCost({
343
+ item: o.sku,
344
+ amount: o.quantity,
345
+ measurement: o.measurement,
346
+ overrides: {
347
+ supplier: y.supplier
348
+ },
349
+ defaultCurrency: de()
350
+ });
351
+ y.updateItem({
352
+ ...o,
353
+ // NOTE: different from PO template, if a default cost is reenabled,
354
+ // the total cost will automatically assigned
355
+ totalCost: s,
356
+ isCustomCost: !1
357
+ });
358
+ }
359
+ });
360
+ }
361
+ }
362
+ );
363
+ },
364
+ enableSorting: !1
365
+ },
366
+ {
367
+ id: "Delete",
368
+ header: "",
369
+ cell(i) {
370
+ const o = i.row.original;
371
+ return Q("div", { class: "flex justify-end" }, [
372
+ Q(pe.FmButton, {
373
+ key: o.sku._id,
374
+ class: "delete-button",
375
+ type: "button",
376
+ icon: "delete",
377
+ variant: "tertiary",
378
+ size: "md",
379
+ disabled: y.disabled,
380
+ onClick: () => {
381
+ y.deleteItem(o);
382
+ }
383
+ })
384
+ ]);
385
+ },
386
+ enableSorting: !1,
387
+ size: 40,
388
+ meta: {
389
+ cellClass: "",
390
+ headerClass: ""
391
+ }
392
+ }
393
+ ], w = q(() => u.enableTotalCost && y.transferType === ue.enum.purchase ? V : V.filter(
394
+ (i) => i.id !== "Cost"
395
+ /* Cost */
396
+ )), v = q(() => ({
397
+ ...y.items.reduce((o, a) => {
398
+ const { cost: r } = S(a);
399
+ return Me.add([o, r]);
400
+ }, Me.reset()),
401
+ currency: y.items[0] ? S(y.items[0]).cost.currency : de()
402
+ }));
403
+ return {
404
+ columnDefs: w,
405
+ totalCost: v
406
+ };
407
+ }
408
+ const $o = { class: "flex flex-col gap-8 px-16 xs:px-4 sm:px-4 py-4 items-center" }, Io = { class: "fm-typo-en-body-lg-600 xs:fm-typo-en-body-md-600 mr-auto xs:w-full" }, Do = { class: "w-[450px] xs:w-full flex" }, To = { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, Vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ct = /* @__PURE__ */ ne({
409
+ __name: "SupplierPriceHistory",
410
+ props: {
411
+ prices: {}
412
+ },
413
+ setup(y) {
414
+ const x = xt();
415
+ function d(u) {
416
+ return x.suppliers.find((g) => g._id === u);
417
+ }
418
+ return (u, g) => (b(), T("div", $o, [
419
+ (b(!0), T(ae, null, fe(Object.keys(u.prices), (n) => {
420
+ var h;
421
+ return b(), T("div", {
422
+ key: n,
423
+ class: "flex items-center gap-12 xs:gap-4 xs:flex-wrap w-full"
424
+ }, [
425
+ t("div", Io, $((h = d(n)) == null ? void 0 : h.name), 1),
426
+ t("div", Do, [
427
+ (b(!0), T(ae, null, fe(u.prices[n].slice(0, 3), (S) => {
428
+ var V;
429
+ return b(), T("div", {
430
+ key: S.date,
431
+ class: "flex flex-col w-[150px] xs:flex-1 text-ellipsis cursor-pointer"
432
+ }, [
433
+ t("div", To, [
434
+ t("span", null, $(S.totalCost ? e(Ce)(S.totalCost) : "No data"), 1),
435
+ g[0] || (g[0] = t("span", { class: "text-fm-color-typo-secondary" }, "/", -1)),
436
+ t("span", null, $(e(_e)(S.totalUnit, !1)), 1),
437
+ t("span", null, $(((V = S.measurement) == null ? void 0 : V.abbrev) ?? S.unit.abbrev), 1)
438
+ ]),
439
+ t("div", Vo, [
440
+ t("span", null, "(#" + $(S.seqNumber) + ")", 1),
441
+ g[1] || (g[1] = t("span", null, $(" "), -1)),
442
+ t("span", null, $(e(Ze)(new Date(S.date))), 1)
443
+ ])
444
+ ]);
445
+ }), 128))
446
+ ])
447
+ ]);
448
+ }), 128))
449
+ ]));
450
+ }
451
+ }), Po = { class: "flex flex-col gap-8 py-16" }, Ro = { class: "flex items-center" }, Oo = { class: "flex-1 flex gap-1 items-center" }, Ao = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Mo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Eo = { class: "flex gap-8 w-full" }, qo = { class: "flex-1 flex flex-col gap-4" }, Uo = { class: "flex-1 flex flex-col gap-4" }, No = { class: "flex gap-8 w-full" }, Bo = { class: "flex-1 flex flex-col gap-4" }, zo = {
452
+ key: 0,
453
+ class: "flex-1 flex flex-col gap-4"
454
+ }, Lo = /* @__PURE__ */ ne({
455
+ __name: "TransferItem",
456
+ props: {
457
+ cellByColId: {},
458
+ comparePriceBySku: {},
459
+ showComparePrice: { type: Boolean },
460
+ row: {}
461
+ },
462
+ setup(y) {
463
+ const { t: x } = ye();
464
+ return (d, u) => {
465
+ var h, S, V, w, v, i, o, a, r, s, _, F, c, f, I, A, X, z, Z, N, B, P, D, E, L, J, se;
466
+ const g = O("FmLabel"), n = O("FmSpacer");
467
+ return b(), T("div", Po, [
468
+ t("div", Ro, [
469
+ t("div", Oo, [
470
+ t("span", Ao, " (" + $(d.row.original.sku.code) + ") ", 1),
471
+ t("span", Mo, $(d.row.original.sku.name), 1)
472
+ ]),
473
+ t("div", null, [
474
+ m(e(ce), {
475
+ render: (V = (S = (h = d.cellByColId.Delete) == null ? void 0 : h.column) == null ? void 0 : S.columnDef) == null ? void 0 : V.cell,
476
+ props: (v = (w = d.cellByColId.Delete) == null ? void 0 : w.getContext) == null ? void 0 : v.call(w)
477
+ }, null, 8, ["render", "props"])
478
+ ])
479
+ ]),
480
+ t("div", Eo, [
481
+ t("div", qo, [
482
+ m(g, {
483
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Code}`)
484
+ }, null, 8, ["label"]),
485
+ m(e(ce), {
486
+ render: (a = (o = (i = d.cellByColId[e(te).Code]) == null ? void 0 : i.column) == null ? void 0 : o.columnDef) == null ? void 0 : a.cell,
487
+ props: (s = (r = d.cellByColId[e(te).Code]) == null ? void 0 : r.getContext) == null ? void 0 : s.call(r)
488
+ }, null, 8, ["render", "props"]),
489
+ u[0] || (u[0] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
490
+ ]),
491
+ t("div", Uo, [
492
+ m(g, {
493
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Name}`)
494
+ }, null, 8, ["label"]),
495
+ m(e(ce), {
496
+ render: (c = (F = (_ = d.cellByColId[e(te).Name]) == null ? void 0 : _.column) == null ? void 0 : F.columnDef) == null ? void 0 : c.cell,
497
+ props: (I = (f = d.cellByColId[e(te).Name]) == null ? void 0 : f.getContext) == null ? void 0 : I.call(f)
498
+ }, null, 8, ["render", "props"]),
499
+ u[1] || (u[1] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
500
+ ])
501
+ ]),
502
+ t("div", No, [
503
+ t("div", Bo, [
504
+ m(g, {
505
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Amount}`)
506
+ }, null, 8, ["label"]),
507
+ m(e(ce), {
508
+ render: (z = (X = (A = d.cellByColId[e(te).Amount]) == null ? void 0 : A.column) == null ? void 0 : X.columnDef) == null ? void 0 : z.cell,
509
+ props: (N = (Z = d.cellByColId[e(te).Amount]) == null ? void 0 : Z.getContext) == null ? void 0 : N.call(Z)
510
+ }, null, 8, ["render", "props"]),
511
+ u[2] || (u[2] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
512
+ ]),
513
+ d.cellByColId[e(te).Cost] ? (b(), T("div", zo, [
514
+ m(gt, { "z-index": 50 }, {
515
+ default: M(() => [
516
+ m(g, {
517
+ label: e(x)(`inventory.transfer.form.items.table.${e(te).Cost}2`)
518
+ }, null, 8, ["label"])
519
+ ]),
520
+ _: 1
521
+ }),
522
+ m(e(ce), {
523
+ render: (D = (P = (B = d.cellByColId[e(te).Cost]) == null ? void 0 : B.column) == null ? void 0 : P.columnDef) == null ? void 0 : D.cell,
524
+ props: (L = (E = d.cellByColId[e(te).Cost]) == null ? void 0 : E.getContext) == null ? void 0 : L.call(E)
525
+ }, null, 8, ["render", "props"]),
526
+ u[3] || (u[3] = t("div", { class: "fm-typo-en-body-md-600 text-fm-color-primary" }, null, -1))
527
+ ])) : Y("", !0)
528
+ ]),
529
+ d.showComparePrice && Object.keys(d.comparePriceBySku[(J = d.row.original.sku) == null ? void 0 : J._id] ?? {}).length > 0 ? (b(), T(ae, { key: 0 }, [
530
+ m(n, { class: "h-8" }),
531
+ m(Ct, {
532
+ prices: d.comparePriceBySku[(se = d.row.original.sku) == null ? void 0 : se._id]
533
+ }, null, 8, ["prices"])
534
+ ], 64)) : Y("", !0)
535
+ ]);
536
+ };
537
+ }
538
+ });
539
+ function jo(y) {
540
+ const x = q({
541
+ get() {
542
+ const n = y.getEffectiveAt();
543
+ return n ? new Date(n) : null;
544
+ },
545
+ set(n) {
546
+ y.setEffectiveAt((n == null ? void 0 : n.toISOString()) ?? null);
547
+ }
548
+ }), d = q({
549
+ get() {
550
+ return !!x.value;
551
+ },
552
+ set(n) {
553
+ n ? x.value = /* @__PURE__ */ new Date() : x.value = null;
554
+ }
555
+ }), u = q({
556
+ get() {
557
+ return x.value === null ? "" : Ze(x.value);
558
+ },
559
+ set(n) {
560
+ n ? x.value = /* @__PURE__ */ new Date(`${n} ${g.value}`) : x.value = null;
561
+ }
562
+ }), g = q({
563
+ get() {
564
+ return x.value === null ? "" : mo(x.value);
565
+ },
566
+ set(n) {
567
+ n ? x.value = /* @__PURE__ */ new Date(`${u.value} ${n}`) : x.value = null;
568
+ }
569
+ });
570
+ return {
571
+ backdatePo: x,
572
+ backdateSwitch: d,
573
+ backdateModel: u,
574
+ backdateTimeModel: g
575
+ };
576
+ }
577
+ const Ho = {
578
+ width: "24",
579
+ height: "24",
580
+ viewBox: "0 0 24 24",
581
+ fill: "none",
582
+ xmlns: "http://www.w3.org/2000/svg"
583
+ }, Qo = ["fill"], Yo = ["fill"], Ko = ["stroke"], Xo = ["stroke"], Zo = /* @__PURE__ */ ne({
584
+ __name: "SparkIcon",
585
+ props: {
586
+ size: {
587
+ type: Number,
588
+ default: 24
589
+ },
590
+ color: {
591
+ type: String,
592
+ default: "#c7c7cc"
593
+ }
594
+ },
595
+ setup(y) {
596
+ return (x, d) => (b(), T("svg", Ho, [
597
+ t("path", {
598
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
599
+ fill: y.color
600
+ }, null, 8, Qo),
601
+ t("path", {
602
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
603
+ fill: y.color
604
+ }, null, 8, Yo),
605
+ t("path", {
606
+ d: "M7.6 7.6C8.17076 6.94229 8.5 5.5 8.5 5.5C8.5 5.5 8.81356 6.87361 9.35714 7.5C9.92948 8.15953 11.5 8.5 11.5 8.5C11.5 8.5 9.92948 8.69761 9.35714 9.35714C8.81356 9.98354 8.5 11.5 8.5 11.5C8.5 11.5 8.32076 10.1888 7.75 9.59091C7.14905 8.96136 5.5 8.5 5.5 8.5C5.5 8.5 6.99905 8.29251 7.6 7.6Z",
607
+ stroke: y.color,
608
+ "stroke-width": "1.5",
609
+ "stroke-linecap": "round",
610
+ "stroke-linejoin": "round"
611
+ }, null, 8, Ko),
612
+ t("path", {
613
+ d: "M12.2 12.2C13.3415 10.8846 14 8 14 8C14 8 14.6271 10.7472 15.7143 12C16.859 13.3191 20 14 20 14C20 14 16.859 14.3952 15.7143 15.7143C14.6271 16.9671 14 20 14 20C14 20 13.6415 17.3777 12.5 16.1818C11.2981 14.9227 8 14 8 14C8 14 10.9981 13.585 12.2 12.2Z",
614
+ stroke: y.color,
615
+ "stroke-width": "1.5",
616
+ "stroke-linecap": "round",
617
+ "stroke-linejoin": "round"
618
+ }, null, 8, Xo)
619
+ ]));
620
+ }
621
+ }), Wo = { class: "flex gap-8 items-center" }, Jo = { class: "fm-typo-en-body-lg-600 line-clamp-1" }, Go = { class: "w-[343px] px-24 py-16 rounded-lg shadow-light-300 flex flex-col gap-[20px]" }, es = { class: "flex items-center w-full" }, ts = { class: "flex-1" }, os = { class: "fm-typo-en-title-sm-800" }, ss = { class: "flex items-start gap-8" }, as = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, rs = { class: "flex gap-1" }, ls = /* @__PURE__ */ ne({
622
+ __name: "ForecastStock",
623
+ props: {
624
+ templateId: {},
625
+ disabled: { type: Boolean },
626
+ poItems: {},
627
+ templateItems: {}
628
+ },
629
+ emits: ["update:poItems", "update:forecastAmounts", "update:predictionId"],
630
+ setup(y, { emit: x }) {
631
+ const d = y, u = x, g = U(!1), n = U(7), h = Kt(), S = we(), { t: V } = ye();
632
+ function w(a, r, s) {
633
+ return r != null && a < r && (a = r), s != null && a > s && (a = s), a;
634
+ }
635
+ function v(a) {
636
+ if (!((a == null ? void 0 : a.amount) == null || (a == null ? void 0 : a.precision) == null))
637
+ return a.amount / Math.pow(10, a.precision);
638
+ }
639
+ function i({
640
+ sku: a,
641
+ code: r,
642
+ name: s,
643
+ baseAmount: _,
644
+ measurement: F,
645
+ min: c,
646
+ max: f
647
+ }) {
648
+ if (F) {
649
+ const I = F.conversion.amount;
650
+ let A = Math.ceil(_ / I);
651
+ return A = w(A, c, f), {
652
+ sku: a,
653
+ code: r,
654
+ name: s,
655
+ quantity: { amount: A, precision: 0 },
656
+ measurement: F
657
+ };
658
+ } else {
659
+ const I = Math.ceil(w(_, c, f));
660
+ return {
661
+ sku: a,
662
+ code: r,
663
+ name: s,
664
+ quantity: { amount: I, precision: 0 },
665
+ measurement: null
666
+ };
667
+ }
668
+ }
669
+ async function o() {
670
+ const a = mt(0)(n.value);
671
+ if (typeof a == "string") {
672
+ S.open({
673
+ message: a,
674
+ type: "error"
675
+ });
676
+ return;
677
+ }
678
+ g.value = !1, await h.readPurchaseOrder(n.value, d.templateId);
679
+ const r = h.purchaseOrderForecast.skus;
680
+ if (r.length === 0) {
681
+ S.open({
682
+ message: V("inventory.transfer.form.items.forecastStock.notAvailable"),
683
+ type: "info"
684
+ }), u("update:predictionId", h.purchaseOrderForecast.prediction_id);
685
+ return;
686
+ }
687
+ const s = d.templateItems.reduce((F, c) => {
688
+ var X;
689
+ const f = (X = d.poItems) == null ? void 0 : X.find((z) => z.sku._id === c.sku._id), I = r.find((z) => z.id === c.sku._id);
690
+ if (!I)
691
+ return f && F.push(f), F;
692
+ if (!d.templateId && I.amount <= 0) return F;
693
+ const A = I.amount ?? v(f == null ? void 0 : f.quantity) ?? 0;
694
+ return F.push(
695
+ i({
696
+ sku: c.sku,
697
+ code: c.code,
698
+ name: c.name,
699
+ baseAmount: A,
700
+ measurement: c.measurement || null,
701
+ min: v(c.minimumQuantity),
702
+ max: v(c.maximumQuantity)
703
+ })
704
+ ), F;
705
+ }, []), _ = r.map((F) => {
706
+ const c = d.templateItems.find((Z) => Z.sku._id === F.id);
707
+ let f = F.amount, I = 0;
708
+ if (c != null && c.measurement) {
709
+ const Z = v(c.measurement.conversion) ?? 1;
710
+ f = Math.ceil(F.amount / Z);
711
+ } else
712
+ f = Math.ceil(F.amount);
713
+ const A = v(c == null ? void 0 : c.minimumQuantity) ?? 0, X = v(c == null ? void 0 : c.maximumQuantity) ?? 1 / 0, z = f < A || f > X ? "error" : "success";
714
+ return { skuId: F.id, amount: f, precision: I, helperState: z };
715
+ });
716
+ u("update:poItems", s), u("update:forecastAmounts", _), u("update:predictionId", h.purchaseOrderForecast.prediction_id);
717
+ }
718
+ return (a, r) => {
719
+ const s = O("FmButton"), _ = O("FmIcon"), F = O("FmStepperField"), c = O("FmPopover");
720
+ return b(), oe(c, {
721
+ disabled: a.disabled,
722
+ class: "flex",
723
+ "show-popover": g.value,
724
+ onPopoverChanged: r[3] || (r[3] = (f) => g.value = f)
725
+ }, {
726
+ "popover-button": M(() => [
727
+ m(s, {
728
+ label: "unused",
729
+ variant: "secondary",
730
+ "text-color": a.disabled ? "disabled" : "primary",
731
+ "bg-color": "transparent",
732
+ "border-color": a.disabled ? "disabled" : "primary",
733
+ disabled: a.disabled
734
+ }, {
735
+ default: M(() => [
736
+ t("div", Wo, [
737
+ m(Zo, {
738
+ size: 24,
739
+ color: a.disabled ? "#c7c7cc" : "#ff7823"
740
+ }, null, 8, ["color"]),
741
+ t("div", Jo, $(e(V)("inventory.transfer.form.items.forecastStock.title")), 1)
742
+ ])
743
+ ]),
744
+ _: 1
745
+ }, 8, ["text-color", "border-color", "disabled"])
746
+ ]),
747
+ default: M(() => [
748
+ t("div", Go, [
749
+ t("div", es, [
750
+ t("div", ts, [
751
+ m(bo, { "z-index": 99 }, {
752
+ default: M(() => [
753
+ t("p", os, $(e(V)("inventory.transfer.form.items.forecastStock.title")), 1)
754
+ ]),
755
+ _: 1
756
+ })
757
+ ]),
758
+ m(s, {
759
+ icon: "close",
760
+ size: "md",
761
+ variant: "tertiary",
762
+ onClick: r[0] || (r[0] = (f) => g.value = !1)
763
+ })
764
+ ]),
765
+ m(F, {
766
+ modelValue: n.value,
767
+ "onUpdate:modelValue": r[1] || (r[1] = (f) => n.value = f),
768
+ label: e(V)("inventory.transfer.form.items.forecastStock.days"),
769
+ rules: [e(mt)(0)]
770
+ }, {
771
+ "helper-text": M(() => [
772
+ t("div", ss, [
773
+ m(_, {
774
+ name: "warning",
775
+ size: "sm",
776
+ class: "text-fm-color-system-warning-300"
777
+ }),
778
+ t("div", as, $(e(V)("inventory.transfer.form.items.forecastStock.replace")), 1)
779
+ ])
780
+ ]),
781
+ _: 1
782
+ }, 8, ["modelValue", "label", "rules"]),
783
+ t("div", rs, [
784
+ r[4] || (r[4] = t("div", { class: "grow" }, null, -1)),
785
+ m(s, {
786
+ label: e(V)("common.cancel"),
787
+ variant: "tertiary",
788
+ onClick: r[2] || (r[2] = (f) => g.value = !1)
789
+ }, null, 8, ["label"]),
790
+ m(s, {
791
+ label: e(V)("inventory.transfer.form.items.forecastStock.generate"),
792
+ onClick: o
793
+ }, null, 8, ["label"])
794
+ ])
795
+ ])
796
+ ]),
797
+ _: 1
798
+ }, 8, ["disabled", "show-popover"]);
799
+ };
800
+ }
801
+ });
802
+ function ns() {
803
+ const y = we(), x = We(), d = U(!1);
804
+ he(d, (h) => {
805
+ h && (g.value = !0, u().finally(() => {
806
+ g.value = !1;
807
+ }));
808
+ });
809
+ async function u() {
810
+ try {
811
+ const { startDate: h, endDate: S } = po(6), v = (await x.getPurchaseOrders({ start: h, end: S })).filter(
812
+ (i) => {
813
+ var o, a;
814
+ return i.status === Mt.enum.COMPLETE && ((o = i.supplier) == null ? void 0 : o.internal) !== "warehouse" && ((a = i.supplier) == null ? void 0 : a.internal) !== "restaurant";
815
+ }
816
+ ).reduce((i, o) => {
817
+ const a = new Date(Et(o._id)), r = o.supplier._id;
818
+ for (const s of o.items) {
819
+ if (!s.totalCost) continue;
820
+ const _ = i[s.sku._id] ?? {}, F = _[r] ?? [];
821
+ F.push({
822
+ date: a.toISOString(),
823
+ totalUnit: s.quantity,
824
+ totalCost: s.totalCost,
825
+ unit: s.sku.unit,
826
+ measurement: s.measurement,
827
+ seqNumber: o.seqNumber
828
+ }), _[r] = F, i[s.sku._id] = _;
829
+ }
830
+ return i;
831
+ }, {});
832
+ n.value = v;
833
+ } catch {
834
+ y.open({
835
+ title: "Something went wrong",
836
+ message: "Cannot retrieve supplier purchase history. Please try again."
837
+ }), d.value = !1;
838
+ }
839
+ }
840
+ const g = U(!1), n = U({});
841
+ return {
842
+ comparePricesToggle: d,
843
+ comparePriceFetching: g,
844
+ comparePriceBySku: n
845
+ };
846
+ }
847
+ const is = { class: "fm-typo-body-md-400 line-clamp-2 w-full" }, us = { key: 0 }, ds = ["colspan"], cs = /* @__PURE__ */ ne({
848
+ __name: "TransferItemTable",
849
+ props: {
850
+ templateItem: {},
851
+ row: {},
852
+ comparePriceBySku: {},
853
+ showComparePrice: { type: Boolean },
854
+ disabled: { type: Boolean }
855
+ },
856
+ emits: ["update:item"],
857
+ setup(y) {
858
+ function x(d) {
859
+ return d.column.columnDef.meta;
860
+ }
861
+ return (d, u) => {
862
+ var g, n;
863
+ return b(), T(ae, null, [
864
+ t("tr", {
865
+ class: W(["border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm", {
866
+ "bg-fm-color-neutral-gray-100": d.row.getIsSelected()
867
+ }])
868
+ }, [
869
+ (b(!0), T(ae, null, fe(d.row.getVisibleCells(), (h) => {
870
+ var S, V, w, v;
871
+ return b(), T("td", {
872
+ key: h.id,
873
+ class: W(["h-[56px] text-fm-color-typo-primary", ((S = x(h)) == null ? void 0 : S.cellClass) ?? "px-16"]),
874
+ style: vt({
875
+ width: (V = x(h)) == null ? void 0 : V.width,
876
+ maxWidth: (w = x(h)) == null ? void 0 : w.maxWidth,
877
+ textAlign: ((v = x(h)) == null ? void 0 : v.textAlign) ?? "left"
878
+ })
879
+ }, [
880
+ t("span", is, [
881
+ m(e(ce), {
882
+ render: h.column.columnDef.cell,
883
+ props: h.getContext()
884
+ }, null, 8, ["render", "props"])
885
+ ])
886
+ ], 6);
887
+ }), 128))
888
+ ], 2),
889
+ d.showComparePrice && Object.keys(d.comparePriceBySku[(g = d.row.original.sku) == null ? void 0 : g._id] ?? {}).length > 0 ? (b(), T("tr", us, [
890
+ t("td", {
891
+ colspan: d.row.getVisibleCells().length
892
+ }, [
893
+ m(Ct, {
894
+ prices: d.comparePriceBySku[(n = d.row.original.sku) == null ? void 0 : n._id]
895
+ }, null, 8, ["prices"])
896
+ ], 8, ds)
897
+ ])) : Y("", !0)
898
+ ], 64);
899
+ };
900
+ }
901
+ }), ms = {
902
+ key: 0,
903
+ class: "flex flex-col gap-8"
904
+ }, ps = { class: "flex flex-col gap-4" }, fs = { class: "flex items-center gap-4" }, vs = {
905
+ key: 0,
906
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
907
+ }, ys = /* @__PURE__ */ ne({
908
+ __name: "NetSuiteField",
909
+ props: {
910
+ required: { type: Boolean },
911
+ disabled: { type: Boolean },
912
+ subsidiaryOptional: { type: Boolean },
913
+ supplier: {},
914
+ setting: {},
915
+ items: {},
916
+ onChange: { type: Function }
917
+ },
918
+ emits: ["netsuite:ready"],
919
+ setup(y, { emit: x }) {
920
+ const d = qe(), u = y, g = x, { t: n } = go(), h = U(!1), S = U();
921
+ function V() {
922
+ var a, r, s, _;
923
+ if (!u.supplier) return;
924
+ u.supplier.internal ? S.value = d.getNetSuiteLocation(
925
+ `${u.supplier.internal}_${u.supplier._id}`
926
+ ) : S.value = d.getNetSuiteVendor(u.supplier._id);
927
+ const i = u.supplier.internal ? d.getLocationSubsidiary((a = S.value) == null ? void 0 : a.netSuiteId).id : (r = S.value) == null ? void 0 : r.subsidiaryId, o = u.supplier.internal ? (s = d.currentLocationSubsidiary()) == null ? void 0 : s.id : (_ = d.currentVendorSubsidiary(u.supplier._id)) == null ? void 0 : _.id;
928
+ h.value = !(!d.isEnabled || i && d.isEnabled && i == o);
929
+ }
930
+ he(
931
+ () => u.supplier,
932
+ () => {
933
+ u.subsidiaryOptional && V();
934
+ },
935
+ { deep: !0 }
936
+ ), He(() => {
937
+ let i = {
938
+ id: "",
939
+ subsidiary: { id: "", name: "" },
940
+ errors: []
941
+ };
942
+ if (d.isReady) {
943
+ if (!d.isEnabled || !u.required) {
944
+ g("netsuite:ready", i);
945
+ return;
946
+ }
947
+ try {
948
+ const o = d.currentLocationSubsidiary();
949
+ u.setting ? i = {
950
+ ...u.setting,
951
+ subsidiary: {
952
+ id: o.id || "",
953
+ name: o.name
954
+ }
955
+ } : i = {
956
+ ...i,
957
+ subsidiary: {
958
+ id: o.id || "",
959
+ name: o.name
960
+ }
961
+ };
962
+ const a = d.getAvailableItems(o.id), r = u.items.filter((s) => {
963
+ if (s.measurement != null) {
964
+ const _ = d.getAvailableMeasurements(
965
+ s.sku._id,
966
+ o.id
967
+ );
968
+ return a.includes(s.sku._id) && _.includes(s.measurement.id);
969
+ }
970
+ return a.includes(s.sku._id);
971
+ }).map((s) => s.sku._id);
972
+ u.onChange(
973
+ u.items.filter((s) => r.includes(s.sku._id)),
974
+ i
975
+ );
976
+ } finally {
977
+ V(), h.value ? u.subsidiaryOptional && g("netsuite:ready", i) : g("netsuite:ready", i);
978
+ }
979
+ }
980
+ });
981
+ const w = q(
982
+ () => u.supplier.internal ? d.currentLocationSubsidiary() : d.currentVendorSubsidiary(u.supplier._id)
983
+ ), v = q(() => {
984
+ var i, o;
985
+ return S.value == null ? `Cannot find the NetSuite location for "${u.supplier.name}"` : `The subsidiary of the request
986
+ location is ${(o = d.getLocationSubsidiary((i = S.value) == null ? void 0 : i.netSuiteId)) == null ? void 0 : o.fullName}`;
987
+ });
988
+ return (i, o) => {
989
+ const a = O("FmLabel"), r = O("FmIcon"), s = O("FmField"), _ = O("FmTooltip");
990
+ return e(d).isEnabled && u.required ? (b(), T("div", ms, [
991
+ m(a, {
992
+ label: `NetSuite ${e(n)("inventory.transfer.form.netsuite.subsidiary")}`
993
+ }, null, 8, ["label"]),
994
+ t("div", ps, [
995
+ m(_, {
996
+ "z-index": 51,
997
+ placement: "left",
998
+ disabled: i.disabled
999
+ }, {
1000
+ content: M(() => o[0] || (o[0] = [
1001
+ ke("This field is locked and based on the location of the request.")
1002
+ ])),
1003
+ default: M(() => [
1004
+ m(s, null, {
1005
+ default: M(() => {
1006
+ var F;
1007
+ return [
1008
+ t("div", fs, [
1009
+ m(r, {
1010
+ name: "lock_outline",
1011
+ size: "sm",
1012
+ color: i.disabled ? "neutral-gray-200" : "neutral-gray-400"
1013
+ }, null, 8, ["color"]),
1014
+ t("div", {
1015
+ class: W([i.disabled ? "text-fm-color-typo-disabled" : ""])
1016
+ }, $((F = w.value) == null ? void 0 : F.fullName), 3)
1017
+ ])
1018
+ ];
1019
+ }),
1020
+ _: 1
1021
+ })
1022
+ ]),
1023
+ _: 1
1024
+ }, 8, ["disabled"]),
1025
+ h.value ? (b(), T("div", vs, $(v.value), 1)) : Y("", !0)
1026
+ ])
1027
+ ])) : Y("", !0);
1028
+ };
1029
+ }
1030
+ }), bs = { class: "flex flex-col gap-4" }, gs = { class: "flex items-center gap-8 overflow-x-auto pb-12" }, _s = { class: "flex flex-col gap-16" }, hs = { class: "flex flex-col gap-24" }, xs = { class: "flex flex-col gap-8" }, ks = { class: "flex flex-col gap-4" }, Cs = { class: "flex items-center gap-4" }, ws = { class: "flex flex-col gap-8" }, Ss = { class: "flex flex-col gap-4" }, Fs = { class: "flex items-center gap-4" }, $s = {
1031
+ key: 3,
1032
+ class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col"
1033
+ }, Is = {
1034
+ key: 0,
1035
+ class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
1036
+ }, Ds = { class: "flex-1" }, Ts = { class: "flex-1" }, Vs = {
1037
+ key: 1,
1038
+ class: "flex items-center gap-4"
1039
+ }, Ps = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary translate-y-[1px]" }, Rs = { class: "flex flex-col gap-16" }, Os = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, As = { class: "flex gap-8" }, Ms = { key: 0 }, Es = {
1040
+ key: 0,
1041
+ class: "flex justify-end p-16 border-t border-fm-color-neutral-gray-300"
1042
+ }, qs = { class: "flex items-center gap-16" }, Us = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-secondary" }, Ns = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Bs = {
1043
+ key: 1,
1044
+ class: "flex flex-col gap-16"
1045
+ }, zs = { class: "flex items-center gap-8" }, Ls = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, js = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mb-8" }, Hs = { class: "flex flex-col gap-8 border border-fm-color-neutral-gray-300 fm-corner-radius-md overflow-hidden" }, Qs = { class: "flex flex-col gap-4 flex-1" }, Ys = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ks = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Xs = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary whitespace-nowrap ml-16" }, Zs = /* @__PURE__ */ ne({
1046
+ __name: "TransferFormWithController",
1047
+ props: {
1048
+ modelValue: {},
1049
+ request: {},
1050
+ disabled: { type: Boolean },
1051
+ suppliers: {},
1052
+ skus: {},
1053
+ lastClosingDate: {}
1054
+ },
1055
+ emits: ["validation-success", "form:ready"],
1056
+ setup(y, { expose: x, emit: d }) {
1057
+ const u = y, g = d, { t: n } = ye(), h = Qe(), S = Ye(), V = uo(), w = Xe(), v = kt(), { breakpoints: i } = Ke(), o = q(() => i.value.xs || i.value.sm), a = zt();
1058
+ a.init(u.modelValue);
1059
+ const { controller: r, state: s } = a, _ = Vt({
1060
+ value: !1
1061
+ }), F = U(!1), c = U(0), f = U([]), I = U(void 0), A = q(
1062
+ () => {
1063
+ var l;
1064
+ return ((l = u.modelValue) == null ? void 0 : l.templateDoc) ?? v.templates.find((p) => {
1065
+ var j;
1066
+ return p._id === ((j = u.modelValue) == null ? void 0 : j.template);
1067
+ });
1068
+ }
1069
+ ), X = q(() => s.value.status === "DRAFT" || !s.value.rev), z = q(
1070
+ () => {
1071
+ var l;
1072
+ return ((l = s.value.items) == null ? void 0 : l.map((p) => p.item)) || [];
1073
+ }
1074
+ );
1075
+ He(async () => {
1076
+ await V.browse(), F.value = !0;
1077
+ }), he([F, _], ([l, p], [j, K]) => {
1078
+ p.value && K.value && g("form:ready");
1079
+ });
1080
+ const Z = q(
1081
+ () => h.currentLocation.type === qt.restaurant
1082
+ ), N = to(), B = vo(
1083
+ () => s.value,
1084
+ (l) => {
1085
+ r.value.selectSupplier(l.supplier._id);
1086
+ },
1087
+ !0,
1088
+ !w.businessSupplierOnly
1089
+ ), P = q({
1090
+ get() {
1091
+ var l;
1092
+ return typeof ((l = s.value.supplier) == null ? void 0 : l.internal) == "string" ? ue.enum.transfer : ue.enum.purchase;
1093
+ },
1094
+ set(l) {
1095
+ r.value.selectType(l);
1096
+ }
1097
+ }), D = q(() => {
1098
+ let l = B.transferLocationOptions.value;
1099
+ return w.mustUsePoTemplate && !s.value.template && (l = l.filter((p) => {
1100
+ var j;
1101
+ return (j = p.sublabel) == null ? void 0 : j.startsWith("restaurant");
1102
+ })), l;
1103
+ }), E = q({
1104
+ get() {
1105
+ var l;
1106
+ return (l = s.value.supplier) == null ? void 0 : l._id;
1107
+ },
1108
+ set(l) {
1109
+ B.transferLocationModel.value = l;
1110
+ }
1111
+ }), L = q({
1112
+ get() {
1113
+ return s.value.remark ?? "";
1114
+ },
1115
+ set(l) {
1116
+ r.value.addRemark(l ?? "");
1117
+ }
1118
+ }), J = q({
1119
+ get() {
1120
+ return s.value.ref ?? "";
1121
+ },
1122
+ set(l) {
1123
+ r.value.addReference(l ?? "");
1124
+ }
1125
+ }), { backdatePo: se, backdateSwitch: k, backdateModel: C, backdateTimeModel: H } = jo({
1126
+ getEffectiveAt() {
1127
+ return s.value.effectiveAt;
1128
+ },
1129
+ setEffectiveAt(l) {
1130
+ r.value.setEffectiveAt(l);
1131
+ }
1132
+ }), { comparePricesToggle: re, comparePriceFetching: ie, comparePriceBySku: ee } = ns(), be = U();
1133
+ x({
1134
+ validateInputs: () => {
1135
+ var l, p;
1136
+ (p = (l = be.value) == null ? void 0 : l.validateInputs) == null || p.call(l);
1137
+ },
1138
+ resetInputsValidation: () => {
1139
+ var l, p;
1140
+ (p = (l = be.value) == null ? void 0 : l.resetInputsValidation) == null || p.call(l);
1141
+ },
1142
+ resetInputs: () => {
1143
+ var l, p;
1144
+ (p = (l = be.value) == null ? void 0 : l.resetInputs) == null || p.call(l);
1145
+ },
1146
+ getFormData: () => {
1147
+ r.value.prepareForSubmit();
1148
+ const p = !!(s.value.id && s.value.rev) ? r.value.toUpdateData() : r.value.toCreateData();
1149
+ return I.value ? { ...p, predictionId: I.value } : p;
1150
+ }
1151
+ });
1152
+ const ve = q(() => ({
1153
+ updateItem: (l) => {
1154
+ const p = Ut.parse(l), j = r.value.toFdtoPOItem(p);
1155
+ r.value.updateSkuInfo(j);
1156
+ },
1157
+ deleteItem: (l) => {
1158
+ r.value.removeSku(l.sku);
1159
+ }
1160
+ })), Te = Fo({
1161
+ formController: r.value,
1162
+ updateItem: (l) => ve.value.updateItem(l),
1163
+ deleteItem: (l) => ve.value.deleteItem(l),
1164
+ get supplier() {
1165
+ return s.value.supplier;
1166
+ },
1167
+ get items() {
1168
+ return z.value;
1169
+ },
1170
+ get transferType() {
1171
+ return P.value;
1172
+ },
1173
+ get template() {
1174
+ return A.value;
1175
+ },
1176
+ get disabled() {
1177
+ return u.disabled;
1178
+ },
1179
+ get forecastAmounts() {
1180
+ return f.value;
1181
+ }
1182
+ }), Ve = q(() => Te.columnDefs.value);
1183
+ function Pe() {
1184
+ const l = r.value.getSkuOptions(), p = z.value.map((K) => K.sku._id), j = [
1185
+ {
1186
+ type: "string",
1187
+ key: "tags",
1188
+ entity: "item",
1189
+ values: ["Inactive", "Active"]
1190
+ }
1191
+ ];
1192
+ N.open({
1193
+ title: n("inventory.transfer.form.items.selectItem"),
1194
+ closeButton: !0,
1195
+ contentComponent: co,
1196
+ contentComponentProps: {
1197
+ modelValue: p,
1198
+ items: l,
1199
+ virtualScroll: !0,
1200
+ filterAttributes: j
1201
+ },
1202
+ primaryActions: {
1203
+ text: n("common.confirm"),
1204
+ close: !0
1205
+ },
1206
+ secondaryActions: {
1207
+ text: n("common.close"),
1208
+ close: !0,
1209
+ variant: "tertiary"
1210
+ }
1211
+ }).onPrimary((K) => {
1212
+ r.value.applySelectedSku(new Set(K));
1213
+ });
1214
+ }
1215
+ function Ue(l) {
1216
+ return l;
1217
+ }
1218
+ const xe = q(() => {
1219
+ var l;
1220
+ return A.value ? ((l = A.value) == null ? void 0 : l.purchaseOrder.items) || [] : S.skus.map((p) => ({
1221
+ quantity: {
1222
+ amount: 0,
1223
+ precision: 0
1224
+ },
1225
+ name: p.name,
1226
+ code: p.code,
1227
+ sku: p,
1228
+ quantityStep: {
1229
+ amount: 0,
1230
+ precision: 0
1231
+ },
1232
+ measurement: p.trackingMeasurement ? p.unit.measurements.find((j) => j.id === p.trackingMeasurement) : null
1233
+ }));
1234
+ }), Se = q(() => {
1235
+ const l = [];
1236
+ return (!w.mustUsePoTemplate || w.mustUsePoTemplate && s.value.template) && l.push({
1237
+ label: n("inventory.transfer.form.type.purchase"),
1238
+ value: ue.enum.purchase
1239
+ }), l.push({
1240
+ label: n("inventory.transfer.form.type.transfer"),
1241
+ value: ue.enum.transfer
1242
+ }), l;
1243
+ }), Fe = q(
1244
+ () => {
1245
+ var l;
1246
+ return ((l = s.value.items) == null ? void 0 : l.every((p) => p.item.quantity.amount <= 0)) ?? !0;
1247
+ }
1248
+ );
1249
+ function Re(l) {
1250
+ if (!l) return "";
1251
+ const p = [];
1252
+ if (l.$and && Array.isArray(l.$and))
1253
+ for (const j of l.$and) {
1254
+ if (j.supplierId && j.supplierId.$eq) {
1255
+ const K = D.value.find((le) => le.value === j.supplierId.$eq);
1256
+ K && p.push(`Supplier: ${K.label}`);
1257
+ }
1258
+ if (j.totalCost) {
1259
+ const K = j.totalCost;
1260
+ let le = "", me = 0;
1261
+ if (K.$lt !== void 0 ? (le = "<", me = K.$lt) : K.$lte !== void 0 ? (le = "≤", me = K.$lte) : K.$gt !== void 0 ? (le = ">", me = K.$gt) : K.$gte !== void 0 ? (le = "≥", me = K.$gte) : K.$eq !== void 0 && (le = "=", me = K.$eq), le) {
1262
+ const Oe = de();
1263
+ p.push(`Total cost ${le} ${Oe} ${me.toFixed(2)}`);
1264
+ }
1265
+ }
1266
+ }
1267
+ return p.length > 0 ? p.join(" and ") : "Always applied";
1268
+ }
1269
+ return (l, p) => {
1270
+ var et, tt;
1271
+ const j = O("FmChip"), K = O("FmLabel"), le = O("FmIcon"), me = O("FmField"), Oe = O("FmTooltip"), Je = O("FmSelect"), wt = O("FmTextField"), St = O("FmTextarea"), Ge = O("FmSwitch"), Ft = O("FmDatePicker"), $t = O("FmTimePicker"), Ne = O("FmFormGroup"), It = O("FmButton"), Dt = O("FmTable"), Tt = O("FmForm");
1272
+ return b(), T("div", bs, [
1273
+ t("div", gs, [
1274
+ (et = u.modelValue) != null && et.template ? (b(), oe(j, {
1275
+ key: 0,
1276
+ variant: l.disabled ? "warning" : void 0,
1277
+ label: `${e(n)("inventory.transfer.template.title")}: ${((tt = A.value) == null ? void 0 : tt.name) ?? e(n)("inventory.transfer.form.loading")}`,
1278
+ icon: "summarize",
1279
+ compact: ""
1280
+ }, null, 8, ["variant", "label"])) : Y("", !0),
1281
+ m(j, {
1282
+ label: e(h).currentLocation.name,
1283
+ icon: "storefront",
1284
+ compact: ""
1285
+ }, null, 8, ["label"]),
1286
+ l.lastClosingDate ? (b(), oe(j, {
1287
+ key: 1,
1288
+ label: `${e(n)("inventory.transfer.form.lastClosing")}: ${e(Ze)(l.lastClosingDate)} ${e(fo)(l.lastClosingDate)}`,
1289
+ icon: "calendar_month",
1290
+ compact: ""
1291
+ }, null, 8, ["label"])) : Y("", !0)
1292
+ ]),
1293
+ m(Tt, {
1294
+ ref_key: "formRef",
1295
+ ref: be,
1296
+ class: "flex flex-col gap-32",
1297
+ disabled: l.disabled,
1298
+ onValidationFailed: console.log,
1299
+ onValidationSuccess: p[15] || (p[15] = (Be) => g("validation-success"))
1300
+ }, {
1301
+ default: M(() => {
1302
+ var Be, ot, st, at, rt, lt, nt;
1303
+ return [
1304
+ t("div", _s, [
1305
+ t("div", hs, [
1306
+ (Be = u.modelValue) != null && Be.template ? (b(), T(ae, { key: 0 }, [
1307
+ t("div", xs, [
1308
+ m(K, {
1309
+ label: e(n)("inventory.transfer.form.type.title")
1310
+ }, null, 8, ["label"]),
1311
+ t("div", ks, [
1312
+ m(Oe, {
1313
+ "z-index": 51,
1314
+ placement: "left",
1315
+ disabled: l.disabled
1316
+ }, {
1317
+ content: M(() => p[16] || (p[16] = [
1318
+ ke("This field is locked from template.")
1319
+ ])),
1320
+ default: M(() => [
1321
+ m(me, null, {
1322
+ default: M(() => [
1323
+ t("div", Cs, [
1324
+ m(le, {
1325
+ name: "lock_outline",
1326
+ size: "sm",
1327
+ color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1328
+ }, null, 8, ["color"]),
1329
+ t("div", {
1330
+ class: W({ "text-fm-color-typo-disabled": l.disabled })
1331
+ }, $(e(n)(`inventory.transfer.form.type.${P.value.toLocaleLowerCase("en-us")}`)), 3)
1332
+ ])
1333
+ ]),
1334
+ _: 1
1335
+ })
1336
+ ]),
1337
+ _: 1
1338
+ }, 8, ["disabled"]),
1339
+ t("div", {
1340
+ class: W([
1341
+ "fm-typo-en-body-sm-400",
1342
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"
1343
+ ])
1344
+ }, null, 2)
1345
+ ])
1346
+ ]),
1347
+ t("div", ws, [
1348
+ m(K, {
1349
+ label: P.value === e(ue).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom")
1350
+ }, null, 8, ["label"]),
1351
+ t("div", Ss, [
1352
+ m(Oe, {
1353
+ "z-index": 51,
1354
+ placement: "left",
1355
+ disabled: l.disabled
1356
+ }, {
1357
+ content: M(() => p[17] || (p[17] = [
1358
+ ke("This field is locked from template.")
1359
+ ])),
1360
+ default: M(() => [
1361
+ m(me, null, {
1362
+ default: M(() => {
1363
+ var R;
1364
+ return [
1365
+ t("div", Fs, [
1366
+ m(le, {
1367
+ name: "lock_outline",
1368
+ size: "sm",
1369
+ color: l.disabled ? "neutral-gray-200" : "neutral-gray-400"
1370
+ }, null, 8, ["color"]),
1371
+ t("div", {
1372
+ class: W({ "text-fm-color-typo-disabled": l.disabled })
1373
+ }, $((R = D.value.find((G) => G.value === E.value)) == null ? void 0 : R.label), 3)
1374
+ ])
1375
+ ];
1376
+ }),
1377
+ _: 1
1378
+ })
1379
+ ]),
1380
+ _: 1
1381
+ }, 8, ["disabled"])
1382
+ ])
1383
+ ])
1384
+ ], 64)) : (b(), T(ae, { key: 1 }, [
1385
+ m(Je, {
1386
+ label: e(n)("inventory.transfer.form.type.title"),
1387
+ "label-mark": "required",
1388
+ modelValue: P.value,
1389
+ "onUpdate:modelValue": p[0] || (p[0] = (R) => P.value = R),
1390
+ items: Se.value,
1391
+ rules: [e(Ee)(1)(Se.value)]
1392
+ }, {
1393
+ default: M(() => [
1394
+ t("span", {
1395
+ class: W([
1396
+ "line-clamp-1 fm-typo-en-body-lg-400",
1397
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1398
+ ])
1399
+ }, $(e(Nt)(P.value)), 3)
1400
+ ]),
1401
+ _: 1
1402
+ }, 8, ["label", "modelValue", "items", "rules"]),
1403
+ m(Je, {
1404
+ label: P.value === e(ue).enum.purchase ? e(n)("inventory.transfer.form.purchaseFrom") : e(n)("inventory.transfer.form.transferFrom"),
1405
+ "label-mark": "required",
1406
+ modelValue: E.value,
1407
+ "onUpdate:modelValue": p[1] || (p[1] = (R) => E.value = R),
1408
+ items: D.value,
1409
+ rules: [e(Ee)(1)(D.value)]
1410
+ }, {
1411
+ "menu-wrapper": M((R) => {
1412
+ var G, $e;
1413
+ return [
1414
+ m(yo, je(R, {
1415
+ items: D.value,
1416
+ "model-value": ($e = (G = l.modelValue) == null ? void 0 : G.supplier) == null ? void 0 : $e._id
1417
+ }), null, 16, ["items", "model-value"])
1418
+ ];
1419
+ }),
1420
+ default: M(() => {
1421
+ var R;
1422
+ return [
1423
+ t("span", {
1424
+ class: W([
1425
+ "line-clamp-1 fm-typo-en-body-lg-400",
1426
+ l.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-primary"
1427
+ ])
1428
+ }, $((R = D.value.find((G) => G.value === E.value)) == null ? void 0 : R.label), 3)
1429
+ ];
1430
+ }),
1431
+ _: 1
1432
+ }, 8, ["label", "modelValue", "items", "rules"])
1433
+ ], 64)),
1434
+ m(wt, {
1435
+ label: e(n)("inventory.transfer.form.reference"),
1436
+ "label-mark": "optional",
1437
+ modelValue: J.value,
1438
+ "onUpdate:modelValue": p[2] || (p[2] = (R) => J.value = R)
1439
+ }, null, 8, ["label", "modelValue"]),
1440
+ m(St, {
1441
+ label: e(n)("inventory.transfer.form.remark"),
1442
+ "label-mark": "optional",
1443
+ "max-length": 240,
1444
+ modelValue: L.value,
1445
+ "onUpdate:modelValue": p[3] || (p[3] = (R) => L.value = R),
1446
+ class: W([l.disabled ? "text-fm-color-typo-disabled " : ""])
1447
+ }, null, 8, ["label", "modelValue", "class"]),
1448
+ F.value ? (b(), oe(ys, {
1449
+ key: 2,
1450
+ required: e(s).template != null || e(s).netSuite != null,
1451
+ subsidiaryOptional: e(s).template == null,
1452
+ disabled: l.disabled,
1453
+ supplier: e(s).supplier,
1454
+ setting: e(s).netSuite,
1455
+ items: z.value,
1456
+ onChange: (R, G) => {
1457
+ e(r).setNetSuiteSetting(G);
1458
+ },
1459
+ "onNetsuite:ready": p[4] || (p[4] = (R) => {
1460
+ _.value = !0;
1461
+ })
1462
+ }, null, 8, ["required", "subsidiaryOptional", "disabled", "supplier", "setting", "items", "onChange"])) : Y("", !0),
1463
+ e(w).enableBackdatePo ? (b(), T("div", $s, [
1464
+ t("div", {
1465
+ class: W([
1466
+ "flex",
1467
+ {
1468
+ "flex-col": o.value
1469
+ }
1470
+ ])
1471
+ }, [
1472
+ m(Ge, {
1473
+ modelValue: e(k),
1474
+ "onUpdate:modelValue": p[5] || (p[5] = (R) => ge(k) ? k.value = R : null),
1475
+ label: e(n)("inventory.transfer.form.backdate.title"),
1476
+ sublabel: e(n)("inventory.transfer.form.backdate.subtitle"),
1477
+ "label-placement": "right",
1478
+ disabled: Z.value && !l.lastClosingDate || l.disabled
1479
+ }, null, 8, ["modelValue", "label", "sublabel", "disabled"]),
1480
+ t("div", {
1481
+ class: W({ hidden: o.value, "w-16": !o.value })
1482
+ }, null, 2),
1483
+ e(k) ? (b(), T("div", Is, [
1484
+ t("div", Ds, [
1485
+ m(Ft, {
1486
+ modelValue: e(C),
1487
+ "onUpdate:modelValue": p[6] || (p[6] = (R) => ge(C) ? C.value = R : null)
1488
+ }, null, 8, ["modelValue"])
1489
+ ]),
1490
+ t("div", Ts, [
1491
+ m($t, {
1492
+ modelValue: e(H),
1493
+ "onUpdate:modelValue": p[7] || (p[7] = (R) => ge(H) ? H.value = R : null)
1494
+ }, null, 8, ["modelValue"])
1495
+ ])
1496
+ ])) : Y("", !0)
1497
+ ], 2),
1498
+ e(se) ? (b(), oe(Ne, {
1499
+ key: 0,
1500
+ modelValue: e(se),
1501
+ "onUpdate:modelValue": p[8] || (p[8] = (R) => ge(se) ? se.value = R : null),
1502
+ rules: [e(so)(new Date(l.lastClosingDate), /* @__PURE__ */ new Date())]
1503
+ }, null, 8, ["modelValue", "rules"])) : Y("", !0),
1504
+ Z.value && !l.lastClosingDate ? (b(), T("div", Vs, [
1505
+ m(le, {
1506
+ name: "error",
1507
+ size: "sm",
1508
+ class: "text-fm-color-typo-warning"
1509
+ }),
1510
+ t("span", Ps, $(e(n)("inventory.transfer.form.backdate.error")), 1)
1511
+ ])) : Y("", !0)
1512
+ ])) : Y("", !0)
1513
+ ])
1514
+ ]),
1515
+ t("div", Rs, [
1516
+ m(Ne, {
1517
+ "model-value": z.value,
1518
+ rules: [e(Ee)(1)]
1519
+ }, null, 8, ["model-value", "rules"]),
1520
+ t("div", {
1521
+ class: W([
1522
+ "flex gap-16",
1523
+ {
1524
+ "flex-col items-start": o.value,
1525
+ "items-center": !o.value
1526
+ }
1527
+ ])
1528
+ }, [
1529
+ t("div", Os, $(e(n)("inventory.transfer.form.items.title")), 1),
1530
+ t("div", As, [
1531
+ m(It, {
1532
+ disabled: l.disabled,
1533
+ label: e(n)("inventory.transfer.form.items.addItem"),
1534
+ "prepend-icon": "add",
1535
+ variant: "secondary",
1536
+ "text-color": "primary",
1537
+ "bg-color": "transparent",
1538
+ "border-color": "primary",
1539
+ onClick: p[9] || (p[9] = (R) => Pe()),
1540
+ size: "md"
1541
+ }, null, 8, ["disabled", "label"]),
1542
+ m(ls, {
1543
+ "template-id": e(s).template || void 0,
1544
+ "template-items": xe.value,
1545
+ "po-items": z.value,
1546
+ "onUpdate:forecastAmounts": p[10] || (p[10] = (R) => {
1547
+ f.value = R;
1548
+ }),
1549
+ "onUpdate:poItems": p[11] || (p[11] = (R) => {
1550
+ e(r).updateItems(R), c.value++;
1551
+ }),
1552
+ "onUpdate:predictionId": p[12] || (p[12] = (R) => {
1553
+ I.value = R;
1554
+ })
1555
+ }, null, 8, ["template-id", "template-items", "po-items"])
1556
+ ])
1557
+ ], 2),
1558
+ P.value === e(ue).enum.purchase && X.value && e(w).enableTotalCost && z.value.length ? (b(), T("div", Ms, [
1559
+ m(Ge, {
1560
+ label: e(ie) ? e(n)("inventory.transfer.form.items.fetchingData") : e(n)("inventory.transfer.form.items.comparePriceHistory"),
1561
+ "prepend-icon": "compare_arrows",
1562
+ "label-placement": "right",
1563
+ "model-value": e(re),
1564
+ "onUpdate:modelValue": p[13] || (p[13] = (R) => ge(re) ? re.value = R : null),
1565
+ disabled: e(ie) || l.disabled
1566
+ }, null, 8, ["label", "model-value", "disabled"])
1567
+ ])) : Y("", !0),
1568
+ m(Ne, {
1569
+ "model-value": Fe.value,
1570
+ rules: [() => Fe.value ? "Must have at least one non-zero item" : !0]
1571
+ }, null, 8, ["model-value", "rules"]),
1572
+ (b(), oe(Dt, {
1573
+ "column-defs": Ve.value,
1574
+ "column-visibility": {
1575
+ [e(te).Code]: !(((ot = l.modelValue) == null ? void 0 : ot.template) ?? ((st = l.modelValue) == null ? void 0 : st.templateDoc)),
1576
+ [e(te).Name]: !(((at = l.modelValue) == null ? void 0 : at.template) ?? ((rt = l.modelValue) == null ? void 0 : rt.templateDoc)),
1577
+ [e(te).TemplateName]: !!(((lt = l.modelValue) == null ? void 0 : lt.template) ?? ((nt = l.modelValue) == null ? void 0 : nt.templateDoc))
1578
+ },
1579
+ "row-data": z.value,
1580
+ key: c.value,
1581
+ "hide-footer": "",
1582
+ "page-size": z.value.length
1583
+ }, {
1584
+ "table-row": M((R) => {
1585
+ var G, $e, it, ut;
1586
+ return [
1587
+ m(cs, {
1588
+ "compare-price-by-sku": e(ee),
1589
+ "show-compare-price": P.value === e(ue).enum.purchase && e(re),
1590
+ row: R,
1591
+ "template-item": (ut = (it = ($e = (G = l.modelValue) == null ? void 0 : G.templateDoc) == null ? void 0 : $e.purchaseOrder) == null ? void 0 : it.items) == null ? void 0 : ut.find(
1592
+ (ze) => ze.sku._id === R.original.sku._id
1593
+ ),
1594
+ "onUpdate:item": p[14] || (p[14] = (ze) => ve.value.updateItem(ze)),
1595
+ disabled: l.disabled
1596
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "template-item", "disabled"])
1597
+ ];
1598
+ }),
1599
+ "list-row": M((R) => [
1600
+ (b(), oe(ht, {
1601
+ row: R,
1602
+ key: z.value.map((G) => G.sku._id).join(".")
1603
+ }, {
1604
+ default: M((G) => [
1605
+ m(Lo, {
1606
+ "compare-price-by-sku": e(ee),
1607
+ "show-compare-price": P.value === e(ue).enum.purchase && e(re),
1608
+ row: R,
1609
+ "cell-by-col-id": G
1610
+ }, null, 8, ["compare-price-by-sku", "show-compare-price", "row", "cell-by-col-id"])
1611
+ ]),
1612
+ _: 2
1613
+ }, 1032, ["row"]))
1614
+ ]),
1615
+ _: 1
1616
+ }, 8, ["column-defs", "column-visibility", "row-data", "page-size"]))
1617
+ ]),
1618
+ e(w).enableTotalCost ? (b(), T("div", Es, [
1619
+ t("div", qs, [
1620
+ t("div", Us, $(e(n)("inventory.transfer.form.surcharges.totalCost")), 1),
1621
+ t("div", Ns, $(e(de)()) + " " + $(e(Ce)({
1622
+ ...e(r).getTotalCosts(),
1623
+ currency: e(de)()
1624
+ }).replace(/[^0-9.,]/g, "")), 1)
1625
+ ])
1626
+ ])) : Y("", !0),
1627
+ e(r).getMatchedSurcharges().length > 0 ? (b(), T("div", Bs, [
1628
+ t("div", zs, [
1629
+ t("div", Ls, $(e(n)("inventory.transfer.form.surcharges.title")), 1),
1630
+ m(j, {
1631
+ label: e(n)("inventory.transfer.form.surcharges.autoApplied"),
1632
+ icon: "auto_awesome",
1633
+ variant: "info",
1634
+ compact: ""
1635
+ }, null, 8, ["label"])
1636
+ ]),
1637
+ t("div", js, $(e(n)("inventory.transfer.form.surcharges.appliedBased")), 1),
1638
+ t("div", Hs, [
1639
+ (b(!0), T(ae, null, fe(e(r).getMatchedSurcharges(), (R, G) => (b(), T("div", {
1640
+ key: G,
1641
+ class: W([
1642
+ "p-16 flex items-center justify-between",
1643
+ G !== e(r).getMatchedSurcharges().length - 1 ? "border-b border-fm-color-neutral-gray-300" : ""
1644
+ ])
1645
+ }, [
1646
+ t("div", Qs, [
1647
+ t("div", Ys, $(R.item.name), 1),
1648
+ t("div", Ks, $(e(n)("inventory.transfer.form.surcharges.appliedBased")) + ": " + $(Re(R.surcharge.rule)), 1)
1649
+ ]),
1650
+ t("div", Xs, $(e(de)()) + " " + $(e(Ce)(R.item.totalCost).replace(/[^0-9.,]/g, "")), 1)
1651
+ ], 2))), 128))
1652
+ ])
1653
+ ])) : Y("", !0)
1654
+ ];
1655
+ }),
1656
+ _: 1
1657
+ }, 8, ["disabled", "onValidationFailed"])
1658
+ ]);
1659
+ };
1660
+ }
1661
+ }), Ws = { class: "flex items-center" }, Js = { class: "fm-typo-en-title-md-800" }, Gs = { class: "flex gap-4" }, ea = { class: "fm-typo-en-title-md-600" }, ta = { class: "flex flex-col gap-16" }, oa = { class: "fm-typo-en-body-md-400" }, sa = { class: "max-h-[300px] overflow-y-auto" }, aa = { class: "list-disc pl-16" }, ra = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, la = { class: "flex w-full gap-8 justify-end" }, na = /* @__PURE__ */ ne({
1662
+ __name: "TransferDialog",
1663
+ props: {
1664
+ mode: {},
1665
+ modelValue: {},
1666
+ templateId: {},
1667
+ show: { type: Boolean },
1668
+ lastClosingDate: {}
1669
+ },
1670
+ emits: ["update:show", "submitted"],
1671
+ setup(y, { expose: x, emit: d }) {
1672
+ var se;
1673
+ const u = y, g = d, n = We(), h = kt(), S = we(), V = xt(), w = Ye(), v = Qe(), { t: i } = ye(), o = U(!1), a = U(!1), r = U(!1), s = U(!1), _ = q(() => {
1674
+ var k;
1675
+ return ((k = I.value.items) == null ? void 0 : k.filter((C) => C.quantity.amount === 0)) ?? [];
1676
+ });
1677
+ async function F(k) {
1678
+ if (k) {
1679
+ a.value = !1;
1680
+ try {
1681
+ await V.readSuppliers(), a.value = !0;
1682
+ } catch {
1683
+ S.open({
1684
+ title: i("inventory.transfer.form.unableToFetchListOfSuppliers.title"),
1685
+ message: i("inventory.transfer.form.unableToFetchListOfSuppliers.message"),
1686
+ type: "error"
1687
+ });
1688
+ }
1689
+ }
1690
+ }
1691
+ v.watchLocation(F);
1692
+ function c() {
1693
+ return {
1694
+ remark: void 0,
1695
+ ref: void 0,
1696
+ stockSnapshotId: void 0,
1697
+ effectiveAt: void 0,
1698
+ items: [],
1699
+ supplier: {
1700
+ _rev: void 0,
1701
+ email: void 0,
1702
+ internal: void 0,
1703
+ contactName: void 0,
1704
+ phoneNumber: void 0,
1705
+ registrationNumber: void 0,
1706
+ supplyItems: void 0,
1707
+ _id: "",
1708
+ name: "",
1709
+ address: {
1710
+ line2: void 0,
1711
+ line1: "",
1712
+ state: "",
1713
+ city: "",
1714
+ postcode: "",
1715
+ country: ""
1716
+ }
1717
+ },
1718
+ status: "DRAFT",
1719
+ _id: "",
1720
+ seqNumber: 0,
1721
+ deliveryOrder: [],
1722
+ template: u.templateId,
1723
+ templateDoc: h.templates.find((C) => C._id === u.templateId)
1724
+ };
1725
+ }
1726
+ const f = _t(u, "show"), I = U(u.modelValue ?? c()), A = U(((se = u.modelValue) == null ? void 0 : se._id) ?? `${Math.random()}`);
1727
+ he(
1728
+ () => u.show,
1729
+ (k) => {
1730
+ var C;
1731
+ k && (r.value = !1, I.value = u.modelValue ?? c(), A.value = ((C = u.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
1732
+ }
1733
+ );
1734
+ const X = q(() => !a.value || !r.value), z = q(() => {
1735
+ switch (u.mode) {
1736
+ case Ie.READ:
1737
+ return "View transfer";
1738
+ case Ie.CREATE:
1739
+ return i("inventory.transfer.receiveRequest.create.title");
1740
+ case Ie.UPDATE:
1741
+ return i("inventory.transfer.receiveRequest.update.title");
1742
+ }
1743
+ return "";
1744
+ }), Z = U();
1745
+ x({
1746
+ validateInputs: () => {
1747
+ var k, C;
1748
+ (C = (k = Z.value) == null ? void 0 : k.validateInputs) == null || C.call(k);
1749
+ },
1750
+ resetInputsValidation: () => {
1751
+ var k, C;
1752
+ (C = (k = Z.value) == null ? void 0 : k.resetInputsValidation) == null || C.call(k);
1753
+ },
1754
+ resetInputs: () => {
1755
+ var k, C;
1756
+ (C = (k = Z.value) == null ? void 0 : k.resetInputs) == null || C.call(k);
1757
+ }
1758
+ });
1759
+ async function N() {
1760
+ const k = I.value;
1761
+ if (o.value = !0, k.items = k.items.filter((C) => C.quantity.amount > 0), !k.items.length) {
1762
+ S.open({
1763
+ title: "Cannot create order",
1764
+ message: "There are no items with non-zero amount in your request.",
1765
+ type: "error"
1766
+ });
1767
+ return;
1768
+ }
1769
+ (k.supplier.internal === "warehouse" || k.supplier.internal === "restaurant") && (k.items = k.items.map(({ totalCost: C, ...H }) => H));
1770
+ try {
1771
+ await n.createPurchaseOrder(k), await new Promise((C) => setTimeout(C, 1e3)), S.open({
1772
+ title: i("inventory.transfer.receiveRequest.create.success"),
1773
+ message: i("inventory.transfer.receiveRequest.create.successMessage"),
1774
+ type: "success"
1775
+ }), g("update:show", !1), g("submitted");
1776
+ } catch (C) {
1777
+ S.open({
1778
+ title: i("inventory.transfer.receiveRequest.create.error.title"),
1779
+ message: i("inventory.transfer.receiveRequest.create.error.message"),
1780
+ type: "error"
1781
+ }), console.error("Error in creating purchase order", C);
1782
+ } finally {
1783
+ o.value = !1;
1784
+ }
1785
+ }
1786
+ async function B() {
1787
+ const k = I.value;
1788
+ if (o.value = !0, k.items = k.items.filter((C) => C.quantity.amount > 0), !k.items.length) {
1789
+ S.open({
1790
+ title: "Cannot create order",
1791
+ message: "There are no items with non-zero amount in your request.",
1792
+ type: "error"
1793
+ });
1794
+ return;
1795
+ }
1796
+ (k.supplier.internal === "warehouse" || k.supplier.internal === "restaurant") && (k.items = k.items.map(({ totalCost: C, ...H }) => H));
1797
+ try {
1798
+ await n.updatePurchaseOrder(k), await new Promise((C) => setTimeout(C, 1e3)), S.open({
1799
+ title: i("inventory.transfer.receiveRequest.update.success"),
1800
+ message: i("inventory.transfer.receiveRequest.update.successMessage"),
1801
+ type: "success"
1802
+ }), g("update:show", !1), g("submitted");
1803
+ } catch (C) {
1804
+ S.open({
1805
+ title: i("inventory.transfer.receiveRequest.update.error.title"),
1806
+ message: i("inventory.transfer.receiveRequest.update.error.message"),
1807
+ type: "error"
1808
+ }), console.error("Error in updating purchase order", C);
1809
+ } finally {
1810
+ o.value = !1;
1811
+ }
1812
+ }
1813
+ function P() {
1814
+ switch (u.mode) {
1815
+ case Ie.CREATE:
1816
+ return N();
1817
+ case Ie.UPDATE:
1818
+ return B();
1819
+ }
1820
+ }
1821
+ function D() {
1822
+ var k;
1823
+ I.value.items = ((k = I.value.items) == null ? void 0 : k.filter((C) => C.quantity.amount > 0)) ?? [], s.value = !1, L();
1824
+ }
1825
+ function E() {
1826
+ Z.value.getFormData && (I.value = {
1827
+ ...I.value,
1828
+ ...Z.value.getFormData()
1829
+ });
1830
+ }
1831
+ function L() {
1832
+ var H, re;
1833
+ const k = io.validatePurchaseOrderItems({
1834
+ skusById: w.skuById ?? {},
1835
+ items: I.value.items ?? []
1836
+ }), C = Object.values(k).flat();
1837
+ if (C.length > 0) {
1838
+ const ie = C[0];
1839
+ S.open({
1840
+ title: `[Row ${ie.index + 1}] "${ie.poItem.sku.name}"`,
1841
+ message: `${ie.message}`,
1842
+ type: "error"
1843
+ });
1844
+ return;
1845
+ }
1846
+ (re = (H = Z.value) == null ? void 0 : H.validateInputs) == null || re.call(H);
1847
+ }
1848
+ function J() {
1849
+ if (E(), _.value.length > 0) {
1850
+ s.value = !0;
1851
+ return;
1852
+ }
1853
+ L();
1854
+ }
1855
+ return (k, C) => {
1856
+ const H = O("FmButton"), re = O("FmSideSheet"), ie = O("FmDialog");
1857
+ return b(), T(ae, null, [
1858
+ m(re, {
1859
+ modelValue: e(f),
1860
+ "onUpdate:modelValue": C[3] || (C[3] = (ee) => ge(f) ? f.value = ee : null),
1861
+ "dismiss-away": "",
1862
+ "close-button": "",
1863
+ "max-width": 900
1864
+ }, {
1865
+ "side-sheet-header": M(() => [
1866
+ t("div", Ws, [
1867
+ t("div", Js, $(z.value), 1)
1868
+ ])
1869
+ ]),
1870
+ default: M(() => [
1871
+ (b(), oe(Zs, {
1872
+ class: "w-full",
1873
+ ref_key: "formRef",
1874
+ ref: Z,
1875
+ "onForm:ready": C[0] || (C[0] = () => r.value = !0),
1876
+ onValidationSuccess: P,
1877
+ modelValue: I.value,
1878
+ "onUpdate:modelValue": C[1] || (C[1] = (ee) => I.value = ee),
1879
+ disabled: o.value || X.value,
1880
+ suppliers: e(V).suppliers,
1881
+ skus: e(w).skus,
1882
+ key: A.value,
1883
+ "last-closing-date": k.lastClosingDate
1884
+ }, null, 8, ["modelValue", "disabled", "suppliers", "skus", "last-closing-date"]))
1885
+ ]),
1886
+ "side-sheet-footer": M(() => [
1887
+ t("div", Gs, [
1888
+ m(H, {
1889
+ loading: o.value,
1890
+ disabled: X.value,
1891
+ label: e(i)("common.save"),
1892
+ onClick: J
1893
+ }, null, 8, ["loading", "disabled", "label"]),
1894
+ m(H, {
1895
+ disabled: X.value,
1896
+ variant: "tertiary",
1897
+ label: e(i)("common.close"),
1898
+ onClick: C[2] || (C[2] = (ee) => g("update:show", !1))
1899
+ }, null, 8, ["disabled", "label"])
1900
+ ])
1901
+ ]),
1902
+ _: 1
1903
+ }, 8, ["modelValue"]),
1904
+ m(ie, {
1905
+ modelValue: s.value,
1906
+ "onUpdate:modelValue": C[5] || (C[5] = (ee) => s.value = ee),
1907
+ overlay: !0
1908
+ }, {
1909
+ "dialog-header": M(() => [
1910
+ t("div", ea, $(e(i)("inventory.transfer.template.zeroQuantity.title")), 1)
1911
+ ]),
1912
+ "dialog-footer": M(() => [
1913
+ t("div", la, [
1914
+ m(H, {
1915
+ label: e(i)("common.cancel"),
1916
+ variant: "tertiary",
1917
+ onClick: C[4] || (C[4] = (ee) => s.value = !1)
1918
+ }, null, 8, ["label"]),
1919
+ m(H, {
1920
+ label: e(i)("inventory.transfer.template.zeroQuantity.removeAll"),
1921
+ variant: "primary",
1922
+ "prepend-icon": "delete",
1923
+ onClick: D
1924
+ }, null, 8, ["label"])
1925
+ ])
1926
+ ]),
1927
+ default: M(() => [
1928
+ t("div", ta, [
1929
+ t("div", oa, $(e(i)("inventory.transfer.template.zeroQuantity.message", { count: _.value.length })), 1),
1930
+ t("div", sa, [
1931
+ t("ul", aa, [
1932
+ (b(!0), T(ae, null, fe(_.value, (ee) => (b(), T("li", {
1933
+ key: ee.sku._id,
1934
+ class: "fm-typo-en-body-md-400"
1935
+ }, $(ee.sku.name) + " (" + $(ee.sku.code) + ") ", 1))), 128))
1936
+ ])
1937
+ ]),
1938
+ t("div", ra, $(e(i)("inventory.transfer.template.zeroQuantity.prompt")), 1)
1939
+ ])
1940
+ ]),
1941
+ _: 1
1942
+ }, 8, ["modelValue"])
1943
+ ], 64);
1944
+ };
1945
+ }
1946
+ });
1947
+ function ia(y) {
1948
+ const [x, d, u, ...g] = _o(y), n = u.map((w) => w.toLowerCase().trim().replace(/ /g, "_")), S = ["item_name", "transfer_quantity(uom)", "uom", "scanned_code"].filter((w) => !n.includes(w));
1949
+ if (S.length)
1950
+ throw new Error(
1951
+ `Missing headers (${S.join()}). Excel file does not come from the template.`
1952
+ );
1953
+ return g.map((w, v) => {
1954
+ const i = {};
1955
+ for (const o in n) {
1956
+ const a = n[o];
1957
+ Object.assign(i, { [a]: w[o] });
1958
+ }
1959
+ return {
1960
+ index: v,
1961
+ data: i
1962
+ };
1963
+ });
1964
+ }
1965
+ function ua(y) {
1966
+ const x = y.SheetNames;
1967
+ try {
1968
+ return x.reduce(
1969
+ (u, g) => {
1970
+ const n = new Array(), h = y.Sheets[g], S = Ye(), V = ia(h), w = [];
1971
+ for (const { index: i, data: o } of V) {
1972
+ o.scanned_code === "" && n.push(`Row ${i + 1}: Scanned code is empty`), o.item_name === "" && n.push(`Row ${i + 1}: Item name is empty`), o.uom === "" && n.push(`Row ${i + 1}: UOM is empty`), o["transfer_quantity(uom)"] === "" && n.push(`Row ${i + 1}: Transfer quantity is empty`);
1973
+ const a = S.skus.find((_) => _.code === o.scanned_code);
1974
+ if (!a) {
1975
+ n.push(`Row ${i + 1}: SKU not found`);
1976
+ continue;
1977
+ }
1978
+ const r = a.unit.abbrev === o.uom;
1979
+ let s = null;
1980
+ if (!r) {
1981
+ const _ = a.unit.measurements.find((F) => F.abbrev === o.uom);
1982
+ if (!_) {
1983
+ n.push(`Row ${i + 1}: Measurement not found`);
1984
+ continue;
1985
+ }
1986
+ s = _;
1987
+ }
1988
+ w.push({
1989
+ sku: a,
1990
+ code: o.scanned_code,
1991
+ name: o.item_name,
1992
+ quantity: bt.fromNumber(Number(o["transfer_quantity(uom)"])),
1993
+ measurement: s
1994
+ });
1995
+ }
1996
+ const v = {
1997
+ type: "create",
1998
+ poItems: w,
1999
+ excelSheetName: g,
2000
+ errors: n
2001
+ };
2002
+ return u.importCreateResult.push(v), u;
2003
+ },
2004
+ {
2005
+ invalidExcel: !1,
2006
+ importCreateResult: new Array()
2007
+ }
2008
+ );
2009
+ } catch (d) {
2010
+ return {
2011
+ invalidExcel: !0,
2012
+ invalidExcelMessage: (d == null ? void 0 : d.message) ?? "Invalid excel",
2013
+ importCreateResult: []
2014
+ };
2015
+ }
2016
+ }
2017
+ const da = { class: "flex flex-col flex-1" }, ca = { class: "flex flex-col" }, ma = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, pa = {
2018
+ key: 0,
2019
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
2020
+ }, fa = { key: 0 }, va = {
2021
+ class: /* @__PURE__ */ W(["fm-typo-en-body-lg-600"])
2022
+ }, ya = { class: "flex-1" }, ba = { class: "flex-auto line-clamp-2 text-ellipsis break-all fm-typo-en-body-sm-400" }, ga = { class: "flex-auto line-clamp-2 text-ellipsis break-all" }, _a = { class: "text-fm-color-typo-primary" }, ha = { class: "ml-auto" }, xa = { key: 0 }, ka = /* @__PURE__ */ ne({
2023
+ __name: "XilnexResult",
2024
+ props: {
2025
+ type: {},
2026
+ name: {},
2027
+ items: {},
2028
+ errors: {}
2029
+ },
2030
+ setup(y) {
2031
+ const x = y, { t: d } = ye(), u = U(!1), g = () => {
2032
+ x.errors.length && (u.value = !u.value);
2033
+ };
2034
+ return (n, h) => {
2035
+ var w;
2036
+ const S = O("FmIcon"), V = O("FmTooltip");
2037
+ return b(), T("div", da, [
2038
+ t("div", {
2039
+ onClick: g,
2040
+ class: W({
2041
+ "cursor-pointer": n.errors.length
2042
+ })
2043
+ }, [
2044
+ t("div", ca, [
2045
+ t("div", ma, [
2046
+ t("div", {
2047
+ class: W({
2048
+ "text-fm-color-system-error-300": n.errors.length
2049
+ })
2050
+ }, [
2051
+ ke($(n.name) + " ", 1),
2052
+ n.type === "create" ? (b(), T("span", pa, "(" + $(e(d)("inventory.closing.template.import.new")) + ")", 1)) : Y("", !0)
2053
+ ], 2),
2054
+ n.errors.length ? (b(), T("div", fa, [
2055
+ m(S, {
2056
+ name: "error",
2057
+ size: "sm",
2058
+ color: "system-error-300"
2059
+ })
2060
+ ])) : Y("", !0)
2061
+ ]),
2062
+ h[0] || (h[0] = t("hr", { class: "my-2" }, null, -1)),
2063
+ t("div", va, [
2064
+ (w = n.items) != null && w.length ? (b(!0), T(ae, { key: 0 }, fe(n.items, (v, i) => (b(), T("div", {
2065
+ key: i,
2066
+ class: "flex gap-4 mt-2 items-center"
2067
+ }, [
2068
+ t("div", ya, [
2069
+ m(V, {
2070
+ content: v.code,
2071
+ placement: "top",
2072
+ "z-index": 51
2073
+ }, {
2074
+ default: M(() => [
2075
+ t("span", ba, $(v.code), 1)
2076
+ ]),
2077
+ _: 2
2078
+ }, 1032, ["content"]),
2079
+ m(V, {
2080
+ content: v.name,
2081
+ placement: "top",
2082
+ "z-index": 51
2083
+ }, {
2084
+ default: M(() => [
2085
+ t("span", ga, $(v.name), 1)
2086
+ ]),
2087
+ _: 2
2088
+ }, 1032, ["content"])
2089
+ ]),
2090
+ t("div", null, [
2091
+ t("span", _a, $(e(bt).toFormatString({
2092
+ value: v.quantity
2093
+ })), 1),
2094
+ ke(" " + $(v.measurement ? v.measurement.abbrev : v.sku.unit.abbrev), 1)
2095
+ ])
2096
+ ]))), 128)) : Y("", !0)
2097
+ ])
2098
+ ]),
2099
+ t("div", ha, [
2100
+ n.errors.length ? (b(), oe(S, {
2101
+ key: 0,
2102
+ name: u.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
2103
+ size: "md"
2104
+ }, null, 8, ["name"])) : Y("", !0)
2105
+ ])
2106
+ ], 2),
2107
+ u.value ? (b(), T("div", {
2108
+ key: 0,
2109
+ class: W(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
2110
+ "text-fm-color-typo-secondary": !n.errors.length,
2111
+ "text-fm-color-system-error-300": n.errors.length
2112
+ }])
2113
+ }, [
2114
+ n.errors.length ? (b(), T("div", xa, [
2115
+ t("ol", null, [
2116
+ (b(!0), T(ae, null, fe(n.errors, (v, i) => (b(), T("li", { key: i }, $(v), 1))), 128))
2117
+ ])
2118
+ ])) : Y("", !0)
2119
+ ], 2)) : Y("", !0)
2120
+ ]);
2121
+ };
2122
+ }
2123
+ }), Ca = { class: "flex flex-col gap-24" }, wa = {
2124
+ key: 0,
2125
+ class: "flex items-center gap-8"
2126
+ }, Sa = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Fa = { class: "flex flex-col gap-8" }, $a = { class: "line-clamp-2 text-ellipsis break-all" }, Ia = {
2127
+ key: 2,
2128
+ class: "shrink-0"
2129
+ }, Da = {
2130
+ key: 0,
2131
+ class: "flex flex-col"
2132
+ }, Ta = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Va = {
2133
+ key: 0,
2134
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
2135
+ }, Pa = { class: "fm-typo-en-body-lg-600" }, pt = "Transfer note", Ra = /* @__PURE__ */ ne({
2136
+ __name: "XilnexImportForm",
2137
+ setup(y, { expose: x }) {
2138
+ const d = U(null), u = we(), g = U(!1), n = U(!1), h = ko(), S = U(!1), V = qe();
2139
+ U([]);
2140
+ const w = q({
2141
+ get() {
2142
+ var c;
2143
+ return ((c = h.supplier) == null ? void 0 : c.name) ?? "";
2144
+ },
2145
+ set(c) {
2146
+ c && (h.supplier = {
2147
+ name: c,
2148
+ registrationNumber: "",
2149
+ _id: "xilnex",
2150
+ internal: "restaurant",
2151
+ address: {
2152
+ line1: "",
2153
+ line2: "",
2154
+ city: "",
2155
+ state: "",
2156
+ country: "",
2157
+ postcode: ""
2158
+ }
2159
+ });
2160
+ }
2161
+ });
2162
+ He(async () => {
2163
+ const c = await V.getNetSuiteLocations();
2164
+ console.log(c), S.value = !0;
2165
+ });
2166
+ const v = q({
2167
+ get() {
2168
+ return "";
2169
+ },
2170
+ set(c) {
2171
+ if (c) {
2172
+ const f = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [I, A, X] = c.split("-");
2173
+ f.setFullYear(parseInt(I)), f.setMonth(parseInt(A) - 1), f.setDate(parseInt(X)), h.effectiveAt = f.toISOString();
2174
+ }
2175
+ }
2176
+ }), i = q({
2177
+ get() {
2178
+ return null;
2179
+ },
2180
+ set(c) {
2181
+ if (c) {
2182
+ const f = h.effectiveAt ? new Date(h.effectiveAt) : /* @__PURE__ */ new Date(), [I, A] = c.split(":");
2183
+ f.setMinutes(parseInt(I)), f.setSeconds(parseInt(A)), h.effectiveAt = f.toISOString();
2184
+ }
2185
+ }
2186
+ }), o = U(new Array()), a = U([]), r = q(
2187
+ () => !!o.value.length || a.value.some((c) => c.errors.length)
2188
+ ), s = U();
2189
+ x({
2190
+ validateInputs: () => {
2191
+ var c, f;
2192
+ (f = (c = s.value) == null ? void 0 : c.validateInputs) == null || f.call(c);
2193
+ },
2194
+ resetInputsValidation: () => {
2195
+ var c, f;
2196
+ (f = (c = s.value) == null ? void 0 : c.resetInputsValidation) == null || f.call(c);
2197
+ },
2198
+ resetInputs: () => {
2199
+ var c, f;
2200
+ (f = (c = s.value) == null ? void 0 : c.resetInputs) == null || f.call(c);
2201
+ }
2202
+ });
2203
+ const { t: _ } = ye();
2204
+ async function F(c) {
2205
+ o.value = [], a.value = [];
2206
+ try {
2207
+ g.value = !0;
2208
+ const [f] = await Promise.all([
2209
+ ho(c),
2210
+ // fake buffer
2211
+ new Promise((A) => setTimeout(A, 1e3))
2212
+ ]), I = ua(f);
2213
+ if (I.invalidExcel) {
2214
+ o.value.push(
2215
+ I.invalidExcelMessage ?? _("inventory.ingredient.import.fileError.invalidExcel")
2216
+ );
2217
+ return;
2218
+ }
2219
+ if (a.value = I.importCreateResult, !a.value.length) {
2220
+ o.value.push(_("inventory.ingredient.import.fileError.noData"));
2221
+ return;
2222
+ }
2223
+ h.items = a.value.map((A) => A.poItems).flat();
2224
+ } catch (f) {
2225
+ u.open({
2226
+ title: _("inventory.ingredient.import.fileError.unableToRead"),
2227
+ message: f == null ? void 0 : f.message,
2228
+ type: "error"
2229
+ }), console.error("Error in reading file", f);
2230
+ } finally {
2231
+ o.value.length && u.open({
2232
+ title: _("inventory.ingredient.import.fileError.invalidExcel"),
2233
+ type: "error"
2234
+ }), g.value = !1;
2235
+ }
2236
+ }
2237
+ return he(d, (c) => {
2238
+ c && F(c);
2239
+ }), (c, f) => {
2240
+ const I = O("FmSelect"), A = O("FmDatePicker"), X = O("FmTimePicker"), z = O("FmCircularProgress"), Z = O("FmLabel"), N = O("FmIcon"), B = O("FmButton"), P = O("FmForm");
2241
+ return b(), oe(P, {
2242
+ ref_key: "formRef",
2243
+ ref: s
2244
+ }, {
2245
+ default: M(() => [
2246
+ t("div", Ca, [
2247
+ m(I, {
2248
+ modelValue: w.value,
2249
+ "onUpdate:modelValue": f[0] || (f[0] = (D) => w.value = D),
2250
+ label: "Transfer from",
2251
+ searchable: "",
2252
+ searchTarget: "label",
2253
+ items: [
2254
+ { label: "Object", value: null },
2255
+ { label: "Array", value: ["array", "1"] },
2256
+ { label: "Number", value: 3 },
2257
+ { label: "String", value: "4" },
2258
+ { label: "1", value: "5" },
2259
+ { label: "2", value: "6" }
2260
+ ],
2261
+ "helper-text": "Helper",
2262
+ rules: [e(De)()]
2263
+ }, null, 8, ["modelValue", "rules"]),
2264
+ m(A, {
2265
+ modelValue: v.value,
2266
+ "onUpdate:modelValue": f[1] || (f[1] = (D) => v.value = D),
2267
+ label: "Transfer date",
2268
+ rules: [e(De)()]
2269
+ }, null, 8, ["modelValue", "rules"]),
2270
+ m(X, {
2271
+ modelValue: i.value,
2272
+ "onUpdate:modelValue": f[2] || (f[2] = (D) => i.value = D),
2273
+ label: "Transfer time",
2274
+ rules: [e(De)()]
2275
+ }, null, 8, ["modelValue", "rules"]),
2276
+ n.value ? (b(), T("div", wa, [
2277
+ t("div", null, [
2278
+ m(z, {
2279
+ size: "md",
2280
+ color: "neutral-gray-200"
2281
+ })
2282
+ ]),
2283
+ t("div", Sa, $(e(_)("inventory.formField.loading")), 1)
2284
+ ])) : (b(), T(ae, { key: 1 }, [
2285
+ m(xo, {
2286
+ "max-file-size": 5,
2287
+ class: W({
2288
+ "w-full": !0,
2289
+ "h-[200px]": !d.value
2290
+ }),
2291
+ accept: ".xlsx,.xls",
2292
+ label: pt,
2293
+ onFileUpload: f[3] || (f[3] = (D) => d.value = D),
2294
+ "button-label": e(_)("inventory.ingredient.import.selectFile")
2295
+ }, Pt({ _: 2 }, [
2296
+ d.value ? {
2297
+ name: "default",
2298
+ fn: M(({ openFileDialog: D }) => [
2299
+ m(Z, null, {
2300
+ default: M(() => [
2301
+ ke($(pt))
2302
+ ]),
2303
+ _: 1
2304
+ }),
2305
+ t("div", Fa, [
2306
+ t("div", {
2307
+ class: W([
2308
+ "fm-corner-radius-md p-16 flex items-center gap-16",
2309
+ {
2310
+ "border border-fm-color-neutral-gray-100": g.value,
2311
+ "border border-fm-color-neutral-gray-200": !g.value && !r.value,
2312
+ "border border-fm-color-system-error-200": r.value
2313
+ }
2314
+ ])
2315
+ }, [
2316
+ g.value ? (b(), oe(z, {
2317
+ key: 0,
2318
+ size: "md",
2319
+ color: "neutral-gray-200"
2320
+ })) : (b(), oe(N, {
2321
+ key: 1,
2322
+ name: r.value ? "error" : "attach_file",
2323
+ outline: "",
2324
+ color: r.value ? "system-error-300" : void 0
2325
+ }, null, 8, ["name", "color"])),
2326
+ t("div", {
2327
+ class: W([
2328
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
2329
+ {
2330
+ "text-fm-color-typo-disabled": g.value,
2331
+ "text-fm-color-typo-primary": !g.value
2332
+ }
2333
+ ])
2334
+ }, [
2335
+ t("div", $a, $(d.value.name), 1)
2336
+ ], 2),
2337
+ g.value ? Y("", !0) : (b(), T("div", Ia, [
2338
+ m(B, {
2339
+ label: e(_)("inventory.ingredient.import.replaceFile"),
2340
+ variant: r.value ? "destructive" : "secondary",
2341
+ "prepend-icon": r.value ? void 0 : "autorenew",
2342
+ onClick: D
2343
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
2344
+ ]))
2345
+ ], 2),
2346
+ o.value.length ? (b(), T("div", Da, [
2347
+ (b(!0), T(ae, null, fe(o.value, (E, L) => (b(), T("div", {
2348
+ key: L,
2349
+ class: "flex gap-8 items-center"
2350
+ }, [
2351
+ m(N, {
2352
+ name: "error",
2353
+ size: "sm",
2354
+ color: "system-error-300"
2355
+ }),
2356
+ t("div", Ta, $(E), 1)
2357
+ ]))), 128))
2358
+ ])) : Y("", !0)
2359
+ ])
2360
+ ]),
2361
+ key: "0"
2362
+ } : void 0
2363
+ ]), 1032, ["class", "button-label"]),
2364
+ d.value ? (b(), T("div", Va, [
2365
+ t("div", Pa, $(e(_)("inventory.ingredient.import.summary")), 1),
2366
+ (b(!0), T(ae, null, fe(a.value, (D, E) => (b(), oe(ka, {
2367
+ key: E,
2368
+ name: `Transfer Note ${E + 1}`,
2369
+ items: D.poItems,
2370
+ errors: D.errors,
2371
+ type: "create"
2372
+ }, null, 8, ["name", "items", "errors"]))), 128))
2373
+ ])) : Y("", !0)
2374
+ ], 64))
2375
+ ])
2376
+ ]),
2377
+ _: 1
2378
+ }, 512);
2379
+ };
2380
+ }
2381
+ }), Oa = { class: "w-[480px]" }, Aa = /* @__PURE__ */ ne({
2382
+ __name: "XilnexImportDialog",
2383
+ props: {
2384
+ show: { type: Boolean }
2385
+ },
2386
+ emits: ["update:show", "submitted"],
2387
+ setup(y, { expose: x, emit: d }) {
2388
+ const u = d, n = _t(y, "show"), h = we(), S = We(), V = U(!1), w = U(), v = U();
2389
+ x({
2390
+ validateInputs: () => {
2391
+ var a, r;
2392
+ (r = (a = w.value) == null ? void 0 : a.validateInputs) == null || r.call(a);
2393
+ },
2394
+ resetInputsValidation: () => {
2395
+ var a, r;
2396
+ (r = (a = w.value) == null ? void 0 : a.resetInputsValidation) == null || r.call(a);
2397
+ },
2398
+ resetInputs: () => {
2399
+ var a, r;
2400
+ (r = (a = w.value) == null ? void 0 : a.resetInputs) == null || r.call(a);
2401
+ }
2402
+ });
2403
+ function i() {
2404
+ var a, r;
2405
+ (r = (a = w.value) == null ? void 0 : a.validateInputs) == null || r.call(a);
2406
+ }
2407
+ async function o() {
2408
+ var r, s, _, F, c;
2409
+ if (!((s = (r = v.value) == null ? void 0 : r.supplier) != null && s.name)) {
2410
+ h.open({
2411
+ title: "Upload failed",
2412
+ message: "Location is required",
2413
+ type: "error"
2414
+ });
2415
+ return;
2416
+ }
2417
+ if (!((_ = v.value) != null && _.items) || ((c = (F = v.value) == null ? void 0 : F.items) == null ? void 0 : c.length) === 0) {
2418
+ h.open({
2419
+ title: "Upload failed",
2420
+ message: "No data to upload",
2421
+ type: "error"
2422
+ });
2423
+ return;
2424
+ }
2425
+ const a = v.value.effectiveAt ? new Date(v.value.effectiveAt) : null;
2426
+ if (!a) {
2427
+ h.open({
2428
+ title: "Invalid date",
2429
+ message: "Transfer date is required",
2430
+ type: "error"
2431
+ });
2432
+ return;
2433
+ }
2434
+ if (a.getTime() > (/* @__PURE__ */ new Date()).getTime()) {
2435
+ h.open({
2436
+ title: "Invalid date",
2437
+ message: "Transfer date cannot be in the future",
2438
+ type: "error"
2439
+ });
2440
+ return;
2441
+ }
2442
+ V.value = !0;
2443
+ try {
2444
+ await S.importFromXilnex(v.value), u("update:show", !1);
2445
+ } catch (f) {
2446
+ await new Promise((I) => setTimeout(I, 1e3)), h.open({
2447
+ title: "Upload failed",
2448
+ message: f == null ? void 0 : f.message,
2449
+ type: "error"
2450
+ });
2451
+ } finally {
2452
+ V.value = !1;
2453
+ }
2454
+ }
2455
+ return (a, r) => {
2456
+ const s = O("FmSpacer"), _ = O("FmButton"), F = O("FmDialog");
2457
+ return b(), oe(F, {
2458
+ modelValue: e(n),
2459
+ "onUpdate:modelValue": r[2] || (r[2] = (c) => ge(n) ? n.value = c : null),
2460
+ overlay: !0,
2461
+ "close-button": !1
2462
+ }, {
2463
+ "dialog-header": M(() => r[3] || (r[3] = [
2464
+ t("div", null, "Xilnex transfer order", -1)
2465
+ ])),
2466
+ "dialog-footer": M(() => [
2467
+ m(s, { class: "sm:hidden xs:hidden" }),
2468
+ m(_, {
2469
+ disabled: V.value,
2470
+ class: "sm:w-full xs:w-full",
2471
+ label: "Cancel",
2472
+ size: "md",
2473
+ variant: "tertiary",
2474
+ onClick: r[1] || (r[1] = (c) => u("update:show", !1))
2475
+ }, null, 8, ["disabled"]),
2476
+ m(_, {
2477
+ disabled: V.value,
2478
+ loading: V.value,
2479
+ class: "sm:w-full xs:w-full",
2480
+ label: "Upload",
2481
+ size: "md",
2482
+ variant: "primary",
2483
+ onClick: i
2484
+ }, null, 8, ["disabled", "loading"])
2485
+ ]),
2486
+ default: M(() => [
2487
+ t("div", Oa, [
2488
+ m(Ra, {
2489
+ ref_key: "formRef",
2490
+ ref: w,
2491
+ onValidationSuccess: o,
2492
+ modelValue: v.value,
2493
+ "onUpdate:modelValue": r[0] || (r[0] = (c) => v.value = c)
2494
+ }, null, 8, ["modelValue"])
2495
+ ])
2496
+ ]),
2497
+ _: 1
2498
+ }, 8, ["modelValue"]);
2499
+ };
2500
+ }
2501
+ }), Ma = { class: "flex flex-col py-8" }, Ea = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qa = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary line-clamp-1" }, Ua = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1" }, Na = {
2502
+ key: 0,
2503
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary line-clamp-1"
2504
+ }, Ba = { class: "pt-8" }, ft = "ReceiveRequestViewSearchCriteria", _r = /* @__PURE__ */ ne({
2505
+ __name: "ReceiveRequestView",
2506
+ setup(y) {
2507
+ const { t: x } = ye(), d = we();
2508
+ Ae.object({
2509
+ name: Ae.string().optional().nullable(),
2510
+ startDate: Ae.string().optional().nullable(),
2511
+ endDate: Ae.string().optional().nullable()
2512
+ });
2513
+ const u = q(
2514
+ () => !o._currentLocation || v.loading.value
2515
+ ), g = Wt(), n = Xe(), h = qe();
2516
+ function S() {
2517
+ const N = {
2518
+ name: "",
2519
+ ...dt()
2520
+ }, B = g.getItem(ft);
2521
+ if (!B)
2522
+ return N;
2523
+ try {
2524
+ return JSON.parse(B);
2525
+ } catch {
2526
+ return N;
2527
+ }
2528
+ }
2529
+ function V() {
2530
+ g.setItem(ft, JSON.stringify(w.value));
2531
+ }
2532
+ const w = U(S()), v = Lt(
2533
+ Le.RECEIVE_REQUEST,
2534
+ w.value
2535
+ ), { columnDefs: i } = jt(
2536
+ Le.RECEIVE_REQUEST,
2537
+ v,
2538
+ v.shipments
2539
+ ), o = Qe();
2540
+ async function a() {
2541
+ const N = `inventory-record_${ct(w.value.startDate).format("DD-MM-YYYY_HH-mm")}-${ct(w.value.endDate).format("DD-MM-YYYY_HH-mm")}.xlsx`, B = v.purchaseOrders.value.flatMap(
2542
+ (D) => D.items.map((E) => {
2543
+ var H;
2544
+ const L = new Date(Xt(D._id) ?? ""), J = D.effectiveAt ? new Date(D.effectiveAt) : void 0, se = _e(
2545
+ Qt(E.sku, D.deliveryOrder || [])
2546
+ ), k = _e(E.quantity), C = ((H = E == null ? void 0 : E.measurement) == null ? void 0 : H.abbrev) || E.sku.unit.abbrev;
2547
+ return {
2548
+ "SKU code": E.code,
2549
+ "SKU name": E.name,
2550
+ "PO #": D.seqNumber,
2551
+ "Effective at": J,
2552
+ Date: L,
2553
+ Status: D.status,
2554
+ Reference: D.ref ?? "",
2555
+ "Received quantity": se,
2556
+ "Ordered quantity": k,
2557
+ Unit: C,
2558
+ "Total cost": E.totalCost ? Ce(E.totalCost) : null
2559
+ };
2560
+ })
2561
+ ), P = [
2562
+ "SKU code",
2563
+ "SKU name",
2564
+ "PO #",
2565
+ "Date",
2566
+ "Status",
2567
+ "Reference",
2568
+ "Received quantity",
2569
+ "Ordered quantity",
2570
+ "Unit"
2571
+ ];
2572
+ n.enableBackdatePo && P.insert("Effective at", 4), n.enableTotalCost && P.push("Total cost"), await Zt(
2573
+ [
2574
+ {
2575
+ name: "purchases",
2576
+ data: B,
2577
+ columns: P
2578
+ }
2579
+ ],
2580
+ N
2581
+ ), d.open({
2582
+ title: x("inventory.transfer.receiveRequest.export.success"),
2583
+ message: x("inventory.transfer.receiveRequest.export.message", [N]),
2584
+ type: "success"
2585
+ });
2586
+ }
2587
+ const r = U(dt()), s = U("");
2588
+ he([() => r.value], ([N]) => {
2589
+ !N.startDate || !N.endDate || (w.value.startDate = N.startDate, w.value.endDate = N.endDate, v.updateDateRange(
2590
+ w.value.startDate,
2591
+ w.value.endDate
2592
+ ), V());
2593
+ }), he([() => s.value], () => {
2594
+ V();
2595
+ });
2596
+ function _(N) {
2597
+ if (N === "create") {
2598
+ if (u.value) {
2599
+ d.open({
2600
+ title: "Loading data...",
2601
+ message: "Please wait.",
2602
+ type: "info"
2603
+ });
2604
+ return;
2605
+ }
2606
+ return v.promptCreateTransferDialog();
2607
+ }
2608
+ if (N === "upload" && n.enableXilnexTransferNote)
2609
+ return v.promptUploadTransferDialog();
2610
+ if (N === "refresh")
2611
+ return v.fetchData();
2612
+ if (N === "export")
2613
+ return a();
2614
+ }
2615
+ const { breakpoints: F } = Ke(), c = q(() => F.value.xs || F.value.sm), f = q(() => c.value ? 10 : 20), I = Jt(), A = q(() => [
2616
+ {
2617
+ label: x("inventory.transfer.receiveRequest.actions.create"),
2618
+ value: "create",
2619
+ isPrimary: !0,
2620
+ prependIcon: "add"
2621
+ },
2622
+ ...n.enableXilnexTransferNote ? [
2623
+ {
2624
+ label: x("inventory.common.upload"),
2625
+ value: "upload"
2626
+ }
2627
+ ] : [],
2628
+ {
2629
+ label: x("inventory.common.refresh"),
2630
+ value: "refresh"
2631
+ },
2632
+ {
2633
+ label: x("inventory.common.export"),
2634
+ value: "export"
2635
+ }
2636
+ ]), X = q(() => {
2637
+ const N = [
2638
+ {
2639
+ type: "string",
2640
+ key: "status",
2641
+ entity: "purchaseOrder",
2642
+ values: Array.from(
2643
+ new Set(v.purchaseOrders.value.map((P) => P.status))
2644
+ )
2645
+ }
2646
+ ], B = [
2647
+ {
2648
+ type: "string",
2649
+ key: "netsuiteTransactionNumber",
2650
+ entity: "purchaseOrder",
2651
+ values: v.purchaseOrders.value.map((P) => {
2652
+ var D, E;
2653
+ return (E = (D = P.netSuite) == null ? void 0 : D.additionalInfo) == null ? void 0 : E.transactionnumber;
2654
+ }).filter((P) => P != null)
2655
+ },
2656
+ {
2657
+ type: "string",
2658
+ key: "netsuiteOrderNo",
2659
+ entity: "purchaseOrder",
2660
+ values: v.purchaseOrders.value.map((P) => {
2661
+ var D;
2662
+ return (D = P.netSuite) == null ? void 0 : D.refNo;
2663
+ }).filter((P) => P != null)
2664
+ },
2665
+ {
2666
+ type: "string",
2667
+ key: "netsuiteOrderId",
2668
+ entity: "purchaseOrder",
2669
+ values: v.purchaseOrders.value.map((P) => {
2670
+ var D;
2671
+ return (D = P.netSuite) == null ? void 0 : D.id;
2672
+ }).filter((P) => P != null)
2673
+ }
2674
+ ];
2675
+ return [...N, ...h.isEnabled ? B : []];
2676
+ }), z = U(null), Z = q(() => {
2677
+ if (!z.value)
2678
+ return v.purchaseOrders.value;
2679
+ const N = Co.build(z.value);
2680
+ return v.purchaseOrders.value.filter((B) => {
2681
+ var P, D, E, L;
2682
+ return wo(
2683
+ {
2684
+ netsuiteTransactionNumber: (D = (P = B.netSuite) == null ? void 0 : P.additionalInfo) == null ? void 0 : D.transactionnumber,
2685
+ netsuiteOrderNo: (E = B.netSuite) == null ? void 0 : E.refNo,
2686
+ netsuiteOrderId: (L = B.netSuite) == null ? void 0 : L.id,
2687
+ status: B.status
2688
+ },
2689
+ N
2690
+ );
2691
+ });
2692
+ });
2693
+ return (N, B) => {
2694
+ const P = O("FmTable");
2695
+ return b(), oe(Gt, {
2696
+ title: e(x)("inventory.transfer.receiveRequest.title2"),
2697
+ actions: A.value,
2698
+ "onClick:action": _
2699
+ }, {
2700
+ default: M(() => {
2701
+ var D, E;
2702
+ return [
2703
+ t("div", {
2704
+ class: W([
2705
+ "flex flex-col gap-8 max-h-full",
2706
+ {
2707
+ "p-0": c.value,
2708
+ "px-24 ": !c.value
2709
+ }
2710
+ ])
2711
+ }, [
2712
+ m(Bt, {
2713
+ "date-range-query": "",
2714
+ "date-range": r.value,
2715
+ "onUpdate:dateRange": B[0] || (B[0] = (L) => r.value = L),
2716
+ searchable: "",
2717
+ "change-location": "",
2718
+ search: s.value,
2719
+ "onUpdate:search": B[1] || (B[1] = (L) => s.value = L),
2720
+ filterable: "",
2721
+ "filter-attributes": X.value,
2722
+ filter: z.value,
2723
+ "onUpdate:filter": B[2] || (B[2] = (L) => z.value = L)
2724
+ }, null, 8, ["date-range", "search", "filter-attributes", "filter"]),
2725
+ (b(), oe(P, {
2726
+ style: vt(e(I).tableHeight),
2727
+ "column-defs": e(i),
2728
+ "row-data": Z.value,
2729
+ "search-value": s.value,
2730
+ loading: u.value,
2731
+ onRowClick: B[3] || (B[3] = (L) => e(v).promptShowTransferDetails(L.original)),
2732
+ key: (D = e(o)._currentLocation) == null ? void 0 : D.dbName,
2733
+ "page-size": f.value
2734
+ }, {
2735
+ "list-row": M((L) => [
2736
+ m(ht, {
2737
+ row: L,
2738
+ onRowClick: e(v).promptShowTransferDetails
2739
+ }, {
2740
+ default: M((J) => {
2741
+ var se, k, C, H, re, ie, ee, be, ve, Te, Ve, Pe, Ue, xe, Se, Fe, Re, l, p, j;
2742
+ return [
2743
+ t("div", Ma, [
2744
+ t("div", Ea, [
2745
+ m(e(ce), {
2746
+ render: (C = (k = (se = J._id) == null ? void 0 : se.column) == null ? void 0 : k.columnDef) == null ? void 0 : C.cell,
2747
+ props: (re = (H = J._id) == null ? void 0 : H.getContext) == null ? void 0 : re.call(H)
2748
+ }, null, 8, ["render", "props"])
2749
+ ]),
2750
+ t("div", qa, [
2751
+ m(e(ce), {
2752
+ render: (be = (ee = (ie = J.supplier_name) == null ? void 0 : ie.column) == null ? void 0 : ee.columnDef) == null ? void 0 : be.cell,
2753
+ props: (Te = (ve = J.supplier_name) == null ? void 0 : ve.getContext) == null ? void 0 : Te.call(ve)
2754
+ }, null, 8, ["render", "props"])
2755
+ ]),
2756
+ t("div", Ua, $(L.original.items.map((K) => `${K.name}`).join(", ")), 1),
2757
+ L.original.ref ? (b(), T("div", Na, [
2758
+ m(e(ce), {
2759
+ render: (Ue = (Pe = (Ve = J.ref) == null ? void 0 : Ve.column) == null ? void 0 : Pe.columnDef) == null ? void 0 : Ue.cell,
2760
+ props: (Se = (xe = J.ref) == null ? void 0 : xe.getContext) == null ? void 0 : Se.call(xe)
2761
+ }, null, 8, ["render", "props"])
2762
+ ])) : Y("", !0),
2763
+ t("div", Ba, [
2764
+ m(e(ce), {
2765
+ render: (l = (Re = (Fe = J.status) == null ? void 0 : Fe.column) == null ? void 0 : Re.columnDef) == null ? void 0 : l.cell,
2766
+ props: (j = (p = J.status) == null ? void 0 : p.getContext) == null ? void 0 : j.call(p)
2767
+ }, null, 8, ["render", "props"])
2768
+ ])
2769
+ ])
2770
+ ];
2771
+ }),
2772
+ _: 2
2773
+ }, 1032, ["row", "onRowClick"])
2774
+ ]),
2775
+ _: 1
2776
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
2777
+ ], 2),
2778
+ (b(), oe(Rt, { to: "body" }, [
2779
+ m(na, je(e(v).transferDialogProps.value, {
2780
+ onSubmitted: e(v).fetchData
2781
+ }), null, 16, ["onSubmitted"]),
2782
+ m(Ht, je({
2783
+ scope: e(Le).RECEIVE_REQUEST
2784
+ }, {
2785
+ ...e(v).transferDetailsProps.value,
2786
+ receivedMap: ((E = e(v).transferDetailsProps.value) == null ? void 0 : E.receivedMap) ?? {},
2787
+ shipments: e(v).shipments.value ?? []
2788
+ }, {
2789
+ onSubmitted: e(v).fetchData
2790
+ }), null, 16, ["scope", "onSubmitted"]),
2791
+ m(Aa, Ot(At(e(v).xilnexImportDialogProps.value)), null, 16)
2792
+ ]))
2793
+ ];
2794
+ }),
2795
+ _: 1
2796
+ }, 8, ["title", "actions"]);
2797
+ };
2798
+ }
2799
+ });
2800
+ export {
2801
+ _r as default
2802
+ };