Could be an issue with some reference field.  Are you using a IS_IN_DB
validator in your model? could be that you are passing a wrong parameter to
the validator.   But with so little info it is just a guess.



2016-09-26 15:21 GMT+02:00 Anthony <abasta...@gmail.com>:

> Hard to say what the problem is without seeing the full traceback as well
> as your models.
>
> Also, what are you trying to do in the check_batch function? You are
> looping through some records and making assignments to form.vars, but only
> the final run of the loop will end up taking effect -- so what is the point
> of the loop?
>
> Anthony
>
>
> On Monday, September 26, 2016 at 8:29:35 AM UTC-4, Oasis Agano wrote:
>>
>> Greetings
>> im creating a payroll app and i need a to create a batch of payslips
>>
>> i want to create payslips for all contracts in the database within the
>> running state
>>  the code
>>
>> def check_batch(form):
>>
>>     contraaa = db(db.contract.state == 'Running').select(db.contract.ALL)
>>     for contraa in contraaa:
>>
>>         if contraa.salary_structure == 'Less than 30000':
>>             totgross=contraa.wage+contraa.allowances
>>
>>             form.vars.employee=contraa.employee.fullname
>>             form.vars.payslip_name=contraa.employee.fullname
>>             form.vars.contract=contraa.contract_name
>>
>>             form.vars.gross=totgross
>>             form.vars.rssb_emp = totgross*0.03
>>             form.vars.rssb_comp = totgross*0.05
>>             form.vars.paye = 0
>>             totrssb=form.vars.rssb_emp+form.vars.rssb_comp
>>             form.vars.rssb_tot=form.vars.rssb_emp+form.vars.rssb_comp
>>             if type(form.vars.loan) !=int :
>>
>>                 form.vars.net = totgross-form.vars.rssb_emp
>>             else:
>>                 payy=db(db.loanpayment.id == 
>> form.vars.loan).select(db.loanpayment.ALL)
>>                 for pay in payy:
>>                     loanpay=int(pay.amount_payed)
>>                     form.vars.net = totgross-form.vars.rssb_emp-loanpay
>>
>>         elif contraa.salary_structure == 'Between 30000 and 100000':
>>
>>             form.vars.employee=contraa.employee.fullname
>>             form.vars.payslip_name=contraa.employee.fullname
>>             form.vars.contract=contraa.contract_name
>>
>>             totgross=contraa.wage+contraa.allowances
>>             form.vars.gross=totgross
>>             form.vars.rssb_emp = totgross*0.03
>>             form.vars.rssb_comp = totgross*0.05
>>             varia =totgross-30000
>>             form.vars.paye = varia*0.2
>>             totrssb=form.vars.rssb_emp+form.vars.rssb_comp
>>             form.vars.rssb_tot=form.vars.rssb_emp+form.vars.rssb_comp
>>             if type(form.vars.loan) !=int :
>>                 form.vars.net = totgross-form.vars.rssb_emp-form.vars.paye
>>             else:
>>                 payy=db(db.loanpayment.id == 
>> form.vars.loan).select(db.loanpayment.ALL)
>>                 for pay in payy:
>>                     loanpay=int(pay.amount_payed)
>>                     form.vars.net = 
>> totgross-form.vars.rssb_emp-form.vars.paye-loanpay
>>
>>
>>             #form = SQLFORM(db.payslip)
>>
>>
>>
>>         elif contraa.salary_structure=='Great than 100000':
>>
>>             form.vars.employee=contraa.employee
>>             form.vars.payslip_name=contraa.employee
>>             form.vars.contract=contraa.contract_name
>>
>>             totgross=contraa.wage+contraa.allowances
>>             form.vars.gross=totgross
>>             form.vars.rssb_emp = totgross*0.03
>>             form.vars.rssb_comp = totgross*0.05
>>             varia2 =totgross-100000
>>             variah = varia2*0.3
>>             varia3 =70000*0.2
>>             form.vars.paye = variah+varia3
>>             totrssb=form.vars.rssb_emp+form.vars.rssb_comp
>>             form.vars.rssb_tot=form.vars.rssb_emp+form.vars.rssb_comp
>>             if type(form.vars.loan) !=int :
>>                 form.vars.net = totgross-form.vars.rssb_emp-form.vars.paye
>>             else:
>>                 payy=db(db.loanpayment.id == 
>> form.vars.loan).select(db.loanpayment.ALL)
>>                 for pay in payy:
>>                     loanpay=int(pay.amount_payed)
>>                     form.vars.net = 
>> totgross-form.vars.rssb_emp-form.vars.paye-loanpay
>>
>>             #form = SQLFORM(db.payslip)
>>
>>         else:
>>             response.flash=T('Select a salary structure and contract')
>>
>>
>> def batch_payslip():
>>        db.payslip.gross.readonly =True
>>        db.payslip.net.readable =False
>>        db.payslip.rssb_emp.readable =False
>>        #db.payslip.salary_structure.readable =False
>>        db.payslip.rssb_comp.readable =False
>>        db.payslip.paye.readable =False
>>        db.payslip.employee.readable =False
>>        db.payslip.employee.writable =False
>>        db.payslip.contract.readable =False
>>        db.payslip.contract.writable =False
>>        db.payslip.payslip_name.readable =False
>>        db.payslip.payslip_name.writable =False
>>        db.payslip.loan.readable =False
>>        db.payslip.loan.writable =False
>>        db.payslip.user.readable =False
>>        db.payslip.user.writable =False
>>        form = SQLFORM(db.payslip)
>>
>>        if form.process(onvalidation=check_batch).accepted:
>>            response.flash=T('Payslip Added')
>>        return dict(form=form)
>>
>>
>> im getting this error
>>
>> ValueError: invalid literal for long() with base 10: 'with a contract name'
>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to