repaykit 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. repaykit-1.0.0/.github/workflows/ci.yml +29 -0
  2. repaykit-1.0.0/.github/workflows/publish.yml +27 -0
  3. repaykit-1.0.0/.gitignore +218 -0
  4. repaykit-1.0.0/CHANGELOG.md +39 -0
  5. repaykit-1.0.0/CODE_OF_CONDUCT.md +8 -0
  6. repaykit-1.0.0/CONTRIBUTING.md +27 -0
  7. repaykit-1.0.0/LICENSE +21 -0
  8. repaykit-1.0.0/PKG-INFO +285 -0
  9. repaykit-1.0.0/README.md +252 -0
  10. repaykit-1.0.0/SECURITY.md +14 -0
  11. repaykit-1.0.0/docs/api.md +79 -0
  12. repaykit-1.0.0/docs/concepts.md +43 -0
  13. repaykit-1.0.0/docs/index.md +13 -0
  14. repaykit-1.0.0/docs/ledger.md +29 -0
  15. repaykit-1.0.0/docs/methods.md +41 -0
  16. repaykit-1.0.0/docs/quickstart.md +24 -0
  17. repaykit-1.0.0/docs/release.md +28 -0
  18. repaykit-1.0.0/docs/schedules.md +35 -0
  19. repaykit-1.0.0/docs/settlement.md +33 -0
  20. repaykit-1.0.0/pyproject.toml +73 -0
  21. repaykit-1.0.0/repaykit/__init__.py +18 -0
  22. repaykit-1.0.0/repaykit/_serialization.py +28 -0
  23. repaykit-1.0.0/repaykit/account.py +98 -0
  24. repaykit-1.0.0/repaykit/accruals/__init__.py +8 -0
  25. repaykit-1.0.0/repaykit/accruals/base.py +25 -0
  26. repaykit-1.0.0/repaykit/accruals/daily.py +18 -0
  27. repaykit-1.0.0/repaykit/accruals/flat.py +14 -0
  28. repaykit-1.0.0/repaykit/accruals/periodic.py +12 -0
  29. repaykit-1.0.0/repaykit/backends/README.md +12 -0
  30. repaykit-1.0.0/repaykit/enums.py +21 -0
  31. repaykit-1.0.0/repaykit/exceptions.py +21 -0
  32. repaykit-1.0.0/repaykit/exporters/__init__.py +12 -0
  33. repaykit-1.0.0/repaykit/exporters/csv.py +35 -0
  34. repaykit-1.0.0/repaykit/exporters/dicts.py +19 -0
  35. repaykit-1.0.0/repaykit/ledger/__init__.py +7 -0
  36. repaykit-1.0.0/repaykit/ledger/account_statement.py +5 -0
  37. repaykit-1.0.0/repaykit/ledger/payment.py +25 -0
  38. repaykit-1.0.0/repaykit/ledger/transaction.py +17 -0
  39. repaykit-1.0.0/repaykit/loan.py +157 -0
  40. repaykit-1.0.0/repaykit/methods/__init__.py +15 -0
  41. repaykit-1.0.0/repaykit/methods/base.py +46 -0
  42. repaykit-1.0.0/repaykit/methods/constant_principal.py +77 -0
  43. repaykit-1.0.0/repaykit/methods/flat_rate.py +93 -0
  44. repaykit-1.0.0/repaykit/methods/reducing_balance.py +85 -0
  45. repaykit-1.0.0/repaykit/methods/sum_of_digits.py +96 -0
  46. repaykit-1.0.0/repaykit/money.py +37 -0
  47. repaykit-1.0.0/repaykit/policies/__init__.py +14 -0
  48. repaykit-1.0.0/repaykit/policies/allocation.py +21 -0
  49. repaykit-1.0.0/repaykit/policies/late_charge.py +63 -0
  50. repaykit-1.0.0/repaykit/policies/rounding.py +36 -0
  51. repaykit-1.0.0/repaykit/policies/settlement.py +66 -0
  52. repaykit-1.0.0/repaykit/py.typed +1 -0
  53. repaykit-1.0.0/repaykit/results.py +58 -0
  54. repaykit-1.0.0/repaykit/schedules/__init__.py +21 -0
  55. repaykit-1.0.0/repaykit/schedules/base.py +48 -0
  56. repaykit-1.0.0/repaykit/schedules/biweekly.py +18 -0
  57. repaykit-1.0.0/repaykit/schedules/custom.py +42 -0
  58. repaykit-1.0.0/repaykit/schedules/daily.py +28 -0
  59. repaykit-1.0.0/repaykit/schedules/monthly.py +29 -0
  60. repaykit-1.0.0/repaykit/schedules/quarterly.py +20 -0
  61. repaykit-1.0.0/repaykit/schedules/weekly.py +23 -0
  62. repaykit-1.0.0/repaykit/schedules/yearly.py +20 -0
  63. repaykit-1.0.0/repaykit/terms/__init__.py +5 -0
  64. repaykit-1.0.0/repaykit/terms/term.py +85 -0
  65. repaykit-1.0.0/tests/test_constant_principal.py +73 -0
  66. repaykit-1.0.0/tests/test_exporters.py +73 -0
  67. repaykit-1.0.0/tests/test_flat_rate.py +107 -0
  68. repaykit-1.0.0/tests/test_full_settlement.py +244 -0
  69. repaykit-1.0.0/tests/test_invariants.py +80 -0
  70. repaykit-1.0.0/tests/test_late_charges.py +147 -0
  71. repaykit-1.0.0/tests/test_payment_ledger.py +170 -0
  72. repaykit-1.0.0/tests/test_public_api.py +69 -0
  73. repaykit-1.0.0/tests/test_reducing_balance.py +90 -0
  74. repaykit-1.0.0/tests/test_rounding.py +43 -0
  75. repaykit-1.0.0/tests/test_schedules.py +124 -0
  76. repaykit-1.0.0/tests/test_sum_of_digits.py +117 -0
  77. repaykit-1.0.0/tests/test_validation.py +125 -0
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.11", "3.12", "3.13"]
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+ - uses: actions/setup-python@v6
16
+ with:
17
+ python-version: ${{ matrix.python-version }}
18
+ - name: Install package
19
+ run: python -m pip install -e ".[dev]"
20
+ - name: Ruff
21
+ run: python -m ruff check .
22
+ - name: Mypy
23
+ run: python -m mypy repaykit
24
+ - name: Pytest
25
+ run: python -m pytest --cov=repaykit --cov-report=term-missing
26
+ - name: Build
27
+ run: python -m build
28
+ - name: Twine check
29
+ run: python -m twine check dist/*
@@ -0,0 +1,27 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+ id-token: write
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ environment: pypi
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ - uses: actions/setup-python@v6
18
+ with:
19
+ python-version: "3.13"
20
+ - name: Install build tools
21
+ run: python -m pip install build twine
22
+ - name: Build package
23
+ run: python -m build
24
+ - name: Check distribution metadata
25
+ run: python -m twine check dist/*
26
+ - name: Publish to PyPI
27
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ Keep a Changelog, and the project uses Semantic Versioning.
5
+
6
+ ## [1.0.0] - 2026-05-26
7
+
8
+ ### Added
9
+
10
+ - Stable public API for `Loan`, `LoanAccount`, result objects, schedules, accruals, methods,
11
+ policies, ledger objects, and exporters.
12
+ - Flat rate repayment schedules.
13
+ - Sum-of-digits / Rule of 78 repayment schedules.
14
+ - Reducing balance repayment schedules.
15
+ - Constant principal repayment schedules.
16
+ - Daily, weekly, biweekly, monthly, quarterly, yearly, and custom schedules.
17
+ - Payment ledger with aggregate oldest-due-first statement allocation.
18
+ - Configurable late charge policy.
19
+ - Settlement quote generation with method-specific unearned profit rebate behavior.
20
+ - Explicit rounding policy for money and rates.
21
+ - Dict and CSV export helpers that serialize `Decimal` as strings and dates as ISO strings.
22
+ - Type hints and `py.typed` marker.
23
+ - PyPI packaging with Hatchling.
24
+ - CI workflow for Ruff, mypy, pytest with coverage, build, and Twine checks.
25
+ - PyPI Trusted Publishing release workflow.
26
+
27
+ ### Changed
28
+
29
+ - Hardened public validation for Decimal money/rate inputs and payment dates.
30
+ - Single-sourced package version from `repaykit.__version__`.
31
+
32
+ ### Fixed
33
+
34
+ - Flat-rate rows now keep `installment == principal + profit` while final rows absorb rounding
35
+ drift.
36
+
37
+ ### Security
38
+
39
+ - Added security reporting policy and release hygiene documentation.
@@ -0,0 +1,8 @@
1
+ # Code of Conduct
2
+
3
+ This project is intended to be a professional, respectful space for maintainers and contributors.
4
+
5
+ Be kind, direct, and constructive. Harassment, discrimination, personal attacks, and bad-faith
6
+ conduct are not acceptable.
7
+
8
+ Report conduct concerns privately to the maintainers through the repository contact channels.
@@ -0,0 +1,27 @@
1
+ # Contributing
2
+
3
+ Thank you for helping improve `repaykit`.
4
+
5
+ ## Development
6
+
7
+ ```bash
8
+ python -m pip install -e ".[dev]"
9
+ python -m ruff check .
10
+ python -m mypy repaykit
11
+ python -m pytest --cov=repaykit --cov-report=term-missing
12
+ python -m build
13
+ python -m twine check dist/*
14
+ ```
15
+
16
+ Use `Decimal` for all money and rates. Do not introduce framework dependencies into the core
17
+ package.
18
+
19
+ ## Calculation Changes
20
+
21
+ Calculation changes need tests that cover exact expected values where the result is contractual,
22
+ and invariant tests where exact pennies are policy-dependent. Document any new business rule as a
23
+ policy choice rather than a legal or regulatory assumption.
24
+
25
+ ## Public API
26
+
27
+ After 1.0.0, breaking public API changes require a major version bump.
repaykit-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 finsure techlab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,285 @@
1
+ Metadata-Version: 2.4
2
+ Name: repaykit
3
+ Version: 1.0.0
4
+ Summary: Pure Python repayment schedule, financing, loan ledger, and settlement calculation toolkit.
5
+ Project-URL: Homepage, https://github.com/finsure-techlab/repaykit
6
+ Project-URL: Repository, https://github.com/finsure-techlab/repaykit
7
+ Project-URL: Issues, https://github.com/finsure-techlab/repaykit/issues
8
+ Author: finsure techlab
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: amortization,financing,ledger,loan,repayment,settlement
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Office/Business :: Financial
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Provides-Extra: dev
25
+ Requires-Dist: build; extra == 'dev'
26
+ Requires-Dist: coverage; extra == 'dev'
27
+ Requires-Dist: mypy; extra == 'dev'
28
+ Requires-Dist: pytest; extra == 'dev'
29
+ Requires-Dist: pytest-cov; extra == 'dev'
30
+ Requires-Dist: ruff; extra == 'dev'
31
+ Requires-Dist: twine; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # repaykit
35
+
36
+ Pure Python repayment schedule, financing, loan ledger, and settlement calculation toolkit.
37
+
38
+ `repaykit` helps software teams calculate loan and financing schedules, payment ledgers, late
39
+ charges, statement balances, and settlement quotes. It is framework-agnostic, uses `Decimal` for
40
+ money and rates, and keeps business rules policy-driven.
41
+
42
+ ## What It Is Not
43
+
44
+ `repaykit` is not a loan origination system, accounting system, regulatory compliance engine, or
45
+ legal opinion. It does not provide legal, accounting, tax, Shariah, regulatory, lending, or
46
+ financial advice. Users are responsible for validating calculations, policies, disclosures, and
47
+ compliance requirements for their jurisdiction and product.
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pip install repaykit
53
+ ```
54
+
55
+ ## Supported Methods
56
+
57
+ - Flat rate
58
+ - Sum-of-digits / Rule of 78
59
+ - Reducing balance amortization
60
+ - Constant principal repayment
61
+
62
+ ## Supported Schedules
63
+
64
+ - Daily, with optional weekend skipping
65
+ - Weekly
66
+ - Biweekly
67
+ - Monthly, with month-end safety
68
+ - Quarterly
69
+ - Yearly
70
+ - Custom explicit due dates
71
+
72
+ ## Quickstart
73
+
74
+ ```python
75
+ from datetime import date
76
+ from decimal import Decimal
77
+
78
+ from repaykit import Loan
79
+
80
+ loan = Loan.create(
81
+ amount=Decimal("10000.00"),
82
+ annual_rate=Decimal("0.08"),
83
+ term="24 months",
84
+ payment_frequency="monthly",
85
+ method="flat_rate",
86
+ start_date=date(2026, 6, 1),
87
+ )
88
+
89
+ payment = loan.payment_amount()
90
+ rows = loan.schedule()
91
+ ```
92
+
93
+ Use `iter_schedule()` for lazy row generation, especially for daily schedules.
94
+
95
+ ## Expert Mode
96
+
97
+ ```python
98
+ from datetime import date
99
+ from decimal import Decimal
100
+
101
+ from repaykit import Loan
102
+ from repaykit.accruals import FlatAccrual
103
+ from repaykit.methods import FlatRateAllocation
104
+ from repaykit.policies import RoundingPolicy
105
+ from repaykit.schedules import MonthlySchedule
106
+ from repaykit.terms import Term
107
+
108
+ loan = Loan(
109
+ principal=Decimal("10000.00"),
110
+ term=Term(months=24),
111
+ payment_schedule=MonthlySchedule(day=1),
112
+ accrual_policy=FlatAccrual(annual_rate=Decimal("0.08")),
113
+ repayment_method=FlatRateAllocation(),
114
+ rounding=RoundingPolicy(currency="MYR"),
115
+ start_date=date(2026, 6, 1),
116
+ )
117
+ ```
118
+
119
+ ## Flat Rate Example
120
+
121
+ ```python
122
+ loan = Loan.create(
123
+ amount=Decimal("10000.00"),
124
+ annual_rate=Decimal("0.08"),
125
+ term="24 months",
126
+ payment_frequency="monthly",
127
+ method="flat_rate",
128
+ start_date=date(2026, 6, 1),
129
+ )
130
+ ```
131
+
132
+ Flat-rate total profit is `principal * annual_rate * term_in_years`. Future scheduled profit is
133
+ treated as unearned profit rebate in the default settlement policy.
134
+
135
+ ## Sum-of-Digits / Rule of 78 Example
136
+
137
+ ```python
138
+ loan = Loan.create(
139
+ amount=Decimal("10000.00"),
140
+ annual_rate=Decimal("0.08"),
141
+ term="12 months",
142
+ payment_frequency="monthly",
143
+ method="sum_of_digits",
144
+ start_date=date(2026, 1, 1),
145
+ )
146
+ ```
147
+
148
+ The denominator is generalized as `n * (n + 1) / 2`, so the method works with non-monthly period
149
+ counts such as 52 weekly periods.
150
+
151
+ ## Reducing Balance Example
152
+
153
+ ```python
154
+ loan = Loan.create(
155
+ amount=Decimal("10000.00"),
156
+ annual_rate=Decimal("0.08"),
157
+ term="24 months",
158
+ payment_frequency="monthly",
159
+ method="reducing_balance",
160
+ start_date=date(2026, 6, 1),
161
+ )
162
+ ```
163
+
164
+ Reducing balance uses fixed-payment amortization. Profit is calculated on the outstanding balance
165
+ for each period.
166
+
167
+ ## Constant Principal Example
168
+
169
+ ```python
170
+ loan = Loan.create(
171
+ amount=Decimal("10000.00"),
172
+ annual_rate=Decimal("0.08"),
173
+ term="24 months",
174
+ payment_frequency="monthly",
175
+ method="constant_principal",
176
+ start_date=date(2026, 6, 1),
177
+ )
178
+ ```
179
+
180
+ The principal component is constant except for the final rounding adjustment; installments decline
181
+ as profit declines.
182
+
183
+ ## Weekly Payment Example
184
+
185
+ ```python
186
+ loan = Loan.create(
187
+ amount=Decimal("5000.00"),
188
+ annual_rate=Decimal("0.10"),
189
+ term="52 weeks",
190
+ payment_frequency="weekly",
191
+ method="constant_principal",
192
+ start_date=date(2026, 1, 1),
193
+ )
194
+ ```
195
+
196
+ ## Daily Payment Example
197
+
198
+ ```python
199
+ loan = Loan.create(
200
+ amount=Decimal("1000.00"),
201
+ annual_rate=Decimal("0.12"),
202
+ term="30 days",
203
+ payment_frequency="daily",
204
+ method="reducing_balance",
205
+ start_date=date(2026, 1, 1),
206
+ )
207
+ ```
208
+
209
+ ## Payment Ledger Example
210
+
211
+ ```python
212
+ from repaykit import LoanAccount
213
+
214
+ account = LoanAccount(loan)
215
+ account.add_payment(
216
+ amount=Decimal("500.00"),
217
+ paid_at=date(2026, 7, 5),
218
+ reference="ANGKASA-JULY-2026",
219
+ )
220
+
221
+ statement = account.statement(as_of=date(2026, 8, 1))
222
+ print(statement.total_due)
223
+ print(statement.total_paid)
224
+ print(statement.arrears)
225
+ print(statement.outstanding_balance)
226
+ ```
227
+
228
+ Statements use aggregate oldest-due-first allocation for due installments and late-charge exposure.
229
+ They do not maintain a double-entry accounting ledger or split each payment into principal/profit
230
+ transactions.
231
+
232
+ ## Late Charge Example
233
+
234
+ ```python
235
+ from repaykit.policies import LateChargePolicy
236
+
237
+ loan.late_charge_policy = LateChargePolicy(
238
+ rate=Decimal("0.01"),
239
+ grace_days=5,
240
+ basis="flat",
241
+ minimum_charge=Decimal("0.00"),
242
+ )
243
+ ```
244
+
245
+ Supported bases are `flat` and `daily`. Negative overdue amounts are treated as zero.
246
+
247
+ ## Settlement Example
248
+
249
+ ```python
250
+ settlement = account.full_settlement(as_of=date(2026, 12, 15))
251
+
252
+ print(settlement.outstanding_principal)
253
+ print(settlement.unearned_profit_rebate)
254
+ print(settlement.late_charges)
255
+ print(settlement.amount_payable)
256
+ print(settlement.explanation)
257
+ ```
258
+
259
+ Settlement is policy-based. Flat-rate and sum-of-digits methods rebate future scheduled profit by
260
+ default. Reducing-balance and constant-principal methods have no unearned profit rebate by default.
261
+ Validate settlement behavior against your contract and regulatory requirements.
262
+
263
+ ## Export Example
264
+
265
+ ```python
266
+ from repaykit.exporters import schedule_to_csv, schedule_to_dicts
267
+
268
+ rows = loan.schedule()
269
+ data = schedule_to_dicts(rows)
270
+ schedule_to_csv(rows, "schedule.csv")
271
+ ```
272
+
273
+ Exporters serialize `Decimal` values as strings and dates as ISO strings. They never convert money
274
+ to floats.
275
+
276
+ ## Rounding Warning
277
+
278
+ The default `RoundingPolicy` uses half-up money rounding with two decimal places. Different
279
+ institutions and jurisdictions may require different rounding points, decimal places, or settlement
280
+ rebate rules. Configure and test policies against the governing contract and regulation.
281
+
282
+ ## Release Status
283
+
284
+ Version 1.0.0 declares the public API documented in `docs/api.md`. Breaking public API changes
285
+ after 1.0.0 require a major version bump.