Repository navigation
Close invoicing gaps: correctness, credit notes, dunning, payments, and API - #876
Merged
Merged
Conversation
Separate lifecycle status from payment settlement, stop marking drafts overdue, recompute paid amounts from the payment ledger, and treat overpayments explicitly so the dashboard and payment flows stay consistent.
Support mixed VAT rates and allowances on invoice lines, keep a tax breakdown for Peppol/CII/FatturaPA/XRechnung exports, and lock financial edits on non-draft invoices while still allowing notes and due-date updates.
Introduce reusable reminder levels with optional fixed or annual late fees, wire the daily overdue job to send each due level once, and expose admin and per-client policy controls plus invoice reminder history.
Extend credit notes with line items and numbering, add create/issue/PDF UI, and export Peppol UBL 381, CII 381, XRechnung, and FatturaPA TD04 documents linked back to the original invoice.
Add Mollie webhooks, verify PayPal signatures, implement provider refunds, send payment receipt emails, and let clients download invoice PDFs from the portal with a provider-neutral checkout page.
Expose send-email plus UBL/XRechnung/FatturaPA downloads on API v1, emit invoice and credit-note webhook events consistently, and document the new scopes and payload surface.
| return redirect(url_for("credit_notes.view_credit_note", cn_id=cn.id)) | ||
| except Exception as exc: | ||
| db.session.rollback() | ||
| logger.exception("Failed to create credit note for invoice %s", invoice_id) |
| from app.utils.credit_note_pdf import generate_credit_note_pdf | ||
| pdf_bytes = generate_credit_note_pdf(cn) | ||
| except Exception as exc: | ||
| logger.exception("Credit note PDF generation failed for cn=%s", cn_id) |
| ) | ||
| xml_str, _ = build_peppol_ubl_credit_note_xml(cn, invoice, supplier, customer) | ||
| except Exception as exc: | ||
| logger.exception("UBL credit note XML build failed for cn=%s", cn_id) |
| client = Client.query.get(invoice.client_id) if invoice.client_id else None | ||
| xml_bytes, filename = build_fatturapa_credit_note_xml(cn, invoice, settings, client) | ||
| except Exception as exc: | ||
| logger.exception("FatturaPA credit note XML build failed for cn=%s", cn_id) |
| class _Concrete(PaymentProvider): | ||
| provider_name = "dummy" | ||
|
|
||
| def create_checkout_session(self, **kw): |
Comment on lines
+8
to
+20
| from flask import ( | ||
| Blueprint, | ||
| Response, | ||
| abort, | ||
| current_app, | ||
| flash, | ||
| jsonify, | ||
| redirect, | ||
| render_template, | ||
| request, | ||
| send_file, | ||
| url_for, | ||
| ) |
| """PayPal Orders v2 payment provider.""" | ||
|
|
||
| import base64 | ||
| import hashlib |
| """Models for invoice reminder policies and policy levels.""" | ||
|
|
||
| from datetime import datetime | ||
| from decimal import Decimal |
| @@ -0,0 +1,448 @@ | |||
| """Phase 5 tests: Mollie, PayPal signature, refunds, portal PDF, pay.html, receipt email.""" | |||
|
|
|||
| import io | |||
Format with black/isort, add the reminder-policy edit script nonce, align position/late_fee server defaults, and make reminder-policy FK adds SQLite-safe with batch_alter_table plus the policy_id index.
| @@ -1,3 +1,4 @@ | |||
| from datetime import date as _date | |||
| from factories import ClientFactory, ProjectFactory, UserFactory | ||
|
|
||
| from app import db | ||
| from app.models import Client, Invoice, InvoiceItem, Project, Settings, User |
|
|
||
| from __future__ import annotations | ||
|
|
||
| from datetime import date, datetime |
| from datetime import date, datetime | ||
| from decimal import Decimal | ||
|
|
||
| import pytest |
| from types import SimpleNamespace | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest |
Sort reminder_policy imports in models and factories-before-app in the overdue scheduled invoice report test so the isort pre-commit hook passes.
Split the suite across eight jobs using pytest-split least_duration, cache merged timings between runs, drop verbose coverage reports on shards, and raise the per-job timeout to 30 minutes as a safety margin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PARTIALLY_PAIDcrash), and keepamount_paiddriven by the payment ledger with explicit overpayment handling.invoice.sent/paid/updated/deleted/overdue,credit_note.created,payment.refunded).Migrations
210_invoice_line_tax_discounts211_invoice_reminder_policies212_credit_notes_extendedTest plan
InvoiceStatus.PARTIALLY_PAIDerroroverpaidPOST /api/v1/invoices/<id>/send-email,GET .../ubl|xrechnung|fatturapa; webhook delivery forinvoice.paid/invoice.sentpytest tests/test_credit_notes.py tests/test_invoice_line_tax_discounts.py tests/test_invoice_reminders.py tests/test_phase5_features.py tests/test_invoice_events.py tests/test_api_invoices_v1.py -q