@feedmepos/mf-order-setting 0.0.7 → 0.0.12

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 (60) hide show
  1. package/.env +2 -0
  2. package/dist/KioskSettingView-YfMgLMyn.js +4 -0
  3. package/dist/app-DnR4r5jW.js +195091 -0
  4. package/dist/app.js +1 -1
  5. package/dist/common/util/index.d.ts +5 -1
  6. package/dist/frontend/mf-order/src/api/index.d.ts +1 -0
  7. package/dist/frontend/mf-order/src/api/restaurant-setting/index.d.ts +3 -8
  8. package/dist/frontend/mf-order/src/helpers/menu.d.ts +7 -0
  9. package/dist/frontend/mf-order/src/stores/restaurant/index.d.ts +9 -14
  10. package/dist/frontend/mf-order/src/views/all-orders/FilterRestaurant.vue.d.ts +4 -4
  11. package/dist/frontend/mf-order/src/views/all-orders/ReflowOrder.vue.d.ts +2 -2
  12. package/dist/frontend/mf-order/src/views/order-settings/delivery/components/TaxInput.vue.d.ts +67 -0
  13. package/dist/frontend/mf-order/src/views/order-settings/delivery/inhouse/InHouseDelivery.vue.d.ts +4 -1
  14. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  15. package/dist/package/entity/auth/auth.dto.d.ts +9 -0
  16. package/dist/package/entity/booking/booking.do.d.ts +40 -40
  17. package/dist/package/entity/delivery/delivery.dto.d.ts +8 -8
  18. package/dist/package/entity/food-court/order.dto.d.ts +6025 -6065
  19. package/dist/package/entity/incoming-order/incoming-order-to-bill.dto.d.ts +9 -6
  20. package/dist/package/entity/incoming-order/incoming-order.do.d.ts +8 -8
  21. package/dist/package/entity/incoming-order/incoming-order.dto.d.ts +26 -16
  22. package/dist/package/entity/index.d.ts +6 -0
  23. package/dist/package/entity/kiosk/marketing/marketing.dto.d.ts +34 -34
  24. package/dist/package/entity/order/manager/manager.dto.d.ts +349 -0
  25. package/dist/package/entity/order/manager/manager.enum.d.ts +7 -0
  26. package/dist/package/entity/order/order.dto.d.ts +4649 -4706
  27. package/dist/package/entity/order/order.enum.d.ts +3 -1
  28. package/dist/package/entity/order/payment/payment.dto.d.ts +2525 -2529
  29. package/dist/package/entity/order-platform/foodpanda/foodpanda-order.dto.d.ts +8 -8
  30. package/dist/package/entity/order-platform/grabfood/grabfood-order.do.d.ts +8 -8
  31. package/dist/package/entity/order-platform/grabfood/grabfood-settings.do.d.ts +0 -3
  32. package/dist/package/entity/order-platform/menu.dto.d.ts +40 -40
  33. package/dist/package/entity/order-platform/shopeefood/shopeefood-order.do.d.ts +8 -8
  34. package/dist/package/entity/payment/payment.dto.d.ts +13 -13
  35. package/dist/package/entity/pubsub/ably/ably.do.d.ts +76 -0
  36. package/dist/package/entity/pubsub/ably/ably.enum.d.ts +3 -0
  37. package/dist/package/entity/pubsub/pubsub.enum.d.ts +3 -0
  38. package/dist/package/entity/queue/queue.do.d.ts +30 -30
  39. package/dist/package/entity/restaurant/restaurant.dto.d.ts +43 -122
  40. package/dist/package/entity/websocket/websocket.dto.d.ts +31 -31
  41. package/dist/package/entity/websocket/websocket.enum.d.ts +1 -1
  42. package/package.json +3 -3
  43. package/src/api/index.ts +46 -33
  44. package/src/api/restaurant-setting/index.ts +7 -18
  45. package/src/helpers/menu.ts +15 -0
  46. package/src/stores/order-setting/index.ts +1 -1
  47. package/src/stores/order-setting/mapper.ts +2 -1
  48. package/src/stores/restaurant/index.ts +5 -19
  49. package/src/views/kiosk/settings/KioskDineInSection.vue +2 -3
  50. package/src/views/order-settings/delivery/DeliverySetting.vue +146 -42
  51. package/src/views/order-settings/delivery/components/TaxInput.vue +57 -0
  52. package/src/views/order-settings/delivery/inhouse/InHouseDelivery.vue +199 -20
  53. package/src/views/order-settings/delivery/integrated-delivery/FeedmeDelivery.vue +0 -2
  54. package/src/views/order-settings/delivery/integrated-delivery/GrabfoodSetting.vue +1 -5
  55. package/src/views/order-settings/delivery/integrated-delivery/ShopeefoodSetting.vue +0 -1
  56. package/src/views/order-settings/dinein/DineInSetting.vue +1 -1
  57. package/src/views/order-settings/pickup/PaymentSidesheet.vue +4 -3
  58. package/src/views/order-settings/pickup/PickUpSettingDialog.vue +1 -1
  59. package/dist/KioskSettingView-DqpBqjGG.js +0 -4
  60. package/dist/app-Bd8YKqAx.js +0 -196933
