From 15ca0785c16572f82a402d2481f03484ee4e2692 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 23 Apr 2024 17:39:47 -0400 Subject: [PATCH] CSR-1742: update naming and some logic to simplify --- src/fmg-components/cart/cart.vue | 63 +++++++++---------- src/layouts/payment-method/payment-method.vue | 19 ++++-- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index 0dad87b0d..5b081cd5b 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -11,7 +11,7 @@ class="col d-flex justify-content-between py-0"> {{ amountDueText }} {{ - isInsuranceStatusPending + isCoverageTypeToDisplayPending ? verifyingCoverageText : getFormattedAmount("", amountDue) }} @@ -24,7 +24,7 @@ {{ - isInsuranceStatusPending + isCoverageTypeToDisplayPending ? verifyingCoverageText : getFormattedAmount("", deductibleLineItem.subTotal) }} @@ -97,8 +97,8 @@ {{ getFormattedAmount(cartItem.category, cartItem.subTotal) }} @@ -106,25 +106,25 @@
- {{ subtotalText }}{{ - isInsuranceStatusPending + {{ subtotalText }} + {{ + isCoverageTypeToDisplayPending ? verifyingCoverageText : getFormattedAmount("", subTotal) }}
- {{ salesTaxText }}{{ getFormattedAmount("", salesTax) }} + {{ salesTaxText }} + {{ getFormattedAmount("", salesTax) }}
{{ amountPaidText }}{{ getFormattedAmount("", amountPaid) }}
- {{ amountDueText }}{{ - isInsuranceStatusPending + {{ amountDueText }} + {{ + isCoverageTypeToDisplayPending ? verifyingCoverageText : getFormattedAmount("", amountDue) }} @@ -188,9 +188,9 @@ export default { allowItemRemoval: Boolean, recyclingModalCmsWidgetName: String, showAsPaid: Boolean, - currentDeductibleFromStore: Number, + insuranceDeductible: Number, insuranceCompanyName: String, - insuranceCoverageStatus: String, + insuranceCoverageTypeToDisplay: String, }, data() { return { @@ -293,22 +293,18 @@ export default { this.$emit("update:modelValue", newValue); }, }, - isInsuranceStatusPending() { - if (this.insuranceCoverageStatus === coverageStatus.PENDING) return true; - if ( - this.insuranceCoverageStatus === coverageStatus.VERIFIED && - !(this.currentDeductible === 0 || this.currentDeductible > 0) - ) - return true; - return false; + isCoverageTypeToDisplayPending() { + return this.insuranceCoverageTypeToDisplay === coverageStatus.PENDING; }, - isInsuranceStatusVerified() { - return this.insuranceCoverageStatus === coverageStatus.VERIFIED; + isCoverageTypeToDisplayVerified() { + return this.insuranceCoverageTypeToDisplay === coverageStatus.VERIFIED; }, currentDeductible() { - if (this.insuranceCoverageStatus === coverageStatus.VERIFIED) - return this.currentDeductibleFromStore; - return null; + const deductible = this.insuranceDeductible; + if (!(deductible === 0 || deductible > 0)) { + global.$logger.logError("Error: currentDeductible should not be null"); + } + return deductible; }, screenReaderTotalAmountDueText() { return this.getCmsContent("ScreenReaderTotalAmountDueWidget", "Text"); @@ -421,10 +417,7 @@ export default { packagePrice() { let packagePrice = 0; - if ( - !this.isInsuranceStatusVerified || - (this.isInsuranceStatusVerified && this.isInsuranceStatusPending) - ) { + if (!this.isCoverageTypeToDisplayVerified) { packagePrice = baseMixin.methods.getTierOnePackagePrice( baseMixin.methods.filterOutFees(this.availableLineItems) ); @@ -476,10 +469,10 @@ export default { deductibleLineItem() { let lineItem = null; - if (this.isInsuranceStatusVerified || this.isInsuranceStatusPending) { + if (this.isCoverageTypeToDisplayVerified || this.isCoverageTypeToDisplayPending) { lineItem = { name: this.deductibleLineItemName, - subTotal: this.currentDeductible >= 0 ? this.currentDeductible : null, + subTotal: this.currentDeductible, }; } @@ -909,7 +902,7 @@ export default { subTotal() { let subTotal = 0; - if (this.isInsuranceStatusVerified) { + if (this.isCoverageTypeToDisplayVerified) { // only include items NOT covered by insurance this.cartItems.forEach((cartItem) => { if (!cartItem.isCoveredByInsurance) { @@ -929,7 +922,7 @@ export default { salesTax() { let salesTax = 0; - if (this.isInsuranceStatusVerified) { + if (this.isCoverageTypeToDisplayVerified) { // only include items NOT covered by insurance this.cartItems.forEach((cartItem) => { if (!cartItem.isCoveredByInsurance) { diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index a97ea9a3a..db82a7a34 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -29,9 +29,9 @@ pageName="payment-method" servicePackageOptionsCmsName="ServicePackageTitle" recyclingModalCmsWidgetName="RecycleModal" - :currentDeductibleFromStore="currentDeductible" + :insuranceDeductible="currentDeductible" :insuranceCompanyName="insuranceCompanyName" - :insuranceCoverageStatus="insuranceCoverageStatus" /> + :insuranceCoverageTypeToDisplay="insuranceCoverageTypeToDisplay" />
@@ -335,7 +335,18 @@ export default { (isMobile && mobileReqs) || (!isMobile && dropOffInshopReqs); // Insurance - const isInsuranceSet = store.getters.order.payment.isInsurance !== null; + const isInsurance = store.getters.order.payment.isInsurance; + const insuranceCoverageStatus = store.getters.payment.insuranceCoverage.coverageStatus; + const currentDeductible = store.getters.policy.currentDeductible; + const isInsuranceSet = () => { + if (isInsurance !== null) { + if (insuranceCoverageStatus === coverageStatus.VERIFIED && !(currentDeductible === 0 || currentDeductible > 0) ) { + return false; // if coverageStatus is verified there must be a valid deductible also + } + return true; + } + return false; + }; // Schedule const schedule = store.getters.order.schedule; @@ -512,7 +523,7 @@ export default { } return false; }, - insuranceCoverageStatus() { + insuranceCoverageTypeToDisplay() { if (!this.isInsurance) return null; if (this.isNoComp) { return coverageStatus.NOCOMP;