beancount-india 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.
@@ -0,0 +1,338 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ <https://fsf.org/>
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, see <https://www.gnu.org/licenses/>.
308
+
309
+ Also add information on how to contact you by electronic and paper mail.
310
+
311
+ If the program is interactive, make it output a short notice like this
312
+ when it starts in an interactive mode:
313
+
314
+ Gnomovision version 69, Copyright (C) year name of author
315
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316
+ This is free software, and you are welcome to redistribute it
317
+ under certain conditions; type `show c' for details.
318
+
319
+ The hypothetical commands `show w' and `show c' should show the appropriate
320
+ parts of the General Public License. Of course, the commands you use may
321
+ be called something other than `show w' and `show c'; they could even be
322
+ mouse-clicks or menu items--whatever suits your program.
323
+
324
+ You should also get your employer (if you work as a programmer) or your
325
+ school, if any, to sign a "copyright disclaimer" for the program, if
326
+ necessary. Here is a sample; alter the names:
327
+
328
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
+
331
+ <signature of Moe Ghoul>, 1 April 1989
332
+ Moe Ghoul, President of Vice
333
+
334
+ This General Public License does not permit incorporating your program into
335
+ proprietary programs. If your program is a subroutine library, you may
336
+ consider it more useful to permit linking proprietary applications with the
337
+ library. If this is what you want to do, use the GNU Lesser General
338
+ Public License instead of this License.
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: beancount-india
3
+ Version: 0.1.0
4
+ Summary: Beancount importers for Indian financial institutions
5
+ Keywords: beancount,beangulp,hdfc,india
6
+ Author: Arpan Kapoor
7
+ Author-email: Arpan Kapoor <a@arpankapoor.com>
8
+ License-Expression: GPL-2.0-only
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Financial and Insurance Industry
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: beangulp>=0.2.0
22
+ Requires-Python: >=3.11
23
+ Project-URL: Homepage, https://github.com/arpankapoor/beancount-india
24
+ Project-URL: Issues, https://github.com/arpankapoor/beancount-india/issues
25
+ Project-URL: Repository, https://github.com/arpankapoor/beancount-india
26
+ Description-Content-Type: text/markdown
27
+
28
+ # beancount-india
29
+
30
+ Beancount importers for Indian financial institutions.
31
+
32
+ ## Installation
33
+
34
+ ```console
35
+ uv add beancount-india
36
+ ```
37
+
38
+ ## HDFC Bank
39
+
40
+ ### Account statements
41
+
42
+ On the HDFC NetBanking Account Statement page, download the statement in
43
+ **Delimited** format. Supported filenames have this form:
44
+
45
+ `Acct_Statement_XXXXXXXX1234_01012025.txt`
46
+
47
+ Transactions use their value dates. When possible, the importer derives an
48
+ opening balance from the first transaction in the statement.
49
+
50
+ ### Credit card statements
51
+
52
+ On the HDFC Bank Get Statement page, download a past statement in **CSV**
53
+ format. Supported filenames have this form:
54
+
55
+ `Jan2025_Billedstatements_1234_06-01-25_20-46.csv`
56
+
57
+ Purchases produce negative liability postings; payments and refunds produce
58
+ positive postings. Nonzero reward points are included as `reward_points`
59
+ metadata.
60
+
61
+ ### Configuration
62
+
63
+ Configure the importers with full account or card numbers mapped to their
64
+ Beancount accounts. Numbers must be strings; filenames are matched using their
65
+ final four digits.
66
+
67
+ ```python
68
+ import beangulp
69
+
70
+ from beancount_india.hdfc import HDFCAccountImporter, HDFCCardImporter
71
+
72
+ ingest = beangulp.Ingest(
73
+ [
74
+ HDFCAccountImporter({"12345678901234": "Assets:HDFC:Account"}),
75
+ HDFCCardImporter({"1234567890123456": "Liabilities:HDFC:Card"}),
76
+ ]
77
+ )
78
+
79
+ if __name__ == "__main__":
80
+ ingest()
81
+ ```
@@ -0,0 +1,54 @@
1
+ # beancount-india
2
+
3
+ Beancount importers for Indian financial institutions.
4
+
5
+ ## Installation
6
+
7
+ ```console
8
+ uv add beancount-india
9
+ ```
10
+
11
+ ## HDFC Bank
12
+
13
+ ### Account statements
14
+
15
+ On the HDFC NetBanking Account Statement page, download the statement in
16
+ **Delimited** format. Supported filenames have this form:
17
+
18
+ `Acct_Statement_XXXXXXXX1234_01012025.txt`
19
+
20
+ Transactions use their value dates. When possible, the importer derives an
21
+ opening balance from the first transaction in the statement.
22
+
23
+ ### Credit card statements
24
+
25
+ On the HDFC Bank Get Statement page, download a past statement in **CSV**
26
+ format. Supported filenames have this form:
27
+
28
+ `Jan2025_Billedstatements_1234_06-01-25_20-46.csv`
29
+
30
+ Purchases produce negative liability postings; payments and refunds produce
31
+ positive postings. Nonzero reward points are included as `reward_points`
32
+ metadata.
33
+
34
+ ### Configuration
35
+
36
+ Configure the importers with full account or card numbers mapped to their
37
+ Beancount accounts. Numbers must be strings; filenames are matched using their
38
+ final four digits.
39
+
40
+ ```python
41
+ import beangulp
42
+
43
+ from beancount_india.hdfc import HDFCAccountImporter, HDFCCardImporter
44
+
45
+ ingest = beangulp.Ingest(
46
+ [
47
+ HDFCAccountImporter({"12345678901234": "Assets:HDFC:Account"}),
48
+ HDFCCardImporter({"1234567890123456": "Liabilities:HDFC:Card"}),
49
+ ]
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ ingest()
54
+ ```
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "beancount-india"
3
+ version = "0.1.0"
4
+ description = "Beancount importers for Indian financial institutions"
5
+ readme = "README.md"
6
+ license = "GPL-2.0-only"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "beancount",
10
+ "beangulp",
11
+ "hdfc",
12
+ "india",
13
+ ]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Financial and Insurance Industry",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Programming Language :: Python :: 3.15",
24
+ "Topic :: Office/Business :: Financial :: Accounting",
25
+ "Typing :: Typed",
26
+ ]
27
+ requires-python = ">=3.11"
28
+ dependencies = ["beangulp>=0.2.0"]
29
+
30
+ [[project.authors]]
31
+ name = "Arpan Kapoor"
32
+ email = "a@arpankapoor.com"
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/arpankapoor/beancount-india"
36
+ Issues = "https://github.com/arpankapoor/beancount-india/issues"
37
+ Repository = "https://github.com/arpankapoor/beancount-india"
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "ruff",
42
+ "ty",
43
+ ]
44
+
45
+ [build-system]
46
+ requires = ["uv_build>=0.13.7,<0.14.0"]
47
+ build-backend = "uv_build"
@@ -0,0 +1,36 @@
1
+ [project]
2
+ name = "beancount-india"
3
+ version = "0.1.0"
4
+ description = "Beancount importers for Indian financial institutions"
5
+ readme = "README.md"
6
+ license = "GPL-2.0-only"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Arpan Kapoor", email = "a@arpankapoor.com" }]
9
+ keywords = ["beancount", "beangulp", "hdfc", "india"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Financial and Insurance Industry",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
19
+ "Programming Language :: Python :: 3.15",
20
+ "Topic :: Office/Business :: Financial :: Accounting",
21
+ "Typing :: Typed",
22
+ ]
23
+ requires-python = ">=3.11"
24
+ dependencies = ["beangulp>=0.2.0"]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/arpankapoor/beancount-india"
28
+ Issues = "https://github.com/arpankapoor/beancount-india/issues"
29
+ Repository = "https://github.com/arpankapoor/beancount-india"
30
+
31
+ [dependency-groups]
32
+ dev = ["ruff", "ty"]
33
+
34
+ [build-system]
35
+ requires = ["uv_build>=0.13.7,<0.14.0"]
36
+ build-backend = "uv_build"
@@ -0,0 +1 @@
1
+ """Beancount importers for Indian financial institutions."""
@@ -0,0 +1,6 @@
1
+ """Importers for HDFC Bank."""
2
+
3
+ from beancount_india.hdfc.cards import HDFCCardImporter
4
+ from beancount_india.hdfc.statements import HDFCAccountImporter
5
+
6
+ __all__ = ["HDFCAccountImporter", "HDFCCardImporter"]
@@ -0,0 +1,39 @@
1
+ """Shared implementation details for HDFC importers."""
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from dataclasses import dataclass
6
+
7
+ _CURRENCY = "INR"
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class _FilenameMatch:
12
+ suffix: str
13
+ download_date: datetime.date
14
+
15
+
16
+ class _SuffixAccounts:
17
+ """Maps unique four-digit identifier suffixes to Beancount accounts."""
18
+
19
+ def __init__(self, accounts: Mapping[str, str], identifier: str) -> None:
20
+ self._accounts: dict[str, str] = {}
21
+ for number, account in accounts.items():
22
+ if len(number) <= 4 or not number.isdecimal():
23
+ raise ValueError(
24
+ f"HDFC {identifier}s must contain more than four digits"
25
+ )
26
+
27
+ suffix = number[-4:]
28
+ if suffix in self._accounts:
29
+ raise ValueError(f"Multiple HDFC {identifier}s end in {suffix!r}")
30
+ self._accounts[suffix] = account
31
+
32
+ def __contains__(self, suffix: str) -> bool:
33
+ return suffix in self._accounts
34
+
35
+ def account(self, suffix: str) -> str:
36
+ try:
37
+ return self._accounts[suffix]
38
+ except KeyError:
39
+ raise ValueError(f"No account configured for suffix {suffix!r}") from None
@@ -0,0 +1,344 @@
1
+ """Parser for HDFC Bank credit card statements in CSV format."""
2
+
3
+ import datetime
4
+ import re
5
+ from collections.abc import Mapping
6
+ from dataclasses import dataclass
7
+ from decimal import Decimal, InvalidOperation
8
+ from pathlib import Path
9
+
10
+ import beangulp
11
+ from beancount.core import amount, data, flags
12
+
13
+ from beancount_india.hdfc._common import _CURRENCY, _FilenameMatch, _SuffixAccounts
14
+
15
+ # Despite the .csv extension, HDFC uses this compound delimiter.
16
+ _DELIMITER = "~|~"
17
+ _FILENAME_PATTERN = re.compile(
18
+ r"[A-Z][a-z]{2}\d{4}_Billedstatements_(?P<suffix>\d{4})_"
19
+ r"(?P<download_date>\d{2}-\d{2}-\d{2})_\d{2}-\d{2}\.csv"
20
+ )
21
+ _TRANSACTION_HEADER = (
22
+ "Transaction type",
23
+ "Primary / Addon Customer Name",
24
+ "DATE",
25
+ "Description",
26
+ "AMT",
27
+ "Debit /Credit",
28
+ "REWARDS",
29
+ "",
30
+ )
31
+ _ACCOUNT_SUMMARY_HEADER = (
32
+ "Opening Bal",
33
+ "-",
34
+ "Payment / Credit",
35
+ "+",
36
+ "Purchases / Debits",
37
+ "+",
38
+ "Finance Charges",
39
+ "=",
40
+ "Total Dues",
41
+ )
42
+ _REWARD_POINTS_SUMMARY_HEADER = (
43
+ "Opening Balance",
44
+ "Feature + Bonus Reward Points Earned",
45
+ "Disbursed",
46
+ "Adjusted/Lapsed",
47
+ "Closing Balance",
48
+ "Points expiring in next 30 days",
49
+ "Points expiring in next 60 days",
50
+ )
51
+ _CARD_NUMBER_PATTERN = re.compile(r"Card No:.*(?P<card_suffix>\d{4})$")
52
+
53
+
54
+ class HDFCCardImporter(beangulp.Importer):
55
+ """Imports HDFC Bank credit card statements in CSV format."""
56
+
57
+ def __init__(self, accounts: Mapping[str, str]) -> None:
58
+ """Initialize the importer with card numbers mapped to accounts."""
59
+ self._accounts = _SuffixAccounts(accounts, "card number")
60
+
61
+ def identify(self, filepath: str) -> bool:
62
+ filename_match = _match_filename(filepath)
63
+ return filename_match is not None and filename_match.suffix in self._accounts
64
+
65
+ def account(self, filepath: str) -> str:
66
+ filename_match = _match_filename(filepath)
67
+ if filename_match is None:
68
+ raise ValueError(f"Not an HDFC card statement: {filepath!r}")
69
+
70
+ return self._accounts.account(filename_match.suffix)
71
+
72
+ def date(self, filepath: str) -> datetime.date | None:
73
+ if _match_filename(filepath) is None:
74
+ return None
75
+ return _parse_card_statement(Path(filepath)).statement_date
76
+
77
+ def filename(self, filepath: str) -> str:
78
+ statement = _parse_card_statement(Path(filepath))
79
+ return f"statement.{statement.statement_date}.csv"
80
+
81
+ def extract(self, filepath: str, existing: data.Entries) -> data.Entries:
82
+ filename_match = _match_filename(filepath)
83
+ if filename_match is None:
84
+ raise ValueError(f"Not an HDFC card statement: {filepath!r}")
85
+
86
+ account = self.account(filepath)
87
+ statement = _parse_card_statement(Path(filepath))
88
+ if statement.card_suffix != filename_match.suffix:
89
+ raise ValueError(
90
+ f"Card suffix {statement.card_suffix!r} does not match filename"
91
+ )
92
+
93
+ filename = Path(filepath).name
94
+ return [
95
+ _make_transaction(transaction, account, filename)
96
+ for transaction in statement.transactions
97
+ ]
98
+
99
+
100
+ @dataclass(frozen=True, slots=True)
101
+ class _CardTransaction:
102
+ line_number: int
103
+ transaction_type: str
104
+ cardholder: str
105
+ timestamp: datetime.datetime
106
+ description: str
107
+ amount: Decimal
108
+ credit: bool
109
+ reward_points: Decimal
110
+
111
+ @property
112
+ def signed_amount(self) -> Decimal:
113
+ return self.amount if self.credit else -self.amount
114
+
115
+
116
+ @dataclass(frozen=True, slots=True)
117
+ class _AccountSummary:
118
+ opening_balance: Decimal
119
+ payments_and_credits: Decimal
120
+ purchases_and_debits: Decimal
121
+ finance_charges: Decimal
122
+ total_dues: Decimal
123
+
124
+
125
+ @dataclass(frozen=True, slots=True)
126
+ class _RewardPointsSummary:
127
+ opening_balance: int
128
+ earned: int
129
+ disbursed: int
130
+ adjusted_or_lapsed: int
131
+ closing_balance: int
132
+ expiring_within_30_days: int
133
+ expiring_within_60_days: int
134
+
135
+
136
+ @dataclass(frozen=True, slots=True)
137
+ class _CardStatement:
138
+ card_suffix: str
139
+ statement_date: datetime.date
140
+ payment_due_date: datetime.date
141
+ total_amount_due: Decimal
142
+ minimum_amount_due: Decimal
143
+ account_summary: _AccountSummary
144
+ reward_points_summary: _RewardPointsSummary
145
+ transactions: list[_CardTransaction]
146
+
147
+
148
+ def _parse_card_statement(path: Path) -> _CardStatement:
149
+ rows = [_split_row(line) for line in path.read_text(encoding="utf-8").splitlines()]
150
+ metadata: dict[str, str] = {}
151
+ card_suffix: str | None = None
152
+
153
+ try:
154
+ transaction_header_index = rows.index(_TRANSACTION_HEADER)
155
+ except ValueError:
156
+ raise ValueError(f"{path.name}: transaction header not found") from None
157
+
158
+ for fields in rows[:transaction_header_index]:
159
+ if len(fields) == 2:
160
+ metadata[fields[0]] = fields[1]
161
+
162
+ regex_match = _CARD_NUMBER_PATTERN.fullmatch(fields[0])
163
+ if regex_match is not None:
164
+ card_suffix = regex_match.group("card_suffix")
165
+
166
+ if card_suffix is None:
167
+ raise ValueError(f"{path.name}: card number not found")
168
+
169
+ try:
170
+ statement_date = _parse_date(metadata["Statement Date"])
171
+ payment_due_date = _parse_date(metadata["Payment Due Date"])
172
+ total_amount_due = _parse_decimal(metadata["Total Amount Due"])
173
+ minimum_amount_due = _parse_decimal(metadata["Minimum Amount Due"])
174
+ except KeyError as error:
175
+ raise ValueError(f"{path.name}: missing {error.args[0]!r}") from None
176
+ except (InvalidOperation, ValueError) as error:
177
+ raise ValueError(f"{path.name}: invalid statement metadata") from error
178
+
179
+ account_summary = _parse_account_summary(path, rows)
180
+ reward_points_summary = _parse_reward_points_summary(path, rows)
181
+
182
+ transactions: list[_CardTransaction] = []
183
+ for index, fields in enumerate(
184
+ rows[transaction_header_index + 1 :], start=transaction_header_index + 2
185
+ ):
186
+ if not any(fields):
187
+ break
188
+
189
+ if len(fields) != len(_TRANSACTION_HEADER):
190
+ raise ValueError(f"{path.name}:{index}: invalid transaction row")
191
+
192
+ (
193
+ transaction_type,
194
+ cardholder,
195
+ timestamp_text,
196
+ description,
197
+ amount_text,
198
+ debit_or_credit,
199
+ reward_points_text,
200
+ trailing_field,
201
+ ) = fields
202
+ if trailing_field or debit_or_credit not in ("", "Cr"):
203
+ raise ValueError(f"{path.name}:{index}: invalid transaction row")
204
+
205
+ try:
206
+ timestamp = datetime.datetime.strptime(timestamp_text, "%d/%m/%Y %H:%M:%S")
207
+ amount = _parse_decimal(amount_text)
208
+ credit = debit_or_credit == "Cr"
209
+ reward_points = _parse_decimal(reward_points_text or "0")
210
+ except (InvalidOperation, ValueError) as error:
211
+ raise ValueError(f"{path.name}:{index}: invalid transaction row") from error
212
+
213
+ transaction = _CardTransaction(
214
+ line_number=index,
215
+ transaction_type=transaction_type,
216
+ cardholder=cardholder,
217
+ timestamp=timestamp,
218
+ description=description,
219
+ amount=amount,
220
+ credit=credit,
221
+ reward_points=reward_points,
222
+ )
223
+ transactions.append(transaction)
224
+
225
+ # HDFC groups transactions by type, so file order may not be chronological.
226
+ transactions.sort(key=lambda transaction: transaction.timestamp)
227
+ return _CardStatement(
228
+ card_suffix=card_suffix,
229
+ statement_date=statement_date,
230
+ payment_due_date=payment_due_date,
231
+ total_amount_due=total_amount_due,
232
+ minimum_amount_due=minimum_amount_due,
233
+ account_summary=account_summary,
234
+ reward_points_summary=reward_points_summary,
235
+ transactions=transactions,
236
+ )
237
+
238
+
239
+ def _parse_account_summary(path: Path, rows: list[tuple[str, ...]]) -> _AccountSummary:
240
+ line_number, fields = _find_table_row(path, rows, _ACCOUNT_SUMMARY_HEADER)
241
+
242
+ try:
243
+ # The intervening fields are arithmetic symbols from the summary table.
244
+ return _AccountSummary(
245
+ opening_balance=_parse_decimal(fields[0]),
246
+ payments_and_credits=_parse_decimal(fields[2]),
247
+ purchases_and_debits=_parse_decimal(fields[4]),
248
+ finance_charges=_parse_decimal(fields[6]),
249
+ total_dues=_parse_decimal(fields[8]),
250
+ )
251
+ except InvalidOperation as error:
252
+ raise ValueError(
253
+ f"{path.name}:{line_number}: invalid account summary"
254
+ ) from error
255
+
256
+
257
+ def _parse_reward_points_summary(
258
+ path: Path, rows: list[tuple[str, ...]]
259
+ ) -> _RewardPointsSummary:
260
+ line_number, fields = _find_table_row(path, rows, _REWARD_POINTS_SUMMARY_HEADER)
261
+
262
+ try:
263
+ points = [int(field.replace(",", "")) for field in fields]
264
+ except ValueError as error:
265
+ raise ValueError(
266
+ f"{path.name}:{line_number}: invalid reward points summary"
267
+ ) from error
268
+
269
+ return _RewardPointsSummary(*points)
270
+
271
+
272
+ def _find_table_row(
273
+ path: Path, rows: list[tuple[str, ...]], header: tuple[str, ...]
274
+ ) -> tuple[int, tuple[str, ...]]:
275
+ """Return the one-based line number and fields immediately after a header."""
276
+ try:
277
+ header_index = rows.index(header)
278
+ row = rows[header_index + 1]
279
+ except (IndexError, ValueError):
280
+ raise ValueError(f"{path.name}: table not found: {header[0]!r}") from None
281
+
282
+ line_number = header_index + 2
283
+ if len(row) != len(header):
284
+ raise ValueError(
285
+ f"{path.name}:{line_number}: expected {len(header)} table fields"
286
+ )
287
+
288
+ return line_number, row
289
+
290
+
291
+ def _split_row(line: str) -> tuple[str, ...]:
292
+ """Split a statement row and remove HDFC's field padding."""
293
+ return tuple(field.strip() for field in line.split(_DELIMITER))
294
+
295
+
296
+ def _make_transaction(
297
+ transaction: _CardTransaction, account: str, filename: str
298
+ ) -> data.Transaction:
299
+ metadata = data.new_metadata(filename, transaction.line_number)
300
+ if transaction.reward_points:
301
+ metadata["reward_points"] = transaction.reward_points
302
+
303
+ posting = data.Posting(
304
+ account,
305
+ amount.Amount(transaction.signed_amount, _CURRENCY),
306
+ None,
307
+ None,
308
+ None,
309
+ None,
310
+ )
311
+ return data.Transaction(
312
+ metadata,
313
+ transaction.timestamp.date(),
314
+ flags.FLAG_OKAY,
315
+ None,
316
+ transaction.description,
317
+ data.EMPTY_SET,
318
+ data.EMPTY_SET,
319
+ [posting],
320
+ )
321
+
322
+
323
+ def _match_filename(filepath: str) -> _FilenameMatch | None:
324
+ """Parse metadata from an original HDFC card statement filename."""
325
+ regex_match = _FILENAME_PATTERN.fullmatch(Path(filepath).name)
326
+ if regex_match is None:
327
+ return None
328
+
329
+ try:
330
+ download_date = datetime.datetime.strptime(
331
+ regex_match.group("download_date"), "%d-%m-%y"
332
+ ).date()
333
+ except ValueError:
334
+ return None
335
+
336
+ return _FilenameMatch(regex_match.group("suffix"), download_date)
337
+
338
+
339
+ def _parse_date(value: str) -> datetime.date:
340
+ return datetime.datetime.strptime(value, "%d/%m/%Y").date()
341
+
342
+
343
+ def _parse_decimal(value: str) -> Decimal:
344
+ return Decimal(value.replace(",", "").replace(" ", ""))
@@ -0,0 +1,256 @@
1
+ """Importer for HDFC Bank account statements in Delimited format."""
2
+
3
+ import csv
4
+ import datetime
5
+ import re
6
+ from collections.abc import Iterable, Iterator, Mapping
7
+ from dataclasses import dataclass
8
+ from decimal import Decimal, InvalidOperation
9
+ from pathlib import Path
10
+
11
+ import beangulp
12
+ from beancount.core import amount, data, flags
13
+
14
+ from beancount_india.hdfc._common import _CURRENCY, _FilenameMatch, _SuffixAccounts
15
+
16
+ _FILENAME_PATTERN = re.compile(
17
+ r"Acct_Statement_XXXXXXXX(?P<suffix>\d{4})_"
18
+ r"(?P<download_date>\d{8})\.txt"
19
+ )
20
+ _HEADER = (
21
+ "Date",
22
+ "Narration",
23
+ "Value Dat",
24
+ "Debit Amount",
25
+ "Credit Amount",
26
+ "Chq/Ref Number",
27
+ "Closing Balance",
28
+ )
29
+
30
+
31
+ class HDFCAccountImporter(beangulp.Importer):
32
+ """Imports HDFC Bank account statements in Delimited format."""
33
+
34
+ def __init__(self, accounts: Mapping[str, str]) -> None:
35
+ """Initialize the importer.
36
+
37
+ Args:
38
+ accounts: Full HDFC account numbers mapped to Beancount accounts.
39
+
40
+ Raises:
41
+ ValueError: If an account number is invalid or suffixes are ambiguous.
42
+ """
43
+ self._accounts = _SuffixAccounts(accounts, "account number")
44
+
45
+ def identify(self, filepath: str) -> bool:
46
+ filename_match = _match_filename(filepath)
47
+ return filename_match is not None and filename_match.suffix in self._accounts
48
+
49
+ def account(self, filepath: str) -> str:
50
+ filename_match = _match_filename(filepath)
51
+ if filename_match is None:
52
+ raise ValueError(f"Not an HDFC account statement: {filepath!r}")
53
+
54
+ return self._accounts.account(filename_match.suffix)
55
+
56
+ def date(self, filepath: str) -> datetime.date | None:
57
+ filename_match = _match_filename(filepath)
58
+ return filename_match.download_date if filename_match is not None else None
59
+
60
+ def filename(self, filepath: str) -> str | None:
61
+ rows = _parse_statement(Path(filepath))
62
+ if not rows:
63
+ return None
64
+
65
+ first_date = min(row.value_date for row in rows)
66
+ last_date = max(row.value_date for row in rows)
67
+ if first_date == last_date:
68
+ return f"statement.{first_date}.txt"
69
+ return f"statement.{first_date}_{last_date}.txt"
70
+
71
+ def extract(self, filepath: str, existing: data.Entries) -> data.Entries:
72
+ account = self.account(filepath)
73
+ rows = _parse_statement(Path(filepath))
74
+ if not rows:
75
+ return []
76
+
77
+ filename = Path(filepath).name
78
+ entries: data.Entries = []
79
+ opening_balance = _make_opening_balance(rows[0], account, filename, existing)
80
+ if opening_balance is not None:
81
+ entries.append(opening_balance)
82
+
83
+ entries.extend(_make_transaction(row, account, filename) for row in rows)
84
+
85
+ return entries
86
+
87
+
88
+ @dataclass(frozen=True, slots=True)
89
+ class _StatementRow:
90
+ line_number: int
91
+ transaction_date: datetime.date
92
+ narration: str
93
+ value_date: datetime.date
94
+ debit: Decimal
95
+ credit: Decimal
96
+ reference_number: str
97
+ closing_balance: Decimal
98
+
99
+ @property
100
+ def amount(self) -> Decimal:
101
+ return self.credit - self.debit
102
+
103
+
104
+ def _parse_statement(path: Path) -> list[_StatementRow]:
105
+ rows: list[_StatementRow] = []
106
+
107
+ # newline="" lets csv.reader handle the file's line endings itself.
108
+ with path.open(encoding="utf-8", newline="") as statement:
109
+ rows_with_lines = _nonempty_rows(csv.reader(statement))
110
+ try:
111
+ header_line, header = next(rows_with_lines)
112
+ except StopIteration:
113
+ raise ValueError(f"{path.name}: statement has no header")
114
+ if tuple(cell.strip() for cell in header) != _HEADER:
115
+ raise ValueError(f"{path.name}:{header_line}: unexpected header")
116
+
117
+ for line_number, fields in rows_with_lines:
118
+ if len(fields) < len(_HEADER):
119
+ raise ValueError(
120
+ f"{path.name}:{line_number}: expected at least {len(_HEADER)} fields"
121
+ )
122
+
123
+ try:
124
+ (
125
+ transaction_date,
126
+ *narration,
127
+ value_date,
128
+ debit,
129
+ credit,
130
+ reference_number,
131
+ closing_balance,
132
+ ) = fields
133
+ parsed_debit = _parse_decimal(debit)
134
+ parsed_credit = _parse_decimal(credit)
135
+ if parsed_debit and parsed_credit:
136
+ raise ValueError("both debit and credit are nonzero")
137
+
138
+ rows.append(
139
+ _StatementRow(
140
+ line_number=line_number,
141
+ transaction_date=_parse_date(transaction_date),
142
+ narration=",".join(narration).strip(),
143
+ value_date=_parse_date(value_date),
144
+ debit=parsed_debit,
145
+ credit=parsed_credit,
146
+ reference_number=reference_number.strip(),
147
+ closing_balance=_parse_decimal(closing_balance),
148
+ )
149
+ )
150
+ except (InvalidOperation, ValueError) as error:
151
+ raise ValueError(
152
+ f"{path.name}:{line_number}: invalid statement row"
153
+ ) from error
154
+
155
+ return rows
156
+
157
+
158
+ def _nonempty_rows(rows: Iterable[list[str]]) -> Iterator[tuple[int, list[str]]]:
159
+ for line_number, row in enumerate(rows, start=1):
160
+ if any(field.strip() for field in row):
161
+ yield line_number, row
162
+
163
+
164
+ def _make_opening_balance(
165
+ row: _StatementRow,
166
+ account: str,
167
+ filepath: str,
168
+ existing: data.Entries,
169
+ ) -> data.Balance | None:
170
+ # The reported closing balance already includes the first transaction.
171
+ opening_amount = amount.Amount(row.closing_balance - row.amount, _CURRENCY)
172
+
173
+ suppress_balance = False
174
+ for entry in existing:
175
+ if (
176
+ isinstance(entry, data.Balance)
177
+ and entry.date == row.value_date
178
+ and entry.account == account
179
+ and entry.amount.currency == _CURRENCY
180
+ ):
181
+ if entry.amount != opening_amount:
182
+ raise ValueError(
183
+ f"Existing balance for {account!r} on {row.value_date} "
184
+ "conflicts with statement"
185
+ )
186
+ suppress_balance = True
187
+ elif (
188
+ isinstance(entry, data.Transaction)
189
+ and entry.date == row.value_date
190
+ and any(posting.account == account for posting in entry.postings)
191
+ ):
192
+ # Beancount cannot assert a balance between same-day transactions.
193
+ suppress_balance = True
194
+
195
+ if suppress_balance:
196
+ return None
197
+
198
+ return data.Balance(
199
+ data.new_metadata(filepath, row.line_number),
200
+ row.value_date,
201
+ account,
202
+ opening_amount,
203
+ None,
204
+ None,
205
+ )
206
+
207
+
208
+ def _make_transaction(
209
+ row: _StatementRow, account: str, filepath: str
210
+ ) -> data.Transaction:
211
+ metadata = data.new_metadata(filepath, row.line_number)
212
+ if row.reference_number:
213
+ metadata["reference"] = row.reference_number
214
+ posting = data.Posting(
215
+ account,
216
+ amount.Amount(row.amount, _CURRENCY),
217
+ None,
218
+ None,
219
+ None,
220
+ None,
221
+ )
222
+
223
+ return data.Transaction(
224
+ metadata,
225
+ row.value_date,
226
+ flags.FLAG_OKAY,
227
+ None,
228
+ row.narration,
229
+ data.EMPTY_SET,
230
+ data.EMPTY_SET,
231
+ [posting],
232
+ )
233
+
234
+
235
+ def _match_filename(filepath: str) -> _FilenameMatch | None:
236
+ """Parse metadata from an original HDFC statement filename."""
237
+ regex_match = _FILENAME_PATTERN.fullmatch(Path(filepath).name)
238
+ if regex_match is None:
239
+ return None
240
+
241
+ try:
242
+ download_date = datetime.datetime.strptime(
243
+ regex_match.group("download_date"), "%d%m%Y"
244
+ ).date()
245
+ except ValueError:
246
+ return None
247
+
248
+ return _FilenameMatch(regex_match.group("suffix"), download_date)
249
+
250
+
251
+ def _parse_date(value: str) -> datetime.date:
252
+ return datetime.datetime.strptime(value.strip(), "%d/%m/%y").date()
253
+
254
+
255
+ def _parse_decimal(value: str) -> Decimal:
256
+ return Decimal(value.strip() or "0")
File without changes