@@ -0,0 +1,57 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+ import type { PropType } from 'vue';
4
+ import { ItemTax } from '@/helpers/menu';
5
+ import type { Tax } from '@/helpers/menu';
6
+ import { FdoProductTaxSetting } from '@feedmepos/menu/entity';
7
+
8
+ const props = defineProps({
9
+ modelValue: {
10
+ type: Object as PropType<Tax>,
11
+ default: null,
12
+ },
13
+ fallback: {
14
+ type: Object as PropType<Tax>,
15
+ default: null,
16
+ },
17
+ taxOptions: {
18
+ type: Object as PropType<{label: string, value: string}[]>,
19
+ required: true,
20
+ },
21
+ disable: {
22
+ type: Boolean,
23
+ default: false,
24
+ },
25
+ title: {
26
+ type: String,
27
+ default: '',
28
+ },
29
+ });
30
+
31
+ const emits = defineEmits<{
32
+ (ev: 'update:model-value', value: FdoProductTaxSetting[]): void;
33
+ }>();
34
+
35
+ const selectedTax = computed(() => {
36
+ return ItemTax.getSelectedTax(props.modelValue, props.fallback, props.taxOptions);
37
+ });
38
+ </script>
39
+
40
+ <template>
41
+ <div>
42
+ <FmSelect
43
+ :model-value="selectedTax || null"
44
+ label-mark="required"
45
+ :label="title"
46
+ :items="taxOptions"
47
+ :disable="disable"
48
+ @update:model-value="
49
+ (ev) => {
50
+ if (ev) {
51
+ emits('update:model-value', [ItemTax.decodeTax(ev)]);
52
+ }
53
+ }
54
+ "
55
+ />
56
+ </div>
57
+ </template>
@@ -4,15 +4,23 @@ import { useMenuStore } from '@/stores/menu/menu'
4
4
  import type {
5
5
  F_ORDER_PAYMENT_TYPE,
6
6
  FdoDeliveryArea,
7
+ FdoDeliveryTaxSetting,
7
8
  FdoDeliveryTime,
8
9
  FdoOfflinePaymentMethod,
9
10
  FdoRestaurantInHouseDelivery
10
11
  } from '@feedmepos/core/entity'
12
+ import { F_FEATURE } from '@feedmepos/core/entity'
13
+ import { FdoProductTaxSetting } from '@feedmepos/menu/entity'
11
14
  import { computed, reactive, watch, type PropType } from 'vue'
12
15
  import Preorder from '../../pickup/Preorder.vue'
13
16
  import DeliveryTime from './DeliveryTime.vue'
14
17
  import DeliveryOrder, { type Address } from './DeliveryOrder.vue'
15
18
  import PaymentSidesheet from '../../pickup/PaymentSidesheet.vue'
19
+ import { ItemTax } from '@/helpers/menu'
20
+ import { Pos } from '@feedmepos/core'
21
+ import TaxInput from '../components/TaxInput.vue'
22
+ import { useCoreStore } from '@feedmepos/mf-common'
23
+ import { useSnackbar } from '@feedmepos/ui-library'
16
24
 
