Files
bodyshop/server/accounting/qbxml/qbxml-utils.js
2021-07-07 15:04:56 -07:00

44 lines
1.3 KiB
JavaScript

exports.addQbxmlHeader = addQbxmlHeader = (xml) => {
return `<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
${xml}
`;
};
exports.generateSourceTier = (jobs_by_pk) => {
return jobs_by_pk.ins_co_nm;
};
exports.generateJobTier = (jobs_by_pk) => {
return jobs_by_pk.ro_number;
};
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 || ""}`;
} else {
//What's the 2 tier pref?
if (twotierpref === "source") {
return this.generateSourceTier(jobs_by_pk);
//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 || ""}`;
}
}
};