-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0] [IMP] payroll: Add new "payslips" object methods #109
Conversation
Hi @appstogrow, |
Maybe it would be good to rename I need to print year-to-date totals on the payslip lines. So I have added a new field l10n_no_total_ytd. (Later I will rewrite the code and use the |
Yes I thought about that, but wanted to mantain compatibily for rules using sum() but I can change the name and call sum_rule from sum() and display a deprecation warning in log. So we remove it in future versions and keep sum_rule.
Yes I also need ytd of some categories, averages and max values. In my country we have rules that are based in previous payslips so it's a common variable to use. This functions make easy to operate with previous payslips inside rules. If you need to print ytd in payslips, you can calculate it in a salary rule and then just filter the payslip lines to find the rule you need. That way you will not need a field. |
@norlinhenrik @mtelahun This is ready for review if you want to do it. I added more methods (they are all explained in the main comment) and also a minor tweak in views to allow inherit "controls" group and add fields on the right of the boolean fields. |
Merging since no reviews. /ocabot merge minor |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 5cea404. Thanks a lot for contributing to OCA. ❤️ |
Hello, this PR is intended to add new functionalities to the "payslips" object.
By default, "payslips" object have the "sum" method, which you need to pass a code and a date (and optionally a to_date) and the function will sum all rules with that code and return the summed value. This is useful if you need the ytd, mtd or just the sum of some rule to calculate a salary rules. Following this approach, the new functionalities introduced in this PR are:
Add "min_category" and "min_rule" method. As "max_category" and "min_rule" methods, this one returns the min value of the selected category/payslips depending of the function used. Example are the same as the last ones, but using the "min_***" methods.
Add "average_category" and "average_rule" methods. This methods, will calculate the average value of a category (or a rule if you are using the rule method) between a given time period. An example of it could be:
This changes also are motivated by the need to reduce the "env" object usage. If some user need to get maximum or sum values, he will use the "env" object to execute a query. As discussed in #94 the usage of "env" is not the best for security, so writing more methods that execute common queries will reduce the use of that object. If we continue doing useful functions for the Browsable Objects, we can think in removing env access in the future.
Regards.