Additional fixes for exporting

This commit is contained in:
Patrick Fic
2021-02-16 18:29:22 -08:00
parent 9533e7c4e0
commit 3cfd8173a0
17 changed files with 552 additions and 94 deletions

View File

@@ -9,6 +9,7 @@ import { auth } from "../../firebase/firebase.utils";
import { UPDATE_BILLS } from "../../graphql/bills.queries";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { logImEXEvent } from "../../firebase/firebase.utils";
import _ from "lodash";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -72,43 +73,49 @@ export function PayableExportAll({
}
console.log("handleQbxml -> PartnerResponse", PartnerResponse);
const failedTransactions = PartnerResponse.data.filter((r) => !r.success);
const successfulTransactions = PartnerResponse.data.filter(
(r) => r.success
);
if (failedTransactions.length > 0) {
//Uh oh. At least one was no good.
failedTransactions.map((ft) =>
notification["error"]({
message: t("bills.errors.exporting", {
error: ft.errorMessage || "",
}),
})
);
}
if (successfulTransactions.length > 0) {
const billUpdateResponse = await updateBill({
variables: {
billIdList: successfulTransactions.map((st) => st.id),
bill: {
exported: true,
exported_at: new Date(),
},
},
});
if (!!!billUpdateResponse.errors) {
notification["success"]({
message: t("bills.successes.exported"),
});
} else {
notification["error"]({
message: t("bills.errors.exporting", {
error: JSON.stringify(billUpdateResponse.error),
}),
});
}
}
const groupedData = _.groupBy(PartnerResponse.data, "id");
const proms = [];
Object.keys(groupedData).forEach((key) => {
proms.push(
(async () => {
const failedTransactions = groupedData[key].filter((r) => !r.success);
if (failedTransactions.length > 0) {
//Uh oh. At least one was no good.
failedTransactions.map((ft) =>
notification["error"]({
message: t("bills.errors.exporting", {
error: ft.errorMessage || "",
}),
})
);
} else {
const billUpdateResponse = await updateBill({
variables: {
billIdList: [key],
bill: {
exported: true,
exported_at: new Date(),
},
},
});
if (!!!billUpdateResponse.errors) {
notification["success"]({
message: t("bills.successes.exported"),
});
} else {
notification["error"]({
message: t("bills.errors.exporting", {
error: JSON.stringify(billUpdateResponse.error),
}),
});
}
}
})()
);
});
await Promise.all(proms);
if (!!completedCallback) completedCallback([]);
if (!!loadingCallback) loadingCallback(false);
setLoading(false);

View File

@@ -107,16 +107,11 @@ export function PaymentFormComponent({
]}
>
<Select disabled={disabled}>
<Select.Option value="Visa">Visa</Select.Option>
<Select.Option value="Master Card">Mastercard</Select.Option>
<Select.Option value="American Express">
American Express
</Select.Option>
<Select.Option value="Discover">Discover</Select.Option>
<Select.Option value="Cash">Cash</Select.Option>
<Select.Option value="Cheque">Cheque</Select.Option>
<Select.Option value="Interac Debit">Interac Debit</Select.Option>
<Select.Option value="EFT">EFT</Select.Option>
{bodyshop.md_payment_types.map((v, idx) => (
<Select.Option key={idx} value={v}>
{v}
</Select.Option>
))}
</Select>
</Form.Item>

View File

@@ -570,6 +570,19 @@ export default function ShopInfoComponent({ form, saveLoading }) {
}}
</Form.List>
<LayoutFormRow>
<Form.Item
name={["md_payment_types"]}
label={t("bodyshop.fields.md_payment_types")}
rules={[
{
required: true,
message: t("general.validation.required"),
type: "array",
},
]}
>
<Select mode="tags" />
</Form.Item>
<Form.Item
name={["md_classes"]}
label={t("bodyshop.fields.md_classes")}

View File

@@ -45,7 +45,7 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
return (
<div>
<strong>{t("bodyshop.labels.responsibilitycenters.title")}</strong>=
<strong>{t("bodyshop.labels.responsibilitycenters.title")}</strong>
<div>
<strong>{t("bodyshop.labels.responsibilitycenters.costs")}</strong>
<Form.List name={["md_responsibility_centers", "costs"]}>
@@ -1350,7 +1350,6 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
<InputNumber precision={2} />
</Form.Item>
</LayoutFormRow>
<LayoutFormRow>
<Form.Item
label={t("bodyshop.fields.responsibilitycenters.ar")}
@@ -1415,7 +1414,7 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
</LayoutFormRow>
<LayoutFormRow>
<Form.Item
label={t("bodyshop.fields.responsibilitycenters.ar")}
label={t("bodyshop.fields.responsibilitycenters.ap")}
rules={[
{
required: true,
@@ -1475,6 +1474,68 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) {
<Input />
</Form.Item>
</LayoutFormRow>
<LayoutFormRow>
<Form.Item
label={t("bodyshop.fields.responsibilitycenters.refund")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_responsibility_centers", "refund", "name"]}
>
<Input />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.responsibilitycenter_accountnumber")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_responsibility_centers", "refund", "accountnumber"]}
>
<Input />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.responsibilitycenter_accountname")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_responsibility_centers", "refund", "accountname"]}
>
<Input />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.responsibilitycenter_accountdesc")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_responsibility_centers", "refund", "accountdesc"]}
>
<Input />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.responsibilitycenter_accountitem")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
name={["md_responsibility_centers", "refund", "accountitem"]}
>
<Input />
</Form.Item>
</LayoutFormRow>
</div>
</div>
</div>

View File

@@ -78,6 +78,7 @@ export const QUERY_BODYSHOP = gql`
default_adjustment_rate
workingdays
use_fippa
md_payment_types
employees {
id
first_name
@@ -154,6 +155,7 @@ export const UPDATE_SHOP = gql`
default_adjustment_rate
workingdays
use_fippa
md_payment_types
employees {
id
first_name

View File

@@ -214,6 +214,7 @@
"md_categories": "Categories",
"md_classes": "Classes",
"md_ins_cos": "Insurance Companies",
"md_payment_types": "Payment Types",
"md_referral_sources": "Referral Sources",
"messaginglabel": "Messaging Preset Label",
"messagingtext": "Messaging Preset Text",

View File

@@ -214,6 +214,7 @@
"md_categories": "",
"md_classes": "",
"md_ins_cos": "",
"md_payment_types": "",
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",

View File

@@ -214,6 +214,7 @@
"md_categories": "",
"md_classes": "",
"md_ins_cos": "",
"md_payment_types": "",
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",