hide payment options if amountDue = 0

implemented via an emit
This commit is contained in:
Bill Richardson 2024-06-06 12:21:05 -04:00
parent ae7fc9a4fe
commit c99fb974ca
3 changed files with 26 additions and 4 deletions

View file

@ -193,6 +193,7 @@ export default {
isInitiallyExpanded: Boolean,
submittedOrder: Object
},
emits: ['amountDueUpdated'],
data() {
return {
isExpanded: this.isInitiallyExpanded,
@ -249,7 +250,9 @@ export default {
return getCartTotal(this.cartOrder);
},
amountDue() {
return this.showAsPaid ? 0 : this.total;
const newAmountDue = this.showAsPaid ? 0 : this.total;
this.$emit('amountDueUpdated', newAmountDue);
return newAmountDue;
},
amountPaid() {
return !this.showAsPaid ? 0 : this.total;

View file

@ -184,10 +184,11 @@ describe('payment-method.vue', () => {
// Assert
expect(result).toBeTruthy();
});
test('returns false when coverageStatus is verified', () => {
test('returns false when coverageStatus is verified and cartAmountDue > 0', () => {
// Arrange
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
const wrapper = setupMocks({}, store, mixin);
wrapper.vm.cartAmountDue = 34.99;
// Act
const result = wrapper.vm.isPayInAdvanceDisabled;
@ -195,6 +196,18 @@ describe('payment-method.vue', () => {
// Assert
expect(result).toBeFalsy();
});
test('returns true when coverageStatus is verified and cartAmountDue = 0', () => {
// Arrange
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
const wrapper = setupMocks({}, store, mixin);
wrapper.vm.cartAmountDue = 0;
// Act
const result = wrapper.vm.isPayInAdvanceDisabled;
// Assert
expect(result).toBeTruthy();
});
test('returns true when pia not enabled', () => {
// Arrange
mixin = {

View file

@ -32,7 +32,8 @@
:showDropdownHeader="true"
:isInitiallyExpanded="false"
recyclingModalCmsWidgetName="RecycleModal"
servicePackageTitleWidgetName="ServicePackageTitle" />
servicePackageTitleWidgetName="ServicePackageTitle"
@amountDueUpdated="updateAmountDue" />
<hr class="mt-0 mb-5" />
<alert
v-if="displayPayInAdvanceAlert"
@ -162,6 +163,7 @@ export default {
},
data() {
return {
cartAmountDue: 0,
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
rules: {
optionRequired: globalRules.OPTION_REQUIRED
@ -187,8 +189,9 @@ export default {
isPayInAdvanceDisabled() {
const piaExperience = this.getSettingValue(experimentSettings.ISS_DISPLAY_PAY_IN_ADVANCE);
const isEnabled = piaExperience === 'true';
const isAmountDueEqualToZero = this.cartAmountDue === 0;
return !isEnabled || useMainStore().isUnverified;
return !isEnabled || useMainStore().isUnverified || isAmountDueEqualToZero;
},
paymentMethod() {
return this.paymentMethodInternalModel;
@ -295,6 +298,9 @@ export default {
? payInAdvanceType
: paymentMethods.PAY_AT_TIME_OF_SERVICE;
},
updateAmountDue(newAmountDue) {
this.cartAmountDue = newAmountDue;
},
updateFooterButtonText(newValue) {
this.$refs.siteFooter.updateButtonText(newValue);
},