Skip to content

FIX invoice generation mindset - #282

Merged
ecino merged 2 commits into
14.0from
14.0-invoicing-fix
Jul 16, 2026
Merged

FIX invoice generation mindset#282
ecino merged 2 commits into
14.0from
14.0-invoicing-fix

Conversation

@ecino

@ecino ecino commented Jul 16, 2026

Copy link
Copy Markdown
Member
  • The next month should be generated if advance_billing_month is 1.

- The next month should be generated if advance_billing_month is 1.
@ecino
ecino requested a review from danpa32 July 16, 2026 11:59
@ecino

ecino commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@danpa32 In production we are waiting for the august invoices to be generated. But since your change this doesn't happen anymore. We don't wan't to wait for August for having the invoices. Can you review if this is correct regarding your changes or should we do it differently?

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the invoice generation range calculation and updates the documentation table in recurring_contract/models/contract_group.py. The review feedback highlights that the new range formula introduces a bug when starting_offset = 1 by exceeding the advance billing limit. It is recommended to cap the upper bound at group.advance_billing_months + 1 and update the documentation table accordingly to maintain consistency.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread recurring_contract/models/contract_group.py
Comment thread recurring_contract/models/contract_group.py Outdated
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

Mostly safe to merge once the active invoice-boundary discussion is resolved.

The change is localized to invoice-offset iteration, and no new issues were identified in the reviewed surrounding code.

recurring_contract/models/contract_group.py controls invoice creation counts and should stay covered by invoice-generation tests.

T-Rex T-Rex Logs

What T-Rex did

  • The environment analysis showed odoo and docker exited with code 127, so the lightweight harness path was selected.
  • The advance_billing_offsets tests ran and all cases passed, with the required outputs [0, 1] and [1] produced.
  • The contract_group.py module compiled successfully with exit code 0, validating the static build step.
  • All related artifacts were organized and linked to the proof to support review.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
recurring_contract/models/contract_group.py Updates the invoice-offset range used by contract-group invoice generation; no additional issues beyond the already-open boundary discussion were identified.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant SchedulerOrUser as Scheduler/User
participant Group as ContractGroup
participant Offset as Start date/offset calculation
participant Skip as Existing invoice check
participant Processor as Invoice processor

SchedulerOrUser->>Group: generate_invoices()
Group->>Offset: _calculate_start_date_and_offset()
Offset-->>Group: invoicing_date, starting_offset
loop invoice_offset in range(starting_offset, advance_billing_months + 1, month_interval)
    Group->>Group: "current_invoicing_date = invoicing_date + offset months"
    Group->>Skip: _should_skip_invoice_generation(current_invoicing_date, active_contract_ids)
    alt invoice already covered
        Skip-->>Group: skip
    else invoice needed
        Group->>Processor: _process_invoice_generation(invoicer, current_invoicing_date)
    end
end
Group->>Group: recompute missing invoices
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant SchedulerOrUser as Scheduler/User
participant Group as ContractGroup
participant Offset as Start date/offset calculation
participant Skip as Existing invoice check
participant Processor as Invoice processor

SchedulerOrUser->>Group: generate_invoices()
Group->>Offset: _calculate_start_date_and_offset()
Offset-->>Group: invoicing_date, starting_offset
loop invoice_offset in range(starting_offset, advance_billing_months + 1, month_interval)
    Group->>Group: "current_invoicing_date = invoicing_date + offset months"
    Group->>Skip: _should_skip_invoice_generation(current_invoicing_date, active_contract_ids)
    alt invoice already covered
        Skip-->>Group: skip
    else invoice needed
        Group->>Processor: _process_invoice_generation(invoicer, current_invoicing_date)
    end
end
Group->>Group: recompute missing invoices
Loading

Reviews (2): Last reviewed commit: "FIX invoice generation upper bound for w..." | Re-trigger Greptile

Comment thread recurring_contract/models/contract_group.py Outdated
Comment thread recurring_contract/models/contract_group.py Outdated
Comment thread recurring_contract/models/contract_group.py Outdated
The previous formula (starting_offset + advance_billing_months +
month_interval) still added starting_offset to the upper bound, which
changes the invoice count depending on whether the contract is waiting
or active. For a waiting contract with advance_billing_months=3, it
generated 4 invoices instead of 3, breaking
test_generate_invoice_data_coherency.

starting_offset should only control where the range starts (skip the
current month for a waiting contract), not where it ends.
@danpa32

danpa32 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I have pushed some changes for the rest to make sense. Can you check it out @ecino ?

@ecino
ecino merged commit fcd9a5d into 14.0 Jul 16, 2026
2 checks passed
@ecino
ecino deleted the 14.0-invoicing-fix branch July 16, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants