#3924 (auto_compute_amount does not always work as expected)
by Luc Saffre · in Developers · assigned to Luc Saffre
Summary
In a JournalEntry voucher, Lino "guesses" the amount by setting it to the opposite of the sum of all other items. This mechanism didn't work in all cases.
Children
Comments
- 5 years, 9 months ago by Luc Saffre about #3924 (auto_compute_amount does not always work as expected) : Yes, the result of an annotated sum can have lots of zeros after the comma. One workaround is to round it before storing it into a database field. We have lino_xl.lib.ledger.utils.myround for that: self.amount = myround(q[0].amount__sum)
- 5 years, 9 months ago by Luc Saffre about #3924 (auto_compute_amount does not always work as expected) : I am having "Ensure that there are no more than 10 digits in total" for the following code: q = self.voucher.items.exclude(id=self.id).annotate(models.Sum('amount'))
self.amount = q[0].amount__sum