ofxtools 1.1.1__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.1/ofxtools.egg-info → ofxtools-1.1.2}/PKG-INFO +1 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/Types.py +9 -7
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/msgsets.py +1 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/i18n.py +27 -9
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/utils.py +4 -2
- {ofxtools-1.1.1 → ofxtools-1.1.2/ofxtools.egg-info}/PKG-INFO +1 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/pyproject.toml +1 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_i18n.py +49 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_msgsets.py +6 -1
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_types.py +146 -7
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_utils.py +10 -5
- {ofxtools-1.1.1 → ofxtools-1.1.2}/LICENSE +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/README.rst +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/docs/conf.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/Client.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/Parser.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/config/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/config/fi.cfg +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/config/ofxget_example.cfg +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/header.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/lib.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/interxfer.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/mail.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/recur.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/stmt.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/stmtend.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/stpchk.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/sync.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/wire.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/bank/xfer.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/base.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/common.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/list.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/mail.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/msgsets.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/pmt.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/recur.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/billpay/sync.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/common.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/email.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/acct.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/mail.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/msgsets.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/openorders.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/positions.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/securities.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/stmt.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/invest/transactions.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/ofx.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/profile.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/signon.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/signup.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/tax1099.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/models/wrapperbases.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/py.typed +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/scripts/__init__.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools/scripts/ofxget.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools.egg-info/SOURCES.txt +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools.egg-info/dependency_links.txt +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools.egg-info/entry_points.txt +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools.egg-info/requires.txt +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/ofxtools.egg-info/top_level.txt +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/setup.cfg +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/base.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_client.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_header.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_interxfer.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_mail.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_recur.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_stmt.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_stmtend.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_stpchk.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_sync.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_wire.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_bank_xfer.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_base.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_common.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_list.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_mail.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_pmt.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_recur.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_billpay_sync.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_common.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_email.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_invest.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_invest_oo.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_invest_transactions.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_ofx.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_profile.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_securities.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_signon.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_models_signup.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_ofxget.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_parser.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_spec_bank.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_spec_billpay.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_spec_invest.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_spec_signon.py +0 -0
- {ofxtools-1.1.1 → ofxtools-1.1.2}/tests/test_spec_tax1099.py +0 -0
|
@@ -304,6 +304,8 @@ class Decimal(Element):
|
|
|
304
304
|
self.scale: decimal.Decimal | None = decimal.Decimal(
|
|
305
305
|
f"0.{'0' * (scale - 1)}1"
|
|
306
306
|
)
|
|
307
|
+
if scale == 0:
|
|
308
|
+
self.scale = decimal.Decimal("1")
|
|
307
309
|
else:
|
|
308
310
|
self.scale = None
|
|
309
311
|
|
|
@@ -315,20 +317,20 @@ class Decimal(Element):
|
|
|
315
317
|
def convert(self, value: Any) -> Any:
|
|
316
318
|
match value:
|
|
317
319
|
case decimal.Decimal():
|
|
318
|
-
|
|
319
|
-
value = value.quantize(self.scale)
|
|
320
|
-
return value
|
|
320
|
+
dec = value
|
|
321
321
|
case str():
|
|
322
322
|
# Handle Euro-style decimal separators (comma)
|
|
323
323
|
try:
|
|
324
324
|
dec = decimal.Decimal(value)
|
|
325
325
|
except decimal.InvalidOperation:
|
|
326
326
|
dec = decimal.Decimal(value.replace(",", "."))
|
|
327
|
-
if self.scale is not None:
|
|
328
|
-
dec = dec.quantize(self.scale)
|
|
329
|
-
return dec
|
|
330
327
|
case _:
|
|
331
|
-
|
|
328
|
+
dec = self.__type__(value)
|
|
329
|
+
|
|
330
|
+
if self.scale is not None:
|
|
331
|
+
dec = dec.quantize(self.scale)
|
|
332
|
+
|
|
333
|
+
return dec
|
|
332
334
|
|
|
333
335
|
def _unconvert(self, value: Any) -> Any:
|
|
334
336
|
match value:
|
|
@@ -108,7 +108,7 @@ class BANKMSGSRQV1(Aggregate):
|
|
|
108
108
|
stmtrq = None
|
|
109
109
|
if isinstance(trnrq, STMTTRNRQ):
|
|
110
110
|
stmtrq = trnrq.stmtrq
|
|
111
|
-
elif isinstance(trnrq,
|
|
111
|
+
elif isinstance(trnrq, STMTENDTRNRQ):
|
|
112
112
|
stmtrq = trnrq.stmtendrq
|
|
113
113
|
|
|
114
114
|
if stmtrq is not None:
|
|
@@ -520,6 +520,7 @@ ISO4217 = (
|
|
|
520
520
|
"BSD",
|
|
521
521
|
"BTN",
|
|
522
522
|
"BWP",
|
|
523
|
+
"BYN",
|
|
523
524
|
"BYR",
|
|
524
525
|
"BZD",
|
|
525
526
|
"CAD",
|
|
@@ -595,6 +596,7 @@ ISO4217 = (
|
|
|
595
596
|
"MNT",
|
|
596
597
|
"MOP",
|
|
597
598
|
"MRO",
|
|
599
|
+
"MRU",
|
|
598
600
|
"MUR",
|
|
599
601
|
"MVR",
|
|
600
602
|
"MWK",
|
|
@@ -628,10 +630,13 @@ ISO4217 = (
|
|
|
628
630
|
"SEK",
|
|
629
631
|
"SGD",
|
|
630
632
|
"SHP",
|
|
633
|
+
"SLE",
|
|
631
634
|
"SLL",
|
|
632
635
|
"SOS",
|
|
633
636
|
"SRD",
|
|
637
|
+
"SSP",
|
|
634
638
|
"STD",
|
|
639
|
+
"STN",
|
|
635
640
|
"SVC",
|
|
636
641
|
"SYP",
|
|
637
642
|
"SZL",
|
|
@@ -651,11 +656,15 @@ ISO4217 = (
|
|
|
651
656
|
"USS",
|
|
652
657
|
"UYI",
|
|
653
658
|
"UYU",
|
|
659
|
+
"UYW",
|
|
654
660
|
"UZS",
|
|
661
|
+
"VED",
|
|
655
662
|
"VEF",
|
|
663
|
+
"VES",
|
|
656
664
|
"VND",
|
|
657
665
|
"VUV",
|
|
658
666
|
"WST",
|
|
667
|
+
"XAD",
|
|
659
668
|
"XAF",
|
|
660
669
|
"XAG",
|
|
661
670
|
"XAU",
|
|
@@ -664,16 +673,21 @@ ISO4217 = (
|
|
|
664
673
|
"XBC",
|
|
665
674
|
"XBD",
|
|
666
675
|
"XCD",
|
|
676
|
+
"XCG",
|
|
667
677
|
"XDR",
|
|
668
678
|
"XOF",
|
|
669
679
|
"XPD",
|
|
670
680
|
"XPF",
|
|
671
681
|
"XPT",
|
|
682
|
+
"XSU",
|
|
672
683
|
"XTS",
|
|
684
|
+
"XUA",
|
|
673
685
|
"XXX",
|
|
674
686
|
"YER",
|
|
675
687
|
"ZAR",
|
|
676
688
|
"ZMK",
|
|
689
|
+
"ZMW",
|
|
690
|
+
"ZWG",
|
|
677
691
|
"ZWL",
|
|
678
692
|
"CNH",
|
|
679
693
|
)
|
|
@@ -956,6 +970,7 @@ ISO3166_1a3 = (
|
|
|
956
970
|
"BDI",
|
|
957
971
|
"BEL",
|
|
958
972
|
"BEN",
|
|
973
|
+
"BES",
|
|
959
974
|
"BFA",
|
|
960
975
|
"BGD",
|
|
961
976
|
"BGR",
|
|
@@ -965,7 +980,7 @@ ISO3166_1a3 = (
|
|
|
965
980
|
"BLM",
|
|
966
981
|
"BLR",
|
|
967
982
|
"BLZ",
|
|
968
|
-
"
|
|
983
|
+
"BMU",
|
|
969
984
|
"BOL",
|
|
970
985
|
"BRA",
|
|
971
986
|
"BRB",
|
|
@@ -989,17 +1004,18 @@ ISO3166_1a3 = (
|
|
|
989
1004
|
"CPV",
|
|
990
1005
|
"CRI",
|
|
991
1006
|
"CUB",
|
|
1007
|
+
"CUW",
|
|
992
1008
|
"CXR",
|
|
993
1009
|
"CYM",
|
|
994
1010
|
"CYP",
|
|
995
1011
|
"CZE",
|
|
996
|
-
"
|
|
1012
|
+
"DEU",
|
|
997
1013
|
"DJI",
|
|
998
1014
|
"DMA",
|
|
999
1015
|
"DNK",
|
|
1000
1016
|
"DOM",
|
|
1001
1017
|
"DZA",
|
|
1002
|
-
"
|
|
1018
|
+
"ECU",
|
|
1003
1019
|
"EGY",
|
|
1004
1020
|
"ERI",
|
|
1005
1021
|
"ESH",
|
|
@@ -1066,7 +1082,7 @@ ISO3166_1a3 = (
|
|
|
1066
1082
|
"LIE",
|
|
1067
1083
|
"LKA",
|
|
1068
1084
|
"LSO",
|
|
1069
|
-
"
|
|
1085
|
+
"LTU",
|
|
1070
1086
|
"LUX",
|
|
1071
1087
|
"LVA",
|
|
1072
1088
|
"MAC",
|
|
@@ -1099,11 +1115,11 @@ ISO3166_1a3 = (
|
|
|
1099
1115
|
"NFK",
|
|
1100
1116
|
"NGA",
|
|
1101
1117
|
"NIC",
|
|
1102
|
-
"
|
|
1118
|
+
"NIU",
|
|
1103
1119
|
"NLD",
|
|
1104
1120
|
"NOR",
|
|
1105
1121
|
"NPL",
|
|
1106
|
-
"
|
|
1122
|
+
"NRU",
|
|
1107
1123
|
"NZL",
|
|
1108
1124
|
"OMN",
|
|
1109
1125
|
"PAK",
|
|
@@ -1121,11 +1137,11 @@ ISO3166_1a3 = (
|
|
|
1121
1137
|
"PSE",
|
|
1122
1138
|
"PYF",
|
|
1123
1139
|
"QAT",
|
|
1124
|
-
"
|
|
1125
|
-
"
|
|
1140
|
+
"REU",
|
|
1141
|
+
"ROU",
|
|
1126
1142
|
"RUS",
|
|
1127
1143
|
"RWA",
|
|
1128
|
-
"
|
|
1144
|
+
"SAU",
|
|
1129
1145
|
"SDN",
|
|
1130
1146
|
"SEN",
|
|
1131
1147
|
"SGP",
|
|
@@ -1139,12 +1155,14 @@ ISO3166_1a3 = (
|
|
|
1139
1155
|
"SOM",
|
|
1140
1156
|
"SPM",
|
|
1141
1157
|
"SRB",
|
|
1158
|
+
"SSD",
|
|
1142
1159
|
"STP",
|
|
1143
1160
|
"SUR",
|
|
1144
1161
|
"SVK",
|
|
1145
1162
|
"SVN",
|
|
1146
1163
|
"SWE",
|
|
1147
1164
|
"SWZ",
|
|
1165
|
+
"SXM",
|
|
1148
1166
|
"SYC",
|
|
1149
1167
|
"SYR",
|
|
1150
1168
|
"TCA",
|
|
@@ -286,8 +286,8 @@ class NYSEcalendar:
|
|
|
286
286
|
NYSE holiday calendar.
|
|
287
287
|
|
|
288
288
|
The Exchange is closed on: New Year's Day, Martin Luther King Jr. Day,
|
|
289
|
-
Washington's Birthday, Good Friday, Memorial Day,
|
|
290
|
-
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.
|
|
291
291
|
|
|
292
292
|
When a fixed-date holiday falls on Saturday, the preceding Friday is
|
|
293
293
|
observed — except New Year's Day, where Dec 31 is the year-end accounting
|
|
@@ -335,6 +335,8 @@ class NYSEcalendar:
|
|
|
335
335
|
cls.mondays(year, 9)[0], # Labor Day (1st Mon in Sep)
|
|
336
336
|
cls.thursdays(year, 11)[3], # Thanksgiving (4th Thu in Nov)
|
|
337
337
|
]
|
|
338
|
+
if year >= 2022:
|
|
339
|
+
hols.append(cls._observed(datetime.date(year, 6, 19))) # Juneteenth
|
|
338
340
|
# New Year's Day: Saturday → skipped (Dec 31 is year-end accounting close)
|
|
339
341
|
# Sunday → observed Monday Jan 2
|
|
340
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
|
|
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
|