From 89cfaa9eaeec95f10f9a819282eb016858ada0e8 Mon Sep 17 00:00:00 2001 From: Sneha Date: Thu, 8 Aug 2024 13:00:16 +0530 Subject: [PATCH 1/2] CSR-2155 --- .../afterpay-modal-banner.vue | 15 +++++++++------ src/layouts/quote/quote.vue | 1 + .../service-package-question.vue | 10 ++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue index a77bde39d..44ff5a6ed 100644 --- a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue +++ b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue @@ -53,6 +53,7 @@ export default { props: { cmsWidgetName: String, lineItems: Array, + activePromos: null, }, data() { return {}; @@ -76,7 +77,11 @@ export default { return this.getCmsContent(this.cmsWidgetName, "SubheaderText"); }, afterpayPrice() { - const allLineItems = getArrayOfAllLineItems(this.lineItems); + let allLineItems = getArrayOfAllLineItems(this.lineItems); + if (this.activePromos) { + allLineItems = allLineItems?.filter((item) => item.partType !== "PROMO_DISCOUNT"); + } + let price = baseMixin.methods.getTierOnePackagePrice( baseMixin.methods.filterOutFees(allLineItems) ); @@ -86,11 +91,9 @@ export default { price += baseMixin.methods.getTotalLineItemPrice(lineItem); }); - if (this.lineItems.promos) { - const promos = getPromosThatMatchLineItemsOnOrder( - this.lineItems.promos, - allLineItems - ); + if (this.activePromos) { + let allLineItems = getArrayOfAllLineItems(this.lineItems); + const promos = getPromosThatMatchLineItemsOnOrder(this.activePromos, allLineItems); promos.forEach((promo) => { price += baseMixin.methods.getTotalLineItemPrice(promo); }); diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 8f9d256e0..212378d03 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -44,6 +44,7 @@
diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index 94cbb7685..d9d0bc6dc 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -76,6 +76,16 @@ export default { this.getServicePackageDiscountPartForSelectedPackage(newValue); let supportingItems = this.supportingLineItems; if (servicePackageDiscountPartInSelectedPackage?.length > 0) { + if ( + containsLineItemWithPartType( + partTypeStrings.SERVICE_PACKAGE_DISCOUNT, + supportingItems + ) + ) { + supportingItems = supportingItems.filter( + (item) => item.partType !== partTypeStrings.SERVICE_PACKAGE_DISCOUNT + ); + } supportingItems?.push(servicePackageDiscountPartInSelectedPackage[0]); } else { if ( From 51071c375af0648512142eb5a20f9b6f956b212d Mon Sep 17 00:00:00 2001 From: Sneha Date: Thu, 8 Aug 2024 16:22:08 +0530 Subject: [PATCH 2/2] code changes --- .../afterpay-modal-banner.vue | 10 +++-- src/layouts/quote/quote.vue | 1 - .../service-package-question.vue | 40 ++++++++----------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue index 44ff5a6ed..512d0f577 100644 --- a/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue +++ b/src/layouts/quote/afterpay-modal-banner/afterpay-modal-banner.vue @@ -53,7 +53,6 @@ export default { props: { cmsWidgetName: String, lineItems: Array, - activePromos: null, }, data() { return {}; @@ -78,7 +77,7 @@ export default { }, afterpayPrice() { let allLineItems = getArrayOfAllLineItems(this.lineItems); - if (this.activePromos) { + if (this.lineItems.promos) { allLineItems = allLineItems?.filter((item) => item.partType !== "PROMO_DISCOUNT"); } @@ -91,9 +90,12 @@ export default { price += baseMixin.methods.getTotalLineItemPrice(lineItem); }); - if (this.activePromos) { + if (this.lineItems.promos) { let allLineItems = getArrayOfAllLineItems(this.lineItems); - const promos = getPromosThatMatchLineItemsOnOrder(this.activePromos, allLineItems); + const promos = getPromosThatMatchLineItemsOnOrder( + this.lineItems.promos, + allLineItems + ); promos.forEach((promo) => { price += baseMixin.methods.getTotalLineItemPrice(promo); }); diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 212378d03..8f9d256e0 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -44,7 +44,6 @@
diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index d9d0bc6dc..c4e73b451 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -75,31 +75,23 @@ export default { const servicePackageDiscountPartInSelectedPackage = this.getServicePackageDiscountPartForSelectedPackage(newValue); let supportingItems = this.supportingLineItems; - if (servicePackageDiscountPartInSelectedPackage?.length > 0) { - if ( - containsLineItemWithPartType( - partTypeStrings.SERVICE_PACKAGE_DISCOUNT, - supportingItems - ) - ) { - supportingItems = supportingItems.filter( - (item) => item.partType !== partTypeStrings.SERVICE_PACKAGE_DISCOUNT - ); - } - supportingItems?.push(servicePackageDiscountPartInSelectedPackage[0]); - } else { - if ( - supportingItems?.length > 0 && - containsLineItemWithPartType( - partTypeStrings.SERVICE_PACKAGE_DISCOUNT, - supportingItems - ) - ) { - supportingItems = supportingItems.filter( - (item) => item.partType !== partTypeStrings.SERVICE_PACKAGE_DISCOUNT - ); - } + if ( + containsLineItemWithPartType( + partTypeStrings.SERVICE_PACKAGE_DISCOUNT, + supportingItems + ) + ) { + supportingItems = supportingItems.filter( + (item) => item.partType !== partTypeStrings.SERVICE_PACKAGE_DISCOUNT + ); } + if ( + servicePackageDiscountPartInSelectedPackage?.length > 0 && + supportingItems != null + ) { + supportingItems.push(servicePackageDiscountPartInSelectedPackage[0]); + } + this.$emit("servicePackageDiscountSelected", supportingItems); }, },