BOD-63 Prevent render of invoice detail when not selected
This commit is contained in:
@@ -5541,6 +5541,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>noneselected</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>state_tax</name>
|
<name>state_tax</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
|
|||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import InvoiceFormContainer from "../invoice-form/invoice-form.container";
|
import InvoiceFormContainer from "../invoice-form/invoice-form.container";
|
||||||
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -18,7 +19,7 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
|
|
||||||
export function InvoiceDetailEditContainer({ bodyshop }) {
|
export function InvoiceDetailEditContainer({ bodyshop }) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const { loading, error, data } = useQuery(QUERY_INVOICE_BY_PK, {
|
const { loading, error, data } = useQuery(QUERY_INVOICE_BY_PK, {
|
||||||
@@ -37,6 +38,7 @@ export function InvoiceDetailEditContainer({ bodyshop }) {
|
|||||||
}, [form, search.invoiceid]);
|
}, [form, search.invoiceid]);
|
||||||
|
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
if (!!!search.invoiceid) return <div>{t("invoices.labels.noneseleced")}</div>;
|
||||||
return (
|
return (
|
||||||
<LoadingSkeleton loading={loading}>
|
<LoadingSkeleton loading={loading}>
|
||||||
<Form
|
<Form
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { DatePicker, Form, Input, Statistic, Switch } from "antd";
|
import { DatePicker, Form, Input, Statistic, Switch } from "antd";
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import DocumentsUploadContainer from "../documents-upload/documents-upload.container";
|
import DocumentsUploadContainer from "../documents-upload/documents-upload.container";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||||
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||||
import InvoiceFormLines from "./invoice-form.lines.component";
|
import InvoiceFormLines from "./invoice-form.lines.component";
|
||||||
import { CalculateInvoiceTotal } from "./invoice-form.totals.utility";
|
|
||||||
import "./invoice-form.styles.scss";
|
import "./invoice-form.styles.scss";
|
||||||
|
import { CalculateInvoiceTotal } from "./invoice-form.totals.utility";
|
||||||
|
|
||||||
export default function InvoiceFormComponent({
|
export default function InvoiceFormComponent({
|
||||||
form,
|
form,
|
||||||
|
|||||||
@@ -24,17 +24,19 @@ export function InvoiceFormContainer({ bodyshop, form, hideVendor }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InvoiceFormComponent
|
<div>
|
||||||
form={form}
|
<InvoiceFormComponent
|
||||||
hideVendor={hideVendor}
|
form={form}
|
||||||
roAutoCompleteOptions={RoAutoCompleteData && RoAutoCompleteData.jobs}
|
hideVendor={hideVendor}
|
||||||
vendorAutoCompleteOptions={
|
roAutoCompleteOptions={RoAutoCompleteData && RoAutoCompleteData.jobs}
|
||||||
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
vendorAutoCompleteOptions={
|
||||||
}
|
VendorAutoCompleteData && VendorAutoCompleteData.vendors
|
||||||
loadLines={loadLines}
|
}
|
||||||
lineData={lineData ? lineData.joblines : null}
|
loadLines={loadLines}
|
||||||
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
lineData={lineData ? lineData.joblines : null}
|
||||||
/>
|
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default connect(mapStateToProps, null)(InvoiceFormContainer);
|
export default connect(mapStateToProps, null)(InvoiceFormContainer);
|
||||||
|
|||||||
@@ -8,20 +8,20 @@ export const CalculateInvoiceTotal = (invoice) => {
|
|||||||
local_tax_rate,
|
local_tax_rate,
|
||||||
state_tax_rate,
|
state_tax_rate,
|
||||||
} = invoice;
|
} = invoice;
|
||||||
|
//TODO Determine why this recalculates so many times.
|
||||||
|
console.log("Calculating invoice total...");
|
||||||
let subtotal = Dinero({ amount: 0 });
|
let subtotal = Dinero({ amount: 0 });
|
||||||
let federalTax = Dinero({ amount: 0 });
|
let federalTax = Dinero({ amount: 0 });
|
||||||
let stateTax = Dinero({ amount: 0 });
|
let stateTax = Dinero({ amount: 0 });
|
||||||
let localTax = Dinero({ amount: 0 });
|
let localTax = Dinero({ amount: 0 });
|
||||||
if (!!!invoicelines) return null;
|
if (!!!invoicelines) return null;
|
||||||
invoicelines.map((i) => {
|
invoicelines.forEach((i) => {
|
||||||
if (!!i) {
|
if (!!i) {
|
||||||
const itemTotal = Dinero({ amount: i.actual_cost * 100 || 0 }).multiply(
|
const itemTotal = Dinero({
|
||||||
i.quantity || 1
|
amount: Math.round((i.actual_cost || 0) * 100) || 0,
|
||||||
);
|
}).multiply(i.quantity || 1);
|
||||||
subtotal = subtotal.add(itemTotal);
|
subtotal = subtotal.add(itemTotal);
|
||||||
if (i.applicable_taxes.federal) {
|
if (i.applicable_taxes.federal) {
|
||||||
console.log("Adding fed tax.");
|
|
||||||
federalTax = federalTax.add(
|
federalTax = federalTax.add(
|
||||||
itemTotal.percentage(federal_tax_rate || 0)
|
itemTotal.percentage(federal_tax_rate || 0)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -381,6 +381,7 @@
|
|||||||
"invoice_total": "Invoice Total Amount",
|
"invoice_total": "Invoice Total Amount",
|
||||||
"local_tax": "Local Tax",
|
"local_tax": "Local Tax",
|
||||||
"new": "New Invoice",
|
"new": "New Invoice",
|
||||||
|
"noneselected": "No invoice selected.F",
|
||||||
"state_tax": "State Tax",
|
"state_tax": "State Tax",
|
||||||
"subtotal": "Subtotal"
|
"subtotal": "Subtotal"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -381,6 +381,7 @@
|
|||||||
"invoice_total": "",
|
"invoice_total": "",
|
||||||
"local_tax": "",
|
"local_tax": "",
|
||||||
"new": "",
|
"new": "",
|
||||||
|
"noneselected": "",
|
||||||
"state_tax": "",
|
"state_tax": "",
|
||||||
"subtotal": ""
|
"subtotal": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -381,6 +381,7 @@
|
|||||||
"invoice_total": "",
|
"invoice_total": "",
|
||||||
"local_tax": "",
|
"local_tax": "",
|
||||||
"new": "",
|
"new": "",
|
||||||
|
"noneselected": "",
|
||||||
"state_tax": "",
|
"state_tax": "",
|
||||||
"subtotal": ""
|
"subtotal": ""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user