feature/IO-3255-simplified-parts-management - Checkpoint

This commit is contained in:
Dave
2025-08-28 14:24:35 -04:00
parent 67002b8443
commit f071a5cc9e
6 changed files with 173 additions and 152 deletions

View File

@@ -23,17 +23,21 @@ const KNOWN_PART_RATE_TYPES = [
* @returns {object} The parts tax rates object.
*/
//PF: Major validation would be required on this - EMS files are inconsistent with things like 5% being passed as 5.0 or .05.
//PF: Is this data being sent by them now?
//TODO: Major validation would be required on this - EMS files are inconsistent with things like 5% being passed as 5.0 or .05.
const extractPartsTaxRates = (profile = {}) => {
const rateInfos = Array.isArray(profile.RateInfo) ? profile.RateInfo : [profile.RateInfo || {}];
const partsTaxRates = {};
/**
* In this context, r.RateType._ accesses the property named _ on the RateType object.
* This pattern is common when handling data parsed from XML, where element values are stored under the _ key. So,
* _ aligns to the actual value/content of the RateType field when RateType is an object (not a string).
*/
for (const r of rateInfos) {
const rateTypeRaw =
typeof r?.RateType === "string"
? r.RateType
: typeof r?.RateType === "object" && r?.RateType._ //PF: what does _ align to?
: typeof r?.RateType === "object" && r?.RateType._
? r.RateType._
: "";
const rateType = (rateTypeRaw || "").toUpperCase();