Add new qif formatter: use label and rdate if exist
This commit is contained in:
parent
057c23f10b
commit
80c0f88474
1 changed files with 18 additions and 0 deletions
|
|
@ -45,6 +45,23 @@ class QifFormatter(IFormatter):
|
|||
return result
|
||||
|
||||
|
||||
class PrettyQifFormatter(QifFormatter):
|
||||
def format_obj(self, obj, alias):
|
||||
if obj.rdate:
|
||||
result = u'D%s\n' % obj.rdate.strftime('%d/%m/%y')
|
||||
else:
|
||||
result = u'D%s\n' % obj.date.strftime('%d/%m/%y')
|
||||
result += u'T%s\n' % obj.amount
|
||||
if obj.category:
|
||||
result += u'N%s\n' % obj.category
|
||||
if obj.label:
|
||||
result += u'M%s\n' % obj.label
|
||||
else:
|
||||
result += u'M%s\n' % obj.raw
|
||||
result += u'^\n'
|
||||
return result
|
||||
|
||||
|
||||
class TransactionsFormatter(IFormatter):
|
||||
MANDATORY_FIELDS = ('date', 'label', 'amount')
|
||||
TYPES = ['', 'Transfer', 'Order', 'Check', 'Deposit', 'Payback', 'Withdrawal', 'Card', 'Loan', 'Bank']
|
||||
|
|
@ -135,6 +152,7 @@ class Boobank(ReplApplication):
|
|||
'recipient_list': RecipientListFormatter,
|
||||
'transfer': TransferFormatter,
|
||||
'qif': QifFormatter,
|
||||
'pretty_qif': PrettyQifFormatter,
|
||||
'ops_list': TransactionsFormatter,
|
||||
}
|
||||
DEFAULT_FORMATTER = 'table'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue