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