def match_entries_by_date_and_amount(self, threshold):
        delta = datetime.timedelta(days=threshold)
        unmatched = (
            to_import for ref, to_import in self.matches if ref is None)
        unmatched_refs = (
            ref for ref, to_import in self.matches if to_import is None)
        amount2refs = defaultdict(list)
        for entry in unmatched_refs:
            amount2refs[entry.amount].append(entry)
        for entry in unmatched:
            if entry.amount not in amount2refs:
                continue
            potentials = amount2refs[entry.amount]
            for ref in potentials:
                if abs(ref.date - entry.date) <= delta:
                    self.bind(ref, entry)
                    potentials.remove(ref)
        self._sort_matches()