hide payment options if amountDue = 0
implemented via an emit
This commit is contained in:
parent
ae7fc9a4fe
commit
c99fb974ca
3 changed files with 26 additions and 4 deletions
|
|
@ -193,6 +193,7 @@ export default {
|
||||||
isInitiallyExpanded: Boolean,
|
isInitiallyExpanded: Boolean,
|
||||||
submittedOrder: Object
|
submittedOrder: Object
|
||||||
},
|
},
|
||||||
|
emits: ['amountDueUpdated'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isExpanded: this.isInitiallyExpanded,
|
isExpanded: this.isInitiallyExpanded,
|
||||||
|
|
@ -249,7 +250,9 @@ export default {
|
||||||
return getCartTotal(this.cartOrder);
|
return getCartTotal(this.cartOrder);
|
||||||
},
|
},
|
||||||
amountDue() {
|
amountDue() {
|
||||||
return this.showAsPaid ? 0 : this.total;
|
const newAmountDue = this.showAsPaid ? 0 : this.total;
|
||||||
|
this.$emit('amountDueUpdated', newAmountDue);
|
||||||
|
return newAmountDue;
|
||||||
},
|
},
|
||||||
amountPaid() {
|
amountPaid() {
|
||||||
return !this.showAsPaid ? 0 : this.total;
|
return !this.showAsPaid ? 0 : this.total;
|
||||||
|
|
|
||||||
|
|
@ -184,10 +184,11 @@ describe('payment-method.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
});
|
});
|
||||||
test('returns false when coverageStatus is verified', () => {
|
test('returns false when coverageStatus is verified and cartAmountDue > 0', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
|
||||||
const wrapper = setupMocks({}, store, mixin);
|
const wrapper = setupMocks({}, store, mixin);
|
||||||
|
wrapper.vm.cartAmountDue = 34.99;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.isPayInAdvanceDisabled;
|
const result = wrapper.vm.isPayInAdvanceDisabled;
|
||||||
|
|
@ -195,6 +196,18 @@ describe('payment-method.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toBeFalsy();
|
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', () => {
|
test('returns true when pia not enabled', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
mixin = {
|
mixin = {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@
|
||||||
:showDropdownHeader="true"
|
:showDropdownHeader="true"
|
||||||
:isInitiallyExpanded="false"
|
:isInitiallyExpanded="false"
|
||||||
recyclingModalCmsWidgetName="RecycleModal"
|
recyclingModalCmsWidgetName="RecycleModal"
|
||||||
servicePackageTitleWidgetName="ServicePackageTitle" />
|
servicePackageTitleWidgetName="ServicePackageTitle"
|
||||||
|
@amountDueUpdated="updateAmountDue" />
|
||||||
<hr class="mt-0 mb-5" />
|
<hr class="mt-0 mb-5" />
|
||||||
<alert
|
<alert
|
||||||
v-if="displayPayInAdvanceAlert"
|
v-if="displayPayInAdvanceAlert"
|
||||||
|
|
@ -162,6 +163,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
cartAmountDue: 0,
|
||||||
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
||||||
rules: {
|
rules: {
|
||||||
optionRequired: globalRules.OPTION_REQUIRED
|
optionRequired: globalRules.OPTION_REQUIRED
|
||||||
|
|
@ -187,8 +189,9 @@ export default {
|
||||||
isPayInAdvanceDisabled() {
|
isPayInAdvanceDisabled() {
|
||||||
const piaExperience = this.getSettingValue(experimentSettings.ISS_DISPLAY_PAY_IN_ADVANCE);
|
const piaExperience = this.getSettingValue(experimentSettings.ISS_DISPLAY_PAY_IN_ADVANCE);
|
||||||
const isEnabled = piaExperience === 'true';
|
const isEnabled = piaExperience === 'true';
|
||||||
|
const isAmountDueEqualToZero = this.cartAmountDue === 0;
|
||||||
|
|
||||||
return !isEnabled || useMainStore().isUnverified;
|
return !isEnabled || useMainStore().isUnverified || isAmountDueEqualToZero;
|
||||||
},
|
},
|
||||||
paymentMethod() {
|
paymentMethod() {
|
||||||
return this.paymentMethodInternalModel;
|
return this.paymentMethodInternalModel;
|
||||||
|
|
@ -295,6 +298,9 @@ export default {
|
||||||
? payInAdvanceType
|
? payInAdvanceType
|
||||||
: paymentMethods.PAY_AT_TIME_OF_SERVICE;
|
: paymentMethods.PAY_AT_TIME_OF_SERVICE;
|
||||||
},
|
},
|
||||||
|
updateAmountDue(newAmountDue) {
|
||||||
|
this.cartAmountDue = newAmountDue;
|
||||||
|
},
|
||||||
updateFooterButtonText(newValue) {
|
updateFooterButtonText(newValue) {
|
||||||
this.$refs.siteFooter.updateButtonText(newValue);
|
this.$refs.siteFooter.updateButtonText(newValue);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue