[Erp5-dev] Conversion applied consistency class

Jérome Perrin jerome at nexedi.com
Fri Jul 18 14:42:26 CEST 2008


Le jeudi 29 mai 2008 à 14:38 +0200, Łukasz Nowak a écrit :
> Hello,
> 
> Long time ago, in not so far away galaxy we've got problem with
> accounting and unconverted transactions.[1]
> 
> Today we know, that using good combination of supported accounting
> simulation states in preferences, we are able to filter out
> transactions, which aren't converted.
> 
> To force users to do conversion, I've created ConversionApplied
> Constraint.

good idea

>  Attached. Feel free to commit it to repository, if you like to.
> 
> Any comments welcome about this class.

OK ...

>     # Well - I really do not know, if we shall trust catalog in this
> case.
>     movement_list = [q for q in obj.objectValues() \
>         if q.getPortalType() in accounting_movement_portal_type_list]

No need to check catalog, lines are contained as subdocuments, using
contentValues or objectValues, is faster for this case. Also those
methods support portal_type= argument to do the filtering.


>     credit_sum = debit_sum = 0.0
>     if obj.AccountingTransaction_isSourceCurrencyConvertible():
>       for movement in movement_list:
>         credit_sum += movement.getSourceAssetCredit()
>         debit_sum += movement.getSourceAssetDebit()
> 
>       if credit_sum == 0.0 or debit_sum == 0.0:

This has rounding issues.
Better check that round(credit_sum, currency_precision) == 0.0
You can get the currency precision from the organisation default
accounting currency.

>         error_list.append(self._generateError(obj,N_('Source
> conversion undefined')))

We now have a new way of defining such messages so that they can be
overloaded in property sheets. Look at constraints in ERP5Type for
examples.

Jérome




More information about the Erp5-dev mailing list