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=u'bal', **kwargs)¶ A balance
-
get_amount
()¶ Return type: the amount of the balance
-
get_date
()¶ Return type: datetime
– date of the balance
-
get_tag_name
()¶ Return type: the XML tag name
-
set_amount
(value)¶ Parameters: value – amount
-
set_date
(value)¶ Parameters: value ( datetime.datetime
) – a date object
-
set_tag_name
(name)¶ Set a XML tag name for this object
Parameters: name ( str
) – name for the XML tag
-
-
class
csb43.ofx.
BankAccount
(tagName=u'bankaccfrom', **kwargs)¶ A bank account
-
TYPE
= [u'CHECKING', u'SAVINGS', u'MONEYMRKT', u'CREDITLINE']¶ account type
-
get_bank
()¶ Return type: str
– bank identifier (Spain: banco, entidad)
-
get_branch
()¶ Return type: str
– branch identifier (Spain: sucursal, oficina)
-
get_id
()¶ Return type: str
– account identifier
-
get_key
()¶ Return type: str
– checksum (Spain: digitos de control)
-
get_tag_name
()¶ Return type: the XML tag name
-
set_bank
(value)¶ Parameters: value – bank identifier
-
set_branch
(value)¶ Parameters: branch – branch identifier
-
set_id
(value)¶ Parameters: value – account id
-
set_key
(value)¶ Parameters: value – checksum
-
set_tag_name
(name)¶ Set a XML tag name for this object
Parameters: name ( str
) – name for the XML tag
-
set_type
(value)¶ Parameters: value ( str
) – type of account
-
-
class
csb43.ofx.
File
(tagName=u'ofx', **kwargs)¶ An OFX file
-
add_response
(value)¶ Add a response to the file
Parameters: value ( Response
) – a response object to include in this object
-
get_responses
()¶ Return type: list
ofResponse
-
get_tag_name
()¶ Return type: the XML tag name
-
set_tag_name
(name)¶ Set a XML tag name for this object
Parameters: name ( str
) – name for the XML tag
-
-
csb43.ofx.
SGMLAggregate
(name, content)¶ 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, content)¶ 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=u'stmttrn', **kwargs)¶ A OFX transaction
-
TYPE
= [u'CREDIT', u'DEBIT', u'INT', u'DIV', u'FEE', u'SRVCHG', u'DEP', u'ATM', u'POS', u'XFER', u'CHECK', u'PAYMENT', u'CASH', u'DIRECTDEP', u'DIRECTDEBIT', u'REPEATPMT', u'OTHER']¶ type of transaction
-
get_amount
()¶ Return type: number – amount of transaction
-
get_bank_account_to
()¶ Return type: BankAccount
– account the transaction is transferring to
-
get_cc_account_to
()¶ cc account to
-
get_check_num
()¶ Return type: str
– check (or other reference) number
-
get_correct_action
()¶ correct action
-
get_correct_fit_id
()¶ correct fit id
-
get_currency
()¶ Return type: pycountry.db.Currency
– currency of the transaction, if different from the one inBankAccount
-
get_date_available
()¶ Return type: datetime.datetime
– date funds are available
-
get_date_initiated
()¶ Return type: datetime.datetime
– date user initiated transaction
-
get_date_posted
()¶ Return type: datetime.datetime
– date transaction was posted to account
-
get_extended_name
()¶ Return type: str
– extended name of payee or description of transaction
-
get_image_data
()¶ image data
-
get_memo
()¶ Return type: str
– extra information
-
get_name
()¶ Return type: str
– name of payee or description of transaction
-
get_origin_currency
()¶ Return type: pycountry.db.Currency
– currency of the transaction, if different from the one inBankAccount
-
get_payee
()¶ Return type: Payee
-
get_payeeid
()¶ Return type: str
– payee identifier
-
get_ref_num
()¶ Return type: str
– reference number that uniquely indentifies the transaction.
-
get_server_tid
()¶ server transaction id
-
get_standard_industrial_code
()¶ standard industrial code
-
get_tag_name
()¶ Return type: the XML tag name
-
get_transaction_id
()¶ Return type: str
– transaction ID issued by financial institution
-
set_extended_name
(value)¶ Parameters: value – extended name of payee or description of transaction
-
set_name
(value)¶ Parameters: value – name of payee or description of transaction
-
set_ref_num
(value)¶ Parameters: value – reference number that uniquely indentifies the transaction.
-
set_tag_name
(name)¶ Set a XML tag name for this object
Parameters: name ( str
) – name for the XML tag
-
-
class
csb43.ofx.
TransactionList
(tagName=u'banktranslist', **kwargs)¶ Transaction list aggregate
-
add_transaction
(value)¶ Add a new transaction to the list
Parameters: value ( Transaction
) – a transaction
-
get_date_end
()¶ Return type: datetime.datetime
– date of the first transaction
-
get_date_start
()¶ Return type: datetime.datetime
– date of the first transaction
-
get_list
()¶ Return type: list
ofTransaction
-
get_tag_name
()¶ Return type: the XML tag name
-
set_date_end
(value)¶ Parameters: value ( datetime.datetime
) – date of end
-
set_date_start
(value)¶ Parameters: value ( datetime.datetime
) – date of start
-
set_tag_name
(name)¶ Set a XML tag name for this object
Parameters: name ( str
) – name for the XML tag
-
-
csb43.ofx.
XMLAggregate
(*args, **kwargs)¶ 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, content)¶ 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)¶ 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)¶ Format a date as specified by OFX
- Args:
- field (datetime)
- Return:
- (str)
-
csb43.ofx.
strText
(field)¶ Format a string as specified by OFX, that is, characters ‘&’, ‘>’ and ‘<’ are XML escaped.
Converter¶
-
csb43.ofx.converter.
convertFromCsb
(csb, sgml=False)¶ Convert a File file into an OFX file
Parameters: csb ( csb43.csb43.File
) – a CSB43 fileReturn type: csb43.ofx.File
>>> # OFX >>> from csb43 import csb43 >>> # >>> csbFile = csb43.File(open("movimientos.csb"), strict=False) >>> # >>> # print to stdout >>> print(convertFromCsb(csbFile))
-
converter.
PAYMODES
= {u'11': 7, u'10': 10, u'99': 16, u'12': 8, u'17': 2, u'02': 0, u'03': 5, u'01': 10, u'15': 9, u'07': 15, u'04': 9, u'05': 3, u'08': 3}¶