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-0001INV-2026-00012026-03-05Overbilling adjustment$120.00
CN-2026-0002INV-2026-00032026-03-06Returned license item$650.00

Sample Statement Output

Date Reference Type Debit Credit Balance
2026-03-01INV-2026-0001Invoice$1,955.00$0.00$1,955.00
2026-03-05CN-2026-0001Credit Note$0.00$120.00$1,835.00
2026-03-10PAY-2026-0142Payment$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

Invoice date: 2026-03-01

Statement-Based
Original Invoice $1,955.00
Credit Note -$120.00
Payment -$800.00
Balance Due $1,035.00
Date Reference Type Amount
2026-03-01INV-2026-0001Invoice$1,955.00
2026-03-05CN-2026-0001Credit Note-$120.00
2026-03-10PAY-2026-0142Payment-$800.00

C# Generation Flow

  1. load approved credit notes or statement requests from the database
  2. bind them to a DevExpress report template
  3. export PDF files in batch
  4. store generated file paths
  5. 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

.NET Core ASP.NET MVC C# SQL Server Azure Entity Framework

Related Reading

Start with How to Automate Invoices in C#, then extend the same approach to credit notes and statements using the workflow above.