[16.0][IMP]commission, account_commission: settlements grouped by payment date#643
[16.0][IMP]commission, account_commission: settlements grouped by payment date#643matteonext wants to merge 2 commits intoOCA:16.0from
Conversation
|
Hi @pedrobaeza, |
b7da3bb to
f801d17
Compare
|
Hi @pedrobaeza, @etobella sorry for bother! |
49a3dbf to
3650074
Compare
6de78ca to
58aa857
Compare
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.
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.
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.
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 |
| 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.
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.
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 |
| comodel_name="account.move", | ||
| compute="_compute_invoice_id", | ||
| ) | ||
| commission_grouped_by = fields.Selection( |
There was a problem hiding this comment.
I would prefer to remove this.
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Passed
All tests for account_commission,commission passed successfully on Odoo 16.0.
Environment: Minikube + K8s Job + oca-ci/py3.10-odoo16.0
Test Coverage Suggestions
Coverage Gaps
The new feature introduces a settled_dates_based_on field and logic to group settlements by Payment Date instead of Invoice Date. While test_groupby_payment_date_settlement exists, it's quite specific and doesn't cover:
- Edge cases with no payments: What happens when an invoice is paid but not fully reconciled or has no payment dates?
- Mixed invoice states: Behavior when some invoices are paid and others are not within the same settlement period.
- Different date formats or invalid data: Robustness of
get_latest_payment_date()in unusual scenarios. - Backward compatibility: Ensuring
invoice_dateis still used whensettled_dates_based_onis not set topayment.
Suggested Test Cases
def test_get_latest_payment_date_edge_cases(self):
"""Test get_latest_payment_date with invoices that have no payments or partial payments."""
def test_mixed_invoice_states_settlement(self):
"""Test settlements with a mix of paid and unpaid invoices in same period."""
def test_commission_grouped_by_field_display(self):
"""Verify commission_grouped_by field displays correct value in UI (tree/form views)."""Codecov Risk
get_latest_payment_date()incommission_make_settle.py– new method, likely to reduce coverage if not tested._get_agent_lines()incommission_make_settle.py– modified logic with new conditional path, requires explicit testing of thepaymentbranch.get_period_date()override – new override; ensures correct usage in period calculation logic.
Note: The existing tests cover core functionality, but edge cases in payment reconciliation and field display are not covered. These new tests would improve robustness and coverage.
⏰ PR Aging Alert
This PR by @matteonext has been open for 158 days (5 months).
💤 Last activity was 40 days ago.
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! Thanks for your contribution to OCA. I reviewed and approved this PR. If any of you have a moment, I would really appreciate a review on my open PR(s):
My open PRs across OCA:
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward faster. Thank you!
Automated review by OCA Neural Reviewer + qwen3-coder:30b
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