Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import {useSplitTreatments} from "@splitsoftware/splitio-react";
|
||||
import {Form, Input, Radio, Select} from "antd";
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Form, Input, Radio, Select } from "antd";
|
||||
import React from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import DatePickerFormItem from "../form-date-picker/form-date-picker.component";
|
||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||
@@ -12,149 +12,134 @@ import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
import PaymentFormTotalPayments from "./payment-form.totalpayments.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
export function PaymentFormComponent({form, bodyshop, disabled,}) {
|
||||
export function PaymentFormComponent({ form, bodyshop, disabled }) {
|
||||
const {
|
||||
treatments: { Qb_Multi_Ar }
|
||||
} = useSplitTreatments({
|
||||
attributes: {},
|
||||
names: ["Qb_Multi_Ar"],
|
||||
splitKey: bodyshop && bodyshop.imexshopid
|
||||
});
|
||||
|
||||
const {treatments: {Qb_Multi_Ar}} = useSplitTreatments({
|
||||
attributes: {},
|
||||
names: ["Qb_Multi_Ar"],
|
||||
splitKey: bodyshop && bodyshop.imexshopid,
|
||||
});
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
name="jobid"
|
||||
label={t("bills.fields.ro_number")}
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<JobSearchSelect disabled={disabled} notExported={false} clm_no />
|
||||
</Form.Item>
|
||||
<Form.Item shouldUpdate={(prev, cur) => cur.jobid && prev.jobid !== cur.jobid}>
|
||||
{() => {
|
||||
return <PaymentFormTotalPayments jobid={form.getFieldValue("jobid")} />;
|
||||
}}
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
|
||||
const {t} = useTranslation();
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("payments.fields.amount")}
|
||||
name="amount"
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<CurrencyInput disabled={disabled} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("payments.fields.transactionid")} name="transactionid">
|
||||
<Input disabled={disabled} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("payments.fields.memo")} name="memo">
|
||||
<Input disabled={disabled} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("payments.fields.date")}
|
||||
name="date"
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<DatePickerFormItem disabled={disabled} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
|
||||
return (
|
||||
<div>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
name="jobid"
|
||||
label={t("bills.fields.ro_number")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<JobSearchSelect disabled={disabled} notExported={false} clm_no/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
shouldUpdate={(prev, cur) => cur.jobid && prev.jobid !== cur.jobid}
|
||||
>
|
||||
{() => {
|
||||
return (
|
||||
<PaymentFormTotalPayments jobid={form.getFieldValue("jobid")}/>
|
||||
);
|
||||
}}
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("payments.fields.payer")}
|
||||
name="payer"
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Select disabled={disabled}>
|
||||
<Select.Option value={t("payments.labels.customer")}>{t("payments.labels.customer")}</Select.Option>
|
||||
{Qb_Multi_Ar.treatment === "on" ? (
|
||||
<>
|
||||
<Select.OptGroup label={t("payments.labels.external")}>
|
||||
{bodyshop.md_ins_cos.map((i, idx) => (
|
||||
<Select.Option key={idx} value={i.name}>
|
||||
{i.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select.OptGroup>
|
||||
</>
|
||||
) : (
|
||||
<Select.Option value={t("payments.labels.insurance")}>{t("payments.labels.insurance")}</Select.Option>
|
||||
)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("payments.fields.amount")}
|
||||
name="amount"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<CurrencyInput disabled={disabled}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("payments.fields.transactionid")}
|
||||
name="transactionid"
|
||||
>
|
||||
<Input disabled={disabled}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t("payments.fields.memo")} name="memo">
|
||||
<Input disabled={disabled}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("payments.fields.date")}
|
||||
name="date"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<DatePickerFormItem disabled={disabled}/>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("payments.fields.payer")}
|
||||
name="payer"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select disabled={disabled}>
|
||||
<Select.Option value={t("payments.labels.customer")}>
|
||||
{t("payments.labels.customer")}
|
||||
</Select.Option>
|
||||
{Qb_Multi_Ar.treatment === "on" ? (
|
||||
<>
|
||||
<Select.OptGroup label={t("payments.labels.external")}>
|
||||
{bodyshop.md_ins_cos.map((i, idx) => (
|
||||
<Select.Option key={idx} value={i.name}>
|
||||
{i.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select.OptGroup>
|
||||
</>
|
||||
) : (
|
||||
<Select.Option value={t("payments.labels.insurance")}>
|
||||
{t("payments.labels.insurance")}
|
||||
</Select.Option>
|
||||
)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t("payments.fields.type")}
|
||||
name="type"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select disabled={disabled}>
|
||||
{bodyshop.md_payment_types.map((v, idx) => (
|
||||
<Select.Option key={idx} value={v}>
|
||||
{v}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
label={t("general.labels.sendby")}
|
||||
name="sendby"
|
||||
initialValue="none"
|
||||
>
|
||||
<Radio.Group disabled={disabled}>
|
||||
<Radio value="none">{t("general.labels.none")}</Radio>
|
||||
<Radio value="email">{t("general.labels.email")}</Radio>
|
||||
<Radio value="print">{t("general.labels.print")}</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</div>
|
||||
);
|
||||
<Form.Item
|
||||
label={t("payments.fields.type")}
|
||||
name="type"
|
||||
rules={[
|
||||
{
|
||||
required: true
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Select disabled={disabled}>
|
||||
{bodyshop.md_payment_types.map((v, idx) => (
|
||||
<Select.Option key={idx} value={v}>
|
||||
{v}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item label={t("general.labels.sendby")} name="sendby" initialValue="none">
|
||||
<Radio.Group disabled={disabled}>
|
||||
<Radio value="none">{t("general.labels.none")}</Radio>
|
||||
<Radio value="email">{t("general.labels.email")}</Radio>
|
||||
<Radio value="print">{t("general.labels.print")}</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(PaymentFormComponent);
|
||||
|
||||
@@ -1,52 +1,44 @@
|
||||
import {useQuery} from "@apollo/client";
|
||||
import {Statistic} from "antd";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { Statistic } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import React from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {QUERY_JOB_PAYMENT_TOTALS} from "../../graphql/payments.queries";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { QUERY_JOB_PAYMENT_TOTALS } from "../../graphql/payments.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
|
||||
export default function PaymentFormTotalPayments({jobid}) {
|
||||
const {t} = useTranslation();
|
||||
export default function PaymentFormTotalPayments({ jobid }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {loading, error, data} = useQuery(QUERY_JOB_PAYMENT_TOTALS, {
|
||||
variables: {id: jobid},
|
||||
skip: !jobid,
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
});
|
||||
const { loading, error, data } = useQuery(QUERY_JOB_PAYMENT_TOTALS, {
|
||||
variables: { id: jobid },
|
||||
skip: !jobid,
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
if (loading) return <LoadingSpinner/>;
|
||||
if (error) return <AlertComponent message={error.message} type="error"/>;
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
if (!data) return <></>;
|
||||
const totalPayments = data.jobs_by_pk.payments.reduce((acc, val) => {
|
||||
return acc.add(
|
||||
Dinero({amount: Math.round(((val && val.amount) || 0) * 100)})
|
||||
);
|
||||
}, Dinero());
|
||||
if (!data) return <></>;
|
||||
const totalPayments = data.jobs_by_pk.payments.reduce((acc, val) => {
|
||||
return acc.add(Dinero({ amount: Math.round(((val && val.amount) || 0) * 100) }));
|
||||
}, Dinero());
|
||||
|
||||
const balance =
|
||||
data.jobs_by_pk.job_totals &&
|
||||
Dinero(data.jobs_by_pk.job_totals.totals.total_repairs).subtract(
|
||||
totalPayments
|
||||
);
|
||||
const balance =
|
||||
data.jobs_by_pk.job_totals && Dinero(data.jobs_by_pk.job_totals.totals.total_repairs).subtract(totalPayments);
|
||||
|
||||
return (
|
||||
<div style={{display: "flex", justifyContent: "space-evenly"}}>
|
||||
<Statistic
|
||||
title={t("payments.labels.totalpayments")}
|
||||
value={totalPayments.toFormat()}
|
||||
/>
|
||||
{balance && (
|
||||
<Statistic
|
||||
title={t("payments.labels.balance")}
|
||||
valueStyle={{color: balance.getAmount() !== 0 ? "red" : "green"}}
|
||||
value={(balance && balance.toFormat()) || ""}
|
||||
/>
|
||||
)}
|
||||
{!balance && <div>{t("jobs.errors.nofinancial")}</div>}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div style={{ display: "flex", justifyContent: "space-evenly" }}>
|
||||
<Statistic title={t("payments.labels.totalpayments")} value={totalPayments.toFormat()} />
|
||||
{balance && (
|
||||
<Statistic
|
||||
title={t("payments.labels.balance")}
|
||||
valueStyle={{ color: balance.getAmount() !== 0 ? "red" : "green" }}
|
||||
value={(balance && balance.toFormat()) || ""}
|
||||
/>
|
||||
)}
|
||||
{!balance && <div>{t("jobs.errors.nofinancial")}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user