17
25
  export interface InhouseDialogData {
18
26
  enable: boolean
@@ -23,8 +31,39 @@ export interface InhouseDialogData {
23
31
  offlinePaymentTypes: FdoOfflinePaymentMethod[] | undefined | null
24
32
  ignoreStock: boolean
25
33
  deliveryTime: FdoDeliveryTime | null
34
+ taxes: { [key: string]: FdoDeliveryTaxSetting }
26
35
  }
27
36
 
37
+ enum TaxOption {
38
+ inclusive,
39
+ exclusive
40
+ }
41
+
42
+ const taxInclusiveOptions = [
43
+ {
44
+ label: 'Inclusive',
45
+ value: TaxOption.inclusive
46
+ },
47
+ {
48
+ label: 'Exclusive',
49
+ value: TaxOption.exclusive
50
+ }
51
+ ]
52
+
53
+ const snackBar = useSnackbar()
54
+ const { currentRestaurant } = useCoreStore()
55
+ const minVersionForTax = Pos.minVersionToUse(F_FEATURE.Enum.calculatorV4)
56
+ const validatePosVersion = computed<string>(() => {
57
+ const posVersion = currentRestaurant.value?.posVersion ?? ''
58
+ const feature = F_FEATURE.Enum.calculatorV4
59
+ const res = Pos.canUse({ feature, posVersion })
60
+ if (!res) {
61
+ const minVersion = Pos.minVersionToUse(feature)
62
+ return `*POS version ${minVersion} or above`
63
+ }
64
+ return ''
65
+ })
66
+
28
67
  const props = defineProps({
29
68
  initialValue: {
30
69
  type: Object as PropType<InhouseDialogData>,
@@ -44,17 +83,85 @@ const inhouse = reactive<InhouseDialogData>(
44
83
  props.initialValue
45
84
  ? clone(props.initialValue)
46
85
  : {
47
- enable: false,
48
- catalogId: null,
49
- term: '',
50
- areas: [],
51
- ignoreStock: false,
52
- paymentTypes: [],
53
- offlinePaymentTypes: [],
54
- deliveryTime: null
55
- }
86
+ enable: false,
87
+ catalogId: null,
88
+ term: '',
89
+ areas: [],
90
+ ignoreStock: false,
91
+ paymentTypes: [],
92
+ offlinePaymentTypes: [],
93
+ deliveryTime: null,
94
+ taxes: {}
95
+ }
56
96
  )
57
97
 
98
+ const tax = computed(() => ItemTax.taxSetting())
99
+ const taxOptions = computed(() => tax.value.countryTaxOptions)
100
+
101
+ const hasInhouseDeliveryTax = computed(() => {
102
+ return Object.keys(inhouse.taxes).length > 0
103
+ })
104
+
105
+ const taxSettings = computed(() => {
106
+ return Object.values(inhouse.taxes)
107
+ })
108
+
109
+ const taxInclusive = computed(() => {
110
+ const value = taxSettings.value[0]?.inclusive ?? false
111
+ return value ? TaxOption.inclusive : TaxOption.exclusive
112
+ })
113
+
114
+ function toggleTax(enable: boolean): void {
115
+ if (!enable) {
116
+ inhouse.taxes = {}
117
+ return
118
+ }
119
+
120
+ const firstTax = taxOptions.value[0]
121
+ if (!firstTax) {
122
+ snackBar.open({
123
+ title: 'ttest',
124
+ message: 'Cannot toggle tax setting, no available tax',
125
+ type: 'error'
126
+ })
127
+ return
128
+ }
129
+
130
+ const [systemCode, taxCode] = firstTax.value.split('/')
131
+ inhouse.taxes = {
132
+ [firstTax.value]: {
133
+ inclusive: true,
134
+ systemCode: systemCode,
135
+ taxCode: taxCode
136
+ }
137
+ }
138
+ }
139
+
140
+ function updateTax(taxes: FdoProductTaxSetting[]): void {
141
+ inhouse.taxes = taxes.reduce<{ [key: string]: FdoDeliveryTaxSetting }>((pv, tax) => {
142
+ pv[tax.systemCode] = {
143
+ systemCode: tax.systemCode,
144
+ taxCode: tax.taxCode,
145
+ inclusive: taxInclusive.value === TaxOption.inclusive
146
+ }
147
+ return pv
148
+ }, {})
149
+ }
150
+
151
+ function updateTaxInclusive(taxOption: TaxOption): void {
152
+ const inclusive = taxOption === TaxOption.inclusive
153
+ inhouse.taxes = Object.entries(inhouse.taxes).reduce<{ [key: string]: FdoDeliveryTaxSetting }>(
154
+ (pv, [key, tax]) => {
155
+ pv[key] = {
156
+ ...tax,
157
+ inclusive: !!inclusive
158
+ }
159
+ return pv
160
+ },
161
+ {}
162
+ )
163
+ }
164
+
58
165
  const emits = defineEmits<{
59
166
  (event: 'update:model-value', v: FdoRestaurantInHouseDelivery): void
60
167
  }>()
@@ -83,6 +190,10 @@ function updateTerm(value: string) {
83
190
  emitUpdatedValue()
84
191
  }
85
192
 
193
+ function updatePaymentTypes(v: F_ORDER_PAYMENT_TYPE[]) {
194
+ inhouse.paymentTypes = v
195
+ }
196
+
86
197
  watch(
87
198
  inhouse,
88
199
  (newValue) => {
@@ -117,32 +228,100 @@ const actualDeliveryTime = computed({
117
228
  </script>
118
229
 
119
230
  <template>
120
- <FmSwitch :model-value="inhouse.enable" label="Activate In house Delivery" label-placement="right"
121
- sublabel="Accept In house Delivery with POS" @update:model-value="updateEnable" />
231
+ <FmSwitch
232
+ :model-value="inhouse.enable"
233
+ label="Activate In house Delivery"
234
+ label-placement="right"
235
+ sublabel="Accept In house Delivery with POS"
236
+ @update:model-value="updateEnable"
237
+ />
122
238
  <div v-if="inhouse.enable">
123
239
  <FmCard variant="outlined" class="p-5 mt-10">
124
240
  <div class="flex-grow fm-typo-en-title-sm-600 mb-3">General setting</div>
125
241
 
126
242
  <div class="mb-5">
127
- <FmSwitch :model-value="inhouse.ignoreStock || false" value="ignoreStock" label="Ignore stock"
128
- sublabel="Customer can order even product out of stocks" label-placement="right"
129
- @update:model-value="updateIgnoreStock" />
243
+ <FmSwitch
244
+ :model-value="inhouse.ignoreStock || false"
245
+ value="ignoreStock"
246
+ label="Ignore stock"
247
+ sublabel="Customer can order even product out of stocks"
248
+ label-placement="right"
249
+ @update:model-value="updateIgnoreStock"
250
+ />
130
251
  </div>
131
252
 
132
253
  <div class="mb-5">
133
- <FmSelect :model-value="inhouse.catalogId" label="Catalog" :items="menuStore.catalogOptions"
134
- @update:model-value="updateCatalogId" />
254
+ <FmSelect
255
+ :model-value="inhouse.catalogId"
256
+ label="Catalog"
257
+ :items="menuStore.catalogOptions"
258
+ @update:model-value="updateCatalogId"
259
+ />
135
260
  </div>
136
261
 
137
262
  <div class="mb-5">
138
- <FmTextarea :model-value="inhouse.term" label="Delivery term" @update:model-value="updateTerm" />
263
+ <FmTextarea
264
+ :model-value="inhouse.term"
265
+ label="Delivery term"
266
+ @update:model-value="updateTerm"
267
+ />
268
+ </div>
269
+ </FmCard>
270
+
271
+ <FmCard variant="outlined" class="p-5 mt-10">
272
+ <div class="flex-grow fm-typo-en-title-sm-600 mb-3">
273
+ Tax settings
274
+ <span
275
+ class="text-fm-color-secondary-salmon fm-typo-en-body-sm-600"
276
+ v-if="validatePosVersion"
277
+ >
278
+ (Tax setting only applicable for POS after {{ minVersionForTax }})</span
279
+ >
280
+ </div>
281
+ <div class="mb-5">
282
+ <FmSwitch
283
+ :model-value="hasInhouseDeliveryTax"
284
+ :disabled="!!validatePosVersion.length"
285
+ label="Delivery fee charge tax"
286
+ label-placement="right"
287
+ sublabel="Accept In house Delivery with POS"
288
+ @update:model-value="toggleTax"
289
+ />
290
+ </div>
291
+ <div v-if="hasInhouseDeliveryTax">
292
+ <div class="mb-5">
293
+ <TaxInput
294
+ :model-value="taxSettings"
295
+ :tax-options="taxOptions"
296
+ :title="`${tax.systemCode} (applicable if restaurant profile SST is set)`"
297
+ @update:model-value="(ev) => updateTax(ev)"
298
+ />
299
+ </div>
300
+ <div class="mb-5">
301
+ <FmRadioGroup
302
+ :model-value="taxInclusive"
303
+ label-mark="required"
304
+ inline
305
+ label="Tax calculation"
306
+ @update:model-value="(ev) => updateTaxInclusive(ev as unknown as number)"
307
+ >
308
+ <div v-for="option in taxInclusiveOptions" :key="option.value">
309
+ <FmRadio :value="option.value" :label="option.label" />
310
+ </div>
311
+ </FmRadioGroup>
312
+ </div>
139
313
  </div>
140
314
  </FmCard>
141
315
 
142
316
  <FmCard variant="outlined" class="p-5 mt-10">
143
- <PaymentSidesheet :paymentTypes="inhouse.paymentTypes" :offlinePaymentTypes="inhouse.offlinePaymentTypes"
144
- @update:payment-types="(v: F_ORDER_PAYMENT_TYPE[]) => (inhouse.paymentTypes = v)" @update:offline-payment-types="(v: FdoOfflinePaymentMethod[] | undefined | null) => (inhouse.offlinePaymentTypes = v)
145
- " />
317
+ <PaymentSidesheet
318
+ :paymentTypes="inhouse.paymentTypes"
319
+ :offlinePaymentTypes="inhouse.offlinePaymentTypes"
320
+ @update:payment-types="(v: F_ORDER_PAYMENT_TYPE[]) => updatePaymentTypes(v)"
321
+ @update:offline-payment-types="
322
+ (v: FdoOfflinePaymentMethod[] | undefined | null) => (inhouse.offlinePaymentTypes = v)
323
+ "
324
+ />
146
325
  </FmCard>
147
326
 
148
327
  <FmCard variant="outlined" class="p-5 mt-10">
@@ -1,7 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { clone } from '@/helpers/object'
3
3
  import { useMenuStore } from '@/stores/menu/menu'
4
- import { useRestaurantStore } from '@/stores/restaurant'
5
4
  import { Pos } from '@feedmepos/core'
6
5
  import {
7
6
  F_FEATURE,
@@ -44,7 +43,6 @@ const data = reactive<FdoRestaurantFeedme>(
44
43
  const { sessionUser } = useCoreStore()
45
44
  const canActivateFeedmeExpress = computed(() => sessionUser.value?.isInternal)
46
45
  const { currentRestaurant } = useCoreStore()
47
- const restaurantStore = useRestaurantStore()
48
46
  const validatePosVersion = computed<ValidateFeedmeResult>(() => {
49
47
  const posVersion = currentRestaurant?.value?.posVersion
50
48
  const res = Pos.canUse({
@@ -5,7 +5,6 @@ import type { FdoLinkedDelivery } from '@feedmepos/core/entity'
5
5
  import { FdoGrabfoodSettings } from '@entity'
6
6
  import type { DeliveryCompany } from '../delivery'
7
7
  import type { IntegratedDeliverySettingData } from './IntegratedDelivery.vue'
8
- import { useRestaurantStore } from '@/stores/restaurant'
9
8
  import { useLoading } from '@/composables/loading'
10
9
  import { remoteOrderApi } from '@/api/remoteOrder'
11
10
  import IntegratedDelivery from './IntegratedDelivery.vue'
@@ -51,7 +50,7 @@ const modelValue = computed<IntegratedDeliverySettingData>(() => {
51
50
  }
52
51
  })
53
52
 
54
- const restaurantStore = useRestaurantStore()
53
+ const { currentRestaurant } = useCoreStore()
55
54
 
56
55
 
57
56
  function updateData({ manual, auto }: IntegratedDeliverySettingData) {
@@ -60,7 +59,6 @@ function updateData({ manual, auto }: IntegratedDeliverySettingData) {
60
59
  ...auto,
61
60
  merchantID: auto.integrationId,
62
61
  commissionRate: auto.commissionRate,
63
- partnerMerchantID: restaurantStore.currentRestaurantId
64
62
  }
65
63
  return { manual: data.manual, integrated: data.integrated };
66
64
  }
@@ -90,8 +88,6 @@ async function syncMenu() {
90
88
  })
91
89
  }
92
90
 
93
- const { currentRestaurant } = useCoreStore()
94
-
95
91
  import { useSnackbarFunctions } from '@/components/snackbar'
96
92
  const { showSuccess } = useSnackbarFunctions();
97
93
 
@@ -6,7 +6,6 @@ import type { DeliveryCompany } from "../delivery";
6
6
  import type { IntegratedDeliverySettingData } from "./IntegratedDelivery.vue";
7
7
  import { useLoading } from "@/composables/loading";
8
8
  import { remoteOrderApi } from "@/api/remoteOrder";
9
- import { useRestaurantStore } from "@/stores/restaurant";
10
9
  import IntegratedDelivery from "./IntegratedDelivery.vue";
11
10
  import { clone } from "@/helpers/object";
12
11
  import { useCoreStore } from "@feedmepos/mf-common";
@@ -82,7 +82,7 @@ async function updateDineInSetting() {
82
82
  const id = currentRestaurant.value?._id ?? ''
83
83
  const orderSetting = dineInSetting.value
84
84
  if (orderSetting) {
85
- await restaurantStore.updateDineInSetting(id, orderSetting)
85
+ await restaurantStore.updateDineInSetting(orderSetting)
86
86
  if (currentRestaurant.value) {
87
87
  currentRestaurant.value.dineIn = orderSetting
88
88
  }
@@ -111,8 +111,8 @@ const handleParentUpdate = (ev: boolean) => {
111
111
  if (nestedVal.value.includes('offline')) {
112
112
  updatedPaymentTypes.push(F_ORDER_PAYMENT_TYPE.enum.cash)
113
113
  }
114
-
115
- emits('update:payments', { paymentTypes: updatedPaymentTypes, offlinePaymentTypes: updatedOfflinePaymentTypes })
114
+ emits('update:paymentTypes', updatedPaymentTypes)
115
+ emits('update:offlinePaymentTypes', updatedOfflinePaymentTypes)
116
116
  }
117
117
 
118
118
  const handleChildUpdate = (ev: string[]) => {
@@ -128,7 +128,8 @@ const handleChildUpdate = (ev: string[]) => {
128
128
  if (ev.includes('offline')) {
129
129
  updatedPaymentTypes.push(F_ORDER_PAYMENT_TYPE.enum.cash)
130
130
  }
131
- emits('update:payments', { paymentTypes: updatedPaymentTypes, offlinePaymentTypes: updatedOfflinePaymentTypes })
131
+ emits('update:paymentTypes', updatedPaymentTypes)
132
+ emits('update:offlinePaymentTypes', updatedOfflinePaymentTypes)
132
133
  }
133
134
 
134
135
  const localOfflinePaymentTypes = ref<FdoRestaurantPickup['offlinePaymentTypes']>(
@@ -58,7 +58,7 @@ function updatePickupSetting(value: FdoRestaurantPickup) {
58
58
  async function onSave() {
59
59
  await startAsyncCallWithErr(async () => {
60
60
  const id = currentRestaurant.value?._id ?? ''
61
- await restaurantStore.updatePickupSetting(id, pickupSetting.value)
61
+ await restaurantStore.updatePickupSetting(pickupSetting.value)
62
62
  if (currentRestaurant.value) {
63
63
  currentRestaurant.value.pickup = pickupSetting.value
64
64
  }
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./app-Bd8YKqAx.js";
2
- export {
3
- f as default
4
- };