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.
Files changed (104) hide show
  1. {ofxtools-1.1.0/ofxtools.egg-info → ofxtools-1.1.2}/PKG-INFO +1 -1
  2. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Client.py +3 -1
  3. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Parser.py +2 -0
  4. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/Types.py +11 -7
  5. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/__init__.py +2 -0
  6. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/header.py +3 -1
  7. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/interxfer.py +2 -0
  8. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/msgsets.py +3 -1
  9. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stmt.py +2 -0
  10. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stmtend.py +2 -0
  11. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/stpchk.py +2 -0
  12. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/wire.py +2 -0
  13. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/xfer.py +2 -0
  14. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/base.py +4 -2
  15. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/common.py +2 -0
  16. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/pmt.py +2 -0
  17. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/recur.py +2 -0
  18. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/common.py +2 -0
  19. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/email.py +2 -0
  20. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/i18n.py +29 -9
  21. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/msgsets.py +2 -0
  22. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/securities.py +2 -0
  23. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/stmt.py +2 -0
  24. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/ofx.py +2 -0
  25. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/profile.py +2 -0
  26. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/signon.py +2 -0
  27. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/signup.py +2 -0
  28. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/tax1099.py +2 -0
  29. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/wrapperbases.py +2 -0
  30. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/scripts/ofxget.py +2 -0
  31. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/utils.py +6 -2
  32. {ofxtools-1.1.0 → ofxtools-1.1.2/ofxtools.egg-info}/PKG-INFO +1 -1
  33. {ofxtools-1.1.0 → ofxtools-1.1.2}/pyproject.toml +1 -1
  34. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_i18n.py +49 -1
  35. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_msgsets.py +6 -1
  36. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_types.py +146 -7
  37. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_utils.py +10 -5
  38. {ofxtools-1.1.0 → ofxtools-1.1.2}/LICENSE +0 -0
  39. {ofxtools-1.1.0 → ofxtools-1.1.2}/README.rst +0 -0
  40. {ofxtools-1.1.0 → ofxtools-1.1.2}/docs/conf.py +0 -0
  41. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/__init__.py +0 -0
  42. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/fi.cfg +0 -0
  43. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/config/ofxget_example.cfg +0 -0
  44. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/lib.py +0 -0
  45. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/__init__.py +0 -0
  46. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/__init__.py +0 -0
  47. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/mail.py +0 -0
  48. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/recur.py +0 -0
  49. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/bank/sync.py +0 -0
  50. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/__init__.py +0 -0
  51. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/list.py +0 -0
  52. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/mail.py +0 -0
  53. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/msgsets.py +0 -0
  54. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/billpay/sync.py +0 -0
  55. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/__init__.py +0 -0
  56. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/acct.py +0 -0
  57. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/mail.py +0 -0
  58. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/openorders.py +0 -0
  59. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/positions.py +0 -0
  60. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/models/invest/transactions.py +0 -0
  61. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/py.typed +0 -0
  62. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools/scripts/__init__.py +0 -0
  63. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/SOURCES.txt +0 -0
  64. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/dependency_links.txt +0 -0
  65. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/entry_points.txt +0 -0
  66. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/requires.txt +0 -0
  67. {ofxtools-1.1.0 → ofxtools-1.1.2}/ofxtools.egg-info/top_level.txt +0 -0
  68. {ofxtools-1.1.0 → ofxtools-1.1.2}/setup.cfg +0 -0
  69. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/base.py +0 -0
  70. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_client.py +0 -0
  71. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_header.py +0 -0
  72. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_interxfer.py +0 -0
  73. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_mail.py +0 -0
  74. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_recur.py +0 -0
  75. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stmt.py +0 -0
  76. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stmtend.py +0 -0
  77. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_stpchk.py +0 -0
  78. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_sync.py +0 -0
  79. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_wire.py +0 -0
  80. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_bank_xfer.py +0 -0
  81. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_base.py +0 -0
  82. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_common.py +0 -0
  83. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_list.py +0 -0
  84. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_mail.py +0 -0
  85. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_pmt.py +0 -0
  86. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_recur.py +0 -0
  87. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_billpay_sync.py +0 -0
  88. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_common.py +0 -0
  89. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_email.py +0 -0
  90. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest.py +0 -0
  91. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest_oo.py +0 -0
  92. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_invest_transactions.py +0 -0
  93. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_ofx.py +0 -0
  94. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_profile.py +0 -0
  95. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_securities.py +0 -0
  96. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_signon.py +0 -0
  97. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_models_signup.py +0 -0
  98. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_ofxget.py +0 -0
  99. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_parser.py +0 -0
  100. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_bank.py +0 -0
  101. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_billpay.py +0 -0
  102. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_invest.py +0 -0
  103. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_signon.py +0 -0
  104. {ofxtools-1.1.0 → ofxtools-1.1.2}/tests/test_spec_tax1099.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ofxtools
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: Library for working with Open Financial Exchange (OFX) data
5
5
  Author-email: Christopher Singley <csingley@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -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: "OFXClient"
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
- if self.scale is not None:
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
- return self.__type__(value)
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:
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  # stdlib imports
2
4
  import json
3
5
  import logging
