I will go for a decimal support. In case decimal is not supported in a database then the DAL can just consider it a number. If you are going production you will anyway be using a database that supports decimal
Please add support for decimal :D On Mar 22, 1:19 pm, Paco <[email protected]> wrote: > All right, I knew about the implied decimal point solution but it won > allow you to handle very big numbers. > > I made a quick check and only SQLite doesn't support DECIMAL types. > > Maybe is worth the effort to make DAL support, for the sake of > simplicity, a MONEY type and make DAL to 'internaly' support decimal > types in SQLite with implied decimal point. > > On 21 mar, 03:45, mdipierro <[email protected]> wrote: > > > > > try this: > > > class IS_DECIMAL: > > def __init__(self,decimals=2,error_message="Invalid"): > > self.decimals=decimals > > self.error_message=error_message > > def __call__(self,value): > > try: > > value=int(float(value)*(10**self.decimals)) > > return (value,None) > > except: > > return (value,self.error_message) > > def format(self,value): > > return float(value)/10**self.decimals > > > On Mar 20, 7:41 pm, Joe Barnhart <[email protected]> wrote: > > > > The easiest workaround is to use INTEGER and leave all amounts in > > > cents, i.e. 123 instead of 1.23. If all math is done with the implied > > > decimal point on integers, you will never have floating-point round- > > > off errors. Only put in the decimal point when you are ready to > > > display the value. (Massimo -- Maybe a validator can help here?) > > > > -- Joe B. > > > > On Mar 20, 12:03 pm, Paco <[email protected]> wrote: > > > > > I've been trying web2py for a couple of days and I believe is just > > > > great. I'm so excited that I'm planning to build my own accounting and > > > > invoicing application, which is, in the other hand, not so complex in > > > > my case. > > > > > I need (and I believe many more people do) a DECIMAL field type or > > > > maybe a CURRENCY type since there are many applications that need > > > > fixed precision numbers. > > > > > It seems to me that is shouldn't be very difficult to do since most > > > > databases, including SQLite, support NUMERIC or DECIMAL types. > > > > > It would be a great newfeature. Are there any plans to do such a > > > > thing? Or maybe there is a nice workaround to do this in web2py? > > > > > Cheers, > > > > Paco --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

