You can even avoid the NTOM() calls if all variables are initialised to
currency type like this:
CLEAR
nNum = $0.01
nRate = $0.21
STORE $0 TO nVat, nGross, nMulti
DO WHILE nNum < $100000
nVat = ROUND(nNum*nRate,2)
nGross = nNum + nVat
nMulti = ROUND(nNum*(1+nRate),2)
IF nGross <> nMulti
? 'Value ' + STR(nNum,9,2) + ' differs. ' + STR(nGross,10,2) +
STR(nMulti,10,2)
EXIT
ENDIF
nNum = nNum + $0.01
ENDDO
? "Finished."
Laurie
On 17 June 2014 08:51, Laurie Alvey <[email protected]> wrote:
> If you modify Peter's test program like this:
>
> CLEAR
> nNum = $0.01
> nRate = $0.21
> DO WHILE nNum < $100000
> nVat = NTOM(ROUND(nNum*nRate,2))
> nGross = NTOM(nNum + nVat)
> nMulti = NTOM(ROUND(nNum*(1+nRate),2))
> IF nGross <> nMulti
> ? 'Value ' + STR(nNum,9,2) + ' differs. ' + STR(nGross,10,2) +
> STR(nMulti,10,2) EXIT
> ENDIF
> nNum = nNum + $0.01
> ENDDO
> ? "Finished."
>
> so that all numerics are converted to CURRENCY, no errors occur. Currency
> data has its own way of doing arithmetic and rounding. I always use the
> Currency type for storing and computing financial transactions.
>
> Laurie
>
>
> On 13 June 2014 13:42, Gérard Lochon <[email protected]> wrote:
>
>> ----- Original Message ----- From: "Rafael Copquin" <
>> [email protected]>
>> To: <[email protected]>
>> Sent: Thursday, June 12, 2014 9:33 PM
>> Subject: Re: VAT Rates
>>
>>
>> Oui monsieur, you are right. When we send the monthly tax return to the
>> tax department, we always indicate the true net and the VAT, and the
>> gross is the sum of both amounts. Otherwise, rounding screws us.
>>
>> BTW, we have electronic invoicing here, which consists of a Web Service
>> that we have to use to send the invoice and VAT information to the Tax
>> Dept. They receive it, and return the invoice number, and a very long
>> number which is called C.A.E. (Spanish for electronic authorization code)
>>
>> If we do not receive the CAE and the invoice number back from the
>> WebService for whatever reason, we cannot issue the invoice. The invoice
>> is only legal if it contains those numbers. The WS replies in seconds,
>> so it is not a problem.
>>
>> One of the main reasons for the WS to reject the data sent to it is the
>> f....g rounding you mention, that is why we send the actual net and tax,
>> plus the rate applied (there are some goods that are taxed at 21% and
>> some others that are taxed at 10.5% and even at 0%) It is very
>> complicated, but it works and we get good fees for maintaining those
>> routines :-)
>>
>> Rafael Copquin
>>
>> ------------------------------
>>
>> I've had a lot of bunch and workarounds about that, 14 years ago,
>> while developing an app used by all our french mandatory
>> representations all over 27 countries (called "francophonie").
>>
>> When you have, in a single bill, many lines expressed
>> in different currencies, someones having à converting rate
>> so low that their current unit is below the -3 decimals,
>> you'll have, formally, half a chance to get rounding issues !
>>
>> Gérard.
>>
>>
>>
>>
>>
>>
>>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/camvtr9ftvgnsh75t_v2xdeo2olufuneff9kadh_6k+oplms...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.