Subject | RE: [firebird-support] Precision question |
---|---|
Author | Alan McDonald |
Post date | 2009-02-11T10:50Z |
> Hi Friends!this is an accounting issue, not a Firebird issue.
>
> In my previous post I had the following problem:
>
> "I have a problem that I cannot solve. I have a procedure that takes
> two input parameters, both represent amount of money according to one
> order.
> One of them represents the full amount, the other represents the
> currently paid amount of money. I have to create invoice from the
> orderitems based on the two input parameters. The method would be the
> following: I create a quotient from the input parameters and each
> item's gross value will be multiplied with this quotient. In this
> case, summing the amount of multiplied values would be equal to the
> currently paid amount. But this is not true. Here is the procedure.
> Sorry for the hungarian naming, but the method would be seen from this
> code snippet. How can I achieve, that summing the BRUTTO_ERTEK_ARANYOS
> field would be equal to the input parameter BEF_OSSZEG?
>
> The full amount of money is the TELJES_OSSZEG, the currently paid is
> BEF_OSSZEG."
>
> I solved the problem by dividing directly with the input parameters.
> It works perfectly in 99 cases out of 100. In the rest of cases, the
> summed result of divided values differs from the original value by
> 0.01. Can I achieve more precision? What datatype should I CAST to?
> Here is the actual procedure. The same rules are valid as in the
> previous post.
In any case you should not be dividing anything - that's your incorrect
assumption. In acccounting, work with addition and subtraction.
Total the paid amounts and subtract this from the invoice amount to find the
unpaid amount.
Alan