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,
|
||||
},
|
||||
referralNumber: "1234567",
|
||||
policy: {
|
||||
policyNumber: "123",
|
||||
},
|
||||
},
|
||||
payment: {
|
||||
isInsurance: true,
|
||||
|
|
@ -195,11 +198,12 @@ afterEach(() => {
|
|||
|
||||
describe("schedule.vue...", () => {
|
||||
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
|
||||
const { wrapper } = setupMocks({});
|
||||
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
|
||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||
|
|
@ -208,7 +212,7 @@ describe("schedule.vue...", () => {
|
|||
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
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ import { getItemsWithoutRecalParts } from "@/helpers/recal-helper";
|
|||
import { partNumberStrings } from "@/constants/part-number-strings";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
import { debugLog } from "@/helpers/debug-log-helper";
|
||||
import { applicationConfig } from "@/constants/application-config";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
||||
|
|
@ -367,12 +368,13 @@ export default {
|
|||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
const pricingByDayUpcharge = showPricingByDay
|
||||
? await baseMixin.methods.getTotalLineItemPrice(
|
||||
resultMap.pricingByDayUpchargePart,
|
||||
false
|
||||
)
|
||||
: null;
|
||||
const pricingByDayUpcharge =
|
||||
showPricingByDay && resultMap.pricingByDayUpchargePart
|
||||
? await baseMixin.methods.getTotalLineItemPrice(
|
||||
resultMap.pricingByDayUpchargePart,
|
||||
false
|
||||
)
|
||||
: null;
|
||||
|
||||
const datePickerInitialData = resultMap.datePickerInitialData;
|
||||
datePickerInitialData.pricingByDayBasePrice = pricingByDayBasePrice;
|
||||
|
|
@ -480,32 +482,76 @@ export default {
|
|||
methods: {
|
||||
splitCopyOnCMSPlaceHolder,
|
||||
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 damageInfo =
|
||||
store.getters.order.damage.isRepair ||
|
||||
(store.getters.order.lineItems?.glassParts != null &&
|
||||
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("store.getters.order.serviceLocation.zipCode:", serviceLocation.zipCode, !preReqResult);
|
||||
debugLog("store.getters.order.serviceLocation.zipCodeCtu:", serviceLocation.zipCodeCtu, !preReqResult);
|
||||
debugLog("store.getters.order.serviceLocation.appointmentType:", serviceLocation.appointmentType, !preReqResult);
|
||||
debugLog("store.getters.order.serviceLocation.provider.providerNumber:", serviceLocation.provider?.providerNumber, !preReqResult);
|
||||
debugLog("store.getters.payment.isInsurance:", store.getters.payment?.isInsurance, !preReqResult);
|
||||
debugLog("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.isInsurance:",
|
||||
store.getters.payment?.isInsurance,
|
||||
!preReqResult
|
||||
);
|
||||
debugLog(
|
||||
"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);
|
||||
};
|
||||
|
||||
if (store.getters.payment.isInsurance) {
|
||||
outputDebugLog(insurancePreReqResult);
|
||||
return insurancePreReqResult;
|
||||
} else {
|
||||
outputDebugLog(cashPreReqResult);
|
||||
return cashPreReqResult;
|
||||
}
|
||||
return preReqResult;
|
||||
},
|
||||
async getMoreScheduleData(startDate, endDate) {
|
||||
// called only when "View more dates" is clicked; not on initial page load
|
||||
|
|
|
|||
Loading…
Reference in a new issue