csb43.ofx

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.

References

[OFX] (1,2,3,4,5,6)

[http://www.ofx.net/] Open Financial Exchange, Specification 2.2 (nov 26, 2017). Intuit Inc. Envestnet

class csb43.ofx.Balance(tag_name: str = 'bal', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, amount: int | float | Decimal | None = None, date: dt.datetime | dt.date | None = None)

a balance

See [OFX] 11.4.4.1

Fields

amount

field <BALAMT>

date

field <DTASOF>

get_amount() int | float | Decimal | None
Return type:

the amount of the balance

Deprecated since version 0.10.0: use attribute

get_date() datetime | date | None
Return type:

datetime – date of the balance

Deprecated since version 0.10.0: use attribute

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_amount(value: int | float | Decimal)
Parameters:

value – amount

Deprecated since version 0.10.0: use attribute

set_date(value: datetime | date)
Parameters:

value (datetime.datetime) – a date object

Deprecated since version 0.10.0: use attribute

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

class csb43.ofx.BankAccount(tag_name: str = 'bankaccfrom', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, bank_id: str | None = None, branch_id: str | None = None, id: str | None = None, type: str = 'SAVINGS', key: str | None = None)

A bank account

See [OFX] 11.3.1 Banking Account

Fields

bank_id

BANKID bank identifier (Spain: banco, entidad)

branch_id

BRANCHID branch identifier (Spain: sucursal, oficina)

id

ACCTID account identifier

type

ACCTTYPE type of account.

key

ACCTKEY checksum (Spain: digitos de control)

get_bank() str | None
Return type:

str – bank identifier (Spain: banco, entidad)

Deprecated since version 0.10.0: use attribute bank_id

get_branch() str | None
Return type:

str – branch identifier (Spain: sucursal, oficina)

Deprecated since version 0.10.0: use attribute branch_id

get_id() str | None
Return type:

str – account identifier

Deprecated since version 0.10.0: use attribute id

get_key() str | None
Return type:

str – checksum (Spain: digitos de control)

Deprecated since version 0.10.0: use attribute key

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

get_type() str
Return type:

str – type of account. See TYPE (default ‘SAVINGS’)

Deprecated since version 0.10.0: use attribute type

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_bank(value: str)
Parameters:

value – bank identifier

Deprecated since version 0.10.0: use attribute bank_id

set_branch(value: str)
Parameters:

branch – branch identifier

Deprecated since version 0.10.0: use attribute branch_id

set_id(value: str)
Parameters:

value – account id

Deprecated since version 0.10.0: use attribute id

set_key(value: str)
Parameters:

value – checksum

Deprecated since version 0.10.0: use attribute key

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

set_type(value: str)
Parameters:

value (str) – type of account

Deprecated since version 0.10.0: use attribute type

class csb43.ofx.File(tag_name: str = 'ofx', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, responses: list[Response] = <factory>)

An OFX file

See [OFX] 2.4.1

Fields

responses

add_response(value: Response)

Add a response to the file

Parameters:

value (Response) – a response object to include in this object

Deprecated since version 0.10.0: use attribute responses

get_responses() Sequence[Response]
Return type:

list of Response

Deprecated since version 0.10.0: use attribute responses

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

class csb43.ofx.Payee(tag_name: str = 'payeeid', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, name: str | None = None, payee: str | None = None, extended_name: str | None = None)

payee info

Fields

name

<NAME>

payee

<PAYEE>

extended_name

<EXTDNAME>

get_extended_name() str | None

Deprecated since version 0.10.0: use attribute extended_name

get_name() str | None

Deprecated since version 0.10.0: use attribute name

get_payee() str | None

Deprecated since version 0.10.0: use attribute payee

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_extended_name(value: str)

Deprecated since version 0.10.0: use attribute extended_name

set_name(value: str)

Deprecated since version 0.10.0: use attribute name

set_payee(value: str)

Deprecated since version 0.10.0: use attribute payee

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

class csb43.ofx.Response(tag_name: str = 'stmtrs', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, currency: AnyCurrency | None = None, account_from: BankAccount | None = None, transaction_list: TransactionList | None = None, ledger_balance: Balance | None = None, available_balance: Balance | None = None, balances: list[Balance] = <factory>, mktginfo: Any | None = None)

STMTRS

See [OFX] 11.4.2.2 Response

add_balance(value: Balance)

Add a complementary balance

Parameters:

value (Balance) – a complementary balance

Deprecated since version 0.10.0: use attribute

get_available_balance() Balance | None
Return type:

Balance – the available balance aggregate

Deprecated since version 0.10.0: use attribute

get_balances() Sequence[Balance] | None
Return type:

list of miscellaneous other Balance s

Deprecated since version 0.10.0: use attribute

get_bank_account_from() BankAccount | None
Return type:

BankAccount – Account-from aggregate

Deprecated since version 0.10.0: use attribute

get_currency()
Return type:

pycountry.dbCurrency – Default currency for the statement

Deprecated since version 0.10.0: use attribute

get_ledger_balance() Balance | None
Return type:

Balance – the ledger balance aggregate

Deprecated since version 0.10.0: use attribute

get_mktginfo()
Return type:

marketing info

Deprecated since version 0.10.0: use attribute

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

get_transaction_list() TransactionList | None
Return type:

TransactionList – Statement-transaction-data aggregate

Deprecated since version 0.10.0: use attribute

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_available_balance(value: Balance)
Parameters:

value (Balance) – available balance

Deprecated since version 0.10.0: use attribute

set_bank_account_from(value: BankAccount)
Parameters:

value (BankAccount) – value

Deprecated since version 0.10.0: use attribute

set_currency(value)
Parameters:

value (pycountry.db.Currency) – currency

Deprecated since version 0.10.0: use attribute

set_ledger_balance(value: Balance)
Parameters:

value (Balance) – ledger balance

Deprecated since version 0.10.0: use attribute

set_mktginfo(value)
Parameters:

value – marketing info

Deprecated since version 0.10.0: use attribute

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

set_transaction_list(value: TransactionList)
Parameters:

value (TransactionList) – transactions list

Deprecated since version 0.10.0: use attribute

class csb43.ofx.SignOnResponse(tag_name: str = 'sonrs', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>)

SONRS

See [OFX] 2.5.1

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

class csb43.ofx.Transaction(tag_name: str = 'stmttrn', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, type: str = 'OTHER', date_posted: dt.datetime | dt.date | None = None, date_initiated: dt.datetime | dt.date | None = None, date_available: dt.datetime | dt.date | None = None, amount: int | float | Decimal | None = None, transaction_id: str | None = None, correct_fit_id: str | None = None, correct_action: str | None = None, server_tid: str | None = None, check_num: str | None = None, ref_num: str | None = None, standard_industrial_code: str | None = None, payee: Payee | None = None, bank_account_to: BankAccount | None = None, cc_account_to: BankAccount | None = None, memo: str | None = None, image_data: Any | None = None, origin_currency: AnyCurrency | None = None, origin_amount: int | float | Decimal | None = None, inv401ksource: Any | str = None, payeeid: str | None = None, name: str | None = None, extended_name: str | None = None)

A OFX transaction

See [OFX] 11.4.4.1

get_amount() int | float | Decimal | None
Return type:

number – amount of transaction

Deprecated since version 0.10.0: use attribute amount

get_bank_account_to() BankAccount | None
Return type:

BankAccount – account the transaction is transferring to

Deprecated since version 0.10.0: use attribute bank_account_to

get_cc_account_to() BankAccount | None

cc account to

Deprecated since version 0.10.0: use attribute cc_account_to

get_check_num() str | None
Return type:

str – check (or other reference) number

Deprecated since version 0.10.0: use attribute check_num

get_correct_action() str | None

correct action

Deprecated since version 0.10.0: use attribute correct_action

get_correct_fit_id() str | None

correct fit id

Deprecated since version 0.10.0: use attribute correct_fit_id

get_currency() AnyCurrency | None
Return type:

pycountry.db.Currency – currency of the transaction, if different from the one in BankAccount

Deprecated since version 0.10.0: use attribute currency

get_date_available() datetime | date | None
Return type:

datetime.datetime – date funds are available

Deprecated since version 0.10.0: use attribute date_available

get_date_initiated() datetime | date | None
Return type:

datetime.datetime – date user initiated transaction

Deprecated since version 0.10.0: use attribute date_initiated

get_date_posted() datetime | date | None
Return type:

datetime.datetime – date transaction was posted to account

Deprecated since version 0.10.0: use attribute date_posted

get_extended_name() str | None
Return type:

str – extended name of payee or description of transaction

Deprecated since version 0.10.0: use attribute extended_name

get_image_data() Any | None

image data

Deprecated since version 0.10.0: use attribute image_data

get_inv_401ksource()

Deprecated since version 0.10.0: use attribute inv_401ksource

get_memo() str | None
Return type:

str – extra information

Deprecated since version 0.10.0: use attribute memo

get_name() str | None
Return type:

str – name of payee or description of transaction

Deprecated since version 0.10.0: use attribute name

get_origin_amount()

Deprecated since version 0.10.0: use attribute origin_amount

get_origin_currency() AnyCurrency | None
Return type:

pycountry.db.Currency – currency of the transaction, if different from the one in BankAccount

Deprecated since version 0.10.0: use attribute origin_currency

get_payee() Payee | None
Return type:

Payee

Deprecated since version 0.10.0: use attribute payee

get_payeeid() str | None
Return type:

str – payee identifier

Deprecated since version 0.10.0: use attribute payeeid

get_ref_num() str | None
Return type:

str – reference number that uniquely indentifies the transaction.

Deprecated since version 0.10.0: use attribute ref_num

get_server_tid() str | None

server transaction id

Deprecated since version 0.10.0: use attribute server_tid

get_standard_industrial_code() str | None

standard industrial code

Deprecated since version 0.10.0: use attribute standard_industrial_code

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

get_transaction_id() str | None
Return type:

str – transaction ID issued by financial institution

Deprecated since version 0.10.0: use attribute transaction_id

get_type() str
Return type:

str – transaction type. See TYPE. Default (‘OTHER’)

Deprecated since version 0.10.0: use attribute type

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_amount(value: int | float | Decimal)

Deprecated since version 0.10.0: use attribute

set_bank_account_to(value: BankAccount)

Deprecated since version 0.10.0: use attribute

set_cc_account_to(value: BankAccount)

Deprecated since version 0.10.0: use attribute

set_check_num(value: str)

Deprecated since version 0.10.0: use attribute

set_correct_action(value: str)

Deprecated since version 0.10.0: use attribute

set_correct_fit_id(value: str)

Deprecated since version 0.10.0: use attribute

set_currency(value)

Deprecated since version 0.10.0: use attribute

set_date_available(value: datetime | date)

Deprecated since version 0.10.0: use attribute

set_date_initialised(value: datetime | date)

Deprecated since version 0.10.0: use attribute

set_date_posted(value: datetime | date)

Deprecated since version 0.10.0: use attribute

set_extended_name(value: str)
Parameters:

value – extended name of payee or description of transaction

Deprecated since version 0.10.0: use attribute extended_name

set_image_data(value)

Deprecated since version 0.10.0: use attribute

set_inv_401ksource(value)

Deprecated since version 0.10.0: use attribute

set_memo(value: str)

Deprecated since version 0.10.0: use attribute

set_name(value: str)
Parameters:

value – name of payee or description of transaction

Deprecated since version 0.10.0: use attribute name

set_origin_amount(value)

Deprecated since version 0.10.0: use attribute

set_origin_currency(value)

Deprecated since version 0.10.0: use attribute

set_payee(value: Payee)

Deprecated since version 0.10.0: use attribute

set_payeeid(value: str)

Deprecated since version 0.10.0: use attribute

set_ref_num(value: str)
Parameters:

value – reference number that uniquely indentifies the transaction.

Deprecated since version 0.10.0: use attribute ref_num

set_server_tid(value: str)

Deprecated since version 0.10.0: use attribute

set_standard_industrial_code(value: str)

Deprecated since version 0.10.0: use attribute

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

set_transaction_id(value: str)

Deprecated since version 0.10.0: use attribute

set_type(value)

Deprecated since version 0.10.0: use attribute type

class csb43.ofx.TransactionList(tag_name: str = 'banktranlist', sgml: bool = False, _elem_f: Callable[[str, Any | None], str] = <function xml_element>, _aggr_f: Callable[[str, Any | None], str] = <function xml_aggregate>, date_start: dt.datetime | dt.date | None = None, date_end: dt.datetime | dt.date | None = None, transactions: list[Transaction] = <factory>)

Transaction list aggregate

add_transaction(value: Transaction)

Add a new transaction to the list

Parameters:

value (Transaction) – a transaction

Deprecated since version 0.10.0: use attribute transactions

get_date_end() datetime | date | None
Return type:

datetime.datetime – date of the first transaction

Deprecated since version 0.10.0: use attribute date_end

get_date_start() datetime | date | None
Return type:

datetime.datetime – date of the first transaction

Deprecated since version 0.10.0: use attribute date_start

get_list() Sequence[Transaction]
Return type:

list of Transaction

Deprecated since version 0.10.0: use attribute transactions

get_tag_name() str
Return type:

the XML tag name

Deprecated since version 0.10.0: use attribute tag_name

is_sgml() bool

return True if SGML mode is on

Deprecated since version 0.10.0: use attribute sgml

set_date_end(value: datetime | date)
Parameters:

value (datetime.datetime) – date of end

Deprecated since version 0.10.0: use attribute date_end

set_date_start(value)
Parameters:

value (datetime.datetime) – date of start

Deprecated since version 0.10.0: use attribute date_start

set_tag_name(name: str)

Set a XML tag name for this object

Parameters:

name (str) – name for the XML tag

Deprecated since version 0.10.0: use attribute tag_name

Converter

Conversion from AEB43 to OFX

csb43.ofx.converter.PAYMODES = {1: TransactionType.CHECK, 2: TransactionType.CREDIT, 3: TransactionType.SRVCHG, 4: TransactionType.XFER, 5: TransactionType.DIV, 7: TransactionType.REPEATPMT, 8: TransactionType.FEE, 9: TransactionType.DIV, 10: TransactionType.CHECK, 11: TransactionType.ATM, 12: TransactionType.POS, 15: TransactionType.XFER, 17: TransactionType.INT, 99: TransactionType.OTHER}

conversion table OFX - Homebank for pay modes

csb43.ofx.converter.convertFromCsb(csb: File, sgml=False) File

Convert a File file into an OFX file

Parameters:

csb (csb43.csb43.File) – a CSB43 file

Return type:

csb43.ofx.File

>>> # OFX
>>> from csb43 import csb43
>>> #
>>> csbFile = csb43.File(open("movimientos.csb"), strict=False) 
>>> #
>>> # print to stdout
>>> print(convertFromCsb(csbFile)) 

Deprecated since version 0.10.0: use csb43.ofx.converter.convert_from_aeb43

csb43.ofx.converter.convert_from_aeb43(batch: Batch, sgml=False) File

convert an AEB43 batch to OFX.

Use sgml=True in order to generate SGML instead of XML