tieout 0.1.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.
- tieout-0.1.0/.editorconfig +15 -0
- tieout-0.1.0/.gitattributes +5 -0
- tieout-0.1.0/.github/workflows/ci.yml +34 -0
- tieout-0.1.0/.github/workflows/release.yml +78 -0
- tieout-0.1.0/.gitignore +28 -0
- tieout-0.1.0/CHANGELOG.md +51 -0
- tieout-0.1.0/LICENSE +202 -0
- tieout-0.1.0/PKG-INFO +177 -0
- tieout-0.1.0/README.md +149 -0
- tieout-0.1.0/benchmarks/bench_matching.py +117 -0
- tieout-0.1.0/docs/adr/0001-technology-stack.md +41 -0
- tieout-0.1.0/docs/design/PRODUCT.md +358 -0
- tieout-0.1.0/docs/design/RESEARCH.md +156 -0
- tieout-0.1.0/examples/stripe-to-bank/data/bank_statement.camt053.xml +40 -0
- tieout-0.1.0/examples/stripe-to-bank/data/stripe_itemized_payouts.csv +8 -0
- tieout-0.1.0/examples/stripe-to-bank/recon.yaml +18 -0
- tieout-0.1.0/pyproject.toml +96 -0
- tieout-0.1.0/src/tieout/__init__.py +39 -0
- tieout-0.1.0/src/tieout/cli.py +121 -0
- tieout-0.1.0/src/tieout/conditions.py +226 -0
- tieout-0.1.0/src/tieout/connectors/__init__.py +122 -0
- tieout-0.1.0/src/tieout/connectors/camt.py +546 -0
- tieout-0.1.0/src/tieout/connectors/csv.py +337 -0
- tieout-0.1.0/src/tieout/connectors/stripe.py +265 -0
- tieout-0.1.0/src/tieout/engine.py +332 -0
- tieout-0.1.0/src/tieout/errors.py +41 -0
- tieout-0.1.0/src/tieout/matching.py +249 -0
- tieout-0.1.0/src/tieout/money.py +204 -0
- tieout-0.1.0/src/tieout/py.typed +0 -0
- tieout-0.1.0/src/tieout/records.py +190 -0
- tieout-0.1.0/src/tieout/report.py +249 -0
- tieout-0.1.0/src/tieout/result.py +104 -0
- tieout-0.1.0/src/tieout/spec.py +217 -0
- tieout-0.1.0/src/tieout/subset_search.py +230 -0
- tieout-0.1.0/tests/fixtures/bank_camt053.xml +87 -0
- tieout-0.1.0/tests/fixtures/ledger.csv +5 -0
- tieout-0.1.0/tests/fixtures/stripe_payouts.csv +5 -0
- tieout-0.1.0/tests/test_cli.py +183 -0
- tieout-0.1.0/tests/test_connectors.py +275 -0
- tieout-0.1.0/tests/test_engine.py +417 -0
- tieout-0.1.0/tests/test_guarantees.py +537 -0
- tieout-0.1.0/tests/test_money.py +172 -0
- tieout-0.1.0/tests/test_properties.py +308 -0
- tieout-0.1.0/tests/test_spec.py +151 -0
- tieout-0.1.0/uv.lock +906 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 4
|
|
10
|
+
|
|
11
|
+
[*.{yaml,yml,toml,json,md}]
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
name: Python ${{ matrix.python }} on ${{ matrix.os }}
|
|
14
|
+
runs-on: ${{ matrix.os }}
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
os: [ubuntu-latest]
|
|
19
|
+
python: ["3.11", "3.12", "3.13"]
|
|
20
|
+
include:
|
|
21
|
+
- os: windows-latest
|
|
22
|
+
python: "3.12"
|
|
23
|
+
- os: macos-latest
|
|
24
|
+
python: "3.12"
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: astral-sh/setup-uv@v6
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python }}
|
|
30
|
+
- run: uv sync --locked
|
|
31
|
+
- run: uv run ruff format --check .
|
|
32
|
+
- run: uv run ruff check .
|
|
33
|
+
- run: uv run mypy
|
|
34
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Push a tag such as v0.1.0 to build, test and publish a GitHub release.
|
|
4
|
+
# Publishing to PyPI uses trusted publishing and stays off until the repository
|
|
5
|
+
# variable PYPI_PUBLISH is set to "true" and a trusted publisher is configured on
|
|
6
|
+
# pypi.org for this workflow and the "pypi" environment.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags: ["v*"]
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: astral-sh/setup-uv@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
- name: Check the tag matches the package version
|
|
24
|
+
run: |
|
|
25
|
+
version=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
26
|
+
test "v${version}" = "${GITHUB_REF_NAME}" || { echo "tag ${GITHUB_REF_NAME} != v${version}"; exit 1; }
|
|
27
|
+
- run: uv sync --locked
|
|
28
|
+
- run: uv run pytest
|
|
29
|
+
- run: uv build
|
|
30
|
+
- name: Smoke-test the wheel
|
|
31
|
+
run: |
|
|
32
|
+
uv venv /tmp/smoke
|
|
33
|
+
uv pip install --python /tmp/smoke dist/*.whl
|
|
34
|
+
/tmp/smoke/bin/tieout --version
|
|
35
|
+
- uses: actions/upload-artifact@v4
|
|
36
|
+
with:
|
|
37
|
+
name: dist
|
|
38
|
+
path: dist/
|
|
39
|
+
|
|
40
|
+
github-release:
|
|
41
|
+
needs: build
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
permissions:
|
|
44
|
+
contents: write
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: actions/download-artifact@v4
|
|
48
|
+
with:
|
|
49
|
+
name: dist
|
|
50
|
+
path: dist/
|
|
51
|
+
- name: Extract release notes from the changelog
|
|
52
|
+
run: |
|
|
53
|
+
version="${GITHUB_REF_NAME#v}"
|
|
54
|
+
awk -v v="$version" '
|
|
55
|
+
$0 ~ "^## \\[" v "\\]" { found = 1; next }
|
|
56
|
+
found && /^## \[/ { exit }
|
|
57
|
+
found && /^\[[^]]+\]: / { exit }
|
|
58
|
+
found { print }
|
|
59
|
+
' CHANGELOG.md > notes.md
|
|
60
|
+
test -s notes.md
|
|
61
|
+
- name: Create the release
|
|
62
|
+
env:
|
|
63
|
+
GH_TOKEN: ${{ github.token }}
|
|
64
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --notes-file notes.md --verify-tag
|
|
65
|
+
|
|
66
|
+
pypi:
|
|
67
|
+
needs: build
|
|
68
|
+
if: vars.PYPI_PUBLISH == 'true'
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
environment: pypi
|
|
71
|
+
permissions:
|
|
72
|
+
id-token: write
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/download-artifact@v4
|
|
75
|
+
with:
|
|
76
|
+
name: dist
|
|
77
|
+
path: dist/
|
|
78
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
tieout-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Private planning material, not part of the open-source project
|
|
2
|
+
/archive/
|
|
3
|
+
|
|
4
|
+
# Python
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.egg-info/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
.venv/
|
|
11
|
+
|
|
12
|
+
# Tooling caches
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
.hypothesis/
|
|
17
|
+
.coverage
|
|
18
|
+
htmlcov/
|
|
19
|
+
|
|
20
|
+
# Local run output
|
|
21
|
+
/out/
|
|
22
|
+
/results/
|
|
23
|
+
|
|
24
|
+
# Editors and OS
|
|
25
|
+
.idea/
|
|
26
|
+
.vscode/
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/). Before 1.0, minor versions may change
|
|
6
|
+
the rule format and the Python API.
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-11-15
|
|
9
|
+
|
|
10
|
+
First public release.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Matching engine with `one_to_one`, `one_to_many` and `many_to_one` rules:
|
|
15
|
+
amount tolerance and sign conventions, date windows on value or booking date,
|
|
16
|
+
normalised reference checks, and grouping by shared key or bounded subset search.
|
|
17
|
+
- Connectors for generic CSV, ISO 20022 camt.053 / camt.054, and Stripe itemized
|
|
18
|
+
payout reconciliation reports.
|
|
19
|
+
- `tieout validate` and `tieout run` commands with a terminal summary, JSON and
|
|
20
|
+
CSV reports, and `--fail-on-breaks` for CI use.
|
|
21
|
+
- YAML specs validated strictly: unknown keys, duplicate keys, impossible date
|
|
22
|
+
windows and rule fields a source cannot produce are rejected before any input
|
|
23
|
+
is read.
|
|
24
|
+
|
|
25
|
+
### Guarantees
|
|
26
|
+
|
|
27
|
+
- **Exact money.** Integer minor units, scaled by the ISO 4217 exponent
|
|
28
|
+
(list of 2026-09-17). Unknown currencies, unrepresentable amounts (`10.005 USD`),
|
|
29
|
+
malformed digit grouping and non-ASCII digits are errors, never roundings.
|
|
30
|
+
`register_currency()` declares private or crypto codes.
|
|
31
|
+
- **No guessing.** Pairs match only as mutual unique best candidates; ties become
|
|
32
|
+
`ambiguous` breaks with their candidates. A subset-search group is refused when
|
|
33
|
+
another target could also claim one of its members.
|
|
34
|
+
- **Every record accounted for.** Each record is in exactly one match or one break,
|
|
35
|
+
and rows a connector filters out are listed with their location. The invariants
|
|
36
|
+
are re-checked at the end of every run.
|
|
37
|
+
- **Reproducible.** Record ids come from natural keys or content, so shuffled input
|
|
38
|
+
rows give the same matches, breaks and run id. Raw-file SHA-256 digests are kept
|
|
39
|
+
in the run log. Search limits count steps, not seconds.
|
|
40
|
+
- **Fail-closed parsing.** Hostile XML, duplicate, missing or misaligned CSV
|
|
41
|
+
columns, unbalanced quotes, and camt statements whose balances or `TxsSummry`
|
|
42
|
+
totals don't add up are rejected with the file and line or entry. A missing
|
|
43
|
+
value date is never filled in from the booking date.
|
|
44
|
+
- **Correct dates and signs.** Stripe `*_utc` columns are preferred, other columns
|
|
45
|
+
need `report_timezone`; camt reversals follow ISO 20022 (`CdtDbtInd` is the
|
|
46
|
+
entry's own direction), with `reversal_sign: flipped` for banks that differ.
|
|
47
|
+
- **Explained and safe output.** Every match states its rule, totals, residual,
|
|
48
|
+
date gap and the reference values that agreed. CSV reports neutralise
|
|
49
|
+
spreadsheet formulas in text cells.
|
|
50
|
+
|
|
51
|
+
[0.1.0]: https://github.com/Vinay-K-Rajith/tieout/releases/tag/v0.1.0
|
tieout-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
tieout-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tieout
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open-source reconciliation engine: match bank, payment-provider, ledger and invoice records, with every match explained.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Vinay-K-Rajith/tieout
|
|
6
|
+
Project-URL: Issues, https://github.com/Vinay-K-Rajith/tieout/issues
|
|
7
|
+
Author: Vinay K Rajith
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: accounting,camt.053,finance,ledger,reconciliation,stripe
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: click>=8.1
|
|
23
|
+
Requires-Dist: defusedxml>=0.7.1
|
|
24
|
+
Requires-Dist: pydantic>=2.7
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: tzdata>=2024.1; sys_platform == 'win32'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# tieout
|
|
30
|
+
|
|
31
|
+
**An open-source reconciliation engine.** tieout matches money records across bank
|
|
32
|
+
statements, payment-provider reports, ledgers and invoices, and explains every match.
|
|
33
|
+
Anything it can't match with certainty comes back as a *break* with the reason. It
|
|
34
|
+
never guesses.
|
|
35
|
+
|
|
36
|
+
> Status: alpha (v0.1). The rule format and Python API may still change before v1.0.
|
|
37
|
+
> See the [changelog](CHANGELOG.md).
|
|
38
|
+
|
|
39
|
+
## Why
|
|
40
|
+
|
|
41
|
+
Every company that moves money has to prove its records agree: bank vs ledger,
|
|
42
|
+
Stripe payouts vs orders, invoices vs incoming payments. That work is still mostly
|
|
43
|
+
spreadsheets, and every fintech writes its own matcher. The open-source finance stack
|
|
44
|
+
has ledgers, payments, billing and AML, but no standalone reconciliation engine.
|
|
45
|
+
See [docs/design/PRODUCT.md](docs/design/PRODUCT.md) for the full case.
|
|
46
|
+
|
|
47
|
+
## What it guarantees
|
|
48
|
+
|
|
49
|
+
- **Exact money.** Amounts are integer minor units, scaled by the ISO 4217 exponent
|
|
50
|
+
of a currency that must exist (`USX` or `XAU` is an error, not "2 decimals").
|
|
51
|
+
A value that can't be represented exactly (`10.005 USD`) is an error, never a
|
|
52
|
+
rounding, and so is misplaced digit grouping (`1,23` read with `,` as the
|
|
53
|
+
thousands separator).
|
|
54
|
+
- **No guessing.** A pair is matched only when each side is the other's unique best
|
|
55
|
+
candidate. Ties are reported as `ambiguous` breaks, with the candidates listed.
|
|
56
|
+
A group found by subset search is refused if any other target could also use
|
|
57
|
+
one of its members.
|
|
58
|
+
- **Every record is accounted for.** Each input record ends up in exactly one match
|
|
59
|
+
or one break, duplicates included, and rows a connector filters out on purpose
|
|
60
|
+
(pending bank entries, Stripe payout lines) are listed with their location.
|
|
61
|
+
These invariants are re-checked at the end of every run; a violation aborts the
|
|
62
|
+
run instead of returning numbers that cannot be right.
|
|
63
|
+
- **Every match is explained.** The rule, the amounts, the date gap and the
|
|
64
|
+
reference values that agreed are all recorded in plain language.
|
|
65
|
+
- **Reproducible.** The same inputs, spec and engine version give the same output and
|
|
66
|
+
the same run id, even if the rows of a file are shuffled: record ids come from
|
|
67
|
+
content or natural keys, never from line numbers. The run log keeps the SHA-256
|
|
68
|
+
of each raw file as well. Search limits count steps, not seconds.
|
|
69
|
+
- **Fail-closed parsing.** Hostile XML, duplicate or missing CSV columns, short or
|
|
70
|
+
long rows, unbalanced quotes, and camt statements whose balances or totals don't
|
|
71
|
+
add up are rejected with the file and line or entry. A missing value date is
|
|
72
|
+
left missing, never filled in from the booking date.
|
|
73
|
+
- **Strict specs.** Unknown keys, duplicate YAML keys, impossible date windows and
|
|
74
|
+
rule fields a source cannot produce (`group: { by: payout_idd }`) fail before a
|
|
75
|
+
single record is read.
|
|
76
|
+
|
|
77
|
+
## Quick start
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install git+https://github.com/Vinay-K-Rajith/tieout@v0.1.0
|
|
81
|
+
tieout run examples/stripe-to-bank/recon.yaml \
|
|
82
|
+
--input stripe=examples/stripe-to-bank/data/stripe_itemized_payouts.csv \
|
|
83
|
+
--input bank=examples/stripe-to-bank/data/bank_statement.camt053.xml
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A spec declares sources and rules:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
version: 1
|
|
90
|
+
sources:
|
|
91
|
+
stripe: { format: stripe }
|
|
92
|
+
bank: { format: camt }
|
|
93
|
+
rules:
|
|
94
|
+
# All Stripe balance transactions of one payout must add up to one bank credit.
|
|
95
|
+
- id: payout-to-bank
|
|
96
|
+
left: stripe
|
|
97
|
+
right: bank
|
|
98
|
+
kind: many_to_one
|
|
99
|
+
group: { by: payout_id }
|
|
100
|
+
date: { min_days: 0, max_days: 4 }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or from Python:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from tieout import load_spec, reconcile
|
|
107
|
+
from tieout.connectors import read_source
|
|
108
|
+
|
|
109
|
+
spec = load_spec("recon.yaml")
|
|
110
|
+
sources = [read_source(name, path, spec.sources[name]) for name, path in inputs.items()]
|
|
111
|
+
result = reconcile(sources, spec)
|
|
112
|
+
|
|
113
|
+
for match in result.matches:
|
|
114
|
+
print(match.rule_id, match.left_ids, match.right_ids, *match.explanation, sep="\n ")
|
|
115
|
+
for item in result.breaks:
|
|
116
|
+
print(item.record_id, item.reason, item.detail)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Rules
|
|
120
|
+
|
|
121
|
+
| Kind | Meaning |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `one_to_one` | One left record against one right record |
|
|
124
|
+
| `one_to_many` | One left record equals the sum of several right records |
|
|
125
|
+
| `many_to_one` | Several left records sum to one right record |
|
|
126
|
+
|
|
127
|
+
Conditions, all optional:
|
|
128
|
+
|
|
129
|
+
| Condition | Example | Meaning |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `amount` | `{ tolerance: 50, sign: opposite }` | Totals agree within 50 minor units; `opposite` when the two sources use opposite signs |
|
|
132
|
+
| `date` | `{ min_days: 0, max_days: 3 }` | Right date minus left date is 0 to 3 days, for every record pair |
|
|
133
|
+
| `references` | `[{ left: invoice_no, right: description, op: left_in_right }]` | Normalised references agree (case and punctuation ignored). Containment matches whole tokens only, and needles shorter than `min_length` (default 4) never match: `INV-0042` is found in `Payment for inv 0042`, `7712` is not found in `Payment #77712` |
|
|
134
|
+
| `group` | `{ by: payout_id }` or `{ max_size: 4 }` | Group by a shared field, or search for subsets of up to 4 records |
|
|
135
|
+
|
|
136
|
+
Rules run in `priority` order (lower first). Put exact rules before tolerant ones.
|
|
137
|
+
|
|
138
|
+
## Connectors
|
|
139
|
+
|
|
140
|
+
| Format | `format:` | Notes |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| Any CSV, with a column mapping | `csv` | Signed amount column or separate inflow/outflow columns; configurable separators and date format |
|
|
143
|
+
| ISO 20022 camt.053 / camt.054 | `camt` | Booked entries by default; one record per entry. Checks opening + entries = closing balance and `TxsSummry` (`verify_balances: false` to skip). `RvslInd` marks a reversal but does not flip the sign: per ISO, `CdtDbtInd` already gives the entry's direction. For a bank that puts the original entry's direction there instead, set `reversal_sign: flipped`; the balance checks reject the wrong setting |
|
|
144
|
+
| Stripe itemized payout reconciliation report | `stripe` | Net amounts, grouped by payout. Dates are taken in `timezone`; `*_utc` columns are preferred, and other columns need `report_timezone` (the zone the report was requested in) unless both are UTC |
|
|
145
|
+
|
|
146
|
+
## Project layout
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
src/tieout/
|
|
150
|
+
money.py exact amounts and currencies
|
|
151
|
+
records.py the canonical Record and Source
|
|
152
|
+
spec.py the YAML spec: sources and rules
|
|
153
|
+
conditions.py what each rule condition means, and how it is explained
|
|
154
|
+
matching.py candidate search and mutual-best resolution
|
|
155
|
+
subset_search.py bounded search for many-to-one groups
|
|
156
|
+
engine.py a reconciliation run, start to finish
|
|
157
|
+
result.py matches, breaks and run metadata
|
|
158
|
+
report.py JSON and CSV output
|
|
159
|
+
cli.py the `tieout` command
|
|
160
|
+
connectors/ one module per input format
|
|
161
|
+
tests/ mirrors src/, plus fixtures/
|
|
162
|
+
docs/adr/ architecture decisions
|
|
163
|
+
examples/ runnable end-to-end examples
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install uv
|
|
170
|
+
uv sync
|
|
171
|
+
uv run pytest
|
|
172
|
+
uv run ruff check . && uv run ruff format --check . && uv run mypy
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
Apache-2.0. See [LICENSE](LICENSE).
|