ledger missing id fix

This commit is contained in:
matthewli1409
2022-10-18 15:33:46 +07:00
parent d97c8c8a7c
commit a50502a0b2

View File

@@ -26,7 +26,8 @@ class Ledger:
DESCRIPTION DESCRIPTION
""" """
def __init__(self, currency, mts, amount, balance, description): def __init__(self, lid, currency, mts, amount, balance, description):
self.id = lid
self.currency = currency self.currency = currency
self.mts = mts self.mts = mts
self.amount = amount self.amount = amount
@@ -40,15 +41,16 @@ class Ledger:
@return Ledger @return Ledger
""" """
lid = raw_ledger[LedgerModel.ID]
currency = raw_ledger[LedgerModel.CURRENCY] currency = raw_ledger[LedgerModel.CURRENCY]
mts = raw_ledger[LedgerModel.MTS] mts = raw_ledger[LedgerModel.MTS]
amount = raw_ledger[LedgerModel.AMOUNT] amount = raw_ledger[LedgerModel.AMOUNT]
balance = raw_ledger[LedgerModel.BALANCE] balance = raw_ledger[LedgerModel.BALANCE]
description = raw_ledger[LedgerModel.DESCRIPTION] description = raw_ledger[LedgerModel.DESCRIPTION]
return Ledger(currency, mts, amount, balance, description) return Ledger(lid, currency, mts, amount, balance, description)
def __str__(self): def __str__(self):
''' Allow us to print the Ledger object in a pretty format ''' ''' Allow us to print the Ledger object in a pretty format '''
text = "Ledger <{} {} balance:{} '{}' mts={}>" text = "Ledger <{} {} {} balance:{} '{}' mts={}>"
return text.format(self.amount, self.currency, self.balance, return text.format(self.id, self.amount, self.currency, self.balance,
self.description, self.mts) self.description, self.mts)