Add Trade Credit & Invoice Factoring Extensions (B2B analytics)#30
Open
Thorium wants to merge 6 commits into
Open
Add Trade Credit & Invoice Factoring Extensions (B2B analytics)#30Thorium wants to merge 6 commits into
Thorium wants to merge 6 commits into
Conversation
Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>
…oring modules Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>
…56d6 # Conflicts: # src/Amortisation.fs # src/FSharp.Finance.Personal.fsproj
Also reverted some copilot changes to original code.
There was a problem hiding this comment.
Pull request overview
Adds initial B2B analytical extensions (trade credit discount-rate analytics + invoice factoring parameter construction) alongside some supporting domain/cashflow scaffolding and documentation.
Changes:
- Introduces
FSharp.Finance.B2B.TradeCreditutilities + unit tests for implied rates and validation. - Adds
FSharp.Finance.B2B.InvoiceFactoringtypes and aFactoringParameters.buildhelper to produce coreScheduling.Parameters. - Adds product metadata/cashflow scaffolding plus a docs script + README section describing the new B2B analytics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TradeCreditTests.fs | Adds unit tests for trade credit calculations and validations. |
| tests/FSharp.Finance.Personal.Tests.fsproj | Includes the new trade credit test file in the test project. |
| src/TradeCredit.fs | Implements trade credit discount terms + implied annual rate calculators. |
| src/InvoiceFactoring.fs | Adds invoice factoring domain types + parameter/statistics builders. |
| src/FSharp.Finance.Personal.fsproj | Compiles the new modules into the main library and updates package description. |
| src/DomainExtensions.fs | Adds business product classification + metadata helpers. |
| src/CashflowModel.fs | Adds (currently unused) cashflow event/type scaffolding. |
| docs/exampleTradeCreditAndFactoring.fsx | Adds an example script demonstrating trade credit + factoring usage. |
| README.md | Documents the new B2B analytical extensions at a high level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This PR introduces the initial Business (B2B) analytical extensions under the namespace
FSharp.Finance.B2B.*.Purpose: provide optional analytics (NOT a full commercial / operational platform) for:
Files Added (Current State)
DomainExtensions.fsBusinessProductTypeDUProductMetadatarecord + helper constructors (consumer,tradeCredit,invoiceFactoring)CashflowModel.fsCashflowTypeDU +CashflowEventrecord (future-facing abstraction; not yet wired in)TradeCredit.fsDiscountTerms,createTermsimpliedAnnualRateSimpleimpliedAnnualRateCompoundedInvoiceFactoring.fsInvoice,InvoiceAdvance(derive)FactoringParameters.build->Parametersdocs/exampleTradeCreditAndFactoring.fsxDesign Decisions
FSharp.Finance.B2B.*Apr.CalculationMethod.UnitedKingdom 2(placeholder)Trade Credit Rate Formulas
Let
d = discountPercent,D = discount deadline day,N = net due day.Simple annualized (no intra-year compounding):
rate_simple = (d / (1 - d)) * (365 / (N - D))Naive compounded:
rate_compounded = (1 + d / (1 - d))^(365 / (N - D)) - 1Comments in code document rationale and limitations.
Documentation Example
docs/exampleTradeCreditAndFactoring.fsx:2/10 net 30implied ratesTests
TradeCreditTests.fsimpliedAnnualRateSimplefor2/10 net 30~=0.3724(tolerance+/- 0.0001m)100mdiscount input to avoid divide-by-zero pathsInvoiceFactoringTests.fsChecklist
Open Questions
AprMethod.Disabledin a future minor version for zero-interest cases?CashflowModel?FSharp.Finance.Analyticsnamespace?Non-Goals (Current Iteration)
Disclaimer
Analytical utilities only. Independent validation required for production or compliance use.