Giter Club home page Giter Club logo

loancalculationlibrary's Introduction

Loan Calculation Library

Javaでローン計算を行うライブラリ

機能

  • 変動金利/固定金利
  • 元利均等 (5年・125%ルールあり/なし)
  • 元金均等
  • 返済途中での金利変更
  • 未払い利息計算
  • 繰り上げ返済 (返済額軽減型/期間短縮型)

各回の利率は年利÷12で計算する。
実際のローンでは初回の利息が日割りになることがあるが、このライブラリでは対応していない。
繰り上げ返済は毎月の返済と同時に処理する。
最終回の残債が少ない場合はゼロになるように返済元本を調整する。ただし、元利均等で残元本や未払い利息が多額の場合は返済元本には組み入れていない。
ボーナス払いは未対応。

Javaバージョン

Java 1.7以上

主要クラス

モデル (nx.domain.loan.model)
  • LoanInfo - 借入額、利率、期間など、ローン設定時の初期条件を保持。
  • PaymentRecord - 各返済回の元金、利息、利率、繰上額、残元本などを保持。
  • LoanResult - ローンの集計結果。支払総額などを保持。
償還表 (nx.domain.loan.payment)
  • ConstantPaymentStandard - 元利均等の償還表(5年・125%ルールあり)
  • ConstantPaymentSimple - 元利均等の償還表(5年・125%ルールなし)
  • EqualPrincipalPayment - 元金均等の償還表

利用方法

  1. 条件を決めてLoanInfoを作成。
  2. 1のLoanInfoを引数にしていずれかの償還表を作成。ここで全返済回の金額が計算される。
  3. 返済途中での利率変更(changeRate())や繰り上げ返済(prepayment())が必要なら適宜メソッドを呼び出し。
  4. 初回から最終回までの償還表を出力。

サンプルプログラム

  • nx.domain.loan.sample.ConstantPaymentCalculator
    3000万円/35年/年利1%/元利均等の条件で借りた場合の償還表を出力する。
    コマンドラインオプションにより、借入額、期間、利率を設定可能。
    出力例

  • 返済途中の利率変更や繰り上げ返済の処理方法は単体試験を参照。

loancalculationlibrary's People

Contributors

tnakagome avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.