Skip to content

SQL-based interest calculation functions, table-valued function, and stored procedure for financial applications. Supports multiple methods (proportional, 30/360, compound, etc.) with flexible parameters for principal, rate, dates, and anticipation.

Notifications You must be signed in to change notification settings

gegedobruna/sql-interest-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SQL Interest Calculator

A collection of SQL Server functions, a stored procedure, and a table-valued function for general interest calculation.
Developed during my internship at ASEE by Asseco as part of a banking system environment.

πŸ“Œ Overview

This project provides reusable SQL utilities to calculate financial interest between two dates with flexible parameters.
It is designed for banking and financial use cases, but the logic is generic enough to apply in other domains.

πŸš€ Features

  • Multiple interest calculation methods:
    • Proporc. (Proportional)
    • 30/360
    • 28–31/365
    • 30/365-6
    • Compound
    • Anticipative options
  • Validates input dates and parameters
  • Returns precise decimal values with rounding
  • Two ways to use:
    • Stored procedure (sp_CalcInterest) β†’ returns results in a queryable resultset
    • Table-valued function (fn_CalcInterest) β†’ can be embedded directly in SELECT queries

βš™οΈ Installation (simple)

  1. Open your target database in SSMS (or any SQL client).
  2. Run the scripts:
    • sql/procedures/sp_CalcInterest.sql (procedure)
    • sql/functions/fn_CalcInterest.sql (table-valued function)
  3. That’s it β€” both are now available in the current database.

▢️ Run Examples

  • Stored Procedure
EXEC dbo.sp_CalcInterest
  @Method = 'ACT/ACT',
  @StartDate = '2023-01-01',
  @EndDate   = '2023-12-31',
  @Principal = 10000,
  @RatePct   = 5,
  @IsAnticipative = 0;
  • Table-Valued Function
SELECT *
FROM dbo.fn_CalcInterest(
  'ACT/ACT',
  '2023-01-01',
  '2023-12-31',
  10000,
  5,
  0
);

πŸ“€ Output Columns

  • Normal:
Start Date End Date Days Rate % Method Principal (initial) Interest (normal) New Balance
2023-01-01 2023-12-31 364 5.00 ACT/365 10000.00 498.63 10498.63
  • Anticipative:
Start Date End Date Days Rate % Method Principal (final) Principal (anticip) Interest (anticip)
2023-07-01 2023-08-15 44 11.00 30/360 250000.00 239103.45 10896.55

πŸ“š Notes

  • This repository was created as part of my internship at ASEE by Asseco.
  • It is intended for educational/demo purposes and may not reflect production-grade financial software.

πŸ‘€ Author: GegΓ« Dobruna (Intern at ASEE by Asseco)
πŸ“… Year: 2025

About

SQL-based interest calculation functions, table-valued function, and stored procedure for financial applications. Supports multiple methods (proportional, 30/360, compound, etc.) with flexible parameters for principal, rate, dates, and anticipation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages