camt053 0.0.1__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.
- camt053-0.0.1/LICENSE +189 -0
- camt053-0.0.1/PKG-INFO +338 -0
- camt053-0.0.1/README.md +304 -0
- camt053-0.0.1/camt053/__init__.py +27 -0
- camt053-0.0.1/camt053/__main__.py +22 -0
- camt053-0.0.1/camt053/api/__init__.py +20 -0
- camt053-0.0.1/camt053/api/app.py +131 -0
- camt053-0.0.1/camt053/api/models.py +61 -0
- camt053-0.0.1/camt053/cli/__init__.py +20 -0
- camt053-0.0.1/camt053/cli/cli.py +215 -0
- camt053-0.0.1/camt053/constants.py +93 -0
- camt053-0.0.1/camt053/exceptions.py +384 -0
- camt053-0.0.1/camt053/models.py +225 -0
- camt053-0.0.1/camt053/parse/__init__.py +31 -0
- camt053-0.0.1/camt053/parse/reason_codes.py +61 -0
- camt053-0.0.1/camt053/parse/statement_parser.py +325 -0
- camt053-0.0.1/camt053/reversal/__init__.py +23 -0
- camt053-0.0.1/camt053/reversal/reversal.py +196 -0
- camt053-0.0.1/camt053/schemas/camt.052.001.14.schema.json +147 -0
- camt053-0.0.1/camt053/schemas/camt.053.001.14.schema.json +141 -0
- camt053-0.0.1/camt053/schemas/camt.054.001.14.schema.json +147 -0
- camt053-0.0.1/camt053/security/__init__.py +20 -0
- camt053-0.0.1/camt053/security/path_validator.py +142 -0
- camt053-0.0.1/camt053/services.py +341 -0
- camt053-0.0.1/camt053/templates/camt.053.001.14/camt.053.001.14.xsd +2169 -0
- camt053-0.0.1/camt053/templates/camt.053.001.14/template.xml +70 -0
- camt053-0.0.1/camt053/validation/__init__.py +62 -0
- camt053-0.0.1/camt053/validation/bic_validator.py +283 -0
- camt053-0.0.1/camt053/validation/iban_validator.py +317 -0
- camt053-0.0.1/camt053/validation/lei_validator.py +222 -0
- camt053-0.0.1/camt053/validation/schema_validator.py +253 -0
- camt053-0.0.1/camt053/xml/__init__.py +34 -0
- camt053-0.0.1/camt053/xml/generate_xml.py +180 -0
- camt053-0.0.1/camt053/xml/validate_via_xsd.py +113 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.01.xsd +1183 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.02.xsd +1298 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.03.xsd +1811 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.04.xsd +1765 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.05.xsd +1905 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.06.xsd +1946 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.07.xsd +1997 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.08.xsd +2070 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.09.xsd +2073 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.10.xsd +2131 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.11.xsd +2139 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.12.xsd +2103 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.13.xsd +2161 -0
- camt053-0.0.1/camt053/xsd/camt.052.001.14.xsd +2169 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.01.xsd +1177 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.02.xsd +1298 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.03.xsd +1810 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.04.xsd +1764 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.05.xsd +1905 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.06.xsd +1946 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.07.xsd +1997 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.08.xsd +2070 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.09.xsd +2073 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.10.xsd +2131 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.11.xsd +2139 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.12.xsd +2103 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.13.xsd +2161 -0
- camt053-0.0.1/camt053/xsd/camt.053.001.14.xsd +2169 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.01.xsd +1111 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.02.xsd +1239 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.03.xsd +1751 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.04.xsd +1709 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.05.xsd +1850 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.06.xsd +1891 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.07.xsd +1936 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.08.xsd +2009 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.09.xsd +2012 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.10.xsd +2070 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.11.xsd +2078 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.12.xsd +2042 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.13.xsd +2100 -0
- camt053-0.0.1/camt053/xsd/camt.054.001.14.xsd +2108 -0
- camt053-0.0.1/pyproject.toml +178 -0
camt053-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including
|
|
48
|
+
the original version of the Work and any modifications or additions
|
|
49
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
50
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
51
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
52
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
53
|
+
means any form of electronic, verbal, or written communication sent
|
|
54
|
+
to the Licensor or its representatives, including but not limited to
|
|
55
|
+
communication on electronic mailing lists, source code control systems,
|
|
56
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
57
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
58
|
+
excluding communication that is conspicuously marked or otherwise
|
|
59
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
60
|
+
|
|
61
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
62
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
63
|
+
subsequently incorporated within the Work.
|
|
64
|
+
|
|
65
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
66
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
67
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
68
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
69
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
70
|
+
Work and such Derivative Works in Source or Object form.
|
|
71
|
+
|
|
72
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
73
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
74
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
75
|
+
(except as stated in this section) patent license to make, have made,
|
|
76
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
77
|
+
where such license applies only to those patent claims licensable
|
|
78
|
+
by such Contributor that are necessarily infringed by their
|
|
79
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
80
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
81
|
+
institute patent litigation against any entity (including a
|
|
82
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
83
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
84
|
+
or contributory patent infringement, then any patent licenses
|
|
85
|
+
granted to You under this License for that Work shall terminate
|
|
86
|
+
as of the date such litigation is filed.
|
|
87
|
+
|
|
88
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
89
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
90
|
+
modifications, and in Source or Object form, provided that You
|
|
91
|
+
meet the following conditions:
|
|
92
|
+
|
|
93
|
+
(a) You must give any other recipients of the Work or
|
|
94
|
+
Derivative Works a copy of this License; and
|
|
95
|
+
|
|
96
|
+
(b) You must cause any modified files to carry prominent notices
|
|
97
|
+
stating that You changed the files; and
|
|
98
|
+
|
|
99
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
100
|
+
that You distribute, all copyright, patent, trademark, and
|
|
101
|
+
attribution notices from the Source form of the Work,
|
|
102
|
+
excluding those notices that do not pertain to any part of
|
|
103
|
+
the Derivative Works; and
|
|
104
|
+
|
|
105
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
106
|
+
distribution, then any Derivative Works that You distribute must
|
|
107
|
+
include a readable copy of the attribution notices contained
|
|
108
|
+
within such NOTICE file, excluding any notices that do not
|
|
109
|
+
pertain to any part of the Derivative Works, in at least one
|
|
110
|
+
of the following places: within a NOTICE text file distributed
|
|
111
|
+
as part of the Derivative Works; within the Source form or
|
|
112
|
+
documentation, if provided along with the Derivative Works; or,
|
|
113
|
+
within a display generated by the Derivative Works, if and
|
|
114
|
+
wherever such third-party notices normally appear. The contents
|
|
115
|
+
of the NOTICE file are for informational purposes only and
|
|
116
|
+
do not modify the License. You may add Your own attribution
|
|
117
|
+
notices within Derivative Works that You distribute, alongside
|
|
118
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
119
|
+
that such additional attribution notices cannot be construed
|
|
120
|
+
as modifying the License.
|
|
121
|
+
|
|
122
|
+
You may add Your own copyright statement to Your modifications and
|
|
123
|
+
may provide additional or different license terms and conditions
|
|
124
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
125
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
126
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
127
|
+
the conditions stated in this License.
|
|
128
|
+
|
|
129
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
130
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
131
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
132
|
+
this License, without any additional terms or conditions.
|
|
133
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
134
|
+
the terms of any separate license agreement you may have executed
|
|
135
|
+
with Licensor regarding such Contributions.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (such as deliberate and grossly
|
|
155
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
156
|
+
liable to You for damages, including any direct, indirect, special,
|
|
157
|
+
incidental, or consequential damages of any character arising as a
|
|
158
|
+
result of this License or out of the use or inability to use the
|
|
159
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
160
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
161
|
+
other commercial damages or losses), even if such Contributor
|
|
162
|
+
has been advised of the possibility of such damages.
|
|
163
|
+
|
|
164
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
165
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
166
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
167
|
+
or other liability obligations and/or rights consistent with this
|
|
168
|
+
License. However, in accepting such obligations, You may act only
|
|
169
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
170
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
171
|
+
defend, and hold each Contributor harmless for any liability
|
|
172
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
173
|
+
of your accepting any such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
Copyright 2023-2026 Sebastien Rousseau
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
+
you may not use this file except in compliance with the License.
|
|
181
|
+
You may obtain a copy of the License at
|
|
182
|
+
|
|
183
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
+
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software
|
|
186
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
+
See the License for the specific language governing permissions and
|
|
189
|
+
limitations under the License.
|
camt053-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: camt053
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Camt053 is a Python library for reading ISO 20022 camt Bank-to-Customer Statements (camt.053/052/054) and generating validated reversing entries by return reason code (e.g. AC04 Closed Account).
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Sebastien Rousseau
|
|
8
|
+
Author-email: sebastian.rousseau@gmail.com
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Dist: click (==8.1.7)
|
|
18
|
+
Requires-Dist: colorama (==0.4.6)
|
|
19
|
+
Requires-Dist: cryptography (>=44.0.1,<47.0.0)
|
|
20
|
+
Requires-Dist: defusedxml (==0.7.1)
|
|
21
|
+
Requires-Dist: fastapi (>=0.95)
|
|
22
|
+
Requires-Dist: httpx (>=0.23)
|
|
23
|
+
Requires-Dist: jinja2 (==3.1.6)
|
|
24
|
+
Requires-Dist: jsonschema (>=4.20,<4.25)
|
|
25
|
+
Requires-Dist: markupsafe (==2.1.5)
|
|
26
|
+
Requires-Dist: pygments (==2.18.0)
|
|
27
|
+
Requires-Dist: rich (==13.7.1)
|
|
28
|
+
Requires-Dist: uvicorn[standard] (>=0.20)
|
|
29
|
+
Requires-Dist: xmlschema (>=3.4.0,<4.0.0)
|
|
30
|
+
Project-URL: Homepage, https://camt053.com
|
|
31
|
+
Project-URL: Repository, https://github.com/sebastienrousseau/camt053
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# camt053: ISO 20022 Bank Statements and Reversing Entries
|
|
35
|
+
|
|
36
|
+
![camt053 banner][banner]
|
|
37
|
+
|
|
38
|
+
[![PyPI Version][pypi-badge]][07]
|
|
39
|
+
[![Python Versions][python-versions-badge]][07]
|
|
40
|
+
[![PyPI Downloads][pypi-downloads-badge]][07]
|
|
41
|
+
[![License][license-badge]][01]
|
|
42
|
+
[![Tests][tests-badge]][tests-url]
|
|
43
|
+
[![Quality][quality-badge]][quality-url]
|
|
44
|
+
[![Documentation][docs-badge]][docs-url]
|
|
45
|
+
|
|
46
|
+
**Read ISO 20022 `camt` Bank-to-Customer Cash Management messages, extract
|
|
47
|
+
booked entries by return reason code (e.g. AC04 Closed Account), and generate
|
|
48
|
+
validated reversing entries** — the core of a modern, AI-assisted treasury
|
|
49
|
+
stack with native MCP and LSP integrations.
|
|
50
|
+
|
|
51
|
+
> **Latest release: v0.0.1** — namespace-agnostic camt.052/053/054 parsing and
|
|
52
|
+
> one-shot reversing-entry generation, validated against the official ISO 20022
|
|
53
|
+
> `camt.053.001.14` schema, for Python 3.10+.
|
|
54
|
+
> [See what's new →][release-001]
|
|
55
|
+
|
|
56
|
+
## Contents
|
|
57
|
+
|
|
58
|
+
- [Overview](#overview)
|
|
59
|
+
- [Install](#install)
|
|
60
|
+
- [Quick Start](#quick-start)
|
|
61
|
+
- [Features](#features)
|
|
62
|
+
- [Usage](#usage)
|
|
63
|
+
- [Supported messages](#supported-messages)
|
|
64
|
+
- [Architecture](#architecture)
|
|
65
|
+
- [Examples](#examples)
|
|
66
|
+
- [Development](#development)
|
|
67
|
+
- [License](#license)
|
|
68
|
+
- [Contributing](#contributing)
|
|
69
|
+
- [Acknowledgements](#acknowledgements)
|
|
70
|
+
|
|
71
|
+
## Overview
|
|
72
|
+
|
|
73
|
+
**camt053** reads ISO 20022 `camt` cash-management messages — the standardised
|
|
74
|
+
bank-to-customer **statements** (camt.053), **account reports** (camt.052), and
|
|
75
|
+
**debit/credit notifications** (camt.054) — into a typed model, lets you filter
|
|
76
|
+
booked entries by ISO external return reason code, and generates a **validated
|
|
77
|
+
reversing entry** for the matching transactions.
|
|
78
|
+
|
|
79
|
+
The headline capability is the one-shot reversing-entry workflow: read an
|
|
80
|
+
incoming camt.053 statement, find the entries carrying a return reason code
|
|
81
|
+
(e.g. **AC04 Closed Account**), and emit a validated reversing entry — answering
|
|
82
|
+
the prompt-engineering dream:
|
|
83
|
+
|
|
84
|
+
> *"Read this incoming bank statement XML, parse out the transactions with error
|
|
85
|
+
> code AC04, and automatically generate the reversing entry."*
|
|
86
|
+
|
|
87
|
+
- **Website:** <https://camt053.com>
|
|
88
|
+
- **Source code:** <https://github.com/sebastienrousseau/camt053>
|
|
89
|
+
- **Bug reports:** <https://github.com/sebastienrousseau/camt053/issues>
|
|
90
|
+
|
|
91
|
+
A single shared facade (`camt053.services`) backs four developer surfaces — the
|
|
92
|
+
Python API, the CLI, the REST API, and the companion MCP and LSP servers — so
|
|
93
|
+
every interface behaves identically. This package is part of the **camt053
|
|
94
|
+
suite** (all Python 3.10+):
|
|
95
|
+
|
|
96
|
+
| Package | Role |
|
|
97
|
+
|---------|------|
|
|
98
|
+
| `camt053` | Core library + Click CLI + FastAPI REST API (this package) |
|
|
99
|
+
| [`camt053-mcp`][mcp-pkg] | Model Context Protocol server (for AI agents) |
|
|
100
|
+
| [`camt053-lsp`][lsp-pkg] | Language Server Protocol server (for editors) |
|
|
101
|
+
|
|
102
|
+
```mermaid
|
|
103
|
+
flowchart LR
|
|
104
|
+
A["Inbound camt.05x XML"] -->|parse| B["camt053.services"]
|
|
105
|
+
B -->|filter by reason code| C["AC04 entries"]
|
|
106
|
+
C -->|reverse + validate| D["camt.053.001.14 reversing entry"]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Install
|
|
110
|
+
|
|
111
|
+
**camt053** runs on macOS, Linux, and Windows and requires **Python 3.10+** and
|
|
112
|
+
**pip**.
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
python -m pip install camt053
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
<details>
|
|
119
|
+
<summary>Using an isolated virtual environment (recommended)</summary>
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
python -m venv venv
|
|
123
|
+
source venv/bin/activate # macOS/Linux
|
|
124
|
+
venv\Scripts\activate # Windows
|
|
125
|
+
python -m pip install -U camt053
|
|
126
|
+
```
|
|
127
|
+
</details>
|
|
128
|
+
|
|
129
|
+
## Quick Start
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from camt053 import services
|
|
133
|
+
|
|
134
|
+
# An incoming camt.053 statement (truncated for brevity — see examples/).
|
|
135
|
+
statement_xml = open("statement.xml", encoding="utf-8").read()
|
|
136
|
+
|
|
137
|
+
# Find the entries returned AC04 (Closed Account).
|
|
138
|
+
ac04 = services.filter_entries(statement_xml, "AC04")
|
|
139
|
+
print(f"{len(ac04)} AC04 entr{'y' if len(ac04) == 1 else 'ies'}")
|
|
140
|
+
|
|
141
|
+
# Generate the reversing entry: parse -> filter -> reverse, in one call.
|
|
142
|
+
reversal_xml = services.generate_reversal(statement_xml, reason_code="AC04")
|
|
143
|
+
print(reversal_xml) # validated camt.053.001.14 document
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or from the command line:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
# Generate a reversing entry for every AC04 entry on a statement
|
|
150
|
+
camt053 reverse -i statement.xml -r AC04 -o reversal.xml
|
|
151
|
+
|
|
152
|
+
# List the entries on a statement (optionally filtered by reason)
|
|
153
|
+
camt053 entries -i statement.xml -r AC04
|
|
154
|
+
|
|
155
|
+
# Inspect the parsed statement as JSON, or validate an identifier
|
|
156
|
+
camt053 parse -i statement.xml
|
|
157
|
+
camt053 validate-id -k iban -v GB29NWBK60161331926819
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`parse`, `entries`, and `reverse` accept `-i -` to read from stdin, so they
|
|
161
|
+
compose in a pipeline.
|
|
162
|
+
|
|
163
|
+
## Features
|
|
164
|
+
|
|
165
|
+
- **Parse** camt.053 / camt.052 / camt.054 into a typed, JSON-serialisable
|
|
166
|
+
model. Parsing is **namespace-agnostic**, so every ISO version (`.001.01`
|
|
167
|
+
through `.001.14`) and real-world bank file is read.
|
|
168
|
+
- **Filter** booked entries by ISO external return reason code (AC04, AC06,
|
|
169
|
+
MD07, …).
|
|
170
|
+
- **Reverse** — generate a `camt.053.001.14` reversing entry from the matching
|
|
171
|
+
entries (credit/debit indicator flipped, `RvslInd` set, return reason carried
|
|
172
|
+
in `RtrInf`), in one call.
|
|
173
|
+
- **Validated output** — generated reversals are checked against the **official
|
|
174
|
+
ISO 20022 `camt.053.001.14` XSD** bundled with the package.
|
|
175
|
+
- **Safe by default** — XML is parsed with `defusedxml` (XXE / billion-laughs
|
|
176
|
+
safe); output paths are traversal-checked.
|
|
177
|
+
- **One facade, four interfaces** — the CLI, REST API, MCP server, and LSP
|
|
178
|
+
server all call `camt053.services`.
|
|
179
|
+
- **IBAN / BIC / LEI validators** (ISO 13616 / 9362 / 17442).
|
|
180
|
+
- **Typed** (mypy `--strict`) and **tested** (100% coverage), validated against
|
|
181
|
+
the official ISO 20022 business samples.
|
|
182
|
+
|
|
183
|
+
## Usage
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from camt053 import parse_statement, services
|
|
187
|
+
|
|
188
|
+
# A minimal incoming camt.053 statement: a EUR 1,500 credit transfer that was
|
|
189
|
+
# booked, then returned because the beneficiary account was closed (AC04).
|
|
190
|
+
statement_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
|
191
|
+
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.14">
|
|
192
|
+
<BkToCstmrStmt>
|
|
193
|
+
<GrpHdr><MsgId>STMT-MSG-0001</MsgId><CreDtTm>2026-06-15T08:00:00</CreDtTm></GrpHdr>
|
|
194
|
+
<Stmt>
|
|
195
|
+
<Id>STMT-0001</Id><CreDtTm>2026-06-15T08:00:00</CreDtTm>
|
|
196
|
+
<Acct><Id><IBAN>GB29NWBK60161331926819</IBAN></Id><Ccy>EUR</Ccy></Acct>
|
|
197
|
+
<Bal><Tp><CdOrPrtry><Cd>CLBD</Cd></CdOrPrtry></Tp>
|
|
198
|
+
<Amt Ccy="EUR">10000.00</Amt><CdtDbtInd>CRDT</CdtDbtInd>
|
|
199
|
+
<Dt><Dt>2026-06-15</Dt></Dt></Bal>
|
|
200
|
+
<Ntry>
|
|
201
|
+
<NtryRef>NTRY-0001</NtryRef>
|
|
202
|
+
<Amt Ccy="EUR">1500.00</Amt><CdtDbtInd>CRDT</CdtDbtInd>
|
|
203
|
+
<Sts><Cd>BOOK</Cd></Sts>
|
|
204
|
+
<NtryDtls><TxDtls>
|
|
205
|
+
<RtrInf><Rsn><Cd>AC04</Cd></Rsn></RtrInf>
|
|
206
|
+
</TxDtls></NtryDtls>
|
|
207
|
+
</Ntry>
|
|
208
|
+
</Stmt>
|
|
209
|
+
</BkToCstmrStmt>
|
|
210
|
+
</Document>"""
|
|
211
|
+
|
|
212
|
+
# 1. Parse into the typed model.
|
|
213
|
+
statement = parse_statement(statement_xml)
|
|
214
|
+
print(statement.account.identifier()) # -> GB29NWBK60161331926819
|
|
215
|
+
print(len(statement.entries)) # -> 1
|
|
216
|
+
|
|
217
|
+
# 2. Select the entries returned AC04 (Closed Account).
|
|
218
|
+
ac04 = statement.entries_with_reason("AC04")
|
|
219
|
+
print(ac04[0].amount, ac04[0].credit_debit_indicator) # -> 1500.00 CRDT
|
|
220
|
+
|
|
221
|
+
# 3. Generate the validated reversing entry (the original CRDT becomes DBIT).
|
|
222
|
+
reversal_xml = services.generate_reversal(statement_xml, reason_code="AC04")
|
|
223
|
+
assert "<RvslInd>true</RvslInd>" in reversal_xml
|
|
224
|
+
assert "<CdtDbtInd>DBIT</CdtDbtInd>" in reversal_xml
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Supported messages
|
|
228
|
+
|
|
229
|
+
| Message type | Name | Direction |
|
|
230
|
+
|--------------|------|-----------|
|
|
231
|
+
| `camt.052.001.14` | Bank To Customer Account Report | read |
|
|
232
|
+
| `camt.053.001.14` | Bank To Customer Statement | read + **reverse** |
|
|
233
|
+
| `camt.054.001.14` | Bank To Customer Debit Credit Notification | read |
|
|
234
|
+
|
|
235
|
+
The parser is namespace-agnostic and reads every ISO version of these messages;
|
|
236
|
+
the official XSDs for `.001.01`–`.001.14` are bundled under `camt053/xsd/`.
|
|
237
|
+
Reversing entries are emitted as `camt.053.001.14`.
|
|
238
|
+
|
|
239
|
+
## Architecture
|
|
240
|
+
|
|
241
|
+
```mermaid
|
|
242
|
+
flowchart TD
|
|
243
|
+
CLI["Click CLI"] --> S["camt053.services"]
|
|
244
|
+
API["FastAPI REST API"] --> S
|
|
245
|
+
MCP["camt053-mcp"] --> S
|
|
246
|
+
LSP["camt053-lsp"] --> S
|
|
247
|
+
S --> P["parse/ — statement_parser, reason_codes"]
|
|
248
|
+
S --> R["reversal/ — reversal builder"]
|
|
249
|
+
S --> X["xml/ — template + official ISO XSD"]
|
|
250
|
+
S --> V["validation/ — IBAN, BIC, LEI, JSON Schema"]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
| Module | Responsibility |
|
|
254
|
+
|--------|----------------|
|
|
255
|
+
| `camt053.parse` | Namespace-agnostic statement parser and return-reason helpers |
|
|
256
|
+
| `camt053.reversal` | Builds flat reversing-entry records from parsed entries |
|
|
257
|
+
| `camt053.xml` | Renders the camt.053 reversal template and validates it via the ISO XSD |
|
|
258
|
+
| `camt053.validation` | IBAN / BIC / LEI and JSON-Schema validators |
|
|
259
|
+
| `camt053.security` | XXE-safe parsing and path-traversal-checked output |
|
|
260
|
+
| `camt053.services` | The shared facade backing every interface |
|
|
261
|
+
|
|
262
|
+
## Examples
|
|
263
|
+
|
|
264
|
+
Runnable, self-contained scripts live in [`examples/`](examples/):
|
|
265
|
+
|
|
266
|
+
| Example | Demonstrates |
|
|
267
|
+
|---------|--------------|
|
|
268
|
+
| [`reverse_ac04.py`](examples/reverse_ac04.py) | The headline workflow — find AC04 entries and generate the reversing entry |
|
|
269
|
+
| [`parse_statement.py`](examples/parse_statement.py) | Parsing a statement into the typed model |
|
|
270
|
+
| [`services_facade.py`](examples/services_facade.py) | The shared `camt053.services` facade |
|
|
271
|
+
| [`validate_identifiers.py`](examples/validate_identifiers.py) | IBAN / BIC / LEI validation |
|
|
272
|
+
| [`rest_api_client.py`](examples/rest_api_client.py) | Driving the FastAPI REST API in-process |
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
git clone https://github.com/sebastienrousseau/camt053.git && cd camt053
|
|
276
|
+
python examples/reverse_ac04.py
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Development
|
|
280
|
+
|
|
281
|
+
**camt053** uses [Poetry](https://python-poetry.org/) and
|
|
282
|
+
[mise](https://mise.jdx.dev/).
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
git clone https://github.com/sebastienrousseau/camt053.git && cd camt053
|
|
286
|
+
mise install
|
|
287
|
+
poetry install
|
|
288
|
+
poetry shell
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
A `Makefile` orchestrates the quality gates (kept in lockstep with CI):
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
make check # all gates (REQUIRED before commit)
|
|
295
|
+
make test # pytest with coverage (100% gate)
|
|
296
|
+
make lint # ruff + black --check
|
|
297
|
+
make type-check # mypy --strict
|
|
298
|
+
make examples # run the example scripts
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
Licensed under the [Apache License, Version 2.0][01]. Any contribution submitted
|
|
304
|
+
for inclusion shall be licensed as above, without additional terms.
|
|
305
|
+
|
|
306
|
+
## Contributing
|
|
307
|
+
|
|
308
|
+
Contributions are welcome — see the [contributing instructions][04]. Thanks to
|
|
309
|
+
all [contributors][05].
|
|
310
|
+
|
|
311
|
+
## Acknowledgements
|
|
312
|
+
|
|
313
|
+
Built on [Click](https://click.palletsprojects.com/),
|
|
314
|
+
[Rich](https://rich.readthedocs.io/), [Jinja2](https://jinja.palletsprojects.com/),
|
|
315
|
+
[xmlschema](https://github.com/sissaschool/xmlschema),
|
|
316
|
+
[defusedxml](https://github.com/tiran/defusedxml), and
|
|
317
|
+
[FastAPI](https://fastapi.tiangolo.com/), against the official ISO 20022
|
|
318
|
+
`camt.05x` schemas.
|
|
319
|
+
|
|
320
|
+
[01]: https://opensource.org/license/apache-2-0/
|
|
321
|
+
[04]: https://github.com/sebastienrousseau/camt053/blob/main/CONTRIBUTING.md
|
|
322
|
+
[05]: https://github.com/sebastienrousseau/camt053/graphs/contributors
|
|
323
|
+
[07]: https://pypi.org/project/camt053/
|
|
324
|
+
[mcp-pkg]: https://github.com/sebastienrousseau/camt053-mcp
|
|
325
|
+
[lsp-pkg]: https://github.com/sebastienrousseau/camt053-lsp
|
|
326
|
+
[release-001]: https://github.com/sebastienrousseau/camt053/releases/tag/v0.0.1
|
|
327
|
+
[banner]: https://cloudcdn.pro/api/transform?url=/camt053/v1/logos/camt053.webp&w=128 'camt053'
|
|
328
|
+
[docs-badge]: https://img.shields.io/badge/Docs-camt053.com-blue?style=for-the-badge
|
|
329
|
+
[docs-url]: https://camt053.com/
|
|
330
|
+
[license-badge]: https://img.shields.io/pypi/l/camt053?style=for-the-badge
|
|
331
|
+
[pypi-badge]: https://img.shields.io/pypi/v/camt053?style=for-the-badge
|
|
332
|
+
[pypi-downloads-badge]: https://img.shields.io/pypi/dm/camt053.svg?style=for-the-badge
|
|
333
|
+
[python-versions-badge]: https://img.shields.io/pypi/pyversions/camt053.svg?style=for-the-badge
|
|
334
|
+
[quality-badge]: https://img.shields.io/github/actions/workflow/status/sebastienrousseau/camt053/ci.yml?branch=main&label=Quality&style=for-the-badge
|
|
335
|
+
[quality-url]: https://github.com/sebastienrousseau/camt053/actions/workflows/ci.yml
|
|
336
|
+
[tests-badge]: https://img.shields.io/github/actions/workflow/status/sebastienrousseau/camt053/ci.yml?branch=main&label=Tests&style=for-the-badge
|
|
337
|
+
[tests-url]: https://github.com/sebastienrousseau/camt053/actions/workflows/ci.yml
|
|
338
|
+
|