MAJOR CHANGE: Renamed invoices to bills BOD-410

This commit is contained in:
Patrick Fic
2020-09-22 17:01:03 -07:00
parent 95ee3ae2bc
commit f84520c260
91 changed files with 2510 additions and 2624 deletions

View File

@@ -4,18 +4,15 @@ import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { alphaSort } from "../../utils/sorters";
import InvoiceExportButton from "../invoice-export-button/invoice-export-button.component";
import InvoiceExportAllButton from "../invoice-export-all-button/invoice-export-all-button.component";
import PayableExportButton from "../payable-export-button/payable-export-button.component";
import PayableExportAll from "../payable-export-all-button/payable-export-all-button.component";
import { DateFormatter } from "../../utils/DateFormatter";
import queryString from "query-string";
import { logImEXEvent } from "../../firebase/firebase.utils";
export default function AccountingPayablesTableComponent({
loading,
invoices,
}) {
export default function AccountingPayablesTableComponent({ loading, bills }) {
const { t } = useTranslation();
const [selectedInvoices, setSelectedInvoices] = useState([]);
const [selectedBills, setSelectedBills] = useState([]);
const [transInProgress, setTransInProgress] = useState(false);
const [state, setState] = useState({
sortedInfo: {},
@@ -28,7 +25,7 @@ export default function AccountingPayablesTableComponent({
const columns = [
{
title: t("invoices.fields.vendorname"),
title: t("bills.fields.vendorname"),
dataIndex: "vendorname",
key: "vendorname",
sorter: (a, b) => alphaSort(a.vendor.name, b.vendor.name),
@@ -46,7 +43,7 @@ export default function AccountingPayablesTableComponent({
),
},
{
title: t("invoices.fields.invoice_number"),
title: t("bills.fields.invoice_number"),
dataIndex: "invoice_number",
key: "invoice_number",
sorter: (a, b) => alphaSort(a.invoice_number, b.invoice_number),
@@ -56,9 +53,9 @@ export default function AccountingPayablesTableComponent({
render: (text, record) => (
<Link
to={{
pathname: `/manage/invoices`,
pathname: `/manage/bills`,
search: queryString.stringify({
invoiceid: record.id,
billid: record.id,
vendorid: record.vendor.id,
}),
}}
@@ -79,7 +76,7 @@ export default function AccountingPayablesTableComponent({
),
},
{
title: t("invoices.fields.date"),
title: t("bills.fields.date"),
dataIndex: "date",
key: "date",
@@ -89,7 +86,7 @@ export default function AccountingPayablesTableComponent({
render: (text, record) => <DateFormatter>{record.date}</DateFormatter>,
},
{
title: t("invoices.fields.total"),
title: t("bills.fields.total"),
dataIndex: "total",
key: "total",
@@ -101,7 +98,7 @@ export default function AccountingPayablesTableComponent({
),
},
{
title: t("invoices.fields.is_credit_memo"),
title: t("bills.fields.is_credit_memo"),
dataIndex: "is_credit_memo",
key: "is_credit_memo",
sorter: (a, b) => a.is_credit_memo - b.is_credit_memo,
@@ -120,8 +117,8 @@ export default function AccountingPayablesTableComponent({
render: (text, record) => (
<div>
<InvoiceExportButton
invoiceId={record.id}
<PayableExportButton
billId={record.id}
disabled={transInProgress || !!record.exported}
loadingCallback={setTransInProgress}
/>
@@ -136,7 +133,7 @@ export default function AccountingPayablesTableComponent({
};
const dataSource = state.search
? invoices.filter(
? bills.filter(
(v) =>
(v.vendor.name || "")
.toLowerCase()
@@ -145,7 +142,7 @@ export default function AccountingPayablesTableComponent({
.toLowerCase()
.includes(state.search.toLowerCase())
)
: invoices;
: bills;
return (
<div>
@@ -160,11 +157,11 @@ export default function AccountingPayablesTableComponent({
placeholder={t("general.labels.search")}
allowClear
/>
<InvoiceExportAllButton
invoiceIds={selectedInvoices}
disabled={transInProgress || selectedInvoices.length === 0}
<PayableExportAll
billIds={selectedBills}
disabled={transInProgress || selectedBills.length === 0}
loadingCallback={setTransInProgress}
completedCallback={setSelectedInvoices}
completedCallback={setSelectedBills}
/>
</div>
);
@@ -177,14 +174,14 @@ export default function AccountingPayablesTableComponent({
onChange={handleTableChange}
rowSelection={{
onSelectAll: (selected, selectedRows) =>
setSelectedInvoices(selectedRows.map((i) => i.id)),
setSelectedBills(selectedRows.map((i) => i.id)),
onSelect: (record, selected, selectedRows, nativeEvent) => {
setSelectedInvoices(selectedRows.map((i) => i.id));
setSelectedBills(selectedRows.map((i) => i.id));
},
getCheckboxProps: (record) => ({
disabled: record.exported,
}),
selectedRowKeys: selectedInvoices,
selectedRowKeys: selectedBills,
type: "checkbox",
}}
/>