Print IH invoices after creation IO-724

This commit is contained in:
Patrick Fic
2021-02-26 16:02:59 -08:00
parent 5945e27148
commit 510bf9c1b9
5 changed files with 53 additions and 17 deletions

View File

@@ -18,7 +18,9 @@ import { setModalContext } from "../../redux/modals/modals.actions";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { DateFormatter } from "../../utils/DateFormatter";
import { alphaSort } from "../../utils/sorters";
import { TemplateList } from "../../utils/TemplateConstants";
import BillDeleteButton from "../bill-delete-button/bill-delete-button.component";
import PrintWrapperComponent from "../print-wrapper/print-wrapper.component";
const mapStateToProps = createStructuredSelector({
//jobRO: selectJobReadOnly,
@@ -49,7 +51,7 @@ export function BillsListTableComponent({
});
const search = queryString.parse(useLocation().search);
const selectedBill = search.billid;
const Templates = TemplateList("bill");
const bills = billsQuery.data ? billsQuery.data.bills : [];
const { refetch } = billsQuery;
const columns = [
@@ -115,7 +117,7 @@ export function BillsListTableComponent({
dataIndex: "actions",
key: "actions",
render: (text, record) => (
<Space>
<Space wrap>
{record.exported ? (
<Button disabled>{t("bills.actions.edit")}</Button>
) : (
@@ -126,6 +128,15 @@ export function BillsListTableComponent({
</Link>
)}
<BillDeleteButton bill={record} />
{record.isinhouse && (
<PrintWrapperComponent
templateObject={{
name: Templates.inhouse_invoice.key,
variables: { id: record.id },
}}
messageObject={{ subject: Templates.inhouse_invoice.subject }}
/>
)}
</Space>
),
},
@@ -275,7 +286,7 @@ export function BillsListTableComponent({
.map((i) => {
return {
line_desc: i.line_desc,
// db_price: i.actual_price,
// db_price: i.actual_price,
act_price: i.actual_price,
quantity: i.quantity,
joblineid: i.joblineid,

View File

@@ -40,7 +40,7 @@ export function PartsOrderListTableComponent({
setPartsReceiveContext,
}) {
const responsibilityCenters = bodyshop.md_responsibility_centers;
const Templates = TemplateList("partsorder");
const { t } = useTranslation();
const [state, setState] = useState({
sortedInfo: {},
@@ -105,7 +105,7 @@ export function PartsOrderListTableComponent({
dataIndex: "actions",
key: "actions",
render: (text, record) => (
<Space>
<Space wrap>
<Button
disabled={jobRO || record.return}
onClick={() => {
@@ -165,10 +165,15 @@ export function PartsOrderListTableComponent({
<PrintWrapper
templateObject={{
name: record.isReturn
? TemplateList("partsorder").parts_return_slip.key
: TemplateList("partsorder").parts_order.key,
? Templates.parts_return_slip.key
: Templates.parts_order.key,
variables: { id: record.id },
}}
messageObject={{
subject: record.isReturn
? Templates.parts_return_slip.subject
: Templates.parts_order.subject,
}}
/>
</Space>
),

View File

@@ -1,6 +1,6 @@
import { MailFilled, PrinterFilled } from "@ant-design/icons";
import { Space } from "antd";
import React from "react";
import { Space, Spin } from "antd";
import React, { useState } from "react";
import { GenerateDocument } from "../../utils/RenderTemplate";
export default function PrintWrapperComponent({
@@ -8,15 +8,19 @@ export default function PrintWrapperComponent({
messageObject = {},
children,
}) {
const [loading, setLoading] = useState(false);
const handlePrint = async (type) => {
setLoading(true);
await GenerateDocument(templateObject, messageObject, type);
setLoading(false);
};
return (
<Space>
{children || null}
<PrinterFilled
onClick={() => GenerateDocument(templateObject, {}, "p")}
/>
<MailFilled
onClick={() => GenerateDocument(templateObject, messageObject, "e")}
/>
<PrinterFilled onClick={() => handlePrint("p")} />
<MailFilled onClick={() => handlePrint("e")} />
{loading && <Spin size="small" />}
</Space>
);
}