[Gambas-user] About financial program in Gambas

Ricardo Díaz Martín oceanosoftlapalma at ...626...
Wed Dec 16 11:46:40 CET 2009


Jean,

You can use numbers of decimal as you want. I you want 4 you only need to
divide by 1000. The only you need to decide on before insert data. If you
need to add more decimals in future you only have to modify a parameter in
your app from 2 to 4 (functions that show from database/write to database
currency values must read this values before show/write info) and update
your database multiplying cur fields by 100 (to add two digit more of
precision)

You never need truncate any value if you always use this especial currency
type. For example if you set decimals to 4, number 19.99657 is no possible.

If you need to get selling prices using four decimal coefficient, define
coefficient as a currency type and set your app to use 4 decimal for all
"currency" values

I hope this helps you

2009/12/16 Jean-Yves F. Barbier <12ukwn at ...626...>

> Ricardo Díaz Martín a écrit :
> > Hi to all,
> >
> > I'm use gambas to write ERP applications. At the first, I got the same
> > problem but I decided to use long integer to save currency values. First
> > rigth two digits are always showed to users as decimal values.
> >
> > I'm rewrited all my apps from windows to gambas and they are working now
> > with no problems in customers servers.
> >
> > I allways use a function to show values in controls in app's forms that
> > convert database fields values showed in textboxes whose name started int
> > dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
> > allways the same function to write forms data to database and make the
> > reverse proccess.
>
> Hooo, thanks for the ad.
>
> > Its simple and works
>
> Sounds exactly like the commercial about women thin down cream we've
> got on tv for months (it works!) (sorry, I couldn't resist:)
>
> So you're truncating everything to 2 decimals, but as I said VAT (and as
> a matter of fact almost all french taxes) is *legally* up to 4 decimals;
> actually only 2 of them are used, but nothing's saying that tomorrow
> is won't be 3 or 4 really used (especially on those times where our
> gov morons (pleonasm) are desesperatly looking for money.)
>
> BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
> In my family's company a cent error is worth €100,000 fine...
>
> Other PB: most of results could be predictable (as of Nb of decimals),
> but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
> maths says decimals should be dN1+dN2=5 but in these cases we only have
> 4 and 2 because of non-significant right zeroes, so you can't obviously
> truncate by adding the comma counting 5 from the right.
> One of the most used manner to get a selling price is to use a coefficient
> which has many decimals (usually a real), how do you determine where to
> put the comma in the resultant number??
>
> I see the possibilities, but AFAIK this is a full processor to write
> based on a complex numbers model, not to mention error possibilities
> have a tremendous cataclysmic potential in a matter where tax
> administration will be more than happy to chop your head and piss
> on your brain (yeah, they're like that here: when they come it is
> not to search, it is to find; no matter if has real justification or not.)
>
> But may be I'm totally mistaking: I always have had PBs with simple
> things.
>
> JY
> --
> God is real, unless declared integer.
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and
> easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list