IO-1030 Bill mark for reexport

This commit is contained in:
Patrick Fic
2021-05-07 13:10:20 -07:00
parent c97d2e0e6f
commit 9435b26042
9 changed files with 147 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project be_version="2.7.1" version="1.2"> <babeledit_project version="1.2" be_version="2.7.1">
<!-- <!--
BabelEdit project file BabelEdit project file
@@ -2307,6 +2307,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>markforreexport</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>new</name> <name>new</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -3990,6 +4011,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>reexport</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>view</name> <name>view</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -22,7 +22,7 @@ import AlertComponent from "../alert/alert.component";
import BillFormContainer from "../bill-form/bill-form.container"; import BillFormContainer from "../bill-form/bill-form.container";
import JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container"; import JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container";
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
import BillReeportButtonComponent from "../bill-reexport-button/bill-reexport-button.component";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { setModalContext } from "../../redux/modals/modals.actions"; import { setModalContext } from "../../redux/modals/modals.actions";
@@ -218,6 +218,7 @@ export function BillDetailEditcontainer({ setPartsOrderContext }) {
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
</Popconfirm> </Popconfirm>
<BillReeportButtonComponent bill={data && data.bills_by_pk} />
</Space> </Space>
} }
/> />

View File

@@ -221,6 +221,8 @@ function BillEnterModalContainer({
useEffect(() => { useEffect(() => {
if (billEnterModal.visible) { if (billEnterModal.visible) {
form.setFieldsValue(formValues); form.setFieldsValue(formValues);
} else {
form.resetFields();
} }
}, [billEnterModal.visible, form, formValues]); }, [billEnterModal.visible, form, formValues]);
@@ -263,7 +265,7 @@ function BillEnterModalContainer({
onFinishFailed={() => { onFinishFailed={() => {
setEnterAgain(false); setEnterAgain(false);
}} }}
initialValues={formValues} // initialValues={formValues}
> >
<BillFormContainer <BillFormContainer
form={form} form={form}

View File

@@ -0,0 +1,80 @@
import { useMutation } from "@apollo/client";
import { Button, notification } from "antd";
import { gql } from "@apollo/client";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import {
selectAuthLevel,
selectBodyshop,
} from "../../redux/user/user.selectors";
import { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
authLevel: selectAuthLevel,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(BillMarkForReexportButton);
export function BillMarkForReexportButton({ bodyshop, authLevel, bill }) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [updateBill] = useMutation(gql`
mutation UPDATE_BILL($billId: uuid!) {
update_bills(where: { id: { _eq: $billId } }, _set: { exported: false }) {
returning {
id
exported
exported_at
}
}
}
`);
const handleUpdate = async () => {
setLoading(true);
const result = await updateBill({
variables: { billId: bill.id },
});
if (!result.errors) {
notification["success"]({ message: t("bills.successes.save") });
} else {
notification["error"]({
message: t("bills.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
//Get the owner details, populate it all back into the job.
};
const hasAccess = HasRbacAccess({
bodyshop,
authLevel,
action: "bills:reexport",
});
if (hasAccess)
return (
<Button
loading={loading}
disabled={!bill.exported}
onClick={handleUpdate}
>
{t("bills.labels.markforreexport")}
</Button>
);
return <></>;
}

View File

@@ -30,6 +30,7 @@ const ret = {
"bills:view": 2, "bills:view": 2,
"bills:list": 2, "bills:list": 2,
"bills:delete": 3, "bills:delete": 3,
"bills:reexport": 3,
"employees:page": 5, "employees:page": 5,

View File

@@ -309,6 +309,18 @@ export default function ShopInfoRbacComponent({ form }) {
> >
<InputNumber /> <InputNumber />
</Form.Item> </Form.Item>
<Form.Item
label={t("bodyshop.fields.rbac.bills.reexport")}
rules={[
{
required: true,
//message: t("general.validation.required"),
},
]}
name={["md_rbac", "bills:reexport"]}
>
<InputNumber />
</Form.Item>
<Form.Item <Form.Item
label={t("bodyshop.fields.rbac.bills.view")} label={t("bodyshop.fields.rbac.bills.view")}
rules={[ rules={[

View File

@@ -153,6 +153,7 @@
"enteringcreditmemo": "You are entering a credit memo. Please ensure you are also entering positive values.", "enteringcreditmemo": "You are entering a credit memo. Please ensure you are also entering positive values.",
"federal_tax": "Federal Tax", "federal_tax": "Federal Tax",
"local_tax": "Local Tax", "local_tax": "Local Tax",
"markforreexport": "Mark for Reexport",
"new": "New Bill", "new": "New Bill",
"noneselected": "No bill selected.", "noneselected": "No bill selected.",
"retailtotal": "Bills Retail Total", "retailtotal": "Bills Retail Total",
@@ -256,6 +257,7 @@
"delete": "Bills -> Delete", "delete": "Bills -> Delete",
"enter": "Bills -> Enter", "enter": "Bills -> Enter",
"list": "Bills -> List", "list": "Bills -> List",
"reexport": "Bills -> Reexport",
"view": "Bills -> View" "view": "Bills -> View"
}, },
"contracts": { "contracts": {

View File

@@ -153,6 +153,7 @@
"enteringcreditmemo": "", "enteringcreditmemo": "",
"federal_tax": "", "federal_tax": "",
"local_tax": "", "local_tax": "",
"markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"retailtotal": "", "retailtotal": "",
@@ -256,6 +257,7 @@
"delete": "", "delete": "",
"enter": "", "enter": "",
"list": "", "list": "",
"reexport": "",
"view": "" "view": ""
}, },
"contracts": { "contracts": {

View File

@@ -153,6 +153,7 @@
"enteringcreditmemo": "", "enteringcreditmemo": "",
"federal_tax": "", "federal_tax": "",
"local_tax": "", "local_tax": "",
"markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"retailtotal": "", "retailtotal": "",
@@ -256,6 +257,7 @@
"delete": "", "delete": "",
"enter": "", "enter": "",
"list": "", "list": "",
"reexport": "",
"view": "" "view": ""
}, },
"contracts": { "contracts": {