IO-1439 Trim QB name fields on export.

This commit is contained in:
Patrick Fic
2021-10-18 12:16:12 -07:00
parent ad6394783d
commit f0a13856bc
3 changed files with 55 additions and 52 deletions

View File

@@ -6,24 +6,25 @@ exports.addQbxmlHeader = addQbxmlHeader = (xml) => {
};
exports.generateSourceTier = (jobs_by_pk) => {
return jobs_by_pk.ins_co_nm;
return jobs_by_pk.ins_co_nm && jobs_by_pk.ins_co_nm.trim();
};
exports.generateJobTier = (jobs_by_pk) => {
return jobs_by_pk.ro_number;
return jobs_by_pk.ro_number && jobs_by_pk.ro_number.trim();
};
exports.generateOwnerTier = (jobs_by_pk, isThreeTier, twotierpref) => {
if (isThreeTier) {
//It's always gonna be the owner now. Same as 2 tier by name
return jobs_by_pk.ownr_co_nm
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
jobs_by_pk.owner.accountingid || ""
}`
: `${`${jobs_by_pk.ownr_ln || ""} ${jobs_by_pk.ownr_fn || ""}`.substring(
0,
30
)} #${jobs_by_pk.owner.accountingid || ""}`;
return (
jobs_by_pk.ownr_co_nm
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
jobs_by_pk.owner.accountingid || ""
}`
: `${`${jobs_by_pk.ownr_ln || ""} ${
jobs_by_pk.ownr_fn || ""
}`.substring(0, 30)} #${jobs_by_pk.owner.accountingid || ""}`
).trim();
} else {
//What's the 2 tier pref?
if (twotierpref === "source") {
@@ -31,13 +32,15 @@ exports.generateOwnerTier = (jobs_by_pk, isThreeTier, twotierpref) => {
//It should be the insurance co.
} else {
//Same as 3 tier
return jobs_by_pk.ownr_co_nm
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
jobs_by_pk.owner.accountingid || ""
}`
: `${`${jobs_by_pk.ownr_ln || ""} ${
jobs_by_pk.ownr_fn || ""
}`.substring(0, 30)} #${jobs_by_pk.owner.accountingid || ""}`;
return (
jobs_by_pk.ownr_co_nm
? `${jobs_by_pk.ownr_co_nm.substring(0, 30)} #${
jobs_by_pk.owner.accountingid || ""
}`
: `${`${jobs_by_pk.ownr_ln || ""} ${
jobs_by_pk.ownr_fn || ""
}`.substring(0, 30)} #${jobs_by_pk.owner.accountingid || ""}`
).trim();
}
}
};