Print IH invoices after creation IO-724
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
),
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ export const QUERY_ALL_BILLS_PAGINATED = gql`
|
||||
total
|
||||
invoice_number
|
||||
date
|
||||
isinhouse
|
||||
exported
|
||||
job {
|
||||
id
|
||||
@@ -80,6 +81,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
|
||||
order_date
|
||||
deliver_by
|
||||
return
|
||||
|
||||
parts_order_lines {
|
||||
id
|
||||
act_price
|
||||
@@ -114,6 +116,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
|
||||
state_tax_rate
|
||||
local_tax_rate
|
||||
is_credit_memo
|
||||
isinhouse
|
||||
exported
|
||||
billlines {
|
||||
actual_price
|
||||
@@ -147,6 +150,7 @@ export const QUERY_BILL_BY_PK = gql`
|
||||
local_tax_rate
|
||||
state_tax_rate
|
||||
federal_tax_rate
|
||||
isinhouse
|
||||
vendor {
|
||||
id
|
||||
name
|
||||
|
||||
@@ -7,10 +7,12 @@ import { connect } from "react-redux";
|
||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||
import BillDeleteButton from "../../components/bill-delete-button/bill-delete-button.component";
|
||||
import PartsOrderModalContainer from "../../components/parts-order-modal/parts-order-modal.container";
|
||||
import PrintWrapperComponent from "../../components/print-wrapper/print-wrapper.component";
|
||||
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";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setPartsOrderContext: (context) =>
|
||||
@@ -34,6 +36,7 @@ export function BillsListPage({
|
||||
const history = useHistory();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { page } = search;
|
||||
const Templates = TemplateList("bill");
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@@ -136,7 +139,7 @@ export function BillsListPage({
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<Space>
|
||||
<Space wrap>
|
||||
<Link to={`/manage/bills?billid=${record.id}`}>
|
||||
<Button>{t("bills.actions.edit")}</Button>
|
||||
</Link>
|
||||
@@ -153,7 +156,7 @@ export function BillsListPage({
|
||||
linesToOrder: record.billlines.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,
|
||||
@@ -167,6 +170,15 @@ export function BillsListPage({
|
||||
{t("bills.actions.return")}
|
||||
</Button>
|
||||
<BillDeleteButton bill={record} />
|
||||
{record.isinhouse && (
|
||||
<PrintWrapperComponent
|
||||
templateObject={{
|
||||
name: Templates.inhouse_invoice.key,
|
||||
variables: { id: record.id },
|
||||
}}
|
||||
messageObject={{ subject: Templates.inhouse_invoice.subject }}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user