Updated issue where old close date not used for calculation of age RPS-75

This commit is contained in:
Patrick Fic
2021-01-12 13:07:26 -08:00
parent 573691c953
commit be709d51e1
4 changed files with 17 additions and 7 deletions

View File

@@ -119,6 +119,7 @@ export const QUERY_JOB_BY_CLM_NO = gql`
query QUERY_JOB_BY_CLM_NO($clm_no: String!) {
jobs(where: { clm_no: { _eq: $clm_no } }) {
id
close_date
joblines {
id
act_price

View File

@@ -28,17 +28,21 @@ export async function UpsertEstimate(job) {
const shopId = store.getState().user.bodyshop.id;
logger.info("Beginning Upserting job from Renderer.");
job = {
...job,
group: await DetermineVehicleGroup(job),
v_age: CalculateVehicleAge(job),
};
const existingJobs = await client.query({
query: QUERY_JOB_BY_CLM_NO,
variables: { clm_no: job.clm_no },
});
job = {
...job,
group: await DetermineVehicleGroup(job),
v_age: CalculateVehicleAge({
...job,
close_date:
existingJobs.data.jobs[0] && existingJobs.data.jobs[0].close_date,
}),
};
if (existingJobs.data.jobs.length === 1) {
let suppDelta = await GetSupplementDelta(
existingJobs.data.jobs[0].id,