def _internal_get_transactions(self, categories, filter_func): TYPES = { 'PT': Transaction.TYPE_CARD, 'AA': Transaction.TYPE_CARD, 'CT': Transaction.TYPE_TRANSFER, 'WEE': Transaction.TYPE_BANK, } transactions = self.request('/api/smrt/transactions?limit=1000') for t in transactions: if not filter_func(t) or t["amount"] == 0: continue new = Transaction() new.date = datetime.fromtimestamp(t["createdTS"] / 1000) new.rdate = datetime.fromtimestamp(t["visibleTS"] / 1000) new.id = t['id'] new.amount = Decimal(str(t["amount"])) if "merchantName" in t: new.raw = new.label = t["merchantName"] elif "partnerName" in t: new.raw = CleanText().filter( t["referenceText"]) if "referenceText" in t else CleanText( ).filter(t["partnerName"]) new.label = t["partnerName"] else: new.raw = new.label = '' if "originalCurrency" in t: new.original_currency = t["originalCurrency"] if "originalAmount" in t: new.original_amount = Decimal(str(t["originalAmount"])) new.type = TYPES.get(t["type"], Transaction.TYPE_UNKNOWN) if t["category"] in categories: new.category = categories[t["category"]] yield new
def _internal_get_transactions(self, categories, filter_func): transactions = self.request('/api/smrt/transactions?limit=1000') for t in transactions: if not filter_func(t): continue new = Transaction() new.date = datetime.fromtimestamp(t["createdTS"] / 1000) new.rdate = datetime.fromtimestamp(t["visibleTS"] / 1000) new.id = t['id'] new.amount = Decimal(str(t["amount"])) if "merchantName" in t: new.raw = new.label = t["merchantName"] elif "partnerName" in t: new.raw = CleanText().filter(t["referenceText"]) if "referenceText" in t else CleanText().filter(t["partnerName"]) new.label = t["partnerName"] else: new.raw = new.label = '' if "originalCurrency" in t: new.original_currency = t["originalCurrency"] if "originalAmount" in t: new.original_amount = Decimal(str(t["originalAmount"])) if t["type"] == 'PT': new.type = Transaction.TYPE_CARD elif t["type"] == 'CT': new.type = Transaction.TYPE_TRANSFER elif t["type"] == 'WEE': new.type = Transaction.TYPE_BANK if t["category"] in categories: new.category = categories[t["category"]] yield new