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 CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||||
import { DateFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
import { alphaSort } from "../../utils/sorters";
|
||||||
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import BillDeleteButton from "../bill-delete-button/bill-delete-button.component";
|
import BillDeleteButton from "../bill-delete-button/bill-delete-button.component";
|
||||||
|
import PrintWrapperComponent from "../print-wrapper/print-wrapper.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//jobRO: selectJobReadOnly,
|
//jobRO: selectJobReadOnly,
|
||||||
@@ -49,7 +51,7 @@ export function BillsListTableComponent({
|
|||||||
});
|
});
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const selectedBill = search.billid;
|
const selectedBill = search.billid;
|
||||||
|
const Templates = TemplateList("bill");
|
||||||
const bills = billsQuery.data ? billsQuery.data.bills : [];
|
const bills = billsQuery.data ? billsQuery.data.bills : [];
|
||||||
const { refetch } = billsQuery;
|
const { refetch } = billsQuery;
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -115,7 +117,7 @@ export function BillsListTableComponent({
|
|||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space>
|
<Space wrap>
|
||||||
{record.exported ? (
|
{record.exported ? (
|
||||||
<Button disabled>{t("bills.actions.edit")}</Button>
|
<Button disabled>{t("bills.actions.edit")}</Button>
|
||||||
) : (
|
) : (
|
||||||
@@ -126,6 +128,15 @@ export function BillsListTableComponent({
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<BillDeleteButton bill={record} />
|
<BillDeleteButton bill={record} />
|
||||||
|
{record.isinhouse && (
|
||||||
|
<PrintWrapperComponent
|
||||||
|
templateObject={{
|
||||||
|
name: Templates.inhouse_invoice.key,
|
||||||
|
variables: { id: record.id },
|
||||||
|
}}
|
||||||
|
messageObject={{ subject: Templates.inhouse_invoice.subject }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -275,7 +286,7 @@ export function BillsListTableComponent({
|
|||||||
.map((i) => {
|
.map((i) => {
|
||||||
return {
|
return {
|
||||||
line_desc: i.line_desc,
|
line_desc: i.line_desc,
|
||||||
// db_price: i.actual_price,
|
// db_price: i.actual_price,
|
||||||
act_price: i.actual_price,
|
act_price: i.actual_price,
|
||||||
quantity: i.quantity,
|
quantity: i.quantity,
|
||||||
joblineid: i.joblineid,
|
joblineid: i.joblineid,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export function PartsOrderListTableComponent({
|
|||||||
setPartsReceiveContext,
|
setPartsReceiveContext,
|
||||||
}) {
|
}) {
|
||||||
const responsibilityCenters = bodyshop.md_responsibility_centers;
|
const responsibilityCenters = bodyshop.md_responsibility_centers;
|
||||||
|
const Templates = TemplateList("partsorder");
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
sortedInfo: {},
|
sortedInfo: {},
|
||||||
@@ -105,7 +105,7 @@ export function PartsOrderListTableComponent({
|
|||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space>
|
<Space wrap>
|
||||||
<Button
|
<Button
|
||||||
disabled={jobRO || record.return}
|
disabled={jobRO || record.return}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -165,10 +165,15 @@ export function PartsOrderListTableComponent({
|
|||||||
<PrintWrapper
|
<PrintWrapper
|
||||||
templateObject={{
|
templateObject={{
|
||||||
name: record.isReturn
|
name: record.isReturn
|
||||||
? TemplateList("partsorder").parts_return_slip.key
|
? Templates.parts_return_slip.key
|
||||||
: TemplateList("partsorder").parts_order.key,
|
: Templates.parts_order.key,
|
||||||
variables: { id: record.id },
|
variables: { id: record.id },
|
||||||
}}
|
}}
|
||||||
|
messageObject={{
|
||||||
|
subject: record.isReturn
|
||||||
|
? Templates.parts_return_slip.subject
|
||||||
|
: Templates.parts_order.subject,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MailFilled, PrinterFilled } from "@ant-design/icons";
|
import { MailFilled, PrinterFilled } from "@ant-design/icons";
|
||||||
import { Space } from "antd";
|
import { Space, Spin } from "antd";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
|
|
||||||
export default function PrintWrapperComponent({
|
export default function PrintWrapperComponent({
|
||||||
@@ -8,15 +8,19 @@ export default function PrintWrapperComponent({
|
|||||||
messageObject = {},
|
messageObject = {},
|
||||||
children,
|
children,
|
||||||
}) {
|
}) {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const handlePrint = async (type) => {
|
||||||
|
setLoading(true);
|
||||||
|
await GenerateDocument(templateObject, messageObject, type);
|
||||||
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Space>
|
<Space>
|
||||||
{children || null}
|
{children || null}
|
||||||
<PrinterFilled
|
<PrinterFilled onClick={() => handlePrint("p")} />
|
||||||
onClick={() => GenerateDocument(templateObject, {}, "p")}
|
<MailFilled onClick={() => handlePrint("e")} />
|
||||||
/>
|
{loading && <Spin size="small" />}
|
||||||
<MailFilled
|
|
||||||
onClick={() => GenerateDocument(templateObject, messageObject, "e")}
|
|
||||||
/>
|
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const QUERY_ALL_BILLS_PAGINATED = gql`
|
|||||||
total
|
total
|
||||||
invoice_number
|
invoice_number
|
||||||
date
|
date
|
||||||
|
isinhouse
|
||||||
exported
|
exported
|
||||||
job {
|
job {
|
||||||
id
|
id
|
||||||
@@ -80,6 +81,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
|
|||||||
order_date
|
order_date
|
||||||
deliver_by
|
deliver_by
|
||||||
return
|
return
|
||||||
|
|
||||||
parts_order_lines {
|
parts_order_lines {
|
||||||
id
|
id
|
||||||
act_price
|
act_price
|
||||||
@@ -114,6 +116,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
|
|||||||
state_tax_rate
|
state_tax_rate
|
||||||
local_tax_rate
|
local_tax_rate
|
||||||
is_credit_memo
|
is_credit_memo
|
||||||
|
isinhouse
|
||||||
exported
|
exported
|
||||||
billlines {
|
billlines {
|
||||||
actual_price
|
actual_price
|
||||||
@@ -147,6 +150,7 @@ export const QUERY_BILL_BY_PK = gql`
|
|||||||
local_tax_rate
|
local_tax_rate
|
||||||
state_tax_rate
|
state_tax_rate
|
||||||
federal_tax_rate
|
federal_tax_rate
|
||||||
|
isinhouse
|
||||||
vendor {
|
vendor {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ import { connect } from "react-redux";
|
|||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
import BillDeleteButton from "../../components/bill-delete-button/bill-delete-button.component";
|
import BillDeleteButton from "../../components/bill-delete-button/bill-delete-button.component";
|
||||||
import PartsOrderModalContainer from "../../components/parts-order-modal/parts-order-modal.container";
|
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 { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||||
import { DateFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
import { alphaSort } from "../../utils/sorters";
|
||||||
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setPartsOrderContext: (context) =>
|
setPartsOrderContext: (context) =>
|
||||||
@@ -34,6 +36,7 @@ export function BillsListPage({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const { page } = search;
|
const { page } = search;
|
||||||
|
const Templates = TemplateList("bill");
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
@@ -136,7 +139,7 @@ export function BillsListPage({
|
|||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space>
|
<Space wrap>
|
||||||
<Link to={`/manage/bills?billid=${record.id}`}>
|
<Link to={`/manage/bills?billid=${record.id}`}>
|
||||||
<Button>{t("bills.actions.edit")}</Button>
|
<Button>{t("bills.actions.edit")}</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -153,7 +156,7 @@ export function BillsListPage({
|
|||||||
linesToOrder: record.billlines.map((i) => {
|
linesToOrder: record.billlines.map((i) => {
|
||||||
return {
|
return {
|
||||||
line_desc: i.line_desc,
|
line_desc: i.line_desc,
|
||||||
// db_price: i.actual_price,
|
// db_price: i.actual_price,
|
||||||
act_price: i.actual_price,
|
act_price: i.actual_price,
|
||||||
quantity: i.quantity,
|
quantity: i.quantity,
|
||||||
joblineid: i.joblineid,
|
joblineid: i.joblineid,
|
||||||
@@ -167,6 +170,15 @@ export function BillsListPage({
|
|||||||
{t("bills.actions.return")}
|
{t("bills.actions.return")}
|
||||||
</Button>
|
</Button>
|
||||||
<BillDeleteButton bill={record} />
|
<BillDeleteButton bill={record} />
|
||||||
|
{record.isinhouse && (
|
||||||
|
<PrintWrapperComponent
|
||||||
|
templateObject={{
|
||||||
|
name: Templates.inhouse_invoice.key,
|
||||||
|
variables: { id: record.id },
|
||||||
|
}}
|
||||||
|
messageObject={{ subject: Templates.inhouse_invoice.subject }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user