ofxtools 1.1.0__tar.gz → 1.1.2__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.
- {ofxtools-1.1.0/ofxtools.egg-info → ofxtools-1.1.2}/PKG-INFO +1 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Client.py +3 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Parser.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Types.py +11 -7
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/__init__.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/header.py +3 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/interxfer.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/msgsets.py +3 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stmt.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stmtend.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stpchk.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/wire.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/xfer.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/base.py +4 -2
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/common.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/pmt.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/recur.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/common.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/email.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/i18n.py +29 -9
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/msgsets.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/securities.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/stmt.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/ofx.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/profile.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/signon.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/signup.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/tax1099.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/wrapperbases.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/scripts/ofxget.py +2 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/utils.py +6 -2
- {ofxtools-1.1.0 → ofxtools-1.1.2/ofxtools.egg-info}/PKG-INFO +1 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/pyproject.toml +1 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_i18n.py +49 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_msgsets.py +6 -1
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_types.py +146 -7
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_utils.py +10 -5
- {ofxtools-1.1.0 → ofxtools-1.1.2}/LICENSE +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/README.rst +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/docs/conf.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/fi.cfg +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/ofxget_example.cfg +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/lib.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/mail.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/recur.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/sync.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/list.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/mail.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/msgsets.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/sync.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/acct.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/mail.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/openorders.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/positions.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/transactions.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/py.typed +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/scripts/__init__.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/SOURCES.txt +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/dependency_links.txt +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/entry_points.txt +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/requires.txt +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/top_level.txt +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/setup.cfg +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/base.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_client.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_header.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_interxfer.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_mail.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_recur.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stmt.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stmtend.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stpchk.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_sync.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_wire.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_xfer.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_base.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_common.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_list.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_mail.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_pmt.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_recur.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_sync.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_common.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_email.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest_oo.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest_transactions.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_ofx.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_profile.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_securities.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_signon.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_signup.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_ofxget.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_parser.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_bank.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_billpay.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_invest.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_signon.py +0 -0
- {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_tax1099.py +0 -0
|
@@ -32,6 +32,8 @@ For example:
|
|
|
32
32
|
>>> response = client.request_statements("t0ps3kr1t", s0, s1, c0)
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
35
37
|
__all__ = [
|
|
36
38
|
"AUTH_PLACEHOLDER",
|
|
37
39
|
"StmtRq",
|
|
@@ -949,7 +951,7 @@ class OFXClient:
|
|
|
949
951
|
|
|
950
952
|
|
|
951
953
|
def wrap_stmtrq(
|
|
952
|
-
nt: RequestParam, rqs: Iterable[RequestParam], client:
|
|
954
|
+
nt: RequestParam, rqs: Iterable[RequestParam], client: OFXClient
|
|
953
955
|
) -> tuple[type[Message], list[TrnRequest]]:
|
|
954
956
|
match nt:
|
|
955
957
|
case StmtRq():
|
|
@@ -23,6 +23,8 @@ No ponies were harmed during the production of this parser:
|
|
|
23
23
|
https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
26
28
|
__all__ = ["OFXTree", "TreeBuilder", "ParseError"]
|
|
27
29
|
|
|
28
30
|
|
|
@@ -10,6 +10,8 @@ Since the OFX schema is highly nested, some of these class attributes
|
|
|
10
10
|
(e.g. ``SubAggregate``) express parent/child relationships between ``Aggregates``.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
13
15
|
__all__ = [
|
|
14
16
|
"OFXTypeWarning",
|
|
15
17
|
"OFXTypeError",
|
|
@@ -302,6 +304,8 @@ class Decimal(Element):
|
|
|
302
304
|
self.scale: decimal.Decimal | None = decimal.Decimal(
|
|
303
305
|
f"0.{'0' * (scale - 1)}1"
|
|
304
306
|
)
|
|
307
|
+
if scale == 0:
|
|
308
|
+
self.scale = decimal.Decimal("1")
|
|
305
309
|
else:
|
|
306
310
|
self.scale = None
|
|
307
311
|
|
|
@@ -313,20 +317,20 @@ class Decimal(Element):
|
|
|
313
317
|
def convert(self, value: Any) -> Any:
|
|
314
318
|
match value:
|
|
315
319
|
case decimal.Decimal():
|
|
316
|
-
|
|
317
|
-
value = value.quantize(self.scale)
|
|
318
|
-
return value
|
|
320
|
+
dec = value
|
|
319
321
|
case str():
|
|
320
322
|
# Handle Euro-style decimal separators (comma)
|
|
321
323
|
try:
|
|
322
324
|
dec = decimal.Decimal(value)
|
|
323
325
|
except decimal.InvalidOperation:
|
|
324
326
|
dec = decimal.Decimal(value.replace(",", "."))
|
|
325
|
-
if self.scale is not None:
|
|
326
|
-
dec = dec.quantize(self.scale)
|
|
327
|
-
return dec
|
|
328
327
|
case _:
|
|
329
|
-
|
|
328
|
+
dec = self.__type__(value)
|
|
329
|
+
|
|
330
|
+
if self.scale is not None:
|
|
331
|
+
dec = dec.quantize(self.scale)
|
|
332
|
+
|
|
333
|
+
return dec
|
|
330
334
|
|
|
331
335
|
def _unconvert(self, value: Any) -> Any:
|
|
332
336
|
match value:
|
|
@@ -17,6 +17,8 @@ appropriate header class based on OFX version #. It's used by
|
|
|
17
17
|
`ofxtools.Client`.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
20
22
|
__all__ = [
|
|
21
23
|
"OFXHeaderError",
|
|
22
24
|
"OFXHeaderV1",
|
|
@@ -53,7 +55,7 @@ class OFXHeaderBase:
|
|
|
53
55
|
codec: Any = NotImplemented # Define in subclass
|
|
54
56
|
|
|
55
57
|
@classmethod
|
|
56
|
-
def parse(cls, rawheader: str) -> tuple[
|
|
58
|
+
def parse(cls, rawheader: str) -> tuple[OFXHeaderBase, int]:
|
|
57
59
|
"""
|
|
58
60
|
Instantiate from string.
|
|
59
61
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Banking message sets
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
5
7
|
__all__ = [
|
|
6
8
|
"BANKMSGSRQV1",
|
|
7
9
|
"BANKMSGSRSV1",
|
|
@@ -106,7 +108,7 @@ class BANKMSGSRQV1(Aggregate):
|
|
|
106
108
|
stmtrq = None
|
|
107
109
|
if isinstance(trnrq, STMTTRNRQ):
|
|
108
110
|
stmtrq = trnrq.stmtrq
|
|
109
|
-
elif isinstance(trnrq,
|
|
111
|
+
elif isinstance(trnrq, STMTENDTRNRQ):
|
|
110
112
|
stmtrq = trnrq.stmtendrq
|
|
111
113
|
|
|
112
114
|
if stmtrq is not None:
|
|
@@ -16,6 +16,8 @@ the OFX spec, to be found in the package namespace by
|
|
|
16
16
|
``Aggregate.from_etree()`` which is called by the ``ofxtools.Parser``.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
19
21
|
__all__ = ["Aggregate", "ElementList"]
|
|
20
22
|
|
|
21
23
|
|
|
@@ -217,7 +219,7 @@ class Aggregate(list[Any]):
|
|
|
217
219
|
raise OFXSpecError(msg)
|
|
218
220
|
|
|
219
221
|
@classmethod
|
|
220
|
-
def from_etree(cls, elem: ET.Element) ->
|
|
222
|
+
def from_etree(cls, elem: ET.Element) -> Aggregate:
|
|
221
223
|
"""
|
|
222
224
|
Instantiate from ``xml.etree.ElementTree.Element``.
|
|
223
225
|
|
|
@@ -238,7 +240,7 @@ class Aggregate(list[Any]):
|
|
|
238
240
|
return instance # type: ignore[no-any-return]
|
|
239
241
|
|
|
240
242
|
@classmethod
|
|
241
|
-
def _convert(cls, elem: ET.Element) ->
|
|
243
|
+
def _convert(cls, elem: ET.Element) -> Aggregate:
|
|
242
244
|
"""Instantiate from ``xml.etree.ElementTree.Element``.
|
|
243
245
|
|
|
244
246
|
N.B. this method must be called on the appropriate subclass,
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
International support - OFX Section 5
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
5
7
|
__all__ = ["LANG_CODES", "CURRENCY_CODES", "COUNTRY_CODES", "CURRENCY", "ORIGCURRENCY"]
|
|
6
8
|
|
|
7
9
|
|
|
@@ -518,6 +520,7 @@ ISO4217 = (
|
|
|
518
520
|
"BSD",
|
|
519
521
|
"BTN",
|
|
520
522
|
"BWP",
|
|
523
|
+
"BYN",
|
|
521
524
|
"BYR",
|
|
522
525
|
"BZD",
|
|
523
526
|
"CAD",
|
|
@@ -593,6 +596,7 @@ ISO4217 = (
|
|
|
593
596
|
"MNT",
|
|
594
597
|
"MOP",
|
|
595
598
|
"MRO",
|
|
599
|
+
"MRU",
|
|
596
600
|
"MUR",
|
|
597
601
|
"MVR",
|
|
598
602
|
"MWK",
|
|
@@ -626,10 +630,13 @@ ISO4217 = (
|
|
|
626
630
|
"SEK",
|
|
627
631
|
"SGD",
|
|
628
632
|
"SHP",
|
|
633
|
+
"SLE",
|
|
629
634
|
"SLL",
|
|
630
635
|
"SOS",
|
|
631
636
|
"SRD",
|
|
637
|
+
"SSP",
|
|
632
638
|
"STD",
|
|
639
|
+
"STN",
|
|
633
640
|
"SVC",
|
|
634
641
|
"SYP",
|
|
635
642
|
"SZL",
|
|
@@ -649,11 +656,15 @@ ISO4217 = (
|
|
|
649
656
|
"USS",
|
|
650
657
|
"UYI",
|
|
651
658
|
"UYU",
|
|
659
|
+
"UYW",
|
|
652
660
|
"UZS",
|
|
661
|
+
"VED",
|
|
653
662
|
"VEF",
|
|
663
|
+
"VES",
|
|
654
664
|
"VND",
|
|
655
665
|
"VUV",
|
|
656
666
|
"WST",
|
|
667
|
+
"XAD",
|
|
657
668
|
"XAF",
|
|
658
669
|
"XAG",
|
|
659
670
|
"XAU",
|
|
@@ -662,16 +673,21 @@ ISO4217 = (
|
|
|
662
673
|
"XBC",
|
|
663
674
|
"XBD",
|
|
664
675
|
"XCD",
|
|
676
|
+
"XCG",
|
|
665
677
|
"XDR",
|
|
666
678
|
"XOF",
|
|
667
679
|
"XPD",
|
|
668
680
|
"XPF",
|
|
669
681
|
"XPT",
|
|
682
|
+
"XSU",
|
|
670
683
|
"XTS",
|
|
684
|
+
"XUA",
|
|
671
685
|
"XXX",
|
|
672
686
|
"YER",
|
|
673
687
|
"ZAR",
|
|
674
688
|
"ZMK",
|
|
689
|
+
"ZMW",
|
|
690
|
+
"ZWG",
|
|
675
691
|
"ZWL",
|
|
676
692
|
"CNH",
|
|
677
693
|
)
|
|
@@ -954,6 +970,7 @@ ISO3166_1a3 = (
|
|
|
954
970
|
"BDI",
|
|
955
971
|
"BEL",
|
|
956
972
|
"BEN",
|
|
973
|
+
"BES",
|
|
957
974
|
"BFA",
|
|
958
975
|
"BGD",
|
|
959
976
|
"BGR",
|
|
@@ -963,7 +980,7 @@ ISO3166_1a3 = (
|
|
|
963
980
|
"BLM",
|
|
964
981
|
"BLR",
|
|
965
982
|
"BLZ",
|
|
966
|
-
"
|
|
983
|
+
"BMU",
|
|
967
984
|
"BOL",
|
|
968
985
|
"BRA",
|
|
969
986
|
"BRB",
|
|
@@ -987,17 +1004,18 @@ ISO3166_1a3 = (
|
|
|
987
1004
|
"CPV",
|
|
988
1005
|
"CRI",
|
|
989
1006
|
"CUB",
|
|
1007
|
+
"CUW",
|
|
990
1008
|
"CXR",
|
|
991
1009
|
"CYM",
|
|
992
1010
|
"CYP",
|
|
993
1011
|
"CZE",
|
|
994
|
-
"
|
|
1012
|
+
"DEU",
|
|
995
1013
|
"DJI",
|
|
996
1014
|
"DMA",
|
|
997
1015
|
"DNK",
|
|
998
1016
|
"DOM",
|
|
999
1017
|
"DZA",
|
|
1000
|
-
"
|
|
1018
|
+
"ECU",
|
|
1001
1019
|
"EGY",
|
|
1002
1020
|
"ERI",
|
|
1003
1021
|
"ESH",
|
|
@@ -1064,7 +1082,7 @@ ISO3166_1a3 = (
|
|
|
1064
1082
|
"LIE",
|
|
1065
1083
|
"LKA",
|
|
1066
1084
|
"LSO",
|
|
1067
|
-
"
|
|
1085
|
+
"LTU",
|
|
1068
1086
|
"LUX",
|
|
1069
1087
|
"LVA",
|
|
1070
1088
|
"MAC",
|
|
@@ -1097,11 +1115,11 @@ ISO3166_1a3 = (
|
|
|
1097
1115
|
"NFK",
|
|
1098
1116
|
"NGA",
|
|
1099
1117
|
"NIC",
|
|
1100
|
-
"
|
|
1118
|
+
"NIU",
|
|
1101
1119
|
"NLD",
|
|
1102
1120
|
"NOR",
|
|
1103
1121
|
"NPL",
|
|
1104
|
-
"
|
|
1122
|
+
"NRU",
|
|
1105
1123
|
"NZL",
|
|
1106
1124
|
"OMN",
|
|
1107
1125
|
"PAK",
|
|
@@ -1119,11 +1137,11 @@ ISO3166_1a3 = (
|
|
|
1119
1137
|
"PSE",
|
|
1120
1138
|
"PYF",
|
|
1121
1139
|
"QAT",
|
|
1122
|
-
"
|
|
1123
|
-
"
|
|
1140
|
+
"REU",
|
|
1141
|
+
"ROU",
|
|
1124
1142
|
"RUS",
|
|
1125
1143
|
"RWA",
|
|
1126
|
-
"
|
|
1144
|
+
"SAU",
|
|
1127
1145
|
"SDN",
|
|
1128
1146
|
"SEN",
|
|
1129
1147
|
"SGP",
|
|
@@ -1137,12 +1155,14 @@ ISO3166_1a3 = (
|
|
|
1137
1155
|
"SOM",
|
|
1138
1156
|
"SPM",
|
|
1139
1157
|
"SRB",
|
|
1158
|
+
"SSD",
|
|
1140
1159
|
"STP",
|
|
1141
1160
|
"SUR",
|
|
1142
1161
|
"SVK",
|
|
1143
1162
|
"SVN",
|
|
1144
1163
|
"SWE",
|
|
1145
1164
|
"SWZ",
|
|
1165
|
+
"SXM",
|
|
1146
1166
|
"SYC",
|
|
1147
1167
|
"SYR",
|
|
1148
1168
|
"TCA",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Utility functions and classes"""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
# stdlib imports
|
|
4
6
|
import calendar
|
|
5
7
|
import datetime
|
|
@@ -284,8 +286,8 @@ class NYSEcalendar:
|
|
|
284
286
|
NYSE holiday calendar.
|
|
285
287
|
|
|
286
288
|
The Exchange is closed on: New Year's Day, Martin Luther King Jr. Day,
|
|
287
|
-
Washington's Birthday, Good Friday, Memorial Day,
|
|
288
|
-
Labor Day, Thanksgiving Day, and Christmas Day.
|
|
289
|
+
Washington's Birthday, Good Friday, Memorial Day, Juneteenth (since 2022),
|
|
290
|
+
Independence Day, Labor Day, Thanksgiving Day, and Christmas Day.
|
|
289
291
|
|
|
290
292
|
When a fixed-date holiday falls on Saturday, the preceding Friday is
|
|
291
293
|
observed — except New Year's Day, where Dec 31 is the year-end accounting
|
|
@@ -333,6 +335,8 @@ class NYSEcalendar:
|
|
|
333
335
|
cls.mondays(year, 9)[0], # Labor Day (1st Mon in Sep)
|
|
334
336
|
cls.thursdays(year, 11)[3], # Thanksgiving (4th Thu in Nov)
|
|
335
337
|
]
|
|
338
|
+
if year >= 2022:
|
|
339
|
+
hols.append(cls._observed(datetime.date(year, 6, 19))) # Juneteenth
|
|
336
340
|
# New Year's Day: Saturday → skipped (Dec 31 is year-end accounting close)
|
|
337
341
|
# Sunday → observed Monday Jan 2
|
|
338
342
|
# weekday → Jan 1 itself
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ofxtools"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.2"
|
|
8
8
|
description = "Library for working with Open Financial Exchange (OFX) data"
|
|
9
9
|
readme = {file = "README.rst", content-type = "text/x-rst"}
|
|
10
10
|
license = "GPL-3.0-only"
|
|
@@ -9,7 +9,12 @@ from xml.etree.ElementTree import Element, SubElement
|
|
|
9
9
|
import base
|
|
10
10
|
|
|
11
11
|
# local imports
|
|
12
|
-
from ofxtools.models.i18n import
|
|
12
|
+
from ofxtools.models.i18n import (
|
|
13
|
+
COUNTRY_CODES,
|
|
14
|
+
CURRENCY,
|
|
15
|
+
CURRENCY_CODES,
|
|
16
|
+
ORIGCURRENCY,
|
|
17
|
+
)
|
|
13
18
|
from ofxtools.utils import classproperty
|
|
14
19
|
|
|
15
20
|
|
|
@@ -48,6 +53,49 @@ class OrigcurrencyTestCase(CurrencyTestCase):
|
|
|
48
53
|
return ORIGCURRENCY(currate=Decimal("59.773"), cursym="EUR")
|
|
49
54
|
|
|
50
55
|
|
|
56
|
+
class CodeListTestCase(unittest.TestCase):
|
|
57
|
+
def test_country_codes_are_alpha3(self):
|
|
58
|
+
for code in COUNTRY_CODES:
|
|
59
|
+
self.assertRegex(code, r"^[A-Z]{3}$")
|
|
60
|
+
|
|
61
|
+
def test_country_codes(self):
|
|
62
|
+
for code in (
|
|
63
|
+
"BES",
|
|
64
|
+
"BMU",
|
|
65
|
+
"CUW",
|
|
66
|
+
"DEU",
|
|
67
|
+
"ECU",
|
|
68
|
+
"LTU",
|
|
69
|
+
"NIU",
|
|
70
|
+
"NRU",
|
|
71
|
+
"REU",
|
|
72
|
+
"ROU",
|
|
73
|
+
"SAU",
|
|
74
|
+
"SSD",
|
|
75
|
+
"SXM",
|
|
76
|
+
):
|
|
77
|
+
self.assertIn(code, COUNTRY_CODES)
|
|
78
|
+
|
|
79
|
+
def test_currency_codes(self):
|
|
80
|
+
for code in (
|
|
81
|
+
"BYN",
|
|
82
|
+
"MRU",
|
|
83
|
+
"SLE",
|
|
84
|
+
"SSP",
|
|
85
|
+
"STN",
|
|
86
|
+
"UYW",
|
|
87
|
+
"VED",
|
|
88
|
+
"VES",
|
|
89
|
+
"XAD",
|
|
90
|
+
"XCG",
|
|
91
|
+
"XSU",
|
|
92
|
+
"XUA",
|
|
93
|
+
"ZMW",
|
|
94
|
+
"ZWG",
|
|
95
|
+
):
|
|
96
|
+
self.assertIn(code, CURRENCY_CODES)
|
|
97
|
+
|
|
98
|
+
|
|
51
99
|
class OrigcurrencyMixinTestCase(unittest.TestCase):
|
|
52
100
|
"""Test Origcurrency mixin property fallback via ORIGCURRENCY (not CURRENCY)."""
|
|
53
101
|
|
|
@@ -50,7 +50,7 @@ from ofxtools.models.bank.msgsets import (
|
|
|
50
50
|
XFERPROF,
|
|
51
51
|
)
|
|
52
52
|
from ofxtools.models.bank.stmt import STMTRS
|
|
53
|
-
from ofxtools.models.bank.stmtend import STMTENDRS
|
|
53
|
+
from ofxtools.models.bank.stmtend import STMTENDRQ, STMTENDRS
|
|
54
54
|
|
|
55
55
|
# local imports
|
|
56
56
|
from ofxtools.models.base import Aggregate, UnknownTagWarning
|
|
@@ -537,6 +537,11 @@ class Bankmsgsrqv1TestCase(unittest.TestCase, base.TestAggregate):
|
|
|
537
537
|
with self.assertWarns(UnknownTagWarning):
|
|
538
538
|
Aggregate.from_etree(root)
|
|
539
539
|
|
|
540
|
+
def testPropertyAliases(self):
|
|
541
|
+
instance = Aggregate.from_etree(self.etree)
|
|
542
|
+
self.assertEqual(len(instance.statements), 4)
|
|
543
|
+
self.assertIsInstance(instance.statements[2], STMTENDRQ)
|
|
544
|
+
|
|
540
545
|
|
|
541
546
|
class Bankmsgsrsv1TestCase(unittest.TestCase, base.TestAggregate):
|
|
542
547
|
__test__ = True
|
|
@@ -8,6 +8,7 @@ import warnings
|
|
|
8
8
|
|
|
9
9
|
# local imports
|
|
10
10
|
import ofxtools
|
|
11
|
+
from ofxtools.models.base import Aggregate
|
|
11
12
|
from ofxtools.Types import OFXSpecError, OFXTypeWarning
|
|
12
13
|
from ofxtools.utils import UTC
|
|
13
14
|
|
|
@@ -365,6 +366,135 @@ class DecimalTestCase(unittest.TestCase, Base):
|
|
|
365
366
|
)
|
|
366
367
|
self.assertEqual(cmp, 0)
|
|
367
368
|
|
|
369
|
+
def test_scale_input_types(self):
|
|
370
|
+
cases = (
|
|
371
|
+
(2, 100, "100.00"),
|
|
372
|
+
(2, "100", "100.00"),
|
|
373
|
+
(2, decimal.Decimal("100"), "100.00"),
|
|
374
|
+
(2, 1.5, "1.50"),
|
|
375
|
+
(2, 1.25, "1.25"),
|
|
376
|
+
(2, (0, (1, 2, 3, 4), -3), "1.23"),
|
|
377
|
+
(2, True, "1.00"),
|
|
378
|
+
(0, 12, "12"),
|
|
379
|
+
(0, 12.75, "13"),
|
|
380
|
+
(0, "12.7", "13"),
|
|
381
|
+
(0, decimal.Decimal("12.7"), "13"),
|
|
382
|
+
(0, 0, "0"),
|
|
383
|
+
(0, -0.0, "-0"),
|
|
384
|
+
)
|
|
385
|
+
with decimal.localcontext() as ctx:
|
|
386
|
+
ctx.prec = 28
|
|
387
|
+
ctx.rounding = decimal.ROUND_HALF_EVEN
|
|
388
|
+
for scale, value, expected in cases:
|
|
389
|
+
with self.subTest(scale=scale, value=value):
|
|
390
|
+
t = self.type_(scale)
|
|
391
|
+
converted = _set(t, value)
|
|
392
|
+
self.assertEqual(
|
|
393
|
+
converted.as_tuple(), decimal.Decimal(expected).as_tuple()
|
|
394
|
+
)
|
|
395
|
+
self.assertEqual(t.unconvert(converted), expected)
|
|
396
|
+
|
|
397
|
+
def test_scale_aggregate_export(self):
|
|
398
|
+
class SCALED(Aggregate):
|
|
399
|
+
amount = ofxtools.Types.Decimal(2)
|
|
400
|
+
whole = ofxtools.Types.Decimal(0)
|
|
401
|
+
|
|
402
|
+
aggregate = SCALED(amount=100, whole="12.7")
|
|
403
|
+
tree = aggregate.to_etree()
|
|
404
|
+
self.assertEqual(tree.findtext("AMOUNT"), "100.00")
|
|
405
|
+
self.assertEqual(tree.findtext("WHOLE"), "13")
|
|
406
|
+
aggregate.amount = 1.5
|
|
407
|
+
self.assertEqual(aggregate.to_etree().findtext("AMOUNT"), "1.50")
|
|
408
|
+
|
|
409
|
+
def test_no_scale_preserves_precision(self):
|
|
410
|
+
t = self.type_()
|
|
411
|
+
with decimal.localcontext() as ctx:
|
|
412
|
+
ctx.prec = 2
|
|
413
|
+
ctx.traps[decimal.Inexact] = True
|
|
414
|
+
ctx.traps[decimal.Rounded] = True
|
|
415
|
+
for text in ("12345.678900", "-0.0000"):
|
|
416
|
+
with self.subTest(value=text):
|
|
417
|
+
value = decimal.Decimal(text)
|
|
418
|
+
self.assertIs(t.convert(value), value)
|
|
419
|
+
self.assertEqual(t.convert(text).as_tuple(), value.as_tuple())
|
|
420
|
+
|
|
421
|
+
def test_scale_rounding(self):
|
|
422
|
+
cases = (
|
|
423
|
+
(decimal.ROUND_HALF_EVEN, 0, 12.5, "12"),
|
|
424
|
+
(decimal.ROUND_HALF_UP, 0, 12.5, "13"),
|
|
425
|
+
(decimal.ROUND_HALF_EVEN, 2, 1.125, "1.12"),
|
|
426
|
+
(decimal.ROUND_HALF_UP, 2, 1.125, "1.13"),
|
|
427
|
+
)
|
|
428
|
+
for rounding, scale, value, expected in cases:
|
|
429
|
+
with self.subTest(rounding=rounding, scale=scale):
|
|
430
|
+
with decimal.localcontext() as ctx:
|
|
431
|
+
ctx.rounding = rounding
|
|
432
|
+
t = self.type_(scale)
|
|
433
|
+
self.assertEqual(t.unconvert(t.convert(value)), expected)
|
|
434
|
+
|
|
435
|
+
def test_scale_native_float_conversion(self):
|
|
436
|
+
with decimal.localcontext() as ctx:
|
|
437
|
+
ctx.rounding = decimal.ROUND_HALF_EVEN
|
|
438
|
+
t = self.type_(2)
|
|
439
|
+
self.assertEqual(t.unconvert(t.convert(2.675)), "2.67")
|
|
440
|
+
self.assertEqual(t.unconvert(t.convert("2.675")), "2.68")
|
|
441
|
+
self.assertEqual(
|
|
442
|
+
self.type_().convert(2.675).as_tuple(),
|
|
443
|
+
decimal.Decimal(2.675).as_tuple(),
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
def test_float_operation_trap(self):
|
|
447
|
+
for scale in (None, 0, 2):
|
|
448
|
+
with self.subTest(scale=scale):
|
|
449
|
+
with decimal.localcontext() as ctx:
|
|
450
|
+
ctx.traps[decimal.FloatOperation] = True
|
|
451
|
+
with self.assertRaises(decimal.FloatOperation):
|
|
452
|
+
self.type_(scale).convert(1.5)
|
|
453
|
+
|
|
454
|
+
def test_scale_quantization_traps(self):
|
|
455
|
+
cases = (
|
|
456
|
+
(decimal.Inexact, 28, 1.125),
|
|
457
|
+
(decimal.Rounded, 28, decimal.Decimal("1.230")),
|
|
458
|
+
(decimal.InvalidOperation, 2, 1.25),
|
|
459
|
+
)
|
|
460
|
+
for signal, precision, value in cases:
|
|
461
|
+
with self.subTest(signal=signal):
|
|
462
|
+
with decimal.localcontext() as ctx:
|
|
463
|
+
ctx.prec = precision
|
|
464
|
+
ctx.traps[signal] = True
|
|
465
|
+
with self.assertRaises(signal):
|
|
466
|
+
self.type_(2).convert(value)
|
|
467
|
+
|
|
468
|
+
def test_scale_untrapped_invalid_operation(self):
|
|
469
|
+
with decimal.localcontext() as ctx:
|
|
470
|
+
ctx.prec = 2
|
|
471
|
+
ctx.traps[decimal.InvalidOperation] = False
|
|
472
|
+
ctx.clear_flags()
|
|
473
|
+
self.assertTrue(self.type_(2).convert(1.25).is_nan())
|
|
474
|
+
self.assertTrue(ctx.flags[decimal.InvalidOperation])
|
|
475
|
+
|
|
476
|
+
def test_decimal_subclass_conversion(self):
|
|
477
|
+
calls = []
|
|
478
|
+
|
|
479
|
+
class CustomDecimal(decimal.Decimal):
|
|
480
|
+
def quantize(self, quantum):
|
|
481
|
+
calls.append(quantum)
|
|
482
|
+
return super().quantize(quantum)
|
|
483
|
+
|
|
484
|
+
class CustomType(ofxtools.Types.Decimal):
|
|
485
|
+
__type__ = CustomDecimal
|
|
486
|
+
|
|
487
|
+
value = CustomDecimal("1.500")
|
|
488
|
+
self.assertIs(self.type_().convert(value), value)
|
|
489
|
+
self.assertIsInstance(CustomType().convert(1), CustomDecimal)
|
|
490
|
+
self.assertEqual(calls, [])
|
|
491
|
+
for source in (value, 1.5):
|
|
492
|
+
with self.subTest(value=source):
|
|
493
|
+
calls.clear()
|
|
494
|
+
t = CustomType(2)
|
|
495
|
+
self.assertEqual(t.unconvert(t.convert(source)), "1.50")
|
|
496
|
+
self.assertEqual(calls, [decimal.Decimal("0.01")])
|
|
497
|
+
|
|
368
498
|
def test_euro_decimal_separator(self):
|
|
369
499
|
# Issue #4
|
|
370
500
|
t = self.type_()
|
|
@@ -372,15 +502,24 @@ class DecimalTestCase(unittest.TestCase, Base):
|
|
|
372
502
|
# Separators other than . and , are illegal
|
|
373
503
|
with self.assertRaises(decimal.InvalidOperation):
|
|
374
504
|
t.convert("1:23")
|
|
505
|
+
t = self.type_(2)
|
|
506
|
+
self.assertEqual(t.unconvert(t.convert("1,2")), "1.20")
|
|
507
|
+
with decimal.localcontext() as ctx:
|
|
508
|
+
ctx.traps[decimal.InvalidOperation] = False
|
|
509
|
+
ctx.clear_flags()
|
|
510
|
+
self.assertTrue(t.convert("1,2").is_nan())
|
|
511
|
+
self.assertTrue(ctx.flags[decimal.InvalidOperation])
|
|
375
512
|
|
|
376
513
|
def test_illegal(self):
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
514
|
+
for scale in (None, 0, 2):
|
|
515
|
+
with self.subTest(scale=scale):
|
|
516
|
+
t = self.type_(scale)
|
|
517
|
+
# Don't accept strings that can't be converted to Decimal
|
|
518
|
+
with self.assertRaises(decimal.InvalidOperation):
|
|
519
|
+
t.convert("foobar")
|
|
520
|
+
# Don't accept random types
|
|
521
|
+
with self.assertRaises(TypeError):
|
|
522
|
+
t.convert(object)
|
|
384
523
|
|
|
385
524
|
def test_unconvert(self):
|
|
386
525
|
t = self.type_()
|
|
@@ -308,16 +308,21 @@ class NYSEcalendarTestCase(unittest.TestCase):
|
|
|
308
308
|
hols = NYSEcalendar.holidays(2024)
|
|
309
309
|
self.assertIn(datetime.date(2024, 3, 29), hols)
|
|
310
310
|
|
|
311
|
+
def test_juneteenth(self):
|
|
312
|
+
# 2022: June 19 is Sunday -> observed June 20; not a holiday before 2022
|
|
313
|
+
self.assertIn(datetime.date(2022, 6, 20), NYSEcalendar.holidays(2022))
|
|
314
|
+
self.assertNotIn(datetime.date(2021, 6, 18), NYSEcalendar.holidays(2021))
|
|
315
|
+
|
|
311
316
|
def test_holidays_sorted(self):
|
|
312
317
|
hols = NYSEcalendar.holidays(2024)
|
|
313
318
|
self.assertEqual(hols, sorted(hols))
|
|
314
319
|
|
|
315
320
|
def test_holidays_count(self):
|
|
316
|
-
# Should be
|
|
317
|
-
# 2024 has all
|
|
318
|
-
self.assertEqual(len(NYSEcalendar.holidays(2024)),
|
|
319
|
-
# 2022 has
|
|
320
|
-
self.assertEqual(len(NYSEcalendar.holidays(2022)),
|
|
321
|
+
# Should be 10 holidays in a typical year (NYD + 9 others)
|
|
322
|
+
# 2024 has all 10 (NYD is Monday)
|
|
323
|
+
self.assertEqual(len(NYSEcalendar.holidays(2024)), 10)
|
|
324
|
+
# 2022 has 9 (NYD Saturday is skipped)
|
|
325
|
+
self.assertEqual(len(NYSEcalendar.holidays(2022)), 9)
|
|
321
326
|
|
|
322
327
|
|
|
323
328
|
class NextBizDayTestCase(unittest.TestCase):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|