Merged in development (pull request #43) IO-808 IO-809 IO-273 IO-792

This commit is contained in:
Patrick Fic
2021-03-26 14:46:18 +00:00
20 changed files with 3859 additions and 1110 deletions

3975
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,11 @@ export default function BillDetailEditcontainer() {
const handleSave = () => { const handleSave = () => {
//It's got a previously deducted bill line! //It's got a previously deducted bill line!
if (data.bills_by_pk.billlines.filter((b) => b.deductedfromlbr).length > 0) if (
data.bills_by_pk.billlines.filter((b) => b.deductedfromlbr).length > 0 ||
form.getFieldValue("billlines").filter((b) => b.deductedfromlbr).length >
0
)
setVisible(true); setVisible(true);
else { else {
form.submit(); form.submit();
@@ -55,18 +59,6 @@ export default function BillDetailEditcontainer() {
const { deductedfromlbr, ...il } = billline; const { deductedfromlbr, ...il } = billline;
delete il.__typename; delete il.__typename;
//Need to compare this line to the previous version of the line to see if there is a change in the adjustments.
const theOldBillLine = data.bills_by_pk.billlines.find(
(bl) => bl.id === billline.id
);
if (theOldBillLine) {
//It was there! Need to change the diff.
if (theOldBillLine.deductedfromlbr !== deductedfromlbr) {
//There's a different
}
}
if (il.id) { if (il.id) {
updates.push( updates.push(
updateBillLine({ updateBillLine({
@@ -101,7 +93,7 @@ export default function BillDetailEditcontainer() {
await Promise.all(updates); await Promise.all(updates);
await refetch(); await refetch();
form.resetFields(); form.setFieldsValue(transformData(data));
form.resetFields(); form.resetFields();
setVisible(false); setVisible(false);
setUpdateLoading(false); setUpdateLoading(false);

View File

@@ -73,6 +73,7 @@ function BillEnterModalContainer({
return { return {
...restI, ...restI,
deductedfromlbr: deductedfromlbr, deductedfromlbr: deductedfromlbr,
lbr_adjustment,
joblineid: i.joblineid === "noline" ? null : i.joblineid, joblineid: i.joblineid === "noline" ? null : i.joblineid,
}; };
}), }),

View File

@@ -255,14 +255,7 @@ export function BillEnterModalLinesComponent({
> >
<Switch disabled={disabled} /> <Switch disabled={disabled} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item shouldUpdate>
shouldUpdate={(prev, cur) =>
prev.billlines[index] &&
prev.billlines[index].deductedfromlbr !==
cur.billlines[index] &&
cur.billlines[index].deductedfromlbr
}
>
{() => { {() => {
if ( if (
getFieldValue([ getFieldValue([

View File

@@ -3,6 +3,16 @@ import React from "react";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectCurrentUser } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
class ErrorBoundary extends React.Component { class ErrorBoundary extends React.Component {
constructor() { constructor() {
super(); super();
@@ -23,6 +33,24 @@ class ErrorBoundary extends React.Component {
this.setState({ ...this.state, error, info }); this.setState({ ...this.state, error, info });
} }
handleErrorSubmit = () => {
const errorDescription = `**Please add relevant details about what you were doing before you encountered this issue**
----
System Generated Log:
${this.state.error.message}
${this.state.error.stack}
`;
const URL = `https://bodyshop.atlassian.net/servicedesk/customer/portal/3/group/8/create/26?summary=123&description=${encodeURI(
errorDescription
)}&customfield_10049=${window.location}&email=${
this.props.currentUser.email
}`;
console.log(`URL`, URL);
window.open(URL, "_blank");
};
render() { render() {
const { t } = this.props; const { t } = this.props;
const { error, info } = this.state; const { error, info } = this.state;
@@ -32,22 +60,20 @@ class ErrorBoundary extends React.Component {
return ( return (
<div> <div>
<Result <Result
status='500' status="500"
title={t("general.labels.exceptiontitle")} title={t("general.labels.exceptiontitle")}
subTitle={t("general.messages.exception")} subTitle={t("general.messages.exception")}
extra={ extra={
<Space> <Space>
<Button <Button
type='primary' type="primary"
onClick={() => { onClick={() => {
window.location.reload(); window.location.reload();
}}> }}
>
{t("general.actions.refresh")} {t("general.actions.refresh")}
</Button> </Button>
<Button <Button onClick={this.handleErrorSubmit}>
onClick={() => {
alert("Not implemented yet.");
}}>
{t("general.actions.submitticket")} {t("general.actions.submitticket")}
</Button> </Button>
</Space> </Space>
@@ -72,4 +98,8 @@ class ErrorBoundary extends React.Component {
} }
} }
} }
export default withTranslation()(ErrorBoundary);
export default connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation()(ErrorBoundary));

View File

@@ -113,6 +113,9 @@ export default function JobReconcilitionPartsTable({
onChange={handleTableChange} onChange={handleTableChange}
rowSelection={{ rowSelection={{
onChange: handleOnRowClick, onChange: handleOnRowClick,
getCheckboxProps: (record) => ({
disabled: record.removed,
}),
selectedRowKeys: selectedLines, selectedRowKeys: selectedLines,
}} }}
rowClassName={(record) => record.removed && "text-strikethrough"} rowClassName={(record) => record.removed && "text-strikethrough"}

View File

@@ -11,7 +11,7 @@ export const reconcileByAssocLine = (
const [selectedJobLines, setSelectedJobLines] = jobLineState; const [selectedJobLines, setSelectedJobLines] = jobLineState;
const allJoblinesFromBills = billLines const allJoblinesFromBills = billLines
.filter((bl) => !!bl.joblineid) .filter((bl) => bl.joblineid && !(bl.jobline && bl.jobline.removed))
.map((bl) => bl.joblineid); .map((bl) => bl.joblineid);
const duplicatedJobLinesbyInvoiceId = _.filter( const duplicatedJobLinesbyInvoiceId = _.filter(
@@ -73,7 +73,7 @@ export const reconcileByPrice = (
jobLines.forEach((jl) => { jobLines.forEach((jl) => {
const matchingBillLineIds = billLines const matchingBillLineIds = billLines
.filter((bl) => bl.actual_price === jl.act_price) .filter((bl) => bl.actual_price === jl.act_price && !jl.removed)
.map((bl) => bl.id); .map((bl) => bl.id);
if (matchingBillLineIds.length > 1) { if (matchingBillLineIds.length > 1) {

View File

@@ -23,9 +23,11 @@ export default function PaymentFormTotalPayments({ jobid }) {
return acc.add(Dinero({ amount: (val.amount || 0) * 100 })); return acc.add(Dinero({ amount: (val.amount || 0) * 100 }));
}, Dinero()); }, Dinero());
const balance = Dinero( const balance =
data.jobs_by_pk.job_totals.totals.total_repairs data.jobs_by_pk.job_totals &&
).subtract(totalPayments); Dinero(data.jobs_by_pk.job_totals.totals.total_repairs).subtract(
totalPayments
);
return ( return (
<div style={{ display: "flex", justifyContent: "space-evenly" }}> <div style={{ display: "flex", justifyContent: "space-evenly" }}>
@@ -33,11 +35,14 @@ export default function PaymentFormTotalPayments({ jobid }) {
title={t("payments.labels.totalpayments")} title={t("payments.labels.totalpayments")}
value={totalPayments.toFormat()} value={totalPayments.toFormat()}
/> />
<Statistic {balance && (
title={t("payments.labels.balance")} <Statistic
valueStyle={{ color: balance.getAmount() !== 0 ? "red" : "green" }} title={t("payments.labels.balance")}
value={balance.toFormat()} valueStyle={{ color: balance.getAmount() !== 0 ? "red" : "green" }}
/> value={balance.toFormat()}
/>
)}
{!balance && <div>{t("jobs.errors.nofinancial")}</div>}
</div> </div>
); );
} }

View File

@@ -50,14 +50,6 @@ export const QUERY_ALL_BILLS_PAGINATED = gql`
id id
ro_number ro_number
} }
billlines {
actual_price
quantity
actual_cost
cost_center
id
line_desc
}
} }
search_bills_aggregate(args: { search: $search }) { search_bills_aggregate(args: { search: $search }) {
aggregate { aggregate {
@@ -129,6 +121,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
line_desc line_desc
applicable_taxes applicable_taxes
deductedfromlbr deductedfromlbr
lbr_adjustment
} }
} }
} }
@@ -167,6 +160,7 @@ export const QUERY_BILL_BY_PK = gql`
joblineid joblineid
applicable_taxes applicable_taxes
deductedfromlbr deductedfromlbr
lbr_adjustment
} }
documents { documents {
id id

View File

@@ -608,6 +608,10 @@ export const GET_JOB_RECONCILIATION_BY_PK = gql`
line_desc line_desc
applicable_taxes applicable_taxes
deductedfromlbr deductedfromlbr
jobline {
id
removed
}
} }
} }
jobs_by_pk(id: $id) { jobs_by_pk(id: $id) {

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."billlines" DROP COLUMN "lbr_adjustment";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."billlines" ADD COLUMN "lbr_adjustment" jsonb NULL;
type: run_sql

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_insert_permission
- args:
permission:
check:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- line_desc
- quantity
- updated_at
set: {}
role: user
table:
name: billlines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_insert_permission
- args:
permission:
check:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- lbr_adjustment
- line_desc
- quantity
- updated_at
set: {}
role: user
table:
name: billlines
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- line_desc
- quantity
- updated_at
computed_fields: []
filter:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: billlines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,40 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: true
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- lbr_adjustment
- line_desc
- quantity
- updated_at
computed_fields: []
filter:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: billlines
schema: public
type: create_select_permission

View File

@@ -0,0 +1,38 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- line_desc
- quantity
- updated_at
filter:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
set: {}
role: user
table:
name: billlines
schema: public
type: create_update_permission

View File

@@ -0,0 +1,39 @@
- args:
role: user
table:
name: billlines
schema: public
type: drop_update_permission
- args:
permission:
columns:
- actual_cost
- actual_price
- applicable_taxes
- billid
- cost_center
- created_at
- deductedfromlbr
- id
- joblineid
- lbr_adjustment
- line_desc
- quantity
- updated_at
filter:
bill:
job:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
set: {}
role: user
table:
name: billlines
schema: public
type: create_update_permission

View File

@@ -394,6 +394,7 @@ tables:
- deductedfromlbr - deductedfromlbr
- id - id
- joblineid - joblineid
- lbr_adjustment
- line_desc - line_desc
- quantity - quantity
- updated_at - updated_at
@@ -410,6 +411,7 @@ tables:
- deductedfromlbr - deductedfromlbr
- id - id
- joblineid - joblineid
- lbr_adjustment
- line_desc - line_desc
- quantity - quantity
- updated_at - updated_at
@@ -438,6 +440,7 @@ tables:
- deductedfromlbr - deductedfromlbr
- id - id
- joblineid - joblineid
- lbr_adjustment
- line_desc - line_desc
- quantity - quantity
- updated_at - updated_at

630
package-lock.json generated

File diff suppressed because it is too large Load Diff