← Back to team overview

credativ team mailing list archive

Re: [Merge] lp:~credativ/account-banking/trunk-refresh into lp:account-banking/5.0

 

On 10/11/11 10:09, Pieter J. Kersten (EduSense BV) wrote:
> Thanks for the explanation.
>
> AFAICT from your point 2), there seems to be a problem in the import parser you use. It is the responsibility of the import parser to calculate correct start and end balance amounts. If these do not correspond with the actual imported transactions, then there is definitely something weird going on. Either the bank misinformed you, or the parser you used miscalculated, misgrouped, whatever.
>
> Your technical explanation makes no sense to me. There is always at least one statement per import. If the bank information provides no statements, you can either generate fake statements (day period most likely), or you can create simple envelopes (1:1 mapping). Either way, the balance and totals should be precalculated, leading to shiny blue statement lists.
>
> "User input" is a relative thing here, as the fields come correctly filled. If the user manually changes the statements after import, he/she can press the button themselves as well. That is what this button is for - signaling incorrect user input.
>
> What parser module are you using?

I'm talking about addons/accounting/account_bank_statement.

class account_bank_statement

Fields:

'balance_start'
'balance_end_real'
'balance_end'

'balance_start' & 'balance_end_real' are imported from the bank 
statement with the help of account_banking & a parser and are correct.

'balance_end' - a field function, is not triggered to recompute at the 
end of the import from account_banking.

If the statement was manually entered, the balance_end is recomputed on 
saving the statemnt.
If the statement is imported from account_banking the recompute is not 
triggered.

to make sure function fields are triggered to recompute, a dummy write 
is required, which then runs the _end_balance function on the 
account/account_bank_statement.

Here is some code, from account module:

>     def _end_balance(self, cursor, user, ids, name, attr, context=None):
>         res_currency_obj = self.pool.get('res.currency')
>         res_users_obj = self.pool.get('res.users')
>         res = {}
>
>         company_currency_id = res_users_obj.browse(cursor, user, user,
>                 context=context).company_id.currency_id.id
>
>         statements = self.browse(cursor, user, ids, context=context)
>         for statement in statements:
>             res[statement.id] = statement.balance_start
>             currency_id = statement.currency.id
>             for line in statement.move_line_ids:
>                 if line.debit > 0:
>                     if line.account_id.id == \
>                             statement.journal_id.default_debit_account_id.id:
>                         res[statement.id] += res_currency_obj.compute(cursor,
>                                 user, company_currency_id, currency_id,
>                                 line.debit, context=context)
>                 else:
>                     if line.account_id.id == \
>                             statement.journal_id.default_credit_account_id.id:
>                         res[statement.id] -= res_currency_obj.compute(cursor,
>                                 user, company_currency_id, currency_id,
>                                 line.credit, context=context)
>             if statement.state == 'draft':
>                 for line in statement.line_ids:
>                     res[statement.id] += line.amount
>         for r in res:
>             res[r] = round(res[r], 2)
>         return res
>


>         'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'),
>             states={'confirm':[('readonly',True)]}),
>         'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'),
>             states={'confirm':[('readonly', True)]}),
>         'balance_end': fields.function(_end_balance, method=True, string='Balance'),

>     def button_dummy(self, cr, uid, ids, context=None):
>         return self.write(cr, uid, ids, {}, context=context)


-- 
With best regards,


Dmitrijs Ledkovs

credativ ltd                     Tel: 01788 298152
36 Regent Street                 Fax: 01788 298159
Rugby CV21 2PS - UK              http://www.credativ.co.uk

credativ Ltd is registered in England & Wales, company no. 5261743
Registered office: Nelson House, 2 Hamilton Terrace, Leamington Spa,
Warwickshire CV32 4LY

Certified by AccredIT UK with the ICT Supply standard of quality for
Software Product Design and Development

https://code.launchpad.net/~credativ/account-banking/trunk-refresh/+merge/81761
Your team credativ is subscribed to branch lp:~credativ/account-banking/trunk-refresh.


References