aeb43 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.
- aeb43-0.1.0/.flake8 +2 -0
- aeb43-0.1.0/.gitlab-ci.yml +66 -0
- aeb43-0.1.0/.hgtags +1 -0
- aeb43-0.1.0/.isort.cfg +2 -0
- aeb43-0.1.0/CHANGELOG +2 -0
- aeb43-0.1.0/COPYRIGHT +25 -0
- aeb43-0.1.0/MANIFEST.in +4 -0
- aeb43-0.1.0/PKG-INFO +90 -0
- aeb43-0.1.0/README.rst +62 -0
- aeb43-0.1.0/aeb43/AEB43.txt +5 -0
- aeb43-0.1.0/aeb43/__init__.py +176 -0
- aeb43-0.1.0/aeb43/test.py +68 -0
- aeb43-0.1.0/aeb43/test_readme.py +16 -0
- aeb43-0.1.0/aeb43.egg-info/PKG-INFO +90 -0
- aeb43-0.1.0/aeb43.egg-info/SOURCES.txt +19 -0
- aeb43-0.1.0/aeb43.egg-info/dependency_links.txt +1 -0
- aeb43-0.1.0/aeb43.egg-info/requires.txt +1 -0
- aeb43-0.1.0/aeb43.egg-info/top_level.txt +1 -0
- aeb43-0.1.0/setup.cfg +4 -0
- aeb43-0.1.0/setup.py +56 -0
- aeb43-0.1.0/tox.ini +19 -0
aeb43-0.1.0/.flake8
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
workflow:
|
|
2
|
+
rules:
|
|
3
|
+
- if: $CI_COMMIT_BRANCH =~ /^topic\/.*/ && $CI_PIPELINE_SOURCE == "push"
|
|
4
|
+
when: never
|
|
5
|
+
- when: always
|
|
6
|
+
|
|
7
|
+
stages:
|
|
8
|
+
- check
|
|
9
|
+
- test
|
|
10
|
+
|
|
11
|
+
.check:
|
|
12
|
+
stage: check
|
|
13
|
+
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/tryton/ci
|
|
14
|
+
|
|
15
|
+
check-flake8:
|
|
16
|
+
extends: .check
|
|
17
|
+
script:
|
|
18
|
+
- flake8
|
|
19
|
+
|
|
20
|
+
check-isort:
|
|
21
|
+
extends: .check
|
|
22
|
+
script:
|
|
23
|
+
- isort --multi-line VERTICAL_GRID --check --diff .
|
|
24
|
+
|
|
25
|
+
check-dist:
|
|
26
|
+
extends: .check
|
|
27
|
+
before_script:
|
|
28
|
+
- pip install twine
|
|
29
|
+
script:
|
|
30
|
+
- python setup.py sdist
|
|
31
|
+
- twine check dist/*
|
|
32
|
+
|
|
33
|
+
.test:
|
|
34
|
+
stage: test
|
|
35
|
+
|
|
36
|
+
.test-tox:
|
|
37
|
+
extends: .test
|
|
38
|
+
variables:
|
|
39
|
+
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
40
|
+
cache:
|
|
41
|
+
paths:
|
|
42
|
+
- .cache/pip
|
|
43
|
+
before_script:
|
|
44
|
+
- pip install tox
|
|
45
|
+
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
|
46
|
+
artifacts:
|
|
47
|
+
reports:
|
|
48
|
+
junit: junit.xml
|
|
49
|
+
coverage_report:
|
|
50
|
+
coverage_format: cobertura
|
|
51
|
+
path: coverage.xml
|
|
52
|
+
|
|
53
|
+
test-tox-python:
|
|
54
|
+
extends: .test-tox
|
|
55
|
+
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:${PYTHON_VERSION}
|
|
56
|
+
script:
|
|
57
|
+
- tox -e "py${PYTHON_VERSION/./}" -vv -- -v --output-file junit.xml
|
|
58
|
+
parallel:
|
|
59
|
+
matrix:
|
|
60
|
+
- PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
61
|
+
|
|
62
|
+
test-tox-pypy:
|
|
63
|
+
extends: .test-tox
|
|
64
|
+
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/pypy:3
|
|
65
|
+
script:
|
|
66
|
+
- tox -e pypy3 -vv -- -v --output-file junit.xml
|
aeb43-0.1.0/.hgtags
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
33740812e29cb15909b59eef025c4a0b6570184b 0.1.0
|
aeb43-0.1.0/.isort.cfg
ADDED
aeb43-0.1.0/CHANGELOG
ADDED
aeb43-0.1.0/COPYRIGHT
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2023, Cédric Krier
|
|
2
|
+
Copyright (c) 2023, B2CK
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name of the <organization> nor the
|
|
13
|
+
names of its contributors may be used to endorse or promote products
|
|
14
|
+
derived from this software without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
19
|
+
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
20
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
aeb43-0.1.0/MANIFEST.in
ADDED
aeb43-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: aeb43
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A module to parse AEB43 files
|
|
5
|
+
Home-page: https://pypi.org/project/aeb43/
|
|
6
|
+
Download-URL: https://downloads.tryton.org/aeb43/
|
|
7
|
+
Author: Tryton
|
|
8
|
+
Author-email: foundation@tryton.org
|
|
9
|
+
License: BSD
|
|
10
|
+
Project-URL: Bug Tracker, https://bugs.tryton.org/aeb43
|
|
11
|
+
Project-URL: Forum, https://discuss.tryton.org/tags/aeb43
|
|
12
|
+
Project-URL: Source Code, https://code.tryton.org/aeb43
|
|
13
|
+
Keywords: AEB43 parser
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Office/Business
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: python-stdnum
|
|
28
|
+
|
|
29
|
+
aeb43
|
|
30
|
+
=====
|
|
31
|
+
|
|
32
|
+
aeb43 is a parser for AEB43 files.
|
|
33
|
+
|
|
34
|
+
Nutshell
|
|
35
|
+
--------
|
|
36
|
+
|
|
37
|
+
Import::
|
|
38
|
+
|
|
39
|
+
>>> import os
|
|
40
|
+
>>> from aeb43 import AEB43
|
|
41
|
+
|
|
42
|
+
Instantiate::
|
|
43
|
+
|
|
44
|
+
>>> aeb43 = AEB43('aeb43/AEB43.txt')
|
|
45
|
+
|
|
46
|
+
The accounts::
|
|
47
|
+
|
|
48
|
+
>>> len(aeb43.accounts)
|
|
49
|
+
1
|
|
50
|
+
>>> account = aeb43.accounts[0]
|
|
51
|
+
>>> account.number
|
|
52
|
+
'0001414452'
|
|
53
|
+
>>> account.start_date
|
|
54
|
+
datetime.date(2018, 3, 18)
|
|
55
|
+
>>> account.end_date
|
|
56
|
+
datetime.date(2018, 3, 20)
|
|
57
|
+
>>> account.initial_balance
|
|
58
|
+
Decimal('3005')
|
|
59
|
+
>>> account.final_balance
|
|
60
|
+
Decimal('2994.02')
|
|
61
|
+
>>> account.currency
|
|
62
|
+
'978'
|
|
63
|
+
|
|
64
|
+
The transactions::
|
|
65
|
+
|
|
66
|
+
>>> len(account.transactions)
|
|
67
|
+
1
|
|
68
|
+
>>> transaction = account.transactions[0]
|
|
69
|
+
>>> transaction.transaction_date
|
|
70
|
+
datetime.date(2018, 3, 19)
|
|
71
|
+
>>> transaction.value_date
|
|
72
|
+
datetime.date(2018, 3, 19)
|
|
73
|
+
>>> transaction.amount
|
|
74
|
+
Decimal('-10.98')
|
|
75
|
+
>>> transaction.shared_item
|
|
76
|
+
'12'
|
|
77
|
+
>>> transaction.own_item
|
|
78
|
+
'408'
|
|
79
|
+
>>> transaction.document
|
|
80
|
+
'0000000000'
|
|
81
|
+
>>> transaction.reference1
|
|
82
|
+
'000000000000'
|
|
83
|
+
>>> transaction.reference2
|
|
84
|
+
'5540014387733014'
|
|
85
|
+
>>> transaction.items
|
|
86
|
+
['COMPRA TARG 5540XXXXXXXX3014 DNH*MICHA', 'EL SCOTT']
|
|
87
|
+
|
|
88
|
+
To report issues please visit the `aeb43 bugtracker`_.
|
|
89
|
+
|
|
90
|
+
.. _aeb43 bugtracker: https://bugs.tryton.org/aeb43
|
aeb43-0.1.0/README.rst
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
aeb43
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
aeb43 is a parser for AEB43 files.
|
|
5
|
+
|
|
6
|
+
Nutshell
|
|
7
|
+
--------
|
|
8
|
+
|
|
9
|
+
Import::
|
|
10
|
+
|
|
11
|
+
>>> import os
|
|
12
|
+
>>> from aeb43 import AEB43
|
|
13
|
+
|
|
14
|
+
Instantiate::
|
|
15
|
+
|
|
16
|
+
>>> aeb43 = AEB43('aeb43/AEB43.txt')
|
|
17
|
+
|
|
18
|
+
The accounts::
|
|
19
|
+
|
|
20
|
+
>>> len(aeb43.accounts)
|
|
21
|
+
1
|
|
22
|
+
>>> account = aeb43.accounts[0]
|
|
23
|
+
>>> account.number
|
|
24
|
+
'0001414452'
|
|
25
|
+
>>> account.start_date
|
|
26
|
+
datetime.date(2018, 3, 18)
|
|
27
|
+
>>> account.end_date
|
|
28
|
+
datetime.date(2018, 3, 20)
|
|
29
|
+
>>> account.initial_balance
|
|
30
|
+
Decimal('3005')
|
|
31
|
+
>>> account.final_balance
|
|
32
|
+
Decimal('2994.02')
|
|
33
|
+
>>> account.currency
|
|
34
|
+
'978'
|
|
35
|
+
|
|
36
|
+
The transactions::
|
|
37
|
+
|
|
38
|
+
>>> len(account.transactions)
|
|
39
|
+
1
|
|
40
|
+
>>> transaction = account.transactions[0]
|
|
41
|
+
>>> transaction.transaction_date
|
|
42
|
+
datetime.date(2018, 3, 19)
|
|
43
|
+
>>> transaction.value_date
|
|
44
|
+
datetime.date(2018, 3, 19)
|
|
45
|
+
>>> transaction.amount
|
|
46
|
+
Decimal('-10.98')
|
|
47
|
+
>>> transaction.shared_item
|
|
48
|
+
'12'
|
|
49
|
+
>>> transaction.own_item
|
|
50
|
+
'408'
|
|
51
|
+
>>> transaction.document
|
|
52
|
+
'0000000000'
|
|
53
|
+
>>> transaction.reference1
|
|
54
|
+
'000000000000'
|
|
55
|
+
>>> transaction.reference2
|
|
56
|
+
'5540014387733014'
|
|
57
|
+
>>> transaction.items
|
|
58
|
+
['COMPRA TARG 5540XXXXXXXX3014 DNH*MICHA', 'EL SCOTT']
|
|
59
|
+
|
|
60
|
+
To report issues please visit the `aeb43 bugtracker`_.
|
|
61
|
+
|
|
62
|
+
.. _aeb43 bugtracker: https://bugs.tryton.org/aeb43
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
110081539800014144521803181803202000000003005009783DUNDER MIFFLIN
|
|
2
|
+
22 09011803191803191240810000000000109800000000000000000000005540014387733014
|
|
3
|
+
2301COMPRA TARG 5540XXXXXXXX3014 DNH*MICHAEL SCOTT
|
|
4
|
+
3300815398000141445200001000000000010980000000000000000000200000000299402978
|
|
5
|
+
88999999999999999999000004
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# This file is part of aeb43. The COPYRIGHT file at the top level of
|
|
2
|
+
# this repository contains the full copyright notices and license terms.
|
|
3
|
+
"""a parser for AEB43 files
|
|
4
|
+
"""
|
|
5
|
+
__version__ = '0.1.0'
|
|
6
|
+
__all__ = ['AEB43']
|
|
7
|
+
|
|
8
|
+
import datetime as dt
|
|
9
|
+
import io
|
|
10
|
+
from decimal import Decimal
|
|
11
|
+
|
|
12
|
+
from stdnum.es.ccc import calc_check_digits, to_iban
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _parse_date(date):
|
|
16
|
+
return dt.datetime.strptime(date, '%y%m%d').date()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class AEB43:
|
|
20
|
+
|
|
21
|
+
def __init__(self, name, encoding=None):
|
|
22
|
+
self.accounts = []
|
|
23
|
+
|
|
24
|
+
if isinstance(name, (bytes, str)):
|
|
25
|
+
with io.open(name, encoding=encoding, mode='r') as f:
|
|
26
|
+
self._parse(f)
|
|
27
|
+
else:
|
|
28
|
+
self._parse(name)
|
|
29
|
+
|
|
30
|
+
def _parse(self, f):
|
|
31
|
+
account = transaction = None
|
|
32
|
+
count = 0
|
|
33
|
+
for line in self._readline(f):
|
|
34
|
+
code = line[:2]
|
|
35
|
+
if code == '00':
|
|
36
|
+
self._parse_file_header(line)
|
|
37
|
+
elif code == '11':
|
|
38
|
+
count += 1
|
|
39
|
+
account = Account()
|
|
40
|
+
self.accounts.append(account)
|
|
41
|
+
self._parse_account_header(line, account)
|
|
42
|
+
elif code == '22':
|
|
43
|
+
count += 1
|
|
44
|
+
transaction = Transaction()
|
|
45
|
+
account.transactions.append(transaction)
|
|
46
|
+
self._parse_transaction(line, transaction)
|
|
47
|
+
elif code == '23':
|
|
48
|
+
count += 1
|
|
49
|
+
self._parse_transaction_optional_item(line, transaction)
|
|
50
|
+
elif code == '33':
|
|
51
|
+
count += 1
|
|
52
|
+
self._parse_account_end(line, account)
|
|
53
|
+
account = transaction = None
|
|
54
|
+
elif code == '88':
|
|
55
|
+
assert count == int(line[20:26])
|
|
56
|
+
account = transaction = None
|
|
57
|
+
break
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def _readline(f):
|
|
61
|
+
for line in f:
|
|
62
|
+
yield line
|
|
63
|
+
|
|
64
|
+
def _parse_file_header(self, line):
|
|
65
|
+
self.bank_code = line[2:6]
|
|
66
|
+
self.accounting_date = _parse_date(line[6:12])
|
|
67
|
+
|
|
68
|
+
def _parse_account_header(self, line, account):
|
|
69
|
+
account.bank_code = line[2:6]
|
|
70
|
+
account.branch_code = line[6:10]
|
|
71
|
+
account.number = line[10:20]
|
|
72
|
+
account.start_date = _parse_date(line[20:26])
|
|
73
|
+
account.end_date = _parse_date(line[26:32])
|
|
74
|
+
sign = {
|
|
75
|
+
'1': -1,
|
|
76
|
+
'2': 1,
|
|
77
|
+
}[line[32]]
|
|
78
|
+
account.initial_balance = sign * Decimal(line[33:47]) / 100
|
|
79
|
+
account.currency = line[47:50]
|
|
80
|
+
account.name = line[51:77].strip()
|
|
81
|
+
account.code = line[77:80]
|
|
82
|
+
|
|
83
|
+
def _parse_transaction(self, line, transaction):
|
|
84
|
+
transaction.branch_code = line[6:10]
|
|
85
|
+
transaction.transaction_date = _parse_date(line[10:16])
|
|
86
|
+
transaction.value_date = _parse_date(line[16:22])
|
|
87
|
+
transaction.shared_item = line[22:24]
|
|
88
|
+
transaction.own_item = line[24:27]
|
|
89
|
+
sign = {
|
|
90
|
+
'1': -1,
|
|
91
|
+
'2': 1,
|
|
92
|
+
}[line[27]]
|
|
93
|
+
transaction.amount = sign * Decimal(line[28:42]) / 100
|
|
94
|
+
transaction.document = line[42:52]
|
|
95
|
+
transaction.reference1 = line[52:64]
|
|
96
|
+
transaction.reference2 = line[64:80]
|
|
97
|
+
|
|
98
|
+
def _parse_transaction_optional_item(self, line, transaction):
|
|
99
|
+
transaction.items.append(line[4:42].strip())
|
|
100
|
+
transaction.items.append(line[42:80].strip())
|
|
101
|
+
|
|
102
|
+
def _parse_account_end(self, line, account):
|
|
103
|
+
assert account.bank_code == line[2:6]
|
|
104
|
+
assert account.branch_code == line[6:10]
|
|
105
|
+
assert account.number == line[10:20]
|
|
106
|
+
assert account.number_of_debit == int(line[20:25])
|
|
107
|
+
assert account.total_debit == Decimal(line[25:39]) / 100
|
|
108
|
+
assert account.number_of_credit == int(line[39:44])
|
|
109
|
+
assert account.total_credit == Decimal(line[44:58]) / 100
|
|
110
|
+
sign = {
|
|
111
|
+
'1': -1,
|
|
112
|
+
'2': 1,
|
|
113
|
+
}[line[58]]
|
|
114
|
+
account.final_balance = sign * Decimal(line[59:73]) / 100
|
|
115
|
+
assert account.currency == line[73:76]
|
|
116
|
+
|
|
117
|
+
assert (
|
|
118
|
+
account.initial_balance
|
|
119
|
+
- account.total_debit
|
|
120
|
+
+ account.total_credit) == account.final_balance
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class _SlotsNone:
|
|
124
|
+
def __init__(self, *args, **kwargs):
|
|
125
|
+
super().__init__(*args, **kwargs)
|
|
126
|
+
for name in self.__slots__:
|
|
127
|
+
setattr(self, name, None)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class Account(_SlotsNone):
|
|
131
|
+
__slots__ = (
|
|
132
|
+
'bank_code', 'branch_code', 'number', 'start_date', 'end_date',
|
|
133
|
+
'initial_balance', 'final_balance', 'currency', 'name', 'code',
|
|
134
|
+
'transactions')
|
|
135
|
+
|
|
136
|
+
def __init__(self):
|
|
137
|
+
super().__init__()
|
|
138
|
+
self.transactions = []
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def client_account_code(self):
|
|
142
|
+
check = calc_check_digits(
|
|
143
|
+
self.bank_code + self.branch_code + '00' + self.number)
|
|
144
|
+
return self.bank_code + self.branch_code + check + self.number
|
|
145
|
+
|
|
146
|
+
ccc = client_account_code
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def iban(self):
|
|
150
|
+
return to_iban(self.client_account_code)
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def number_of_debit(self):
|
|
154
|
+
return len([t for t in self.transactions if t.amount < 0])
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def total_debit(self):
|
|
158
|
+
return -sum((t.amount for t in self.transactions if t.amount < 0))
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def number_of_credit(self):
|
|
162
|
+
return len([t for t in self.transactions if t.amount > 0])
|
|
163
|
+
|
|
164
|
+
@property
|
|
165
|
+
def total_credit(self):
|
|
166
|
+
return -sum((t.amount for t in self.transactions if t.amount > 0))
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class Transaction(_SlotsNone):
|
|
170
|
+
__slots__ = (
|
|
171
|
+
'branch_code', 'transaction_date', 'value_date', 'shared_item',
|
|
172
|
+
'own_item', 'amount', 'document', 'reference1', 'reference2', 'items')
|
|
173
|
+
|
|
174
|
+
def __init__(self):
|
|
175
|
+
super().__init__()
|
|
176
|
+
self.items = []
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# This file is part of aeb43. The COPYRIGHT file at the top level of
|
|
2
|
+
# this repository contains the full copyright notices and license terms.
|
|
3
|
+
"""Test AEB43
|
|
4
|
+
"""
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import io
|
|
7
|
+
import os
|
|
8
|
+
import unittest
|
|
9
|
+
from decimal import Decimal
|
|
10
|
+
|
|
11
|
+
from aeb43 import AEB43
|
|
12
|
+
|
|
13
|
+
here = os.path.dirname(__file__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TestAEB43(unittest.TestCase):
|
|
17
|
+
|
|
18
|
+
def setUp(self):
|
|
19
|
+
self.aeb43 = AEB43(os.path.join(here, 'AEB43.txt'))
|
|
20
|
+
|
|
21
|
+
def test_number_accounts(self):
|
|
22
|
+
"Test number of accounts"
|
|
23
|
+
self.assertEqual(len(self.aeb43.accounts), 1)
|
|
24
|
+
|
|
25
|
+
def test_account(self):
|
|
26
|
+
"Test account"
|
|
27
|
+
account = self.aeb43.accounts[0]
|
|
28
|
+
self.assertEqual(account.bank_code, '0081')
|
|
29
|
+
self.assertEqual(account.branch_code, '5398')
|
|
30
|
+
self.assertEqual(account.number, '0001414452')
|
|
31
|
+
self.assertEqual(account.start_date, dt.date(2018, 3, 18))
|
|
32
|
+
self.assertEqual(account.end_date, dt.date(2018, 3, 20))
|
|
33
|
+
self.assertEqual(account.initial_balance, Decimal('3005.00'))
|
|
34
|
+
self.assertEqual(account.final_balance, Decimal('2994.02'))
|
|
35
|
+
self.assertEqual(account.currency, '978')
|
|
36
|
+
self.assertEqual(account.name, 'DUNDER MIFFLIN')
|
|
37
|
+
self.assertEqual(account.code, ' ')
|
|
38
|
+
self.assertEqual(account.client_account_code, '00815398730001414452')
|
|
39
|
+
self.assertEqual(account.iban, 'ES0600815398730001414452')
|
|
40
|
+
|
|
41
|
+
def test_number_transactions(self):
|
|
42
|
+
"Test number of transactions"
|
|
43
|
+
account = self.aeb43.accounts[0]
|
|
44
|
+
self.assertEqual(len(account.transactions), 1)
|
|
45
|
+
|
|
46
|
+
def test_transaction(self):
|
|
47
|
+
"Test transaction"
|
|
48
|
+
account = self.aeb43.accounts[0]
|
|
49
|
+
transaction = account.transactions[0]
|
|
50
|
+
self.assertEqual(transaction.branch_code, '0901')
|
|
51
|
+
self.assertEqual(transaction.transaction_date, dt.date(2018, 3, 19))
|
|
52
|
+
self.assertEqual(transaction.value_date, dt.date(2018, 3, 19))
|
|
53
|
+
self.assertEqual(transaction.shared_item, '12')
|
|
54
|
+
self.assertEqual(transaction.own_item, '408')
|
|
55
|
+
self.assertEqual(transaction.amount, Decimal('-10.98'))
|
|
56
|
+
self.assertEqual(transaction.document, '0' * 10)
|
|
57
|
+
self.assertEqual(transaction.reference1, '0' * 12)
|
|
58
|
+
self.assertEqual(transaction.reference2, '5540014387733014')
|
|
59
|
+
self.assertEqual(
|
|
60
|
+
transaction.items,
|
|
61
|
+
['COMPRA TARG 5540XXXXXXXX3014 DNH*MICHA', 'EL SCOTT'])
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TestAEB43Stream(TestAEB43):
|
|
65
|
+
|
|
66
|
+
def setUp(self):
|
|
67
|
+
with io.open(os.path.join(here, 'AEB43.txt')) as f:
|
|
68
|
+
self.aeb43 = AEB43(f)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file is part of aeb43. The COPYRIGHT file at the top level of
|
|
2
|
+
# this repository contains the full copyright notices and license terms.
|
|
3
|
+
import doctest
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
here = os.path.dirname(__file__)
|
|
7
|
+
readme = os.path.normpath(os.path.join(here, '..', 'README.rst'))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def load_tests(loader, tests, pattern):
|
|
11
|
+
if os.path.isfile(readme):
|
|
12
|
+
tests.addTest(doctest.DocFileSuite(
|
|
13
|
+
readme, module_relative=False,
|
|
14
|
+
encoding='utf-8',
|
|
15
|
+
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
|
16
|
+
return tests
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: aeb43
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A module to parse AEB43 files
|
|
5
|
+
Home-page: https://pypi.org/project/aeb43/
|
|
6
|
+
Download-URL: https://downloads.tryton.org/aeb43/
|
|
7
|
+
Author: Tryton
|
|
8
|
+
Author-email: foundation@tryton.org
|
|
9
|
+
License: BSD
|
|
10
|
+
Project-URL: Bug Tracker, https://bugs.tryton.org/aeb43
|
|
11
|
+
Project-URL: Forum, https://discuss.tryton.org/tags/aeb43
|
|
12
|
+
Project-URL: Source Code, https://code.tryton.org/aeb43
|
|
13
|
+
Keywords: AEB43 parser
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Office/Business
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: python-stdnum
|
|
28
|
+
|
|
29
|
+
aeb43
|
|
30
|
+
=====
|
|
31
|
+
|
|
32
|
+
aeb43 is a parser for AEB43 files.
|
|
33
|
+
|
|
34
|
+
Nutshell
|
|
35
|
+
--------
|
|
36
|
+
|
|
37
|
+
Import::
|
|
38
|
+
|
|
39
|
+
>>> import os
|
|
40
|
+
>>> from aeb43 import AEB43
|
|
41
|
+
|
|
42
|
+
Instantiate::
|
|
43
|
+
|
|
44
|
+
>>> aeb43 = AEB43('aeb43/AEB43.txt')
|
|
45
|
+
|
|
46
|
+
The accounts::
|
|
47
|
+
|
|
48
|
+
>>> len(aeb43.accounts)
|
|
49
|
+
1
|
|
50
|
+
>>> account = aeb43.accounts[0]
|
|
51
|
+
>>> account.number
|
|
52
|
+
'0001414452'
|
|
53
|
+
>>> account.start_date
|
|
54
|
+
datetime.date(2018, 3, 18)
|
|
55
|
+
>>> account.end_date
|
|
56
|
+
datetime.date(2018, 3, 20)
|
|
57
|
+
>>> account.initial_balance
|
|
58
|
+
Decimal('3005')
|
|
59
|
+
>>> account.final_balance
|
|
60
|
+
Decimal('2994.02')
|
|
61
|
+
>>> account.currency
|
|
62
|
+
'978'
|
|
63
|
+
|
|
64
|
+
The transactions::
|
|
65
|
+
|
|
66
|
+
>>> len(account.transactions)
|
|
67
|
+
1
|
|
68
|
+
>>> transaction = account.transactions[0]
|
|
69
|
+
>>> transaction.transaction_date
|
|
70
|
+
datetime.date(2018, 3, 19)
|
|
71
|
+
>>> transaction.value_date
|
|
72
|
+
datetime.date(2018, 3, 19)
|
|
73
|
+
>>> transaction.amount
|
|
74
|
+
Decimal('-10.98')
|
|
75
|
+
>>> transaction.shared_item
|
|
76
|
+
'12'
|
|
77
|
+
>>> transaction.own_item
|
|
78
|
+
'408'
|
|
79
|
+
>>> transaction.document
|
|
80
|
+
'0000000000'
|
|
81
|
+
>>> transaction.reference1
|
|
82
|
+
'000000000000'
|
|
83
|
+
>>> transaction.reference2
|
|
84
|
+
'5540014387733014'
|
|
85
|
+
>>> transaction.items
|
|
86
|
+
['COMPRA TARG 5540XXXXXXXX3014 DNH*MICHA', 'EL SCOTT']
|
|
87
|
+
|
|
88
|
+
To report issues please visit the `aeb43 bugtracker`_.
|
|
89
|
+
|
|
90
|
+
.. _aeb43 bugtracker: https://bugs.tryton.org/aeb43
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.flake8
|
|
2
|
+
.gitlab-ci.yml
|
|
3
|
+
.hgtags
|
|
4
|
+
.isort.cfg
|
|
5
|
+
CHANGELOG
|
|
6
|
+
COPYRIGHT
|
|
7
|
+
MANIFEST.in
|
|
8
|
+
README.rst
|
|
9
|
+
setup.py
|
|
10
|
+
tox.ini
|
|
11
|
+
aeb43/AEB43.txt
|
|
12
|
+
aeb43/__init__.py
|
|
13
|
+
aeb43/test.py
|
|
14
|
+
aeb43/test_readme.py
|
|
15
|
+
aeb43.egg-info/PKG-INFO
|
|
16
|
+
aeb43.egg-info/SOURCES.txt
|
|
17
|
+
aeb43.egg-info/dependency_links.txt
|
|
18
|
+
aeb43.egg-info/requires.txt
|
|
19
|
+
aeb43.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
python-stdnum
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aeb43
|
aeb43-0.1.0/setup.cfg
ADDED
aeb43-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# This file is part of aeb43. The COPYRIGHT file at the top level of
|
|
3
|
+
# this repository contains the full copyright notices and license terms.
|
|
4
|
+
import codecs
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
|
|
8
|
+
from setuptools import find_packages, setup
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def read(fname):
|
|
12
|
+
return codecs.open(
|
|
13
|
+
os.path.join(os.path.dirname(__file__), fname), 'r', 'utf-8').read()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_version():
|
|
17
|
+
init = read(os.path.join('aeb43', '__init__.py'))
|
|
18
|
+
return re.search("__version__ = '([0-9.]*)'", init).group(1)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
setup(name='aeb43',
|
|
22
|
+
version=get_version(),
|
|
23
|
+
description='A module to parse AEB43 files',
|
|
24
|
+
long_description=read('README.rst'),
|
|
25
|
+
author='Tryton',
|
|
26
|
+
author_email='foundation@tryton.org',
|
|
27
|
+
url='https://pypi.org/project/aeb43/',
|
|
28
|
+
download_url='https://downloads.tryton.org/aeb43/',
|
|
29
|
+
project_urls={
|
|
30
|
+
"Bug Tracker": 'https://bugs.tryton.org/aeb43',
|
|
31
|
+
"Forum": 'https://discuss.tryton.org/tags/aeb43',
|
|
32
|
+
"Source Code": 'https://code.tryton.org/aeb43',
|
|
33
|
+
},
|
|
34
|
+
keywords='AEB43 parser',
|
|
35
|
+
packages=find_packages(),
|
|
36
|
+
package_data={
|
|
37
|
+
'aeb43': ['AEB43.txt'],
|
|
38
|
+
},
|
|
39
|
+
python_requires='>=3.8',
|
|
40
|
+
install_requires=['python-stdnum'],
|
|
41
|
+
classifiers=[
|
|
42
|
+
'Intended Audience :: Developers',
|
|
43
|
+
'License :: OSI Approved :: BSD License',
|
|
44
|
+
'Operating System :: OS Independent',
|
|
45
|
+
'Programming Language :: Python :: 3',
|
|
46
|
+
'Programming Language :: Python :: 3.8',
|
|
47
|
+
'Programming Language :: Python :: 3.9',
|
|
48
|
+
'Programming Language :: Python :: 3.10',
|
|
49
|
+
'Programming Language :: Python :: 3.11',
|
|
50
|
+
'Programming Language :: Python :: 3.12',
|
|
51
|
+
'Topic :: Office/Business',
|
|
52
|
+
'Topic :: Software Development :: Libraries',
|
|
53
|
+
'Topic :: Utilities',
|
|
54
|
+
],
|
|
55
|
+
license='BSD',
|
|
56
|
+
)
|
aeb43-0.1.0/tox.ini
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Tox (http://tox.testrun.org/) is a tool for running tests
|
|
2
|
+
# in multiple virtualenvs. This configuration file will run the
|
|
3
|
+
# test suite on all supported python versions. To use it, "pip install tox"
|
|
4
|
+
# and then run "tox" from this directory.
|
|
5
|
+
|
|
6
|
+
[tox]
|
|
7
|
+
envlist = py38, py39, py310, py311, py312, pypy3
|
|
8
|
+
|
|
9
|
+
[testenv]
|
|
10
|
+
usedevelop = true
|
|
11
|
+
commands =
|
|
12
|
+
coverage run --omit=*/tests/* -m xmlrunner discover -s aeb43.test {posargs}
|
|
13
|
+
commands_post =
|
|
14
|
+
coverage report --omit=README.rst
|
|
15
|
+
coverage xml --omit=README.rst
|
|
16
|
+
deps =
|
|
17
|
+
coverage
|
|
18
|
+
unittest-xml-reporting
|
|
19
|
+
passenv = *
|