General gendoc function & reprint parts orders IO-411
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Input, Table, Typography } from "antd";
|
||||
import { MailFilled, PrinterFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Input, Space, Table, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -7,13 +7,15 @@ import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { DateFormatter } from "../../utils/DateFormatter";
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import PartsOrderLineBackorderButton from "../parts-order-line-backorder-button/parts-order-line-backorder-button.component";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
jobRO: selectJobReadOnly,
|
||||
@@ -90,37 +92,67 @@ export function PartsOrderListTableComponent({
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<Button
|
||||
disabled={jobRO}
|
||||
onClick={() => {
|
||||
logImEXEvent("parts_order_receive_bill");
|
||||
<Space>
|
||||
<Button
|
||||
disabled={jobRO}
|
||||
onClick={() => {
|
||||
logImEXEvent("parts_order_receive_bill");
|
||||
|
||||
setBillEnterContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
job: job,
|
||||
bill: {
|
||||
vendorid: record.vendor.id,
|
||||
billlines: record.parts_order_lines.map((pol) => {
|
||||
return {
|
||||
joblineid: pol.job_line_id,
|
||||
line_desc: pol.line_desc,
|
||||
quantity: pol.quantity,
|
||||
actual_price: pol.act_price,
|
||||
cost_center: pol.jobline.part_type
|
||||
? responsibilityCenters.defaults.costs[
|
||||
pol.jobline.part_type
|
||||
] || null
|
||||
: null,
|
||||
};
|
||||
}),
|
||||
setBillEnterContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
job: job,
|
||||
bill: {
|
||||
vendorid: record.vendor.id,
|
||||
billlines: record.parts_order_lines.map((pol) => {
|
||||
return {
|
||||
joblineid: pol.job_line_id,
|
||||
line_desc: pol.line_desc,
|
||||
quantity: pol.quantity,
|
||||
actual_price: pol.act_price,
|
||||
cost_center: pol.jobline.part_type
|
||||
? responsibilityCenters.defaults.costs[
|
||||
pol.jobline.part_type
|
||||
] || null
|
||||
: null,
|
||||
};
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("parts_orders.actions.receivebill")}
|
||||
</Button>
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("parts_orders.actions.receivebill")}
|
||||
</Button>
|
||||
<PrinterFilled
|
||||
onClick={() =>
|
||||
GenerateDocument(
|
||||
{
|
||||
name: record.isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
variables: { id: record.id },
|
||||
},
|
||||
{},
|
||||
"p"
|
||||
)
|
||||
}
|
||||
/>
|
||||
<MailFilled
|
||||
onClick={() =>
|
||||
GenerateDocument(
|
||||
{
|
||||
name: record.isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
variables: { id: record.id },
|
||||
},
|
||||
{},
|
||||
"e"
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user