*Field('markupCalc', 'integer', compute=lambda r: (float(r['markup']/*
*100.0**)*float(r['unitPrice']))),*


*??*


*but why integer?*
*you will have no precision.....*



Em segunda-feira, 13 de janeiro de 2020 13:54:25 UTC-3, mostwanted escreveu:
>
> I'm trying to calculate a required percentage value for the entered figure 
> but i am getting the wrong answer
>
> Field('unitPrice', 'float', label=SPAN('Unit Price', _style="font-weight: 
> bold;"), requires=IS_MATCH('[0-9]+', error_message=T('Enter Money in 
> Proper Figures'))),
> Field('markup', 'integer', label=SPAN('Markup', _style="font-weight: 
> bold;"), requires=IS_NOT_EMPTY()),
> *Field('markupCalc', 'integer', compute=lambda r: 
> (100.0/float(r['markup'])*float(r['unitPrice']))),*
> Field('markedupPrice', 'float', compute=lambda r: round(float(r[
> 'unitPrice'])+r['markupCalc'])),
>
> On the code above I'm getting the markupCalc field wrong and it affects 
> the markedUpPrice value. How can i correctly calculate a required 
> percentage of a given value?
>
> Mostwanted
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/97654e8d-1bce-4680-90e9-4a65f0201bd1%40googlegroups.com.

Reply via email to