Merged in release/2022-09-30 (pull request #587)

Release/2022 09 30
This commit is contained in:
Patrick Fic
2022-09-27 19:20:01 +00:00
10 changed files with 205 additions and 51 deletions

View File

@@ -26084,6 +26084,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>additionalpayeroverallocation</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> <concept_node>
<name>additionaltotal</name> <name>additionaltotal</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -28062,6 +28083,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>multipayers</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> <concept_node>
<name>net_repairs</name> <name>net_repairs</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -16,6 +16,7 @@ import DataLabel from "../data-label/data-label.component";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { useTreatments } from "@splitsoftware/splitio-react";
const SelectorDiv = styled.div` const SelectorDiv = styled.div`
.ant-form-item .ant-select { .ant-form-item .ant-select {
@@ -37,6 +38,11 @@ export default connect(
export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { Qb_Multi_Ar } = useTreatments(
["Qb_Multi_Ar"],
{},
bodyshop && bodyshop.imexshopid
);
const [costOptions, setCostOptions] = useState( const [costOptions, setCostOptions] = useState(
[ [
@@ -4535,24 +4541,26 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) {
<Input /> <Input />
</Form.Item> </Form.Item>
</LayoutFormRow> </LayoutFormRow>
<LayoutFormRow header={<div>Multiple Payers Item</div>}> {Qb_Multi_Ar.treatment === "on" && (
<Form.Item <LayoutFormRow header={<div>Multiple Payers Item</div>}>
label={t("bodyshop.fields.responsibilitycenter_accountitem")} <Form.Item
rules={[ label={t("bodyshop.fields.responsibilitycenter_accountitem")}
{ rules={[
required: true, {
//message: t("general.validation.required"), required: true,
}, //message: t("general.validation.required"),
]} },
name={[ ]}
"md_responsibility_centers", name={[
"qb_multiple_payers", "md_responsibility_centers",
"accountitem", "qb_multiple_payers",
]} "accountitem",
> ]}
<Input /> >
</Form.Item> <Input />
</LayoutFormRow> </Form.Item>
</LayoutFormRow>
)}
<Typography.Title level={4}> <Typography.Title level={4}>
{t("bodyshop.labels.responsibilitycenters.sales_tax_codes")} {t("bodyshop.labels.responsibilitycenters.sales_tax_codes")}
</Typography.Title> </Typography.Title>

View File

@@ -26,6 +26,7 @@ export const QUERY_AUDIT_TRAIL = gql`
subject subject
to to
useremail useremail
status
} }
} }
`; `;

View File

@@ -12,7 +12,9 @@ import {
Popconfirm, Popconfirm,
Select, Select,
Space, Space,
Statistic,
Switch, Switch,
Typography,
} from "antd"; } from "antd";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -33,7 +35,7 @@ import { generateJobLinesUpdatesForInvoicing } from "../../graphql/jobs-lines.qu
import { UPDATE_JOB } from "../../graphql/jobs.queries"; import { UPDATE_JOB } from "../../graphql/jobs.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import Dinero from "dinero.js";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
jobRO: selectJobReadOnly, jobRO: selectJobReadOnly,
@@ -325,9 +327,41 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
</Form.Item> </Form.Item>
)} )}
</LayoutFormRow> </LayoutFormRow>
<Divider>{t("jobs.labels.multipayers")}</Divider>
{Qb_Multi_Ar.treatment === "on" && ( {Qb_Multi_Ar.treatment === "on" && (
<> <Space>
<Form.List name={["qb_multiple_payers"]}> <Form.List
name={["qb_multiple_payers"]}
rules={[
({ getFieldValue }) => ({
validator(_, value) {
let totalAllocated = Dinero();
const payers = form.getFieldValue("qb_multiple_payers");
payers &&
payers.forEach((payer) => {
totalAllocated = totalAllocated.add(
Dinero({
amount: Math.round((payer?.amount || 0) * 100),
})
);
});
const discrep = job.job_totals
? Dinero(job.job_totals.totals.total_repairs).subtract(
totalAllocated
)
: Dinero();
return discrep.getAmount() > 0
? Promise.resolve()
: Promise.reject(
new Error(
t("jobs.labels.additionalpayeroverallocation")
)
);
},
}),
]}
>
{(fields, { add, remove }) => { {(fields, { add, remove }) => {
return ( return (
<div> <div>
@@ -382,7 +416,7 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
<Button <Button
disabled={jobRO} disabled={jobRO}
onClick={() => { onClick={() => {
if (fields.length < 3) add(); add();
}} }}
style={{ width: "100%" }} style={{ width: "100%" }}
> >
@@ -393,7 +427,50 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
); );
}} }}
</Form.List> </Form.List>
</> <Form.Item shouldUpdate>
{() => {
//Perform Calculation to determine discrepancy.
let totalAllocated = Dinero();
const payers = form.getFieldValue("qb_multiple_payers");
payers &&
payers.forEach((payer) => {
totalAllocated = totalAllocated.add(
Dinero({ amount: Math.round((payer?.amount || 0) * 100) })
);
});
const discrep = job.job_totals
? Dinero(job.job_totals.totals.total_repairs).subtract(
totalAllocated
)
: Dinero();
return (
<Space size="large" wrap align="center">
<Statistic
title={t("jobs.labels.total_repairs")}
value={(job.job_totals
? Dinero(job.job_totals.totals.total_repairs)
: Dinero()
).toFormat()}
/>
<Typography.Title>-</Typography.Title>
<Statistic
title={t("jobs.labels.dms.totalallocated")}
value={totalAllocated.toFormat()}
/>
<Typography.Title>=</Typography.Title>
<Statistic
title={t("jobs.labels.total_cust_payable")}
valueStyle={{
color: discrep.getAmount() > 0 ? "green" : "red",
}}
value={discrep.toFormat()}
/>
</Space>
);
}}
</Form.Item>
</Space>
)} )}
<Divider /> <Divider />
<JobsCloseLines job={job} /> <JobsCloseLines job={job} />

View File

@@ -1546,6 +1546,7 @@
"actual_completion_inferred": "$t(jobs.fields.actual_completion) inferred using $t(jobs.fields.scheduled_completion).", "actual_completion_inferred": "$t(jobs.fields.actual_completion) inferred using $t(jobs.fields.scheduled_completion).",
"actual_delivery_inferred": "$t(jobs.fields.actual_delivery) inferred using $t(jobs.fields.scheduled_delivery).", "actual_delivery_inferred": "$t(jobs.fields.actual_delivery) inferred using $t(jobs.fields.scheduled_delivery).",
"actual_in_inferred": "$t(jobs.fields.actual_in) inferred using $t(jobs.fields.scheduled_in).", "actual_in_inferred": "$t(jobs.fields.actual_in) inferred using $t(jobs.fields.scheduled_in).",
"additionalpayeroverallocation": "You have allocated more than the sale of the Job to additional payers.",
"additionaltotal": "Additional Total", "additionaltotal": "Additional Total",
"adjustmentrate": "Adjustment Rate", "adjustmentrate": "Adjustment Rate",
"adjustments": "Adjustments", "adjustments": "Adjustments",
@@ -1649,6 +1650,7 @@
"mapa": "Paint Materials", "mapa": "Paint Materials",
"markforreexport": "Mark for Re-export", "markforreexport": "Mark for Re-export",
"mash": "Shop Materials", "mash": "Shop Materials",
"multipayers": "Additional Payers",
"net_repairs": "Net Repairs", "net_repairs": "Net Repairs",
"notes": "Notes", "notes": "Notes",
"othertotal": "Other Totals", "othertotal": "Other Totals",

View File

@@ -1546,6 +1546,7 @@
"actual_completion_inferred": "", "actual_completion_inferred": "",
"actual_delivery_inferred": "", "actual_delivery_inferred": "",
"actual_in_inferred": "", "actual_in_inferred": "",
"additionalpayeroverallocation": "",
"additionaltotal": "", "additionaltotal": "",
"adjustmentrate": "", "adjustmentrate": "",
"adjustments": "", "adjustments": "",
@@ -1649,6 +1650,7 @@
"mapa": "", "mapa": "",
"markforreexport": "", "markforreexport": "",
"mash": "", "mash": "",
"multipayers": "",
"net_repairs": "", "net_repairs": "",
"notes": "Notas", "notes": "Notas",
"othertotal": "", "othertotal": "",

View File

@@ -1546,6 +1546,7 @@
"actual_completion_inferred": "", "actual_completion_inferred": "",
"actual_delivery_inferred": "", "actual_delivery_inferred": "",
"actual_in_inferred": "", "actual_in_inferred": "",
"additionalpayeroverallocation": "",
"additionaltotal": "", "additionaltotal": "",
"adjustmentrate": "", "adjustmentrate": "",
"adjustments": "", "adjustments": "",
@@ -1649,6 +1650,7 @@
"mapa": "", "mapa": "",
"markforreexport": "", "markforreexport": "",
"mash": "", "mash": "",
"multipayers": "",
"net_repairs": "", "net_repairs": "",
"notes": "Remarques", "notes": "Remarques",
"othertotal": "", "othertotal": "",

View File

@@ -100,7 +100,9 @@ exports.default = async (req, res) => {
oauthClient, oauthClient,
qbo_realmId, qbo_realmId,
req, req,
job job,
isThreeTier,
insCoCustomerTier
); );
//Query for the owner itself. //Query for the owner itself.
if (!ownerCustomerTier) { if (!ownerCustomerTier) {
@@ -121,7 +123,11 @@ exports.default = async (req, res) => {
qbo_realmId, qbo_realmId,
req, req,
job, job,
isThreeTier ? ownerCustomerTier : null // ownerCustomerTier || insCoCustomerTier isThreeTier
? ownerCustomerTier
: twoTierPref === "source"
? insCoCustomerTier
: ownerCustomerTier
); );
// Need to validate that the job tier is associated to the right individual? // Need to validate that the job tier is associated to the right individual?
@@ -342,7 +348,14 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
} }
exports.InsertInsuranceCo = InsertInsuranceCo; exports.InsertInsuranceCo = InsertInsuranceCo;
async function QueryOwner(oauthClient, qbo_realmId, req, job) { async function QueryOwner(
oauthClient,
qbo_realmId,
req,
job,
isThreeTier,
parentTierRef
) {
const ownerName = generateOwnerTier(job, true, null); const ownerName = generateOwnerTier(job, true, null);
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: urlBuilder(
@@ -362,7 +375,9 @@ async function QueryOwner(oauthClient, qbo_realmId, req, job) {
result.json && result.json &&
result.json.QueryResponse && result.json.QueryResponse &&
result.json.QueryResponse.Customer && result.json.QueryResponse.Customer &&
result.json.QueryResponse.Customer[0] result.json.QueryResponse.Customer.find(
(x) => x.ParentRef?.value === parentTierRef?.Id
)
); );
} }
exports.QueryOwner = QueryOwner; exports.QueryOwner = QueryOwner;

View File

@@ -205,8 +205,8 @@ exports.default = async (req, res) => {
Party: { Party: {
PersonInfo: { PersonInfo: {
PersonName: { PersonName: {
FirstName: job.ownr_fn, FirstName: job.ownr_co_nm ? "" : job.ownr_fn,
LastName: job.ownr_ln, LastName: job.ownr_co_nm ? job.ownr_co_nm : job.ownr_ln,
}, },
// Communications: [ // Communications: [
// { // {
@@ -336,7 +336,7 @@ exports.default = async (req, res) => {
LossDateTime: LossDateTime:
job.loss_date && job.loss_date &&
moment(job.loss_date) moment(job.loss_date)
.tz(bodyshop.timezone) //.tz(bodyshop.timezone)
.format(momentFormat), .format(momentFormat),
LossDescCode: "Collision", LossDescCode: "Collision",
PrimaryPOI: { PrimaryPOI: {
@@ -515,8 +515,11 @@ exports.default = async (req, res) => {
{ {
TotalType: "LAB", TotalType: "LAB",
TotalTypeDesc: "Body Labor", TotalTypeDesc: "Body Labor",
TotalHours: job.job_totals.rates.lab.hours, TotalHours:
TotalAmt: Dinero(job.job_totals.rates.lab.total).toFormat("0.00"), job.job_totals.rates.lab.hours + job.job_totals.rates.la1.hours,
TotalAmt: Dinero(job.job_totals.rates.lab.total)
.add(Dinero(job.job_totals.rates.la1.total))
.toFormat("0.00"),
}, },
{ {
TotalType: "LAF", TotalType: "LAF",
@@ -635,9 +638,9 @@ exports.default = async (req, res) => {
{ {
TotalType: "OTAC", TotalType: "OTAC",
TotalTypeDesc: "Additional Charges", TotalTypeDesc: "Additional Charges",
TotalAmt: Dinero( TotalAmt: Dinero(job.job_totals.additional.additionalCosts)
job.job_totals.additional.additionalCosts .add(Dinero(job.job_totals.additional.pvrt))
).toFormat("0.00"), .toFormat("0.00"),
}, },
], ],
SummaryTotalsInfo: [ SummaryTotalsInfo: [

View File

@@ -209,17 +209,15 @@ async function logEmail(req, email) {
exports.emailBounce = async function (req, res, next) { exports.emailBounce = async function (req, res, next) {
try { try {
const body = JSON.parse(req.body); const body = JSON.parse(req.body);
if (body.type === "SubscriptionConfirmation") { if (body.Type === "SubscriptionConfirmation") {
logger.log("SNS-confirmation", "DEBUG", "api", null, { logger.log("SNS-message", "DEBUG", "api", null, {
message: body.message, body: req.body,
url: body.SubscribeUrl,
body: body,
}); });
} }
if (body.Type === "Notification") { if (body.notificationType === "Bounce") {
const message = JSON.parse(body.Message); // const message = JSON.parse(body.Message);
let replyTo, subject, messageId; let replyTo, subject, messageId;
message.mail.headers.forEach((header) => { body.mail.headers.forEach((header) => {
if (header.name === "Reply-To") { if (header.name === "Reply-To") {
replyTo = header.value; replyTo = header.value;
} else if (header.name === "Subject") { } else if (header.name === "Subject") {
@@ -228,26 +226,30 @@ exports.emailBounce = async function (req, res, next) {
messageId = header.value; messageId = header.value;
} }
}); });
if (replyTo === "noreply@imex.online") {
res.sendStatus(200);
return;
}
//If it's bounced, log it as bounced in audit log. Send an email to the user. //If it's bounced, log it as bounced in audit log. Send an email to the user.
const result = await client.request(queries.UPDATE_EMAIL_AUDIT, { const result = await client.request(queries.UPDATE_EMAIL_AUDIT, {
sesid: messageId, sesid: messageId,
status: "Bounced", status: "Bounced",
context: message.bounce?.bouncedRecipients, context: body.bounce?.bouncedRecipients,
}); });
transporter.sendMail( transporter.sendMail(
{ {
from: `ImEX Online <noreply@imex.online>`, from: `ImEX Online <noreply@imex.online>`,
to: "patrick@snapt.ca", // replyTo, to: replyTo,
bcc: "patrick@snapt.ca", bcc: "patrick@snapt.ca",
subject: `ImEX Online Bounced Email - RE: ${subject}`, subject: `ImEX Online Bounced Email - RE: ${subject}`,
text: ` text: `ImEX Online has tried to deliver an email with the subject: ${subject} to the intended recipients but encountered an error.
ImEX Online has tried to deliver an email with the subject: ${subject} to the intended recipients but encountered an error.
${message.bounce?.bouncedRecipients.map( ${body.bounce?.bouncedRecipients.map(
(r) => (r) =>
`Recipient: ${r.emailAddress} | Status: ${r.action} | Code: ${r.diagnosticCode} `Recipient: ${r.emailAddress} | Status: ${r.action} | Code: ${r.diagnosticCode}
` `
)} )}
`, `,
}, },
(err, info) => { (err, info) => {