-
-
Notifications
You must be signed in to change notification settings - Fork 388
[16.0][IMP]commission, account_commission: settlements grouped by payment date #643
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
base: 16.0
Are you sure you want to change the base?
Conversation
|
Hi @pedrobaeza, |
b7da3bb to
f801d17
Compare
|
Hi @pedrobaeza, @etobella sorry for bother! |
49a3dbf to
3650074
Compare
6de78ca to
58aa857
Compare
VBNext
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality tested. LGTM
19a7e9a to
56d6ba3
Compare
56d6ba3 to
91a9d45
Compare
|
Hi @pedrobaeza, @etobella sorry for bother! |
etobella
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side, the code looks ok,
However, I don't know if it makes sense to split in an extra module and add the necessary hooks in account_comission 🤔
@pedrobaeza WDYT?
pedrobaeza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For not forcing a new module being an small configurable addition, and having a test, let's keep it here, but please remove the empty lines inside methods, following the same style as the rest, and check the comments inline.
Another thing to think is to put a generic field "Group by", including this option and the standard one, and leaving the door opened for other groupings.
| order="invoice_date", | ||
|
|
||
| lines = self.env["account.invoice.line.agent"].search( | ||
| self._get_account_settle_domain(agent, date_to_agent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing the order here?
| if dates: | ||
| payment_date_by_inv[inv.id] = max(dates) | ||
|
|
||
| # Filtra solo le righe con fatture che hanno pagamenti entro date_payment_to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments in English only
| if line.agent_id.commission_id.settled_dates_based_on != "payment": | ||
| return super().get_period_date(line) | ||
| return self.get_latest_payment_date(line.invoice_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better readability doing the contrary:
| if line.agent_id.commission_id.settled_dates_based_on != "payment": | |
| return super().get_period_date(line) | |
| return self.get_latest_payment_date(line.invoice_id) | |
| if line.agent_id.commission_id.settled_dates_based_on == "payment": | |
| return self.get_latest_payment_date(line.invoice_id) | |
| return super().get_period_date(line) |
| for ( | ||
| _partial, | ||
| _amount, | ||
| counterpart_line, | ||
| ) in invoice_partials: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid excessive lines:
| for ( | |
| _partial, | |
| _amount, | |
| counterpart_line, | |
| ) in invoice_partials: | |
| for (_p, _a, counterpart_line) in invoice_partials: |
| be settled as well, resulting in a 0 net commission between both operations. | ||
|
|
||
| #. For payment-based commissions, you can choose how settlements are grouped. | ||
| By default, they’re grouped by 'Invoice Date', but you can also group them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentation.
| comodel_name="account.move", | ||
| compute="_compute_invoice_id", | ||
| ) | ||
| commission_grouped_by = fields.Selection( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to remove this.
This pr allows to generate commissions based on the payment date.
For example, if you have three invoices from three different months but with a payment date in the same month, the current behavior generates three separate period, one for each month. With this change, however, all commissions are assigned to a single period.
It covers a similar scope but is managed in a different way #581