IO-177 Paint/Mat Thresholds

This commit is contained in:
Patrick Fic
2022-03-14 10:41:52 -07:00
parent 9a65b6a1ce
commit 148c645f18
11 changed files with 86 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project version="1.2" be_version="2.7.1">
<babeledit_project be_version="2.7.1" version="1.2">
<!--
BabelEdit project file
@@ -27371,6 +27371,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>threshhold</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>total_cost</name>
<definition_loaded>false</definition_loaded>

View File

@@ -1,4 +1,4 @@
import { Table } from "antd";
import { Space, Table } from "antd";
import Dinero from "dinero.js";
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -119,7 +119,18 @@ export default function JobTotalsTableLabor({ job }) {
</Table.Summary.Cell>
</Table.Summary.Row>
<Table.Summary.Row>
<Table.Summary.Cell>{t("jobs.labels.mapa")}</Table.Summary.Cell>
<Table.Summary.Cell>
<Space>
{t("jobs.labels.mapa")}
{job.materials &&
job.materials.mapa &&
job.materials.mapa.cal_maxdlr &&
job.materials.mapa.cal_maxdlr > 0 &&
t("jobs.labels.threshhold", {
amount: job.materials.mapa.cal_maxdlr,
})}
</Space>
</Table.Summary.Cell>
<Table.Summary.Cell align="right">
<CurrencyFormatter>
{job.job_totals.rates.mapa.rate}
@@ -133,7 +144,18 @@ export default function JobTotalsTableLabor({ job }) {
</Table.Summary.Cell>
</Table.Summary.Row>
<Table.Summary.Row>
<Table.Summary.Cell>{t("jobs.labels.mash")}</Table.Summary.Cell>
<Table.Summary.Cell>
<Space wrap>
{t("jobs.labels.mash")}
{job.materials &&
job.materials.mash &&
job.materials.mash.cal_maxdlr &&
job.materials.mash.cal_maxdlr > 0 &&
t("jobs.labels.threshhold", {
amount: job.materials.mash.cal_maxdlr,
})}
</Space>
</Table.Summary.Cell>
<Table.Summary.Cell align="right">
<CurrencyFormatter>
{job.job_totals.rates.mash.rate}

View File

@@ -595,6 +595,7 @@ export const GET_JOB_BY_PK = gql`
ca_gst_registrant
ownerid
ded_note
materials
owner {
id
ownr_fn

View File

@@ -1602,6 +1602,7 @@
"supplementnote": "The job had a supplement imported.",
"suspended": "SUSPENDED",
"suspense": "Suspense",
"threshhold": "Max Threshold: ${{amount}}",
"total_cost": "Total Cost",
"total_cust_payable": "Total Customer Amount Payable",
"total_repairs": "Total Repairs",

View File

@@ -1602,6 +1602,7 @@
"supplementnote": "",
"suspended": "",
"suspense": "",
"threshhold": "",
"total_cost": "",
"total_cust_payable": "",
"total_repairs": "",

View File

@@ -1602,6 +1602,7 @@
"supplementnote": "",
"suspended": "",
"suspense": "",
"threshhold": "",
"total_cost": "",
"total_cust_payable": "",
"total_repairs": "",

View File

@@ -2804,6 +2804,7 @@
- loss_desc
- loss_of_use
- loss_type
- materials
- other_amount_payable
- owner_owing
- ownerid
@@ -3061,6 +3062,7 @@
- loss_desc
- loss_of_use
- loss_type
- materials
- other_amount_payable
- owner_owing
- ownerid
@@ -3328,6 +3330,7 @@
- loss_desc
- loss_of_use
- loss_type
- materials
- other_amount_payable
- owner_owing
- ownerid

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."jobs" add column "materials" jsonb
-- not null default jsonb_build_object();

View File

@@ -0,0 +1,2 @@
alter table "public"."jobs" add column "materials" jsonb
not null default jsonb_build_object();

View File

@@ -960,6 +960,7 @@ exports.GET_JOB_BY_PK = ` query GET_JOB_BY_PK($id: uuid!) {
voided
ca_bc_pvrt
ca_customer_gst
materials
joblines(where: { removed: { _eq: false } }){
id
line_no

View File

@@ -234,11 +234,30 @@ function CalculateRatesTotals(ratesList) {
if (!ret[property].total) {
ret[property].total = Dinero();
}
ret[property].total = ret[property].total.add(
Dinero({
let threshold;
//Check if there is a max for this type.
if (ratesList.materials[property]) {
//
if (
ratesList.materials[property].cal_maxdlr &&
ratesList.materials[property].cal_maxdlr > 0
) {
//It has an upper threshhold.
threshold = Dinero({
amount: Math.round(ratesList.materials[property].cal_maxdlr * 100),
});
}
}
const total = Dinero({
amount: Math.round((ret[property].rate || 0) * 100),
}).multiply(ret[property].hours)
);
}).multiply(ret[property].hours);
if (threshold && total.greaterThanOrEqual(threshold)) {
ret[property].total = ret[property].total.add(threshold);
} else {
ret[property].total = ret[property].total.add(total);
}
}
subtotal = subtotal.add(ret[property].total);
@@ -252,6 +271,7 @@ function CalculateRatesTotals(ratesList) {
return ret;
}
function CalculatePartsTotals(jobLines) {
const ret = jobLines
.filter((jl) => !jl.removed)