Merged in feature/2021-08-13 (pull request #163)

Feature/2021 08 13
This commit is contained in:
Patrick Fic
2021-08-11 15:09:36 +00:00
8 changed files with 29 additions and 21 deletions

View File

@@ -121,6 +121,7 @@ export default function AccountingPayablesTableComponent({ loading, bills }) {
billId={record.id} billId={record.id}
disabled={transInProgress || !!record.exported} disabled={transInProgress || !!record.exported}
loadingCallback={setTransInProgress} loadingCallback={setTransInProgress}
setSelectedBills={setSelectedBills}
/> />
</div> </div>
), ),

View File

@@ -120,6 +120,7 @@ export default function AccountingPayablesTableComponent({
paymentId={record.id} paymentId={record.id}
disabled={transInProgress || !!record.exportedat} disabled={transInProgress || !!record.exportedat}
loadingCallback={setTransInProgress} loadingCallback={setTransInProgress}
setSelectedPayments={setSelectedPayments}
/> />
), ),
}, },

View File

@@ -125,6 +125,7 @@ export default function AccountingReceivablesTableComponent({ loading, jobs }) {
<JobExportButton <JobExportButton
jobId={record.id} jobId={record.id}
disabled={!!record.date_exported} disabled={!!record.date_exported}
setSelectedJobs={setSelectedJobs}
/> />
<Link to={`/manage/jobs/${record.id}/close`}> <Link to={`/manage/jobs/${record.id}/close`}>
<Button>{t("jobs.labels.viewallocations")}</Button> <Button>{t("jobs.labels.viewallocations")}</Button>

View File

@@ -90,13 +90,7 @@ export function JobsAvailableContainer({
const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk); const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk);
if ( if (!(estData && estData.est_data)) {
!(
estData &&
estData.est_data
)
) {
//We don't have the right data. Error! //We don't have the right data. Error!
setInsertLoading(false); setInsertLoading(false);
notification["error"]({ notification["error"]({
@@ -115,10 +109,7 @@ export function JobsAvailableContainer({
).data; ).data;
let existingVehicles; let existingVehicles;
if ( if (estData.est_data.vehicle && estData.est_data.vin) {
estData.est_data.vehicle &&
estData.est_data.vin
) {
//There's vehicle data, need to double check the VIN. //There's vehicle data, need to double check the VIN.
existingVehicles = await client.query({ existingVehicles = await client.query({
query: SEARCH_VEHICLE_BY_VIN, query: SEARCH_VEHICLE_BY_VIN,
@@ -197,13 +188,7 @@ export function JobsAvailableContainer({
setJobModalVisible(false); setJobModalVisible(false);
setInsertLoading(true); setInsertLoading(true);
const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk); const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk);
if ( if (!(estData && estData.est_data)) {
!(
estData &&
estData.est_data
)
) {
//We don't have the right data. Error! //We don't have the right data. Error!
setInsertLoading(false); setInsertLoading(false);
notification["error"]({ notification["error"]({
@@ -215,7 +200,8 @@ export function JobsAvailableContainer({
delete supp.owner; delete supp.owner;
delete supp.vehicle; delete supp.vehicle;
if (importOptions.overrideHeaders) { delete supp.ins_co_nm;
if (!importOptions.overrideHeaders) {
HeaderFields.forEach((item) => delete supp[item]); HeaderFields.forEach((item) => delete supp[item]);
} }
@@ -396,7 +382,7 @@ export default connect(
function replaceEmpty(someObj, replaceValue = null) { function replaceEmpty(someObj, replaceValue = null) {
const replacer = (key, value) => (value === "" ? replaceValue : value); const replacer = (key, value) => (value === "" ? replaceValue : value);
//^ because you seem to want to replace (strings) "null" or "undefined" too //^ because you seem to want to replace (strings) "null" or "undefined" too
console.log(someObj) console.log(someObj);
const temp = JSON.stringify(someObj, replacer); const temp = JSON.stringify(someObj, replacer);
console.log(`temp`, temp); console.log(`temp`, temp);
return JSON.parse(temp); return JSON.parse(temp);

View File

@@ -32,7 +32,7 @@ export function JobsCloseAutoAllocate({ bodyshop, joblines, form, disabled }) {
} }
//Verify that this is also manually updated in server/job-costing //Verify that this is also manually updated in server/job-costing
if (!jl.part_type && !jl.mod_lbr_ty) { if (!jl.part_type && !jl.mod_lbr_ty) {
const lineDesc = jl.line_desc.toLowerCase(); const lineDesc = jl.line_desc && jl.line_desc.toLowerCase();
if (lineDesc.includes("shop materials")) { if (lineDesc.includes("shop materials")) {
ret.profitcenter_part = defaults.profits["MASH"]; ret.profitcenter_part = defaults.profits["MASH"];
} else if (lineDesc.includes("paint/materials")) { } else if (lineDesc.includes("paint/materials")) {

View File

@@ -24,6 +24,7 @@ export function JobsCloseExportButton({
currentUser, currentUser,
jobId, jobId,
disabled, disabled,
setSelectedJobs,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [updateJob] = useMutation(UPDATE_JOB); const [updateJob] = useMutation(UPDATE_JOB);
@@ -147,6 +148,11 @@ export function JobsCloseExportButton({
}), }),
}); });
} }
if (setSelectedJobs) {
setSelectedJobs((selectedJobs) => {
return selectedJobs.filter((i) => i.id !== jobId);
});
}
} }
setLoading(false); setLoading(false);

View File

@@ -25,6 +25,7 @@ export function PayableExportButton({
billId, billId,
disabled, disabled,
loadingCallback, loadingCallback,
setSelectedBills,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [updateBill] = useMutation(UPDATE_BILLS); const [updateBill] = useMutation(UPDATE_BILLS);
@@ -142,6 +143,11 @@ export function PayableExportButton({
}), }),
}); });
} }
if (setSelectedBills) {
setSelectedBills((selectedBills) => {
return selectedBills.filter((i) => i.id !== billId);
});
}
} }
if (!!loadingCallback) loadingCallback(false); if (!!loadingCallback) loadingCallback(false);

View File

@@ -24,6 +24,7 @@ export function PaymentExportButton({
paymentId, paymentId,
disabled, disabled,
loadingCallback, loadingCallback,
setSelectedPayments,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [updatePayment] = useMutation(UPDATE_PAYMENTS); const [updatePayment] = useMutation(UPDATE_PAYMENTS);
@@ -141,6 +142,12 @@ export function PaymentExportButton({
}), }),
}); });
} }
if (setSelectedPayments) {
setSelectedPayments((selectedBills) => {
return selectedBills.filter((i) => i.id !== paymentId);
});
}
} }
if (!!loadingCallback) loadingCallback(false); if (!!loadingCallback) loadingCallback(false);