Skip to content

✨(backend) add final_reference field to Invoice model#1333

Open
jonathanreveille wants to merge 1 commit into
mainfrom
feature/invoice_generate_on_demand_once_order_completed
Open

✨(backend) add final_reference field to Invoice model#1333
jonathanreveille wants to merge 1 commit into
mainfrom
feature/invoice_generate_on_demand_once_order_completed

Conversation

@jonathanreveille
Copy link
Copy Markdown
Member

@jonathanreveille jonathanreveille commented Apr 28, 2026

Purpose

The final reference field will be used when we generate on demand a final invoice. This may happen when orders are completed and all their installments are paid. This means the balance should be at 0. The final reference will be unique per organization. We also allow to generate the final invoice when a batch order uses the card payment.

🥚 Note : Not to be merged yet in main. This branch is the first PR for the implementation of this issue #1247

Proposal

  • add new field final_reference in Invoice model
  • add property and method to generate a unique reference per organization.

@jonathanreveille jonathanreveille self-assigned this Apr 28, 2026
@kernicPanel kernicPanel requested a review from Copilot April 28, 2026 09:23
@jonathanreveille jonathanreveille force-pushed the feature/invoice_generate_on_demand_once_order_completed branch from ad6b84d to 2f0de28 Compare April 28, 2026 09:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for generating and storing a “final invoice reference” on Invoice, intended for uniquely identifying finalized invoices per organization.

Changes:

  • Add nullable unique final_reference field to Invoice (with a migration).
  • Add eligibility logic (can_generate_final_reference) and reference generation/update methods on Invoice.
  • Add tests covering final reference generation/uniqueness and eligibility behavior; document change in changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/backend/joanie/payment/models.py Adds final_reference field and generation/eligibility logic on Invoice.
src/backend/joanie/payment/migrations/0013_invoice_final_reference.py Creates DB column for final_reference.
src/backend/joanie/tests/payment/test_models_invoice.py Adds tests for final reference uniqueness and eligibility rules.
CHANGELOG.md Notes the addition of final_reference on invoices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/joanie/payment/models.py Outdated
Comment thread src/backend/joanie/payment/models.py Outdated
Comment thread src/backend/joanie/tests/payment/test_models_invoice.py
Comment thread src/backend/joanie/tests/payment/test_models_invoice.py
Comment thread src/backend/joanie/payment/models.py
Comment thread src/backend/joanie/payment/models.py
@jonathanreveille jonathanreveille changed the title ✨(backend) add final_reference field to Invoice model ✨(backend) add final_reference field to Invoice model Apr 28, 2026
@jonathanreveille jonathanreveille force-pushed the feature/invoice_generate_on_demand_once_order_completed branch from 2f0de28 to c638694 Compare April 28, 2026 10:41
Comment thread src/backend/joanie/payment/models.py
@jonathanreveille jonathanreveille force-pushed the feature/invoice_generate_on_demand_once_order_completed branch from c638694 to 0e7364f Compare April 29, 2026 14:24
@jonathanreveille jonathanreveille force-pushed the feature/invoice_generate_on_demand_once_order_completed branch from 0e7364f to 7907e6d Compare May 13, 2026 13:54
The final reference field will be used when we generate on demand
a final invoice. This may happen when orders are completed and
all their installments are paid. This means the balance should be at 0.
The final reference will be unique per organization.
We also allow to generate the final invoice when a batch order uses
the card payment.
@jonathanreveille jonathanreveille force-pushed the feature/invoice_generate_on_demand_once_order_completed branch from 7907e6d to 6397bbc Compare May 13, 2026 13:56
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.

3 participants