Repository navigation
Add credit notes - #194
Merged
Merged
Add credit notes#194
Conversation
Issued invoices can now be corrected with a credit note instead of being
edited ("Create credit note" in the invoice's More menu). The credit note
starts as a draft copy of the invoice that references it; edit it to
credit only part of the invoice, then publish it like an invoice.
- Data: invoices.document_type ('invoice' | 'credit_note') and
invoices.credited_invoice_id. Credit notes store positive amounts; the
document type makes them a credit.
- Numbering: credit notes share the invoice counter by default (one
continuous sequence, as required e.g. in Bulgaria). Under Numbering they
can get their own pattern instead (default CN-{YYYY}-{SEQ}).
- PDF/HTML: credit-note title and labels in all invoice languages, and a
"Credit note for invoice <number> (<date>)" line in the built-in
templates. Downloads are named credit-note-<number>.
- XML: UBL exports a CreditNote document (type 381, BillingReference,
CreditNoteLine/CreditedQuantity, no header DueDate); Factur-X/ZUGFeRD
uses type 381 with InvoiceReferencedDocument; FatturaPA uses TD04 with
DatiFattureCollegate.
- UI: credit notes are marked in the invoice list and dashboard and shown
with negative totals; an invoice links to its credit notes and vice
versa. Dashboard revenue, billed, paid and outstanding subtract credit
notes, and they are not counted as open invoices.
Closes kittendevv#191
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
Owner
|
Could you possibly resolve the merge conflicts |
Owner
|
Then its ready to merge |
Contributor
Author
|
Let me check |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CsybXd62SCcD732L4x6uYX
Contributor
Author
|
@kittendevv merge conflict resolved |
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
Closes #191
Issued invoices can't be edited, and the error messages already tell users to "issue a credit note instead", but there was no way to do that. This adds credit notes.
Workflow: on an issued invoice (sent, overdue, paid or complete), choose More → Create credit note. This opens a draft copy of the invoice that references it. Edit the draft to credit only part of the invoice, then publish it like an invoice.
Changes
Data
invoices.document_type(invoice|credit_note, defaultinvoice) andinvoices.credited_invoice_id, added by the usual column migration and included in the table rebuild for old databases.creditedInvoice(for credit notes) andcreditNotes(for invoices).POST /api/v1/invoices/:id/credit-note(permissioninvoices:create). Drafts, voided invoices and credit notes can't be credited.Numbering
CN-{YYYY}-{SEQ}).PDF / HTML
credit-note-<number>.pdf/.xml; the email body says "Credit note".E-invoice XML
CreditNotedocument (CreditNote-2namespace),CreditNoteTypeCode381,BillingReference/InvoiceDocumentReference,CreditNoteLine/CreditedQuantity, no headerDueDate.TypeCode381 andInvoiceReferencedDocument(BG-3) after the monetary summation.TipoDocumentoTD04 andDatiFattureCollegate.App
Verification
backend/src/controllers/credit_notes_test.ts(10 tests): creation and references, which invoices can be credited, shared and separate numbering, duplicating, no overdue status, UBL/Factur-X/FatturaPA output, PDF labels in English and German.deno checkandsvelte-checkhave no errors.GS-{SEQ}the next credit note became GS-001. The PDF, UBL and Factur-X files were checked by hand and are well-formed; they were not run through an official validator.Not included
Note: this touches the same numbering code and settings section as #192 and #193, so whichever is merged later needs a small conflict resolution.
🤖 Generated with Claude Code