I'm relatively new to python and openerp and in my new module, I'm trying to write a function that does this:
monthly_pay = float(int(annual_pay_1 / number_of_months)) annual_pay_2 = monthly_pay * number_of_months diff = annual_pay_1 - annual_pay_2 jan_pay = monthly_pay + diff feb_pay = jan_pay + monthly_pay mar_pay = feb_pay + monthly_pay apr_pay = mar_pay + monthly_pay may_pay = apr_pay + monthly_pay jun_pay = may_pay + monthly_pay jul_pay = jun_pay + monthly_pay aug_pay = jul_pay + monthly_pay sep_pay = aug_pay + monthly_pay oct_pay = sep_pay + monthly_pay nov_pay = oct_pay + monthly_pay dec_pay = nov_pay + monthly_pay
Sometimes, the number or months may not be up to 12. It could be say 8 or 9 for instance and it doesn't necessarily start from january or end in december.
Is this a proper recursion or for loop problem? Whats the best way to write the function to handle this?
Could be this (not complete):
start_month=3 number_of_months=7 annual_pay_1=40000 monthly_pay = float(int(annual_pay_1 / number_of_months)) annual_pay_2 = monthly_pay * number_of_months diff = annual_pay_1 - annual_pay_2 pay =  * 12 pay[start_month] = monthly_pay + diff for i in range(start_month+1, start_month+number_of_months): pay[i] = monthly_pay print(pay)
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 12/8/13, 2:42 AM|
|Seen: 671 times|
|Last updated: 3/16/15, 8:10 AM|