Skip to content

Add statement generation to Amortisation.fs#59

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/add-statement-generation-function
Draft

Add statement generation to Amortisation.fs#59
Copilot wants to merge 4 commits into
mainfrom
copilot/add-statement-generation-function

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

Adds a month-by-month account statement generation feature to Amortisation.fs, as a prerequisite for regulatory disclosure documents (e.g. SECCI, CCA s.77A).

Changes Made

src/Amortisation.fs

  • StatementLine record: 12 fields covering Date, OpeningBalance, Advance, InterestCharged, ChargesIncurred, Payment, PrincipalPortion, FeePortion, InterestPortion, ChargesPortion, ClosingBalance, and CumulativeInterestPaid
  • Statement.generate: converts an AmortisationSchedule into a StatementLine array, carrying forward opening/closing balances and a running cumulative interest total
  • Statement.toPlainText: renders the statement as a fixed-width right-aligned plain-text table (suitable for inclusion in a letter or email)
  • Statement.toCsv: renders the statement as RFC 4180-compliant CSV, quoting any field that contains a comma, double-quote, or newline

tests/StatementTests.fs (new file)

23 tests covering:

  • generate: line count, opening/closing balance chain, zero opening balance, zero final closing balance when fully repaid, monotonically non-decreasing cumulative interest, date alignment, advance amount, cumulative interest equals sum of interest portions; add-on interest variants
  • toPlainText: header column names, separator row, line count, fixed-width table invariant, day-0 data row content
  • toCsv: header prefix, header column count, line count, comma-containing amounts are quoted, day-0 CSV row content, RFC 4180-aware column-count invariant (correct "" escape handling)

tests/FSharp.Finance.Personal.Tests.fsproj

  • Registered StatementTests.fs in the compile list

Testing

  • ✅ Build passes for netstandard2.0 and netstandard2.1
  • ✅ All 23 new statement tests pass
  • ✅ No regressions introduced (219 pre-existing unrelated failures unchanged)

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/simontreanor/FSharp.Finance.Personal/sessions/7d70f64a-926f-4ae2-9c4a-e95bcea2f44b

Co-authored-by: simontreanor <4550815+simontreanor@users.noreply.github.com>
Copilot AI requested a review from simontreanor April 28, 2026 23:30
Copy link
Copy Markdown
Owner

@simontreanor simontreanor left a comment

Choose a reason for hiding this comment

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

@copilot continue

Copy link
Copy Markdown
Author

Copilot AI commented Apr 29, 2026

@copilot continue

Completed. The implementation adds StatementLine and Statement (with generate, toPlainText, toCsv) to Amortisation.fs, along with 23 tests in StatementTests.fs. Also addressed the code-review feedback:

  • Added a toPlainText data-row content test verifying specific formatted amounts for a known schedule
  • Added an RFC 4180-aware CSV column-count test with a correct state machine that handles the "" escape sequence inside quoted fields
  • Fixed a misleading comment in the double-quote test

Commits: 2feaada, ca576a0

Copilot AI changed the title [WIP] Add statement generation function to Formatting.fs Add statement generation to Amortisation.fs Apr 29, 2026
Copilot AI requested a review from simontreanor April 29, 2026 22:43
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.

Formatting.fs: statement generation

2 participants