A C# console application that calculates interest rates and total cost of borrowing for fixed amounts over specified periods, using monthly capitalization.
- CSV Input: Reads borrowing data and parameters from CSV files
- Monthly Capitalization: Calculates interest and commission with monthly compounding
- Variable Rates: Supports different interest/commission rates for different time periods
- Detailed Reports: Generates human-readable markdown files with complete calculation breakdowns
- .NET 8.0 SDK or later
InterestCalculator/
├── Models/
│ ├── Borrowing.cs # Borrowing record model
│ ├── BorrowingParameter.cs # Parameter period model
│ ├── BorrowingCalculation.cs # Calculation result model
│ └── CapitalizationPeriod.cs # Single period calculation
├── Services/
│ ├── CsvReaderService.cs # CSV file parser
│ ├── InterestCalculatorService.cs # Interest calculation logic
│ └── MarkdownGeneratorService.cs # Report generator
├── Program.cs # Application entry point
├── borrowing.csv # Sample borrowing data
├── parameters.csv # Sample parameters
└── InterestCalculator.csproj # Project file
Contains the borrowing records with the following fields:
| Field | Description | Format |
|---|---|---|
| amount | Principal amount borrowed | Decimal (e.g., 10000.00) |
| start_date | Start date of borrowing | yyyy-MM-dd |
| end_date | End date of borrowing | yyyy-MM-dd |
| interest_rate | Annual interest rate | Decimal (e.g., 0.08 for 8%) |
| commission | Annual commission rate | Decimal (e.g., 0.02 for 2%) |
Example:
amount,start_date,end_date,interest_rate,commission
10000.00,2024-01-01,2024-06-30,0.08,0.02
25000.50,2024-03-15,2024-12-15,0.065,0.015Contains borrowing parameters for different time periods:
| Field | Description | Format |
|---|---|---|
| interest_rate | Annual interest rate for the period | Decimal |
| commission | Annual commission rate for the period | Decimal |
| start_date | Start date of this parameter period | yyyy-MM-dd |
| end_date | End date of this parameter period | yyyy-MM-dd |
Example:
interest_rate,commission,start_date,end_date
0.075,0.018,2024-01-01,2024-03-31
0.08,0.02,2024-04-01,2024-06-30
0.085,0.022,2024-07-01,2024-09-30- Place
borrowing.csvandparameters.csvin the same directory as the executable - Run the application:
dotnet runYou can override default file paths:
dotnet run <borrowing_file> <parameters_file> <output_directory>Example:
dotnet run "C:\data\loans.csv" "C:\data\rates.csv" "C:\reports"The application generates markdown files named calculation N.md for each borrowing, where N is the borrowing number (1-based).
Each report includes:
- Summary: Principal amount, dates, rates, and duration
- Total Costs: Total interest, commission, and final amount owed
- Monthly Capitalization Details: Table showing each period's calculations
- Detailed Breakdown: Step-by-step calculation for each period
For each capitalization period:
- Daily Interest Rate = Annual Interest Rate ÷ Days in Year
- Interest Amount = Opening Balance × Daily Interest Rate × Days in Period
- Daily Commission Rate = Annual Commission Rate ÷ Days in Year
- Commission Amount = Opening Balance × Daily Commission Rate × Days in Period
- Total Capitalization = Interest Amount + Commission Amount
- Closing Balance = Opening Balance + Total Capitalization
The closing balance becomes the opening balance for the next period.
When calculating each period, the application:
- First checks if any parameter period covers the capitalization period
- Falls back to the borrowing's own rates if no matching parameter is found
dotnet builddotnet runCheck the output directory for generated reports.
MIT License