csb43.ofx
¶
Note
license: GNU Lesser General Public License v3.0 (see LICENSE)
Partial implementation of a OFX file writer.
This package is not intended to fully implement the OFX Spec. Its final purpose is the conversion from CSB43 (norma 43 del Consejo Superior Bancario). That is, only transaction response is (partially) implemented.
- class csb43.ofx.Balance(tagName='bal', **kwargs)¶
A balance
- get_amount() → Optional[Union[int, float, decimal.Decimal]]¶
- Return type
the amount of the balance
- get_date() → Optional[datetime.datetime]¶
- Return type
datetime
– date of the balance
- set_amount(value: Union[int, float, decimal.Decimal])¶
- Parameters
value – amount
- set_date(value: datetime.datetime)¶
- Parameters
value (
datetime.datetime
) – a date object
- class csb43.ofx.BankAccount(tagName='bankaccfrom', **kwargs)¶
A bank account
- TYPE = ['CHECKING', 'SAVINGS', 'MONEYMRKT', 'CREDITLINE']¶
account type
- class csb43.ofx.File(tagName='ofx', **kwargs)¶
An OFX file
- add_response(value: csb43.ofx.Response)¶
Add a response to the file
- Parameters
value (
Response
) – a response object to include in this object
- csb43.ofx.SGMLAggregate(name: str, content) → str¶
Build a name SGML aggregate with content as body.
- Args:
name – tag name content – content of the node
- Return:
(str) <NAME>content</NAME>
>>> SGMLAggregate("hello", 12) '<HELLO>12</HELLO>'
- csb43.ofx.SGMLElement(name: str, content) → str¶
Build a name SGML element with content as body.
- Args:
name – tag name content – content of the node
- Return:
(str) <NAME>content
>>> SGMLElement("hello", 12) '<HELLO>12'
- class csb43.ofx.Transaction(tagName='stmttrn', **kwargs)¶
A OFX transaction
- TYPE = ['CREDIT', 'DEBIT', 'INT', 'DIV', 'FEE', 'SRVCHG', 'DEP', 'ATM', 'POS', 'XFER', 'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER']¶
type of transaction
- get_amount() → Optional[Union[int, float, decimal.Decimal]]¶
- Return type
number – amount of transaction
- get_bank_account_to() → Optional[csb43.ofx.BankAccount]¶
- Return type
BankAccount
– account the transaction is transferring to
- get_cc_account_to() → Optional[csb43.ofx.BankAccount]¶
cc account to
- get_currency()¶
- Return type
pycountry.db.Currency
– currency of the transaction, if different from the one inBankAccount
- get_date_available() → Optional[datetime.datetime]¶
- Return type
datetime.datetime
– date funds are available
- get_date_initiated() → Optional[datetime.datetime]¶
- Return type
datetime.datetime
– date user initiated transaction
- get_date_posted() → Optional[datetime.datetime]¶
- Return type
datetime.datetime
– date transaction was posted to account
- get_extended_name() → Optional[str]¶
- Return type
str
– extended name of payee or description of transaction
- get_image_data()¶
image data
- get_origin_currency()¶
- Return type
pycountry.db.Currency
– currency of the transaction, if different from the one inBankAccount
- get_payee() → Optional[csb43.ofx.Payee]¶
- Return type
Payee
- get_ref_num() → Optional[str]¶
- Return type
str
– reference number that uniquely indentifies the transaction.
- set_extended_name(value: str)¶
- Parameters
value – extended name of payee or description of transaction
- class csb43.ofx.TransactionList(tagName='banktranslist', **kwargs)¶
Transaction list aggregate
- add_transaction(value: csb43.ofx.Transaction)¶
Add a new transaction to the list
- Parameters
value (
Transaction
) – a transaction
- get_date_end() → Optional[datetime.datetime]¶
- Return type
datetime.datetime
– date of the first transaction
- get_date_start() → Optional[datetime.datetime]¶
- Return type
datetime.datetime
– date of the first transaction
- get_list() → Sequence[csb43.ofx.Transaction]¶
- Return type
list
ofTransaction
- set_date_end(value: datetime.datetime)¶
- Parameters
value (
datetime.datetime
) – date of end
- set_date_start(value)¶
- Parameters
value (
datetime.datetime
) – date of start
- csb43.ofx.XMLAggregate(*args, **kwargs) → str¶
Build a name XML aggregate with content as body.
- Args:
name – tag name content – content of the node
- Return:
(str) <NAME>content</NAME>
>>> XMLAggregate("hello", 12) '<HELLO>12</HELLO>'
- csb43.ofx.XMLElement(name: str, content) → str¶
Build a name XML element with content as body.
- Args:
name – tag name content – content of the node
- Return:
(str) <NAME>content</NAME>
>>> XMLElement("hello", 12) '<HELLO>12</HELLO>'
- csb43.ofx.strBool(field: Optional[bool]) → Optional[str]¶
Format a boolean as specified by OFX
- Args:
field (bool)
- Return:
(str)
- csb43.ofx.strCurrency(field)¶
Format a ISO-4217 currency entity as specified by OFX
- Args:
field (pycountry.Currency)
- Return:
(str)
- csb43.ofx.strDate(field: Optional[datetime.datetime]) → Optional[str]¶
Format a date as specified by OFX
- Args:
field (datetime)
- Return:
(str)
- csb43.ofx.strText(field: Optional[str]) → Optional[str]¶
Format a string as specified by OFX, that is, characters ‘&’, ‘>’ and ‘<’ are XML escaped.
Converter¶
- csb43.ofx.converter.convertFromCsb(csb: csb43.csb43.csb_file.File, sgml=False) → csb43.ofx.File¶
Convert a File file into an OFX file
- Parameters
csb (
csb43.csb43.File
) – a CSB43 file- Return type
>>> # OFX >>> from csb43 import csb43 >>> # >>> csbFile = csb43.File(open("movimientos.csb"), strict=False) >>> # >>> # print to stdout >>> print(convertFromCsb(csbFile))
- converter.PAYMODES = {'01': 10, '02': 0, '03': 5, '04': 9, '05': 3, '07': 15, '08': 3, '10': 10, '11': 7, '12': 8, '15': 9, '17': 2, '99': 16}¶