Compare commits

...

8 Commits

Author SHA1 Message Date
Allan Carr
8db8744782 IO-3629 PostBatchWip Rtn != 0 error
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-03-27 15:38:27 -07:00
Dave Richer
71aec6d0c5 Merged in hotfix/2026-03-27 (pull request #3159)
Hotfix/2026 03 27
2026-03-27 18:48:24 +00:00
Dave
f89d7865fa Restore hasura metadata tables from master-AIO 2026-03-27 14:46:00 -04:00
Dave
8fd368ebb4 Revert hasura metadata tables changes 2026-03-27 14:45:01 -04:00
Dave
132fc0a20f hotfix/2026-03-27 - Missing chatter stuff. 2026-03-27 14:36:37 -04:00
Allan Carr
9ea2d83043 Merged in feature/IO-3599-Taxable-Amount (pull request #3155)
IO-3599 Taxable Amount

Approved-by: Dave Richer
2026-03-25 22:36:08 +00:00
Allan Carr
abad7d5f00 Merged in feature/IO-3627-Courtesy-Car-Create-RO (pull request #3156)
IO-3627 Courtesy Car Create RO

Approved-by: Dave Richer
2026-03-25 22:35:33 +00:00
Allan Carr
c97213bc96 IO-3599 Taxable Amount
Signed-off-by: Allan Carr <allan@imexsystems.ca>
2026-03-24 18:12:04 -07:00
5 changed files with 76 additions and 19 deletions

View File

@@ -24,6 +24,15 @@
- name: x-imex-auth
value_from_env: DATAPUMP_AUTH
comment: Project Mexico
- name: Chatter API Data Pump
webhook: '{{HASURA_API_URL}}/data/chatter-api'
schedule: 45 4 * * *
include_in_metadata: true
payload: {}
headers:
- name: x-imex-auth
value_from_env: DATAPUMP_AUTH
comment: ""
- name: Chatter Data Pump
webhook: '{{HASURA_API_URL}}/data/chatter'
schedule: 45 5 * * *

View File

@@ -51,7 +51,8 @@ awslocal ses verify-email-identity --email-address noreply@imex.online --region
# Secrets
ensure_secret_file "CHATTER_PRIVATE_KEY" "/tmp/certs/io-ftp-test.key"
ensure_secret_string "CHATTER_COMPANY_KEY_6713" "${CHATTER_COMPANY_KEY_6713:-REPLACE_ME}"
ensure_secret_string "CHATTER_COMPANY_KEY_6713" "${CHATTER_COMPANY_KEY_6713}"
ensure_secret_string "CHATTER_COMPANY_KEY_6746" "${CHATTER_COMPANY_KEY_6746}"
# Logs
ensure_log_group "development"

View File

@@ -67,7 +67,7 @@ const createLocation = async (req, res) => {
const chatterApi = await createChatterClient(DEFAULT_COMPANY_ID);
const locationIdentifier = `${DEFAULT_COMPANY_ID}-${bodyshop.id}`;
const locationIdentifier = bodyshop?.imexshopid ?? `${DEFAULT_COMPANY_ID}-${bodyshop.id}`;
const locationPayload = {
name: bodyshop.shopname,

View File

@@ -334,30 +334,48 @@ async function FortellisSelectedCustomer({ socket, redisHelpers, selectedCustome
socket.emit("export-success", JobData.id);
} else {
//There was something wrong. Throw an error to trigger clean up.
//throw new Error("Error posting DMS Batch Transaction");
const batchPostError = new Error(DmsBatchTxnPost.sendline || "Error posting DMS Batch Transaction");
batchPostError.errorData = { DMSTransHeader, DmsBatchTxnPost };
throw batchPostError;
}
} catch {
} catch (error) {
//Clean up the transaction and insert a faild error code
// //Get the error code
CreateFortellisLogEvent(socket, "DEBUG", `{6.1} Getting errors for Transaction ID ${DMSTransHeader.transID}`);
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
// //Delete the transaction
let dmsErrors = [];
try {
const DmsError = await QueryDmsErrWip({ socket, redisHelpers, JobData });
dmsErrors = Array.isArray(DmsError?.errMsg) ? DmsError.errMsg.filter((e) => e !== null && e !== "") : [];
dmsErrors.forEach((e) => {
CreateFortellisLogEvent(socket, "ERROR", `Error encountered in posting transaction => ${e} `);
});
} catch (queryError) {
CreateFortellisLogEvent(
socket,
"ERROR",
`{6.1} Unable to read ErrWIP for Transaction ID ${DMSTransHeader.transID}: ${queryError.message}`
);
}
//Delete the transaction, even if querying ErrWIP fails.
CreateFortellisLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${DMSTransHeader.transID}`);
try {
await DeleteDmsWip({ socket, redisHelpers, JobData });
} catch (cleanupError) {
CreateFortellisLogEvent(
socket,
"ERROR",
`{6.2} Failed cleanup for Transaction ID ${DMSTransHeader.transID}: ${cleanupError.message}`
);
}
await DeleteDmsWip({ socket, redisHelpers, JobData });
DmsError.errMsg.map(
(e) =>
e !== null &&
e !== "" &&
CreateFortellisLogEvent(socket, "ERROR", `Error encountered in posting transaction => ${e} `)
);
await InsertFailedExportLog({
socket,
JobData,
error: DmsError.errMsg
});
if (!error.errorData || typeof error.errorData !== "object") {
error.errorData = {};
}
error.errorData.issues = dmsErrors.length ? dmsErrors : [error.message];
throw error;
}
}
} catch (error) {

View File

@@ -116,6 +116,32 @@ async function TotalsServerSide(req, res) {
ret.totals.ttl_tax_adjustment = Dinero({ amount: Math.round(ttlTaxDifference * 100) });
ret.totals.total_repairs = ret.totals.total_repairs.add(ret.totals.ttl_tax_adjustment);
ret.totals.net_repairs = ret.totals.net_repairs.add(ret.totals.ttl_tax_adjustment);
if (Math.abs(totalUsTaxes) === 0) {
const laborRates = Object.values(job.cieca_pfl)
.map((v) => v.lbr_taxp)
.filter((v) => v != null);
const materialRates = Object.values(job.materials)
.map((v) => v.mat_taxp)
.filter((v) => v != null);
const partsRates = Object.values(job.parts_tax_rates)
.map((v) => {
const field = v.prt_tax_rt ?? v.part_tax_rt;
if (field == null) return null;
const raw = typeof field === "object" ? field.parsedValue : field;
return raw != null ? raw * 100 : null;
})
.filter((v) => v != null);
const taxRate = Math.max(...laborRates, ...materialRates, ...partsRates);
const totalTaxes = ret.totals.taxableAmounts.total.multiply(taxRate > 1 ? taxRate / 100 : taxRate);
ret.totals.taxableAmounts.total = ret.totals.taxableAmounts.total
.multiply(emsTaxTotal)
.divide(totalTaxes.toUnit());
} else {
ret.totals.taxableAmounts.total = ret.totals.taxableAmounts.total.multiply(emsTaxTotal).divide(totalUsTaxes);
}
logger.log("job-totals-USA-ttl-tax-adj", "debug", null, job.id, {
adjAmount: ttlTaxDifference
});
@@ -993,6 +1019,8 @@ function CalculateTaxesTotals(job, otherTotals) {
}
});
taxableAmounts.total = Object.values(taxableAmounts).reduce((acc, amount) => acc.add(amount), Dinero({ amount: 0 }));
// console.log("*** Taxable Amounts***");
// console.table(JSON.parse(JSON.stringify(taxableAmounts)));
@@ -1203,6 +1231,7 @@ function CalculateTaxesTotals(job, otherTotals) {
let ret = {
subtotal: subtotal,
taxableAmounts: taxableAmounts,
federal_tax: subtotal
.percentage((job.federal_tax_rate || 0) * 100)
.add(otherTotals.additional.pvrt.percentage((job.federal_tax_rate || 0) * 100)),