Merge remote-tracking branch 'origin/master' into feature/america
This commit is contained in:
@@ -13,12 +13,26 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updateJobCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
jobs(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(jobRef) => jobRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function JobsCloseExportButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -100,6 +114,9 @@ export function JobsCloseExportButton({
|
||||
|
||||
//Check to see if any of them failed. If they didn't don't execute the update.
|
||||
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.forEach((ft) => {
|
||||
@@ -158,12 +175,15 @@ export function JobsCloseExportButton({
|
||||
},
|
||||
});
|
||||
|
||||
if (!jobUpdateResponse.errors) {
|
||||
if (!!!jobUpdateResponse.errors) {
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
updateJobCache(
|
||||
jobUpdateResponse.data.update_jobs.returning.map((job) => job.id)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.exporting", {
|
||||
@@ -178,6 +198,18 @@ export function JobsCloseExportButton({
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
updateJobCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||
? "jobid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
if (setSelectedJobs) {
|
||||
setSelectedJobs((selectedJobs) => {
|
||||
@@ -185,7 +217,6 @@ export function JobsCloseExportButton({
|
||||
});
|
||||
}
|
||||
}
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,26 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updateJobCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
jobs(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(jobRef) => jobRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function JobsExportAllButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -96,7 +110,9 @@ export function JobsExportAllButton({
|
||||
Object.keys(groupedData).map(async (key) => {
|
||||
//Check to see if any of them failed. If they didn't don't execute the update.
|
||||
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||
|
||||
const successfulTransactions = groupedData[key].filter(
|
||||
(r) => r.success
|
||||
);
|
||||
if (failedTransactions.length > 0) {
|
||||
//Uh oh. At least one was no good.
|
||||
failedTransactions.forEach((ft) => {
|
||||
@@ -155,12 +171,17 @@ export function JobsExportAllButton({
|
||||
},
|
||||
});
|
||||
|
||||
if (!jobUpdateResponse.errors) {
|
||||
if (!!!jobUpdateResponse.errors) {
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
updateJobCache(
|
||||
jobUpdateResponse.data.update_jobs.returning.map(
|
||||
(job) => job.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.exporting", {
|
||||
@@ -175,6 +196,18 @@ export function JobsExportAllButton({
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
updateJobCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||
? "jobid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -182,7 +215,6 @@ export function JobsExportAllButton({
|
||||
|
||||
if (!!completedCallback) completedCallback([]);
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,26 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updateBillCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
bills(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(billRef) => billRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function PayableExportAll({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -96,7 +110,9 @@ export function PayableExportAll({
|
||||
proms.push(
|
||||
(async () => {
|
||||
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||
|
||||
const successfulTransactions = groupedData[key].filter(
|
||||
(r) => r.success
|
||||
);
|
||||
if (failedTransactions.length > 0) {
|
||||
//Uh oh. At least one was no good.
|
||||
failedTransactions.map((ft) =>
|
||||
@@ -142,7 +158,15 @@ export function PayableExportAll({
|
||||
|
||||
const billUpdateResponse = await updateBill({
|
||||
variables: {
|
||||
billIdList: [key],
|
||||
billIdList: successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "billid"
|
||||
: "id"
|
||||
]
|
||||
),
|
||||
bill: {
|
||||
exported: true,
|
||||
exported_at: new Date(),
|
||||
@@ -155,6 +179,11 @@ export function PayableExportAll({
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
updateBillCache(
|
||||
billUpdateResponse.data.update_bills.returning.map(
|
||||
(bill) => bill.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("bills.errors.exporting", {
|
||||
@@ -169,6 +198,19 @@ export function PayableExportAll({
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
updateBillCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "billid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -178,7 +220,6 @@ export function PayableExportAll({
|
||||
await Promise.all(proms);
|
||||
if (!!completedCallback) completedCallback([]);
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,26 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updateBillCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
bills(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(billRef) => billRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function PayableExportButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -158,6 +172,11 @@ export function PayableExportButton({
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
updateBillCache(
|
||||
billUpdateResponse.data.update_bills.returning.map(
|
||||
(bill) => bill.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("bills.errors.exporting", {
|
||||
@@ -172,6 +191,18 @@ export function PayableExportButton({
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
updateBillCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||
? "billid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (setSelectedBills) {
|
||||
@@ -182,7 +213,6 @@ export function PayableExportButton({
|
||||
}
|
||||
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,26 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updatePaymentCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
payments(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(paymentRef) => paymentRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function PaymentExportButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -157,6 +171,11 @@ export function PaymentExportButton({
|
||||
key: "paymentsuccessexport",
|
||||
message: t("payments.successes.exported"),
|
||||
});
|
||||
updatePaymentCache(
|
||||
paymentUpdateResponse.data.update_payments.returning.map(
|
||||
(payment) => payment.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("payments.errors.exporting", {
|
||||
@@ -178,9 +197,20 @@ export function PaymentExportButton({
|
||||
key: "paymentsuccessexport",
|
||||
message: t("payments.successes.exported"),
|
||||
});
|
||||
updatePaymentCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||
? "paymentid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,11 +13,25 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
function updatePaymentCache(items) {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
payments(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(paymentRef) => paymentRef.__ref.includes(items) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function PaymentsExportAllButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
@@ -84,7 +98,9 @@ export function PaymentsExportAllButton({
|
||||
proms.push(
|
||||
(async () => {
|
||||
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||
|
||||
const successfulTransactions = groupedData[key].filter(
|
||||
(r) => r.success
|
||||
);
|
||||
if (failedTransactions.length > 0) {
|
||||
//Uh oh. At least one was no good.
|
||||
failedTransactions.map((ft) =>
|
||||
@@ -130,7 +146,15 @@ export function PaymentsExportAllButton({
|
||||
});
|
||||
const paymentUpdateResponse = await updatePayments({
|
||||
variables: {
|
||||
paymentIdList: [key],
|
||||
paymentIdList: successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "paymentid"
|
||||
: "id"
|
||||
]
|
||||
),
|
||||
payment: {
|
||||
exportedat: new Date(),
|
||||
},
|
||||
@@ -142,6 +166,11 @@ export function PaymentsExportAllButton({
|
||||
key: "paymentsuccessexport",
|
||||
message: t("payments.successes.exported"),
|
||||
});
|
||||
updatePaymentCache(
|
||||
paymentUpdateResponse.data.update_payments.returning.map(
|
||||
(payment) => payment.id
|
||||
)
|
||||
);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("payments.errors.exporting", {
|
||||
@@ -156,6 +185,19 @@ export function PaymentsExportAllButton({
|
||||
key: "paymentsuccessexport",
|
||||
message: t("payments.successes.exported"),
|
||||
});
|
||||
updatePaymentCache([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "paymentid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -164,7 +206,6 @@ export function PaymentsExportAllButton({
|
||||
await Promise.all(proms);
|
||||
if (!!completedCallback) completedCallback([]);
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client";
|
||||
import { Button, Card, Form, notification, Space } from "antd";
|
||||
import axios from "axios";
|
||||
import moment from "moment";
|
||||
import momenttz from "moment-timezone";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -51,14 +52,20 @@ export function TechClockInContainer({
|
||||
const handleFinish = async (values) => {
|
||||
setLoading(true);
|
||||
const theTime = (await axios.post("/utils/time")).data;
|
||||
|
||||
const result = await insertTimeTicket({
|
||||
variables: {
|
||||
timeTicketInput: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
employeeid: technician.id,
|
||||
date: moment(theTime).format("YYYY-MM-DD"),
|
||||
date:
|
||||
typeof bodyshop.timezone === "string"
|
||||
? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD")
|
||||
: typeof bodyshop.timezone === "number"
|
||||
? moment(theTime)
|
||||
.format("YYYY-MM-DD")
|
||||
.utcOffset(bodyshop.timezone)
|
||||
: moment(theTime).format("YYYY-MM-DD"),
|
||||
clockon: moment(theTime),
|
||||
jobid: values.jobid,
|
||||
cost_center: values.cost_center,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client";
|
||||
import { Button, Form, Space, notification } from "antd";
|
||||
import axios from "axios";
|
||||
import moment from "moment";
|
||||
import momenttz from "moment-timezone";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -68,7 +69,14 @@ export function TimeTicektShiftContainer({
|
||||
employeeid: isTechConsole ? technician.id : employeeId,
|
||||
cost_center: "timetickets.labels.shift",
|
||||
clockon: theTime,
|
||||
date: theTime,
|
||||
date:
|
||||
typeof bodyshop.timezone === "string"
|
||||
? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD")
|
||||
: typeof bodyshop.timezone === "number"
|
||||
? moment(theTime)
|
||||
.utcOffset(bodyshop.timezone)
|
||||
.format("YYYY-MM-DD")
|
||||
: moment(theTime).format("YYYY-MM-DD"),
|
||||
memo: values.memo,
|
||||
created_by: isTechConsole
|
||||
? currentUser.email.concat(
|
||||
|
||||
Reference in New Issue
Block a user