CASH-926: adjust donation in cart without redoing pricing
This commit is contained in:
parent
eecb29cf43
commit
9089da5d5a
3 changed files with 42 additions and 36 deletions
|
|
@ -119,7 +119,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-if="donationCartItem" class="donation-amount">
|
<div v-if="donationCartItem" class="donation-amount">
|
||||||
<span>{{ donationCartItemName }}</span>
|
<span>{{ donationCartItemName }}</span>
|
||||||
<span>{{ getLineItemAmount(donationCartItem.subTotal) }}</span>
|
<span>{{ getLineItemAmount(donationCartItem.sellingPrice) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="amount-due">
|
<div class="amount-due">
|
||||||
<span>{{ amountDueText }}</span>
|
<span>{{ amountDueText }}</span>
|
||||||
|
|
@ -182,6 +182,7 @@ import {
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
getSubTotal,
|
||||||
getSalesTax,
|
getSalesTax,
|
||||||
|
getAmountDueWithDonation,
|
||||||
} from "@/helpers/pricing-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
@ -211,6 +212,7 @@ export default {
|
||||||
isNoComp: Boolean,
|
isNoComp: Boolean,
|
||||||
isExpandedOnLoad: Boolean,
|
isExpandedOnLoad: Boolean,
|
||||||
isMSRFeeApplicable: Boolean,
|
isMSRFeeApplicable: Boolean,
|
||||||
|
donationCartItem: Object,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -1083,33 +1085,6 @@ export default {
|
||||||
donationCartItemName() {
|
donationCartItemName() {
|
||||||
return this.getCmsContent("DonationCartTextWidget", "Text");
|
return this.getCmsContent("DonationCartTextWidget", "Text");
|
||||||
},
|
},
|
||||||
donationCartItem() {
|
|
||||||
if (!this.lineItems || !this.lineItems.supportingItems) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const donationLineItem = this.lineItems.supportingItems.find(
|
|
||||||
(item) => item.partType === partTypeStrings.DONATION
|
|
||||||
);
|
|
||||||
|
|
||||||
if (donationLineItem) {
|
|
||||||
return {
|
|
||||||
name: this.donationCartItemName,
|
|
||||||
category: cartItemCategories.SUPPORTING_ITEMS,
|
|
||||||
cartItemType: cartItemTypes.DONATION,
|
|
||||||
isDisplayed: true,
|
|
||||||
isRemovable: false,
|
|
||||||
subTotal: donationLineItem.sellingPrice,
|
|
||||||
salesTax: 0,
|
|
||||||
lineItems: [],
|
|
||||||
isCoveredByInsurance: cartItemTypesCoveredByInsurance.includes(
|
|
||||||
cartItemTypes.DONATION
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
removeLinkText() {
|
removeLinkText() {
|
||||||
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
||||||
},
|
},
|
||||||
|
|
@ -1156,9 +1131,15 @@ export default {
|
||||||
amountDue() {
|
amountDue() {
|
||||||
if (!this.lineItems || this.lineItems.length < 1) return;
|
if (!this.lineItems || this.lineItems.length < 1) return;
|
||||||
if (this.showAsPaid) return 0;
|
if (this.showAsPaid) return 0;
|
||||||
return this.isInsurance || !this.shouldHideRecalibration
|
if (this.isInsurance || !this.shouldHideRecalibration) {
|
||||||
? getAmountDue(this.lineItems) // calculate with recal (if on order)
|
return this.donationCartItem
|
||||||
: getAmountDue(this.lineItemsWithoutRecal); // calculated without recal
|
? getAmountDueWithDonation(this.lineItems, this.donationCartItem)
|
||||||
|
: getAmountDue(this.lineItems);
|
||||||
|
} else {
|
||||||
|
return this.donationCartItem
|
||||||
|
? getAmountDueWithDonation(this.lineItemsWithoutRecal, this.donationCartItem)
|
||||||
|
: getAmountDue(this.lineItemsWithoutRecal);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
amountPaid() {
|
amountPaid() {
|
||||||
if (!this.showAsPaid) {
|
if (!this.showAsPaid) {
|
||||||
|
|
@ -1311,8 +1292,7 @@ export default {
|
||||||
.amount-due,
|
.amount-due,
|
||||||
.amount-paid,
|
.amount-paid,
|
||||||
.donation-amount {
|
.donation-amount {
|
||||||
font-family:
|
font-family: UrbanistSemibold;
|
||||||
UrbanistSemibold, AvertaSemibold; /* Okay to remove AvertaSemibold after 2025.06.19 merge/release */
|
|
||||||
color: $black;
|
color: $black;
|
||||||
}
|
}
|
||||||
.sub-total {
|
.sub-total {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
|
|
||||||
export function getDisplayAmountDue(lineItemsObject, includeTax = true) {
|
export function getDisplayAmountDue(lineItemsObject, includeTax = true) {
|
||||||
return getAmountDue(lineItemsObject, includeTax).toLocaleString("en-US", {
|
return getAmountDue(lineItemsObject, includeTax).toLocaleString("en-US", {
|
||||||
|
|
@ -62,6 +63,13 @@ export function getSalesTax(lineItemsObject) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAmountDueWithDonation(lineItemsObject, donationLineItem) {
|
||||||
|
// this is amount due with Donation added
|
||||||
|
const lineItemsCloneWithDonation = deepClone(lineItemsObject);
|
||||||
|
lineItemsCloneWithDonation.supportingItems.push(donationLineItem);
|
||||||
|
return getAmountDue(lineItemsCloneWithDonation, false);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getPricingByDayPartWithPrice(pageNameToLog) {
|
export async function getPricingByDayPartWithPrice(pageNameToLog) {
|
||||||
// Get the Pricing By Day Part
|
// Get the Pricing By Day Part
|
||||||
const basePriceByDayPart = await baseMixin.methods.dispatchStoreActionWithLogging(
|
const basePriceByDayPart = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@
|
||||||
:damage="damageInfo"
|
:damage="damageInfo"
|
||||||
:availableVaps="vaps"
|
:availableVaps="vaps"
|
||||||
:allowItemRemoval="false"
|
:allowItemRemoval="false"
|
||||||
v-model="lineItems"
|
v-model="lineItemsWithoutDonation"
|
||||||
|
:donationCartItem="donationLineItem"
|
||||||
:showAsPaid="isPia"
|
:showAsPaid="isPia"
|
||||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||||
:isInsurance="isInsurance"
|
:isInsurance="isInsurance"
|
||||||
|
|
@ -123,6 +124,7 @@ import experimentMixin from "@/mixins/experiment-mixin.js";
|
||||||
import { containsRecalParts } from "@/helpers/recal-helper.js";
|
import { containsRecalParts } from "@/helpers/recal-helper.js";
|
||||||
import donationBlock from "@/experiment-components/donation-block.vue";
|
import donationBlock from "@/experiment-components/donation-block.vue";
|
||||||
import { partNumberStrings } from "@/constants/part-number-strings";
|
import { partNumberStrings } from "@/constants/part-number-strings";
|
||||||
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -229,7 +231,7 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
const donationItems = lineItemsFromSubmittedOrder.supportingItems?.filter(
|
const donationItems = lineItemsFromSubmittedOrder.supportingItems?.filter(
|
||||||
(item) => item.partNumber === partNumberStrings.DONATION
|
(item) => item.partType === partTypeStrings.DONATION
|
||||||
);
|
);
|
||||||
const donationAmount = donationItems?.length > 0 ? donationItems[0].sellingPrice : 0;
|
const donationAmount = donationItems?.length > 0 ? donationItems[0].sellingPrice : 0;
|
||||||
|
|
||||||
|
|
@ -243,7 +245,7 @@ export default {
|
||||||
vm.shouldDisplayFosterLove = hasFosterLoveExperiment;
|
vm.shouldDisplayFosterLove = hasFosterLoveExperiment;
|
||||||
vm.donationAmount = donationAmount;
|
vm.donationAmount = donationAmount;
|
||||||
vm.showDonationSuccess = lineItemsFromSubmittedOrder.supportingItems?.some(
|
vm.showDonationSuccess = lineItemsFromSubmittedOrder.supportingItems?.some(
|
||||||
(item) => item.partType === partNumberStrings.DONATION
|
(item) => item.partType === partTypeStrings.DONATION
|
||||||
);
|
);
|
||||||
|
|
||||||
vm.pushAnalytics();
|
vm.pushAnalytics();
|
||||||
|
|
@ -490,6 +492,22 @@ export default {
|
||||||
donationValues() {
|
donationValues() {
|
||||||
return [1, 3, 5];
|
return [1, 3, 5];
|
||||||
},
|
},
|
||||||
|
lineItemsWithoutDonation() {
|
||||||
|
const lineItemsClone = deepClone(this.lineItems);
|
||||||
|
lineItemsClone.supportingItems = lineItemsClone.supportingItems?.filter(
|
||||||
|
(item) => item.partType !== partTypeStrings.DONATION
|
||||||
|
);
|
||||||
|
return lineItemsClone;
|
||||||
|
},
|
||||||
|
donationLineItem() {
|
||||||
|
if (!this.lineItems) return null;
|
||||||
|
const donationLineItems = this.lineItems.supportingItems?.filter(
|
||||||
|
(item) => item.partType === partTypeStrings.DONATION
|
||||||
|
);
|
||||||
|
let output =
|
||||||
|
donationLineItems && donationLineItems.length > 0 ? donationLineItems[0] : null;
|
||||||
|
return output;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue