@@ -0,0 +1,100 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Button, notification } from "antd";
|
||||||
|
import { useMutation } from "@apollo/client";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||||
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
currentUser: selectCurrentUser,
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
setPaymentContext: (context) =>
|
||||||
|
dispatch(setModalContext({ context: context, modal: "payment" })),
|
||||||
|
});
|
||||||
|
|
||||||
|
const PaymentMarkForExportButton = ({
|
||||||
|
bodyshop,
|
||||||
|
payment,
|
||||||
|
refetch,
|
||||||
|
setPaymentContext,
|
||||||
|
currentUser,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [insertExportLog, { loading: exportLogLoading }] =
|
||||||
|
useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [updatePayment, { loading: updatePaymentLoading }] =
|
||||||
|
useMutation(UPDATE_PAYMENT);
|
||||||
|
|
||||||
|
const handleClick = async () => {
|
||||||
|
const today = new Date();
|
||||||
|
|
||||||
|
await insertExportLog({
|
||||||
|
variables: {
|
||||||
|
logs: [
|
||||||
|
{
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
paymentid: payment.id,
|
||||||
|
successful: true,
|
||||||
|
useremail: currentUser.email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const paymentUpdateResponse = await updatePayment({
|
||||||
|
variables: {
|
||||||
|
paymentId: payment.id,
|
||||||
|
payment: {
|
||||||
|
exportedat: today,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!!paymentUpdateResponse.errors) {
|
||||||
|
notification.open({
|
||||||
|
type: "success",
|
||||||
|
key: "paymentsuccessmarkforexport",
|
||||||
|
message: t("payments.successes.markexported"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (refetch) refetch();
|
||||||
|
|
||||||
|
setPaymentContext({
|
||||||
|
actions: {
|
||||||
|
refetch,
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
...payment,
|
||||||
|
exportedat: today,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("payments.errors.exporting", {
|
||||||
|
error: JSON.stringify(paymentUpdateResponse.error),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
onClick={handleClick}
|
||||||
|
loading={exportLogLoading || updatePaymentLoading}
|
||||||
|
disabled={!!payment.exportedat}
|
||||||
|
>
|
||||||
|
{t("payments.labels.markforexport")}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(PaymentMarkForExportButton);
|
||||||
@@ -19,8 +19,8 @@ import {
|
|||||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import PaymentForm from "../payment-form/payment-form.component";
|
import PaymentForm from "../payment-form/payment-form.component";
|
||||||
import PaymentExportButton from "../payment-export-button/payment-export-button.component";
|
|
||||||
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
||||||
|
import PaymentMarkForExportButton from "../payment-mark-export-button/payment-mark-export-button-component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
paymentModal: selectPayment,
|
paymentModal: selectPayment,
|
||||||
@@ -180,10 +180,9 @@ function PaymentModalContainer({
|
|||||||
>
|
>
|
||||||
<Space>
|
<Space>
|
||||||
<PaymentReexportButton payment={context} refetch={actions.refetch} />
|
<PaymentReexportButton payment={context} refetch={actions.refetch} />
|
||||||
<PaymentExportButton
|
<PaymentMarkForExportButton
|
||||||
bodyshop={bodyshop}
|
bodyshop={bodyshop}
|
||||||
paymentId={context.id}
|
payment={context}
|
||||||
disabled={!!context.exportedat}
|
|
||||||
refetch={actions.refetch}
|
refetch={actions.refetch}
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
|||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
message: t("payments.successes.reexported"),
|
message: t("payments.successes.markreexported"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (refetch) refetch();
|
if (refetch) refetch();
|
||||||
@@ -58,7 +58,7 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
disabled={!payment.exportedat}
|
disabled={!payment.exportedat}
|
||||||
>
|
>
|
||||||
{t("bills.labels.markforreexport")}
|
{t("payments.labels.markforreexport")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,29 +53,29 @@ export function ScheduleCalendarComponent({ data, refetch, bodyshop }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const filteredData = useMemo(() => {
|
const filteredData = useMemo(() => {
|
||||||
return data
|
return data.filter((d) => {
|
||||||
.filter((d) => {
|
const estFilter =
|
||||||
if (d.__typename === "appointments") {
|
d.__typename === "appointments"
|
||||||
if (estimatorsFilter.length === 0) return true;
|
? estimatorsFilter.length === 0
|
||||||
|
? true
|
||||||
|
: !!estimatorsFilter.find(
|
||||||
|
(e) => e === `${d.job.est_ct_fn} ${d.job.est_ct_ln}`
|
||||||
|
)
|
||||||
|
: true;
|
||||||
|
|
||||||
return !!estimatorsFilter.find(
|
return (
|
||||||
(e) => e !== `${d.job.est_ct_fn} ${d.job.est_ct_ln}`
|
(d.block ||
|
||||||
);
|
(filter.intake && d.isintake) ||
|
||||||
}
|
(filter.manual && !d.isintake && d.block === false) ||
|
||||||
return true;
|
(d.__typename === "employee_vacation" &&
|
||||||
})
|
filter.employeevacation &&
|
||||||
.filter(
|
!!d.employee)) &&
|
||||||
(d) =>
|
(filter.ins_co_nm && filter.ins_co_nm.length > 0
|
||||||
(d.block ||
|
? filter.ins_co_nm.includes(d.job?.ins_co_nm)
|
||||||
(filter.intake && d.isintake) ||
|
: true) &&
|
||||||
(filter.manual && !d.isintake && d.block === false) ||
|
estFilter
|
||||||
(d.__typename === "employee_vacation" &&
|
|
||||||
filter.employeevacation &&
|
|
||||||
!!d.employee)) &&
|
|
||||||
(filter.ins_co_nm && filter.ins_co_nm.length > 0
|
|
||||||
? filter.ins_co_nm.includes(d.job?.ins_co_nm)
|
|
||||||
: true)
|
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}, [data, filter, estimatorsFilter]);
|
}, [data, filter, estimatorsFilter]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const CONVERSATION_LIST_QUERY = gql`
|
|||||||
query CONVERSATION_LIST_QUERY($offset: Int!) {
|
query CONVERSATION_LIST_QUERY($offset: Int!) {
|
||||||
conversations(
|
conversations(
|
||||||
order_by: { updated_at: desc }
|
order_by: { updated_at: desc }
|
||||||
limit: 20
|
limit: 50
|
||||||
offset: $offset
|
offset: $offset
|
||||||
where: { archived: { _eq: false } }
|
where: { archived: { _eq: false } }
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -2219,11 +2219,11 @@
|
|||||||
"title": "Payments",
|
"title": "Payments",
|
||||||
"totalpayments": "Total Payments",
|
"totalpayments": "Total Payments",
|
||||||
"markforexport": "Mark for Export",
|
"markforexport": "Mark for Export",
|
||||||
"markforreexport": "Mark for Reexport"
|
"markforreexport": "Mark for Re-export"
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"exported": "Payment(s) exported successfully.",
|
"exported": "Payment(s) exported successfully.",
|
||||||
"reexported": "Payment Re-exported successfully",
|
"markreexported": "Payment marked for re-export successfully",
|
||||||
"markexported": "Payment(s) marked exported.",
|
"markexported": "Payment(s) marked exported.",
|
||||||
"payment": "Payment created successfully. ",
|
"payment": "Payment created successfully. ",
|
||||||
"stripe": "Credit card transaction charged successfully."
|
"stripe": "Credit card transaction charged successfully."
|
||||||
|
|||||||
Reference in New Issue
Block a user