@@ -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["OFXHeaderBase", int]:
58
+ def parse(cls, rawheader: str) -> tuple[OFXHeaderBase, int]:
57
59
  """
58
60
  Instantiate from string.
59
61
 
@@ -2,6 +2,8 @@
2
2
  Interbank fund transfers - OFX Section 11.8
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "INTERRQ",
7
9
  "INTERRS",
@@ -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, STMTTRNRQ):
111
+ elif isinstance(trnrq, STMTENDTRNRQ):
110
112
  stmtrq = trnrq.stmtendrq
111
113
 
112
114
  if stmtrq is not None:
@@ -2,6 +2,8 @@
2
2
  Bank statement download - OFX Section 11.4
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "INV401KSOURCES",
7
9
  "ACCTTYPES",
@@ -2,6 +2,8 @@
2
2
  Statement closing information - OFX Section 11.5
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "CLOSING",
7
9
  "STMTENDRQ",
@@ -2,6 +2,8 @@
2
2
  Bank stop check - OFX Section 11.6
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "CHKRANGE",
7
9
  "CHKDESC",
@@ -2,6 +2,8 @@
2
2
  Wire fund transfers - OFX Section 11.9
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "WIREBENEFICIARY",
7
9
  "EXTBANKDESC",
@@ -2,6 +2,8 @@
2
2
  Intrabank funds transfer - OFX Section 11.6
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "XFERINFO",
7
9
  "XFERPRCSTS",
@@ -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) -> "Aggregate":
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) -> "Aggregate":
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,
@@ -4,6 +4,8 @@ Common payments aggregates - OFX Section 12.5
4
4
  PAYEE is defined in ``ofxtools.models.bank.stmt`` to avoid circular imports.
5
5
  """
6
6
 
7
+ from __future__ import annotations
8
+
7
9
  __all__ = [
8
10
  "BPACCTINFO",
9
11
  "BILLPUBINFO",
@@ -2,6 +2,8 @@
2
2
  Payments Functions - OFX Section 12.6
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "PMTRQ",
7
9
  "PMTRS",
@@ -2,6 +2,8 @@
2
2
  Recurring payments - OFX Section 12.7
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "RECPMTRQ",
7
9
  "RECPMTRS",
@@ -2,6 +2,8 @@
2
2
  Common Aggregates (OFX Section 3.1); message extensions (OFX Section 2.7)
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = ["SVCSTATUSES", "STATUS", "BAL", "OFXELEMENT", "OFXEXTENSION", "MSGSETCORE"]
6
8
 
7
9
 
@@ -2,6 +2,8 @@
2
2
  email - OFX Section 9
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "MAIL",
7
9
  "MAILRQ",
@@ -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
- "BM",
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
- "DE",
1012
+ "DEU",
995
1013
  "DJI",
996
1014
  "DMA",
997
1015
  "DNK",
998
1016
  "DOM",
999
1017
  "DZA",
1000
- "EC",
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
- "LT",
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
- "NI",
1118
+ "NIU",
1101
1119
  "NLD",
1102
1120
  "NOR",
1103
1121
  "NPL",
1104
- "NR",
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
- "RE",
1123
- "RO",
1140
+ "REU",
1141
+ "ROU",
1124
1142
  "RUS",
1125
1143
  "RWA",
1126
- "SA",
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",
@@ -2,6 +2,8 @@
2
2
  Bill pay message sets
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "INVSTMTMSGSRQV1",
7
9
  "INVSTMTMSGSRSV1",
@@ -2,6 +2,8 @@
2
2
  Security information - OFX section 13.7.2
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "SECID",
7
9
  "SECRQ",
@@ -2,6 +2,8 @@
2
2
  Investments - OFX Section 13
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "LOANPMTFREQUENCIES",
7
9
  "INCPOS",
@@ -3,6 +3,8 @@ Python object model for fundamental data aggregates such as transactions,
3
3
  balances, and securities.
4
4
  """
5
5
 
6
+ from __future__ import annotations
7
+
6
8
  __all__ = ["OFX"]
7
9
 
8
10
 
@@ -1,5 +1,7 @@
1
1
  """FI Profile - OFX Section 7"""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  __all__ = [
4
6
  "SIGNONINFO",
5
7
  "SIGNONINFOLIST",
@@ -2,6 +2,8 @@
2
2
  Client signon - OFX Section 2.5
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "FI",
7
9
  "MFACHALLENGE",
@@ -2,6 +2,8 @@
2
2
  Activation and Account Information - OFX Section 8
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "ENROLLRQ",
7
9
  "ENROLLRS",
@@ -2,6 +2,8 @@
2
2
  Tax form 1099 - as of TY2018
3
3
  """
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  __all__ = [
6
8
  "PAYERADDR",
7
9
  "RECADDR",
@@ -5,6 +5,8 @@ These can't be defined in models.base because models.common.STATUS would
5
5
  create circular imports.
6
6
  """
7
7
 
8
+ from __future__ import annotations
9
+
8
10
  __all__ = ["TrnRq", "TrnRs", "SyncRqList", "SyncRsList"]
9
11
 
10
12
 
@@ -4,6 +4,8 @@ Configurable CLI front end for ``ofxtools.Client``
4
4
  """
5
5
 
6
6
  # stdlib imports
7
+ from __future__ import annotations
8
+
7
9
  import argparse
8
10
  import concurrent.futures
9
11
  import configparser
@@ -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, Independence 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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ofxtools
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: Library for working with Open Financial Exchange (OFX) data
5
5
  Author-email: Christopher Singley <csingley@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ofxtools"
7
- version = "1.1.0"
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 CURRENCY, CURRENCY_CODES, ORIGCURRENCY
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
- t = self.type_()
378
- # Don't accept strings that can't be converted to Decimal
379
- with self.assertRaises(decimal.InvalidOperation):
380
- t.convert("foobar")
381
- # Don't accept random types
382
- with self.assertRaises(TypeError):
383
- t.convert(object)
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 9 holidays in a typical year (NYD + 8 others)
317
- # 2024 has all 9 (NYD is Monday)
318
- self.assertEqual(len(NYSEcalendar.holidays(2024)), 9)
319
- # 2022 has 8 (NYD Saturday is skipped)
320
- self.assertEqual(len(NYSEcalendar.holidays(2022)), 8)
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