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
@@ -2307,6 +2307,27 @@
</translation>
</translations>
</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>
<name>new</name>
<definition_loaded>false</definition_loaded>
@@ -3990,6 +4011,27 @@
</translation>
</translations>
</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>
<name>view</name>
<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 JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container";
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
import BillReeportButtonComponent from "../bill-reexport-button/bill-reexport-button.component";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setModalContext } from "../../redux/modals/modals.actions";
@@ -218,6 +218,7 @@ export function BillDetailEditcontainer({ setPartsOrderContext }) {
{t("general.actions.save")}
</Button>
</Popconfirm>
<BillReeportButtonComponent bill={data && data.bills_by_pk} />
</Space>
}
/>

View File

@@ -221,6 +221,8 @@ function BillEnterModalContainer({
useEffect(() => {
if (billEnterModal.visible) {
form.setFieldsValue(formValues);
} else {
form.resetFields();
}
}, [billEnterModal.visible, form, formValues]);
@@ -263,7 +265,7 @@ function BillEnterModalContainer({
onFinishFailed={() => {
setEnterAgain(false);
}}
initialValues={formValues}
// initialValues={formValues}
>
<BillFormContainer
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:list": 2,
"bills:delete": 3,
"bills:reexport": 3,
"employees:page": 5,

View File

@@ -309,6 +309,18 @@ export default function ShopInfoRbacComponent({ form }) {
>
<InputNumber />
</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
label={t("bodyshop.fields.rbac.bills.view")}
rules={[

View File

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

View File

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

View File

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