Esempio n. 1
0
File: eval.py Progetto: cdeee/web
    def __value_match(self, t1, t2, threshold=0):
        """
        Compares two financial values (incl. currencies).
        If one is equal or, if there is a threshold set, in
        allowed margin, returns True.

        :param t1: record from file containing ["fin_value"] and ["currency"] fields
        :param t2: record from file containing ["fin_value"] and ["currency"] fields
        :param threshold: allowed tolerance, e.g., 0.2 = 20%
        :return: are financial values equal?
        """
        v1 = float(t1.get("fin_value"))
        v2 = float(t2.get("fin_value"))
        c1 = t1.get("currency")
        c2 = t2.get("currency")

        return ExtractionUtils.money_equals(v1, c1, v2, c2, EVAL_MONEY_TOLERANCE_PERCENT)