CASH-845 stage 2: update pagePrerequisites
This commit is contained in:
parent
89bbe043c0
commit
9f37c2cf42
2 changed files with 75 additions and 25 deletions
|
|
@ -176,6 +176,9 @@ beforeEach(() => {
|
||||||
isRepair: false,
|
isRepair: false,
|
||||||
},
|
},
|
||||||
referralNumber: "1234567",
|
referralNumber: "1234567",
|
||||||
|
policy: {
|
||||||
|
policyNumber: "123",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
payment: {
|
payment: {
|
||||||
isInsurance: true,
|
isInsurance: true,
|
||||||
|
|
@ -195,11 +198,12 @@ afterEach(() => {
|
||||||
|
|
||||||
describe("schedule.vue...", () => {
|
describe("schedule.vue...", () => {
|
||||||
describe("initial load", () => {
|
describe("initial load", () => {
|
||||||
test("should pass arePagePrerequisitesValid with a mobile order and no providerNumber", () => {
|
test("should pass arePagePrerequisitesValid with a mobile CASH order and no providerNumber", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
store.getters.order.serviceLocation.appointmentType = "Mobile";
|
store.getters.order.serviceLocation.appointmentType = "Mobile";
|
||||||
store.getters.order.serviceLocation.provider = null;
|
store.getters.order.serviceLocation.provider.policyNumber = null;
|
||||||
|
store.getters.payment.isInsurance = false;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -208,7 +212,7 @@ describe("schedule.vue...", () => {
|
||||||
expect(arePagePrerequisitesValid).toBe(true);
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should pass arePagePrerequisitesValid with a inshop order and providerNumber", () => {
|
test("should pass arePagePrerequisitesValid with an inshop order and providerNumber", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ import { getItemsWithoutRecalParts } from "@/helpers/recal-helper";
|
||||||
import { partNumberStrings } from "@/constants/part-number-strings";
|
import { partNumberStrings } from "@/constants/part-number-strings";
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
import { debugLog } from "@/helpers/debug-log-helper";
|
import { debugLog } from "@/helpers/debug-log-helper";
|
||||||
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
||||||
|
|
@ -367,12 +368,13 @@ export default {
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
const pricingByDayUpcharge = showPricingByDay
|
const pricingByDayUpcharge =
|
||||||
? await baseMixin.methods.getTotalLineItemPrice(
|
showPricingByDay && resultMap.pricingByDayUpchargePart
|
||||||
resultMap.pricingByDayUpchargePart,
|
? await baseMixin.methods.getTotalLineItemPrice(
|
||||||
false
|
resultMap.pricingByDayUpchargePart,
|
||||||
)
|
false
|
||||||
: null;
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
const datePickerInitialData = resultMap.datePickerInitialData;
|
const datePickerInitialData = resultMap.datePickerInitialData;
|
||||||
datePickerInitialData.pricingByDayBasePrice = pricingByDayBasePrice;
|
datePickerInitialData.pricingByDayBasePrice = pricingByDayBasePrice;
|
||||||
|
|
@ -480,32 +482,76 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
splitCopyOnCMSPlaceHolder,
|
splitCopyOnCMSPlaceHolder,
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
const serviceLocation = store.getters.order.serviceLocation; // TODO - MAY NEED TO REMOVE THIS AS A PREREQ
|
|
||||||
|
|
||||||
const serviceLocationPreReqs = serviceLocation.zipCode && serviceLocation.zipCodeCtu; // TODO - MAY NEED TO ADD IN SERVICE LOCATION PREREQS HERE TOO
|
|
||||||
|
|
||||||
const paymentInfo = store.getters.payment.isInsurance !== null;
|
const paymentInfo = store.getters.payment.isInsurance !== null;
|
||||||
|
|
||||||
const damageInfo =
|
const damageInfo =
|
||||||
store.getters.order.damage.isRepair ||
|
store.getters.order.damage.isRepair ||
|
||||||
(store.getters.order.lineItems?.glassParts != null &&
|
(store.getters.order.lineItems?.glassParts != null &&
|
||||||
store.getters.order.lineItems.glassParts.length > 0);
|
store.getters.order.lineItems.glassParts.length > 0);
|
||||||
|
const parentAccountNumberInfo =
|
||||||
|
store.getters.payment.parentAccountNumber !==
|
||||||
|
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER;
|
||||||
|
const policyNumberInfo = store.getters.order.policy.policyNumber;
|
||||||
|
const zipCodeInfo = store.getters.order.serviceLocation.zipCode;
|
||||||
|
const supportingItemsInfo = store.getters.lineItems.supportingItems;
|
||||||
|
|
||||||
const preReqResult = serviceLocationPreReqs && paymentInfo && damageInfo;
|
// insurance drops the recycle fee on replace orders so it won't be in supportingItems
|
||||||
|
const insurancePreReqResult =
|
||||||
|
parentAccountNumberInfo &&
|
||||||
|
policyNumberInfo &&
|
||||||
|
zipCodeInfo &&
|
||||||
|
paymentInfo &&
|
||||||
|
damageInfo;
|
||||||
|
const cashPreReqResult =
|
||||||
|
supportingItemsInfo && zipCodeInfo && paymentInfo && damageInfo;
|
||||||
|
|
||||||
// prettier-ignore
|
const outputDebugLog = (preReqResult) => {
|
||||||
{
|
// prettier-ignore
|
||||||
debugLog("--- schedule.vue pagePrereqs start ---", null, !preReqResult);
|
debugLog("--- schedule.vue pagePrereqs start ---", null, !preReqResult);
|
||||||
debugLog("store.getters.order.serviceLocation.zipCode:", serviceLocation.zipCode, !preReqResult);
|
debugLog(
|
||||||
debugLog("store.getters.order.serviceLocation.zipCodeCtu:", serviceLocation.zipCodeCtu, !preReqResult);
|
"store.getters.payment.isInsurance:",
|
||||||
debugLog("store.getters.order.serviceLocation.appointmentType:", serviceLocation.appointmentType, !preReqResult);
|
store.getters.payment?.isInsurance,
|
||||||
debugLog("store.getters.order.serviceLocation.provider.providerNumber:", serviceLocation.provider?.providerNumber, !preReqResult);
|
!preReqResult
|
||||||
debugLog("store.getters.payment.isInsurance:", store.getters.payment?.isInsurance, !preReqResult);
|
);
|
||||||
debugLog("store.getters.order.damage.isRepair:", store.getters.order.damage?.isRepair, !preReqResult);
|
debugLog(
|
||||||
debugLog("store.getters.order.lineItems.glassParts:", store.getters.order.lineItems?.glassParts, !preReqResult);
|
"store.getters.order.damage.isRepair:",
|
||||||
|
store.getters.order.damage?.isRepair,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
|
debugLog(
|
||||||
|
"store.getters.order.lineItems.glassParts:",
|
||||||
|
store.getters.order.lineItems?.glassParts,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
|
debugLog(
|
||||||
|
"store.getters.payment.parentAccountNumber:",
|
||||||
|
store.getters.payment.parentAccountNumber,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
|
debugLog(
|
||||||
|
"store.getters.order.policy.policyNumber:",
|
||||||
|
store.getters.order.policy.policyNumber,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
|
debugLog(
|
||||||
|
"store.getters.order.serviceLocation.zipCode:",
|
||||||
|
store.getters.order.serviceLocation.zipCode,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
|
debugLog(
|
||||||
|
"store.getters.lineItems.supportingItems:",
|
||||||
|
store.getters.lineItems.supportingItems,
|
||||||
|
!preReqResult
|
||||||
|
);
|
||||||
debugLog("--- schedule.vue pagePrereqs end ---", null, !preReqResult);
|
debugLog("--- schedule.vue pagePrereqs end ---", null, !preReqResult);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (store.getters.payment.isInsurance) {
|
||||||
|
outputDebugLog(insurancePreReqResult);
|
||||||
|
return insurancePreReqResult;
|
||||||
|
} else {
|
||||||
|
outputDebugLog(cashPreReqResult);
|
||||||
|
return cashPreReqResult;
|
||||||
}
|
}
|
||||||
return preReqResult;
|
|
||||||
},
|
},
|
||||||
async getMoreScheduleData(startDate, endDate) {
|
async getMoreScheduleData(startDate, endDate) {
|
||||||
// called only when "View more dates" is clicked; not on initial page load
|
// called only when "View more dates" is clicked; not on initial page load
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue