[capabilities.base] Inverted iteration loops for get_currency
Since the currencies dictionary is ordered, it is preferable to first iter over this dictionary and then iter over the curtexts in order to prevent mismatches. For example, the get_currency method selected the 'PEN' currency in several cases: if the text contains 'en EUR', the curtexts list will be ['en', 'EUR'] and if we iterate over curtexts first, 'en' will be matched with 'PEN' because of the "if curtext in currency" line without ever trying to match 'EUR' with 'EUR'. Therefore, curtexts are now strictly matched with currencies since most websites use the ISO-4217 norm anyways and because it is better to return None than to match wrong currencies such as peruvian sols. Example: if the text contains 'CHAUDE', it will match it with 'AUD' (australian dollars) with is wrong, whereas "if curtext == currency" is stricter but avoids false matches. Closes: 5548@zendesk
parent
a2db3743
Please register or sign in to comment