Introduction
Once invoice automation is working, the next documents most finance teams need are credit notes and customer statements. Credit notes reverse or reduce invoice amounts, while customer statements summarize all invoices, payments, and outstanding balances over a period.
In C#, the process is very similar to invoice generation: store the right data, query the right records, bind them to a report, and export PDFs in batches.
Credit Note Table Design
CREATE TABLE CreditNotes (
CreditNoteId INT PRIMARY KEY IDENTITY(1,1),
InvoiceId INT NOT NULL,
CreditNoteNumber NVARCHAR(30) NOT NULL,
CreditNoteDate DATE NOT NULL,
Reason NVARCHAR(300) NULL,
CreditAmount DECIMAL(18,2) NOT NULL,
PdfGenerated BIT NOT NULL DEFAULT 0,
PdfPath NVARCHAR(300) NULL,
FOREIGN KEY (InvoiceId) REFERENCES Invoices(InvoiceId)
);
Customer Statement Query Shape
A customer statement usually combines invoices, payments, and credit notes into one running balance report.
SELECT
c.CustomerName,
t.TransactionDate,
t.ReferenceNumber,
t.TransactionType,
t.DebitAmount,
t.CreditAmount,
t.RunningBalance
FROM CustomerStatementTransactions t
INNER JOIN Customers c ON c.CustomerId = t.CustomerId
WHERE t.CustomerId = @CustomerId
AND t.TransactionDate BETWEEN @FromDate AND @ToDate
ORDER BY t.TransactionDate, t.ReferenceNumber;
Sample Credit Note Data
| Credit Note | Invoice | Date | Reason | Amount |
|---|---|---|---|---|
| CN-2026-0001 | INV-2026-0001 | 2026-03-05 | Overbilling adjustment | $120.00 |
| CN-2026-0002 | INV-2026-0003 | 2026-03-06 | Returned license item | $650.00 |
Sample Statement Output
| Date | Reference | Type | Debit | Credit | Balance |
|---|---|---|---|---|---|
| 2026-03-01 | INV-2026-0001 | Invoice | $1,955.00 | $0.00 | $1,955.00 |
| 2026-03-05 | CN-2026-0001 | Credit Note | $0.00 | $120.00 | $1,835.00 |
| 2026-03-10 | PAY-2026-0142 | Payment | $0.00 | $800.00 | $1,035.00 |
Visual Invoice Preview
This mock invoice uses only the data shown in the sample statement and credit note tables above, presented in a clean PDF-style layout.
Invoice Preview
INV-2026-0001
| Date | Reference | Type | Amount |
|---|---|---|---|
| 2026-03-01 | INV-2026-0001 | Invoice | $1,955.00 |
| 2026-03-05 | CN-2026-0001 | Credit Note | -$120.00 |
| 2026-03-10 | PAY-2026-0142 | Payment | -$800.00 |
C# Generation Flow
- load approved credit notes or statement requests from the database
- bind them to a DevExpress report template
- export PDF files in batch
- store generated file paths
- optionally email the PDFs to customers or finance staff
public void GenerateCreditNoteBatch(IEnumerable<CreditNoteModel> notes, string outputFolder)
{
foreach (var note in notes)
{
var report = new CreditNoteXtraReport();
report.DataSource = note.Items;
var path = Path.Combine(outputFolder, note.CreditNoteNumber + ".pdf");
report.ExportToPdf(path);
MarkCreditNoteAsGenerated(note.CreditNoteId, path);
}
}
Why This Matters
If invoices are automated but credit notes and statements are still manual, the finance workflow is still incomplete. Bringing all three document types into one C# reporting pipeline gives you consistency, auditability, and much less manual work at month-end.
Technologies I Use
Related Reading
Start with How to Automate Invoices in C#, then extend the same approach to credit notes and statements using the workflow above.