mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[FIX] Various fixes after presentation to F.Clementi
(lp:c2c-financial-addons/6.1 rev 24.1.23)
This commit is contained in:
@@ -55,7 +55,42 @@ class GenericFileParser(FileParser):
|
||||
def parser_for(cls, parser_name):
|
||||
return parser_name == 'generic_csvxls_so'
|
||||
|
||||
|
||||
def get_st_line_vals(self, line, *args, **kwargs):
|
||||
"""This method must return a dict of vals that can be passed to create
|
||||
method of statement line in order to record it. It is the responsibility
|
||||
of every parser to give this dict of vals, so each one can implement his
|
||||
own way of recording the lines.
|
||||
:param: line: a dict of vals that represent a line of result_row_list
|
||||
:return: dict of values to give to the create method of statement line,
|
||||
it MUST contain at least:
|
||||
{
|
||||
'name':value,
|
||||
'date':value,
|
||||
'amount':value,
|
||||
'ref':value,
|
||||
'label':value,
|
||||
'commission_amount':value,
|
||||
}
|
||||
In this generic parser, the commission is given for every line, so we store it
|
||||
for each one.
|
||||
"""
|
||||
return {
|
||||
'name': line.get('label', line.get('ref','/')),
|
||||
'date': line.get('date', datetime.datetime.now().date()),
|
||||
'amount': line.get('amount', 0.0),
|
||||
'ref': line.get('ref','/'),
|
||||
'label': line.get('label',''),
|
||||
'commission_amount': line.get('commission_amount', 0.0),
|
||||
}
|
||||
|
||||
def _post(self, *args, **kwargs):
|
||||
"""Compute the commission from value of each line"""
|
||||
res = super(GenericFileParser, self)._post(*args, **kwargs)
|
||||
val = 0.0
|
||||
for row in self.result_row_list:
|
||||
val += row.get('commission_amount',0.0)
|
||||
self.commission_global_amount = val
|
||||
return res
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user