@managesome/eposmatic-toolkit 0.2.314 → 0.2.315
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.
- package/lib/constants/COMMON.d.ts +3 -0
- package/lib/constants/COMMON.js +4 -1
- package/lib/helpers/store/cart-actions.js +34 -4
- package/lib/helpers/utils/offer-apply-helpers.js +36 -4
- package/lib/helpers/utils/simplified-tenant.d.ts +1 -0
- package/lib/helpers/utils/simplified-tenant.js +1 -0
- package/lib/schemas/models/tenant.d.ts +3 -0
- package/lib/schemas/models/tenant.js +4 -0
- package/lib/schemas/types/tenant.d.ts +1 -0
- package/package.json +1 -1
|
@@ -69,4 +69,7 @@ export declare const SUBSCRIPTION_STATUS_COLOR: {
|
|
|
69
69
|
};
|
|
70
70
|
export declare const SPECIALS_CATEGORY_ID = "680437e050ad8ba788150b32";
|
|
71
71
|
export declare const SPECIALS_CATEGORY_NAME = "Specials";
|
|
72
|
+
export declare const WALLET_CASHBACK_SPECIAL_DISCOUNT_ID = "wallet_cashback_redemption";
|
|
73
|
+
export declare const WALLET_CASHBACK_SPECIAL_DISCOUNT_NAME = "Wallet Cashback";
|
|
74
|
+
export declare const WALLET_CASHBACK_SPECIAL_REFERENCE = "WALLET_CASHBACK";
|
|
72
75
|
export {};
|
package/lib/constants/COMMON.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SPECIALS_CATEGORY_NAME = exports.SPECIALS_CATEGORY_ID = exports.SUBSCRIPTION_STATUS_COLOR = exports.AUTO_DELIVERY_CHARGES_PLATFORMS = exports.TAX_INVOICE_PROVIDER_CHARGES_MAP = exports.PAYMENT_CHARGES_MAP = exports.NOTIFICATION_CHARGES_MAP = exports.WHATSAPP_CHARGES_MAP = exports.SMS_CHARGES_MAP = exports.SMS_UNIT_LENGTH = exports.PROVIDER_OPERATIONAL_COUNTRIES = exports.ALL_PLAFORMS_OBJ = exports.LOW_VALUE_CURRENCY_COUNTRIES = void 0;
|
|
3
|
+
exports.WALLET_CASHBACK_SPECIAL_REFERENCE = exports.WALLET_CASHBACK_SPECIAL_DISCOUNT_NAME = exports.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID = exports.SPECIALS_CATEGORY_NAME = exports.SPECIALS_CATEGORY_ID = exports.SUBSCRIPTION_STATUS_COLOR = exports.AUTO_DELIVERY_CHARGES_PLATFORMS = exports.TAX_INVOICE_PROVIDER_CHARGES_MAP = exports.PAYMENT_CHARGES_MAP = exports.NOTIFICATION_CHARGES_MAP = exports.WHATSAPP_CHARGES_MAP = exports.SMS_CHARGES_MAP = exports.SMS_UNIT_LENGTH = exports.PROVIDER_OPERATIONAL_COUNTRIES = exports.ALL_PLAFORMS_OBJ = exports.LOW_VALUE_CURRENCY_COUNTRIES = void 0;
|
|
4
4
|
const ENUMS_1 = require("./ENUMS");
|
|
5
5
|
/**
|
|
6
6
|
* Countries with low-value currencies that should have:
|
|
@@ -342,3 +342,6 @@ exports.SUBSCRIPTION_STATUS_COLOR = {
|
|
|
342
342
|
};
|
|
343
343
|
exports.SPECIALS_CATEGORY_ID = '680437e050ad8ba788150b32';
|
|
344
344
|
exports.SPECIALS_CATEGORY_NAME = 'Specials';
|
|
345
|
+
exports.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID = 'wallet_cashback_redemption';
|
|
346
|
+
exports.WALLET_CASHBACK_SPECIAL_DISCOUNT_NAME = 'Wallet Cashback';
|
|
347
|
+
exports.WALLET_CASHBACK_SPECIAL_REFERENCE = 'WALLET_CASHBACK';
|
|
@@ -33,7 +33,6 @@ const lodash_1 = require("lodash");
|
|
|
33
33
|
const constants_1 = require("../../constants");
|
|
34
34
|
const utils_1 = require("../utils");
|
|
35
35
|
const platform_catalog_1 = require("../utils/platform-catalog");
|
|
36
|
-
const WALLET_CASHBACK_SPECIAL_DISCOUNT_ID = 'wallet_cashback_redemption';
|
|
37
36
|
function getItemQuantityChangeResults({ prevQuantity, newQuantity, prevItemDiscountDetails, }) {
|
|
38
37
|
let item_discount_details = prevItemDiscountDetails;
|
|
39
38
|
const getScaledFixedDiscount = (discountValue, isPercentage) => {
|
|
@@ -530,7 +529,7 @@ function getWalletRedemptionsMap(walletRedemptions) {
|
|
|
530
529
|
return Object.keys(normalized).length > 0 ? normalized : null;
|
|
531
530
|
}
|
|
532
531
|
function isWalletCashbackSpecialDiscount(orderDiscountDetails) {
|
|
533
|
-
return orderDiscountDetails?.special_discount_id === WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
532
|
+
return orderDiscountDetails?.special_discount_id === constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
534
533
|
}
|
|
535
534
|
function getWalletCashbackAmountFromOrderData({ orderDiscountDetails, walletRedemptions, }) {
|
|
536
535
|
if (!isWalletCashbackSpecialDiscount(orderDiscountDetails)) {
|
|
@@ -560,7 +559,7 @@ function getSyncedWalletCashbackOrderDiscountDetails({ orderDiscountDetails, wal
|
|
|
560
559
|
}
|
|
561
560
|
return {
|
|
562
561
|
...orderDiscountDetails,
|
|
563
|
-
special_discount_id: WALLET_CASHBACK_SPECIAL_DISCOUNT_ID,
|
|
562
|
+
special_discount_id: constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID,
|
|
564
563
|
special_discount: (0, utils_1.parseNum)(walletCashbackAmount),
|
|
565
564
|
is_special_discount_percentage: false,
|
|
566
565
|
};
|
|
@@ -603,6 +602,7 @@ function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calcu
|
|
|
603
602
|
});
|
|
604
603
|
}
|
|
605
604
|
let syncedOrderDiscountDetails = data.order_discount_details;
|
|
605
|
+
let syncedRedeemedOffers = getRedeemedOffersMap(data.redeemed_offers);
|
|
606
606
|
let syncedWalletRedemptions = getWalletRedemptionsMap(data.wallet_redemptions);
|
|
607
607
|
const hasWalletCashbackSpecialDiscount = isWalletCashbackSpecialDiscount(syncedOrderDiscountDetails);
|
|
608
608
|
const hasWalletCashbackMetadata = Number(syncedWalletRedemptions?.cashback_amount ?? 0) > 0;
|
|
@@ -629,6 +629,36 @@ function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calcu
|
|
|
629
629
|
cashback_amount: undefined,
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
|
+
const hasNonWalletSpecialDiscount = syncedOrderDiscountDetails?.special_discount_id != null &&
|
|
633
|
+
syncedOrderDiscountDetails.special_discount_id !== constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
634
|
+
const walletGiftCardRedeemedTimes = Number(syncedWalletRedemptions?.gift_cards?.value_redeemed ?? 0);
|
|
635
|
+
const hasWalletGiftCardMetadata = syncedWalletRedemptions?.gift_cards?.gift_card_id != null &&
|
|
636
|
+
syncedWalletRedemptions.gift_cards.gift_card_id.trim().length > 0 &&
|
|
637
|
+
Number.isFinite(walletGiftCardRedeemedTimes) &&
|
|
638
|
+
walletGiftCardRedeemedTimes > 0;
|
|
639
|
+
// Empty carts must not retain non-wallet special discounts or gift-card wallet claims.
|
|
640
|
+
if (subtotal <= 0) {
|
|
641
|
+
if (hasNonWalletSpecialDiscount && syncedOrderDiscountDetails != null) {
|
|
642
|
+
syncedOrderDiscountDetails = {
|
|
643
|
+
...syncedOrderDiscountDetails,
|
|
644
|
+
special_discount_id: undefined,
|
|
645
|
+
special_discount_name: undefined,
|
|
646
|
+
special_discount: undefined,
|
|
647
|
+
is_special_discount_percentage: false,
|
|
648
|
+
special_reference_number: undefined,
|
|
649
|
+
total_discount: 0,
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
if (syncedRedeemedOffers != null) {
|
|
653
|
+
syncedRedeemedOffers = null;
|
|
654
|
+
}
|
|
655
|
+
if (hasWalletGiftCardMetadata) {
|
|
656
|
+
syncedWalletRedemptions = getWalletRedemptionsMap({
|
|
657
|
+
...(syncedWalletRedemptions ?? {}),
|
|
658
|
+
gift_cards: undefined,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
}
|
|
632
662
|
const applyGSTOnOriginalPrice = data.exclude_discount_from_gst;
|
|
633
663
|
const order_discount_details = getDiscountDetails(syncedOrderDiscountDetails, subtotal);
|
|
634
664
|
// This can be both negative or positive
|
|
@@ -860,7 +890,7 @@ function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calcu
|
|
|
860
890
|
...data,
|
|
861
891
|
categories,
|
|
862
892
|
order_discount_details,
|
|
863
|
-
redeemed_offers:
|
|
893
|
+
redeemed_offers: syncedRedeemedOffers,
|
|
864
894
|
wallet_redemptions: syncedWalletRedemptions,
|
|
865
895
|
total_discount_applied,
|
|
866
896
|
delivery_details,
|
|
@@ -10,7 +10,7 @@ exports.getSyncOffersWithCartData = getSyncOffersWithCartData;
|
|
|
10
10
|
const constants_1 = require("../../constants");
|
|
11
11
|
const cart_actions_1 = require("../store/cart-actions");
|
|
12
12
|
const common_1 = require("./common");
|
|
13
|
-
//
|
|
13
|
+
// ================================><================================= //
|
|
14
14
|
// === Shared order subtotal for discount logic === //
|
|
15
15
|
// ================================><================================= //
|
|
16
16
|
function getOrderSubtotalFromCategories(categories) {
|
|
@@ -25,9 +25,8 @@ function getOrderSubtotalFromCategories(categories) {
|
|
|
25
25
|
}
|
|
26
26
|
return subtotal;
|
|
27
27
|
}
|
|
28
|
-
const WALLET_CASHBACK_SPECIAL_DISCOUNT_ID = 'wallet_cashback_redemption';
|
|
29
28
|
function isWalletCashbackSpecialDiscount(orderDiscountDetails) {
|
|
30
|
-
return orderDiscountDetails?.special_discount_id === WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
29
|
+
return orderDiscountDetails?.special_discount_id === constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
31
30
|
}
|
|
32
31
|
function getWalletCashbackAmountFromOrderData({ orderDiscountDetails, walletRedemptions, }) {
|
|
33
32
|
if (!isWalletCashbackSpecialDiscount(orderDiscountDetails)) {
|
|
@@ -60,7 +59,7 @@ function getSyncedWalletCashbackOrderDiscountDetails({ orderDiscountDetails, wal
|
|
|
60
59
|
}
|
|
61
60
|
return {
|
|
62
61
|
...orderDiscountDetails,
|
|
63
|
-
special_discount_id: WALLET_CASHBACK_SPECIAL_DISCOUNT_ID,
|
|
62
|
+
special_discount_id: constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID,
|
|
64
63
|
special_discount: (0, common_1.parseNum)(walletCashbackAmount),
|
|
65
64
|
is_special_discount_percentage: false,
|
|
66
65
|
};
|
|
@@ -565,6 +564,39 @@ offers) {
|
|
|
565
564
|
});
|
|
566
565
|
hasChanges = true;
|
|
567
566
|
}
|
|
567
|
+
const hasNonWalletSpecialDiscount = order_discount_details?.special_discount_id != null &&
|
|
568
|
+
order_discount_details.special_discount_id !== constants_1.WALLET_CASHBACK_SPECIAL_DISCOUNT_ID;
|
|
569
|
+
const walletGiftCardRedeemedTimes = Number(wallet_redemptions?.gift_cards?.value_redeemed ?? 0);
|
|
570
|
+
const hasWalletGiftCardMetadata = wallet_redemptions?.gift_cards?.gift_card_id != null &&
|
|
571
|
+
wallet_redemptions.gift_cards.gift_card_id.trim().length > 0 &&
|
|
572
|
+
Number.isFinite(walletGiftCardRedeemedTimes) &&
|
|
573
|
+
walletGiftCardRedeemedTimes > 0;
|
|
574
|
+
// Empty carts must not retain non-wallet special discounts or gift-card wallet claims.
|
|
575
|
+
if (orderLevelDiscountBaseAmount <= 0) {
|
|
576
|
+
if (hasNonWalletSpecialDiscount && order_discount_details != null) {
|
|
577
|
+
order_discount_details = {
|
|
578
|
+
...order_discount_details,
|
|
579
|
+
special_discount_id: undefined,
|
|
580
|
+
special_discount_name: undefined,
|
|
581
|
+
special_discount: undefined,
|
|
582
|
+
is_special_discount_percentage: false,
|
|
583
|
+
special_reference_number: undefined,
|
|
584
|
+
total_discount: 0,
|
|
585
|
+
};
|
|
586
|
+
hasChanges = true;
|
|
587
|
+
}
|
|
588
|
+
if (redeemed_offers != null) {
|
|
589
|
+
redeemed_offers = null;
|
|
590
|
+
hasChanges = true;
|
|
591
|
+
}
|
|
592
|
+
if (hasWalletGiftCardMetadata) {
|
|
593
|
+
wallet_redemptions = getNormalizedWalletRedemptionsMap({
|
|
594
|
+
...(wallet_redemptions ?? {}),
|
|
595
|
+
gift_cards: undefined,
|
|
596
|
+
});
|
|
597
|
+
hasChanges = true;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
568
600
|
const redeemedOffersPresenceMap = getReconciledRedeemedOffersMap({
|
|
569
601
|
existingRedeemedOffers: redeemed_offers,
|
|
570
602
|
categories,
|
|
@@ -199,6 +199,7 @@ export interface ISettingsForPOS {
|
|
|
199
199
|
playstore_url: ITenant['playstore_url'];
|
|
200
200
|
appstore_url: ITenant['appstore_url'];
|
|
201
201
|
google_review_link: ITenant['google_review_link'];
|
|
202
|
+
force_isolated_printing: ITenant['force_isolated_printing'];
|
|
202
203
|
}
|
|
203
204
|
export declare function getSettingsForPOS(settings: ITenant): ISettingsForPOS;
|
|
204
205
|
export interface ISettingsForPrinter {
|
|
@@ -296,6 +296,7 @@ function getSettingsForPOS(settings) {
|
|
|
296
296
|
playstore_url: settings.playstore_url,
|
|
297
297
|
appstore_url: settings.appstore_url,
|
|
298
298
|
google_review_link: settings.google_review_link,
|
|
299
|
+
force_isolated_printing: settings.force_isolated_printing,
|
|
299
300
|
};
|
|
300
301
|
}
|
|
301
302
|
function getSettingsForCloud(settings) {
|
|
@@ -174,6 +174,7 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
|
|
|
174
174
|
receipt_qr_type?: import("../../constants").RECEIPT_QR_CODE_TYPE_ENUM | null | undefined;
|
|
175
175
|
menu_source?: string | null | undefined;
|
|
176
176
|
app_version?: string | null | undefined;
|
|
177
|
+
force_isolated_printing?: boolean | null | undefined;
|
|
177
178
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
178
179
|
createdAt: NativeDate;
|
|
179
180
|
updatedAt: NativeDate;
|
|
@@ -344,6 +345,7 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
|
|
|
344
345
|
receipt_qr_type?: import("../../constants").RECEIPT_QR_CODE_TYPE_ENUM | null | undefined;
|
|
345
346
|
menu_source?: string | null | undefined;
|
|
346
347
|
app_version?: string | null | undefined;
|
|
348
|
+
force_isolated_printing?: boolean | null | undefined;
|
|
347
349
|
}>> & import("mongoose").FlatRecord<{
|
|
348
350
|
createdAt: NativeDate;
|
|
349
351
|
updatedAt: NativeDate;
|
|
@@ -514,6 +516,7 @@ export declare const TenantSchema: Schema<any, import("mongoose").Model<any, any
|
|
|
514
516
|
receipt_qr_type?: import("../../constants").RECEIPT_QR_CODE_TYPE_ENUM | null | undefined;
|
|
515
517
|
menu_source?: string | null | undefined;
|
|
516
518
|
app_version?: string | null | undefined;
|
|
519
|
+
force_isolated_printing?: boolean | null | undefined;
|
|
517
520
|
}> & Required<{
|
|
518
521
|
_id: string;
|
|
519
522
|
}> & {
|