Merged in feature/IO-2368-QBO-Successful-Export (pull request #967)
IO-2368 Move Cache update to function and just pass in keys array
This commit is contained in:
@@ -20,6 +20,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function JobsCloseExportButton({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -160,39 +173,17 @@ export function JobsCloseExportButton({
|
|||||||
date_exported: new Date(),
|
date_exported: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
jobs(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(jobRef) =>
|
|
||||||
jobRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "jobid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!jobUpdateResponse.errors) {
|
if (!!!jobUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
message: t("jobs.successes.exported"),
|
message: t("jobs.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updateJobCache(
|
||||||
|
jobUpdateResponse.data.update_jobs.returning.map((job) => job.id)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("jobs.errors.exporting", {
|
message: t("jobs.errors.exporting", {
|
||||||
@@ -207,29 +198,18 @@ export function JobsCloseExportButton({
|
|||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
message: t("jobs.successes.exported"),
|
message: t("jobs.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updateJobCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
jobs(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(jobRef) =>
|
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||||
jobRef.__ref.includes([
|
? "jobid"
|
||||||
...new Set(
|
: "id"
|
||||||
successfulTransactions.map(
|
]
|
||||||
(st) =>
|
)
|
||||||
st[
|
),
|
||||||
bodyshop.accountingconfig &&
|
]);
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "jobid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (setSelectedJobs) {
|
if (setSelectedJobs) {
|
||||||
setSelectedJobs((selectedJobs) => {
|
setSelectedJobs((selectedJobs) => {
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function JobsExportAllButton({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -97,7 +110,7 @@ export function JobsExportAllButton({
|
|||||||
Object.keys(groupedData).map(async (key) => {
|
Object.keys(groupedData).map(async (key) => {
|
||||||
//Check to see if any of them failed. If they didn't don't execute the update.
|
//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 failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||||
const successfulTransactions = PartnerResponse.data.filter(
|
const successfulTransactions = groupedData[key].filter(
|
||||||
(r) => r.success
|
(r) => r.success
|
||||||
);
|
);
|
||||||
if (failedTransactions.length > 0) {
|
if (failedTransactions.length > 0) {
|
||||||
@@ -156,39 +169,19 @@ export function JobsExportAllButton({
|
|||||||
date_exported: new Date(),
|
date_exported: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
jobs(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(jobRef) =>
|
|
||||||
jobRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "jobid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!jobUpdateResponse.errors) {
|
if (!!!jobUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
message: t("jobs.successes.exported"),
|
message: t("jobs.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updateJobCache(
|
||||||
|
jobUpdateResponse.data.update_jobs.returning.map(
|
||||||
|
(job) => job.id
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("jobs.errors.exporting", {
|
message: t("jobs.errors.exporting", {
|
||||||
@@ -203,27 +196,18 @@ export function JobsExportAllButton({
|
|||||||
key: "jobsuccessexport",
|
key: "jobsuccessexport",
|
||||||
message: t("jobs.successes.exported"),
|
message: t("jobs.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updateJobCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
jobs(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(jobRef) =>
|
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||||
jobRef.__ref.includes(
|
? "jobid"
|
||||||
successfulTransactions.map(
|
: "id"
|
||||||
(st) =>
|
]
|
||||||
st[
|
)
|
||||||
bodyshop.accountingconfig &&
|
),
|
||||||
bodyshop.accountingconfig.qbo
|
]);
|
||||||
? "jobid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,6 +21,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function PayableExportAll({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -97,7 +110,7 @@ export function PayableExportAll({
|
|||||||
proms.push(
|
proms.push(
|
||||||
(async () => {
|
(async () => {
|
||||||
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||||
const successfulTransactions = PartnerResponse.data.filter(
|
const successfulTransactions = groupedData[key].filter(
|
||||||
(r) => r.success
|
(r) => r.success
|
||||||
);
|
);
|
||||||
if (failedTransactions.length > 0) {
|
if (failedTransactions.length > 0) {
|
||||||
@@ -159,31 +172,6 @@ export function PayableExportAll({
|
|||||||
exported_at: new Date(),
|
exported_at: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
bills(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(billRef) =>
|
|
||||||
billRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "billid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (!!!billUpdateResponse.errors) {
|
if (!!!billUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
@@ -191,6 +179,11 @@ export function PayableExportAll({
|
|||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
message: t("bills.successes.exported"),
|
message: t("bills.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updateBillCache(
|
||||||
|
billUpdateResponse.data.update_bills.returning.map(
|
||||||
|
(bill) => bill.id
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("bills.errors.exporting", {
|
message: t("bills.errors.exporting", {
|
||||||
@@ -205,29 +198,19 @@ export function PayableExportAll({
|
|||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
message: t("bills.successes.exported"),
|
message: t("bills.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updateBillCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
bills(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(billRef) =>
|
bodyshop.accountingconfig &&
|
||||||
billRef.__ref.includes([
|
bodyshop.accountingconfig.qbo
|
||||||
...new Set(
|
? "billid"
|
||||||
successfulTransactions.map(
|
: "id"
|
||||||
(st) =>
|
]
|
||||||
st[
|
)
|
||||||
bodyshop.accountingconfig &&
|
),
|
||||||
bodyshop.accountingconfig.qbo
|
]);
|
||||||
? "billid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function PayableExportButton({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -152,31 +165,6 @@ export function PayableExportButton({
|
|||||||
exported_at: new Date(),
|
exported_at: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
bills(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(billRef) =>
|
|
||||||
billRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "billid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (!!!billUpdateResponse.errors) {
|
if (!!!billUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
@@ -184,6 +172,11 @@ export function PayableExportButton({
|
|||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
message: t("bills.successes.exported"),
|
message: t("bills.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updateBillCache(
|
||||||
|
billUpdateResponse.data.update_bills.returning.map(
|
||||||
|
(bill) => bill.id
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("bills.errors.exporting", {
|
message: t("bills.errors.exporting", {
|
||||||
@@ -198,29 +191,18 @@ export function PayableExportButton({
|
|||||||
key: "billsuccessexport",
|
key: "billsuccessexport",
|
||||||
message: t("bills.successes.exported"),
|
message: t("bills.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updateBillCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
bills(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(billRef) =>
|
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||||
billRef.__ref.includes([
|
? "billid"
|
||||||
...new Set(
|
: "id"
|
||||||
successfulTransactions.map(
|
]
|
||||||
(st) =>
|
)
|
||||||
st[
|
),
|
||||||
bodyshop.accountingconfig &&
|
]);
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "billid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setSelectedBills) {
|
if (setSelectedBills) {
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function PaymentExportButton({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -151,31 +164,6 @@ export function PaymentExportButton({
|
|||||||
exportedat: new Date(),
|
exportedat: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
payments(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(paymentRef) =>
|
|
||||||
paymentRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "paymentid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (!!!paymentUpdateResponse.errors) {
|
if (!!!paymentUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
@@ -183,6 +171,11 @@ export function PaymentExportButton({
|
|||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
message: t("payments.successes.exported"),
|
message: t("payments.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updatePaymentCache(
|
||||||
|
paymentUpdateResponse.data.update_payments.returning.map(
|
||||||
|
(payment) => payment.id
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting", {
|
message: t("payments.errors.exporting", {
|
||||||
@@ -204,29 +197,18 @@ export function PaymentExportButton({
|
|||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
message: t("payments.successes.exported"),
|
message: t("payments.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updatePaymentCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
payments(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(paymentRef) =>
|
bodyshop.accountingconfig && bodyshop.accountingconfig.qbo
|
||||||
paymentRef.__ref.includes([
|
? "paymentid"
|
||||||
...new Set(
|
: "id"
|
||||||
successfulTransactions.map(
|
]
|
||||||
(st) =>
|
)
|
||||||
st[
|
),
|
||||||
bodyshop.accountingconfig &&
|
]);
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "paymentid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (!!loadingCallback) loadingCallback(false);
|
if (!!loadingCallback) loadingCallback(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -19,6 +19,19 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
currentUser: selectCurrentUser,
|
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({
|
export function PaymentsExportAllButton({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
currentUser,
|
currentUser,
|
||||||
@@ -85,7 +98,7 @@ export function PaymentsExportAllButton({
|
|||||||
proms.push(
|
proms.push(
|
||||||
(async () => {
|
(async () => {
|
||||||
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
const failedTransactions = groupedData[key].filter((r) => !r.success);
|
||||||
const successfulTransactions = PartnerResponse.data.filter(
|
const successfulTransactions = groupedData[key].filter(
|
||||||
(r) => r.success
|
(r) => r.success
|
||||||
);
|
);
|
||||||
if (failedTransactions.length > 0) {
|
if (failedTransactions.length > 0) {
|
||||||
@@ -146,31 +159,6 @@ export function PaymentsExportAllButton({
|
|||||||
exportedat: new Date(),
|
exportedat: new Date(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update(cache) {
|
|
||||||
cache.modify({
|
|
||||||
id: "ROOT_QUERY",
|
|
||||||
fields: {
|
|
||||||
payments(existingJobs = []) {
|
|
||||||
return existingJobs.filter(
|
|
||||||
(paymentRef) =>
|
|
||||||
paymentRef.__ref.includes([
|
|
||||||
...new Set(
|
|
||||||
successfulTransactions.map(
|
|
||||||
(st) =>
|
|
||||||
st[
|
|
||||||
bodyshop.accountingconfig &&
|
|
||||||
bodyshop.accountingconfig.qbo
|
|
||||||
? "paymentid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (!!!paymentUpdateResponse.errors) {
|
if (!!!paymentUpdateResponse.errors) {
|
||||||
notification.open({
|
notification.open({
|
||||||
@@ -178,6 +166,11 @@ export function PaymentsExportAllButton({
|
|||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
message: t("payments.successes.exported"),
|
message: t("payments.successes.exported"),
|
||||||
});
|
});
|
||||||
|
updatePaymentCache(
|
||||||
|
paymentUpdateResponse.data.update_payments.returning.map(
|
||||||
|
(payment) => payment.id
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting", {
|
message: t("payments.errors.exporting", {
|
||||||
@@ -192,29 +185,19 @@ export function PaymentsExportAllButton({
|
|||||||
key: "paymentsuccessexport",
|
key: "paymentsuccessexport",
|
||||||
message: t("payments.successes.exported"),
|
message: t("payments.successes.exported"),
|
||||||
});
|
});
|
||||||
client.cache.modify({
|
updatePaymentCache([
|
||||||
id: "ROOT_QUERY",
|
...new Set(
|
||||||
fields: {
|
successfulTransactions.map(
|
||||||
payments(existingJobs = []) {
|
(st) =>
|
||||||
return existingJobs.filter(
|
st[
|
||||||
(paymentRef) =>
|
bodyshop.accountingconfig &&
|
||||||
paymentRef.__ref.includes([
|
bodyshop.accountingconfig.qbo
|
||||||
...new Set(
|
? "paymentid"
|
||||||
successfulTransactions.map(
|
: "id"
|
||||||
(st) =>
|
]
|
||||||
st[
|
)
|
||||||
bodyshop.accountingconfig &&
|
),
|
||||||
bodyshop.accountingconfig.qbo
|
]);
|
||||||
? "paymentid"
|
|
||||||
: "id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]) === false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
Reference in New Issue
Block a user