Added automatic parts order receiving BOD-218
This commit is contained in:
@@ -5,20 +5,35 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { DateFormatter } from "../../utils/DateFormatter";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import PartsOrderLineBackorderButton from "../parts-order-line-backorder-button/parts-order-line-backorder-button.component";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setInvoiceEnterContext: (context) =>
|
||||
dispatch(setModalContext({ context: context, modal: "invoiceEnter" })),
|
||||
});
|
||||
|
||||
export function PartsOrderListTableComponent({
|
||||
setInvoiceEnterContext,
|
||||
bodyshop,
|
||||
job,
|
||||
loading,
|
||||
invoicesQuery,
|
||||
|
||||
handleOnRowClick,
|
||||
}) {
|
||||
const responsibilityCenters = bodyshop.md_responsibility_centers;
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [state, setState] = useState({
|
||||
sortedInfo: {},
|
||||
@@ -71,6 +86,43 @@ export function PartsOrderListTableComponent({
|
||||
<DateFormatter>{record.deliver_by}</DateFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("general.labels.actions"),
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<Button
|
||||
onClick={() => {
|
||||
logImEXEvent("parts_order_receive_invoice");
|
||||
|
||||
setInvoiceEnterContext({
|
||||
actions: { refetch: refetch },
|
||||
context: {
|
||||
job: job,
|
||||
invoice: {
|
||||
vendorid: record.vendor.id,
|
||||
invoicelines: 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.receiveinvoice")}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const handleTableChange = (pagination, filters, sorter) => {
|
||||
@@ -229,4 +281,7 @@ export function PartsOrderListTableComponent({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(null, mapDispatchToProps)(PartsOrderListTableComponent);
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(PartsOrderListTableComponent);
|
||||
|
||||
Reference in New Issue
Block a user