csb43.aeb43¶
Parsing utilities for the AEB43 file format.
Parsing and validation utilities for the Spanish standard norm 43 by the “Consejo Superior Bancario” (CSB) / “Asociación Española de Banca” (AEB) for storing bank account transactions.
[es] Herramientas para leer y validar datos almacenados siguiendo la norma 43 del Consejo Superior Bancario (CSB) / Asociación Española de Banca (CSB).
References
@techreport{n43_2012,
author = {Varios},
institution = {Confederación Española de Cajas de Ahorros},
month = 6,
number = {Serie normas y procedimientos bancarios nº 43},
publisher = {Asociación Española de Banca},
title = {{Información normalizada de cuenta corriente (SEPA)}},
year = {2012}
}
- class csb43.aeb43.Account(context=None, raw=None, bank_code=String(field_id=<Field.BANK_CODE: 1>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), branch_code=String(field_id=<Field.BRANCH_CODE: 2>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), account_number=String(field_id=<Field.ACCOUNT_NUMBER: 3>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), initial_date=Date(field_id=<Field.INITIAL_DATE: 4>, factory=<built-in method today of type object>), final_date=Date(field_id=<Field.FINAL_DATE: 5>, factory=<built-in method today of type object>), initial_balance=Money(value_id=<Field.INITIAL_BALANCE: 7>, mode_id=<Field.EXPENSE_OR_INCOME: 6>, default_mode=b'2', padding=b'0', non_negative=False, factory=<class 'decimal.Decimal'>), currency=Currency(field_id=<Field.CURRENCY_CODE: 8>, factory=<function euro_currency>), information_mode=InformationModeField(field_id=<Field.INFORMATION_MODE: 9>, factory=<function InformationModeField.<lambda>>), short_name=String(field_id=<Field.SHORT_NAME: 10>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>), padding=String(field_id=<Field.PADDING: 11>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>), transactions=None, summary=None)¶
Account record.
COD 11
[es] Registro de cabecera de cuenta
See [n43_2012] Appendix 1, section 1.1
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
bank_code (String)
branch_code (String)
account_number (String)
initial_date (Date)
final_date (Date)
initial_balance (Money)
currency (Currency)
information_mode (InformationModeField)
short_name (String)
padding (String)
transactions (NestedCollection[Transaction])
summary (SummaryField[ClosingAccount])
- __iter__()¶
Iterate raw records associated to this object.
- Return type:
Iterator[bytes]
- accepts_nested_codes(record)¶
Return True if the record accepts this nested record.
- Parameters:
record (bytes)
- Return type:
bool
- append(raw)¶
Append a bytes record to the collection of dependent records.
- Parameters:
raw (bytes | bytearray)
- Return type:
None
- describe(indent='')¶
Return a textual summary.
- Parameters:
indent (str)
- Return type:
str
- is_closed()¶
Return True if this account has a final summary.
- Return type:
bool
- to_dict(translated=True)¶
Return fields as a dict of typed values.
- Parameters:
translated (bool)
- Return type:
dict[str, Any]
- validate_summary(summary)¶
Validate summary record against the extant nested records.
- Parameters:
summary (ClosingAccount)
- Return type:
None
- property account_control_key: str¶
Get the account control key (CC).
- currency: Currency = Currency(alpha_3='EUR', name='Euro', numeric='978')¶
currency / divisa (Currency)
- Type:
field
- information_mode: InformationModeField = 3¶
information mode / modalidad de información (Integer[1..3])
- Type:
field
- class csb43.aeb43.Batch(context=None, accounts=None, summary=None)¶
A batch of transactions grouped by accounts.
- Parameters:
context (Aeb43Context | None)
accounts (NestedCollection[Account])
summary (SummaryField[EndOfFile])
- __iter__()¶
Iterate associated records.
- Return type:
Iterator[bytes]
- accepts_nested_codes(record)¶
Return True if the record accepts this nested record.
- Parameters:
record (bytes)
- Return type:
bool
- append(raw)¶
Append a bytes record to the collection of dependent records.
- Parameters:
raw (bytes | bytearray)
- Return type:
None
- describe(indent='')¶
User friendly summary.
- Parameters:
indent (str)
- Return type:
str
- dump()¶
Dump content to bytes.
- Return type:
bytes
- is_closed()¶
Return True if the container is closed.
- Return type:
bool
- to_dict(translated=True)¶
Return content as a dictionary.
- Parameters:
translated (bool)
- Return type:
dict[str, Any]
- validate_summary(summary)¶
Validate summary against the current content.
- Parameters:
summary (EndOfFile)
- Return type:
None
- accounts: NestedCollection[Account] = None¶
accounts / cuentas (list[Account])
- class csb43.aeb43.ClosingAccount(context=None, raw=None, _validated=False, bank_code=String(field_id=<Field.BANK_CODE: 1>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), branch_code=String(field_id=<Field.BRANCH_CODE: 2>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), account_number=String(field_id=<Field.ACCOUNT_NUMBER: 3>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), expense_entries=Integer(field_id=<Field.EXPENSE_ENTRIES: 4>, factory=<class 'int'>), expense=Money(value_id=<Field.EXPENSE_AMOUNT: 5>, mode_id=None, default_mode=b'2', padding=b'0', non_negative=True, factory=<class 'decimal.Decimal'>), income_entries=Integer(field_id=<Field.INCOME_ENTRIES: 6>, factory=<class 'int'>), income=Money(value_id=<Field.INCOME_AMOUNT: 7>, mode_id=None, default_mode=b'2', padding=b'0', non_negative=True, factory=<class 'decimal.Decimal'>), final_balance=Money(value_id=<Field.FINAL_BALANCE: 9>, mode_id=<Field.FINAL_BALANCE_CODE: 8>, default_mode=b'2', padding=b'0', non_negative=False, factory=<class 'decimal.Decimal'>), currency=Currency(field_id=<Field.CURRENCY_CODE: 10>, factory=<function euro_currency>), padding=String(field_id=<Field.PADDING: 11>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>))¶
Closing account record.
COD 33
[es] Registro de asiento de cuentas
See [n43_2012] Appendix 1, section 1.5
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
_validated (bool)
bank_code (String)
branch_code (String)
account_number (String)
expense_entries (Integer)
expense (Money)
income_entries (Integer)
income (Money)
final_balance (Money)
currency (Currency)
padding (String)
- class csb43.aeb43.EndOfFile(context=None, raw=None, _validated=False, total_records=Integer(field_id=<Field.TOTAL_RECORDS: 1>, factory=<class 'int'>), padding=String(field_id=<Field.PADDING: 2>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>))¶
End of file record.
COD 88
[es] Registro de fin de fichero
See [n43_2012] Appendix 1, section 1.6
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
_validated (bool)
total_records (Integer)
padding (String)
- class csb43.aeb43.Exchange(context=None, raw=None, original_currency=Currency(field_id=<Field.CURRENCY: 1>, factory=<function euro_currency>), amount=Money(value_id=<Field.AMOUNT: 2>, mode_id=None, default_mode=b'2', padding=b'0', non_negative=False, factory=<class 'decimal.Decimal'>), padding=String(field_id=<Field.PADDING: 3>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>))¶
Exchange record.
COD 24-01
[es] Registro complementario de información de equivalencia de importe del apunte.
See [n43_2012] Appendix 1, section 1.4
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
original_currency (Currency)
amount (Money)
padding (String)
- amount: Money = Decimal('0')¶
transaction amount in the original currency / import en divisa origen (Money[12.2])
- class csb43.aeb43.Item(context=None, raw=None, record_code=Integer(field_id=<Field.RECORD: 1>, factory=<function default_record_code>), item1=String(field_id=<Field.ITEM1: 2>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>), item2=String(field_id=<Field.ITEM2: 3>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>))¶
Complementary item / [es] Registro complementario de concepto.
COD 23
For SEPA normalization using item records, see:
csb43.aeb43.sepa_debitcsb43.aeb43.sepa_transfer
See [n43_2012] Appendix 1, section 1.3
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
record_code (Integer)
item1 (String)
item2 (String)
- classmethod accepts_sequence_code(encoding, start, code)¶
Return True if the provided code is allowed at the current transaction.
- Parameters:
encoding (str) – string encoding
start (int) – first item record to check
code (bytes)
- Return type:
bool
- class csb43.aeb43.SepaDebit(item1, item2, item3, item4, item5, context=None)¶
SEPA direct debit.
Set of five 80-bytes records
See [n43_2012] Appendix 4, section 2
- Parameters:
item1 (NestedRecord[SepaDebitItem1])
item2 (NestedRecord[SepaDebitItem2])
item3 (NestedRecord[SepaDebitItem3])
item4 (NestedRecord[SepaDebitItem4])
item5 (NestedRecord[SepaDebitItem5])
context (Aeb43Context | None)
- classmethod new(*records, context=None)¶
Return an empty/default SEPA direct debit object.
- Parameters:
records (bytes | bytearray)
context (Aeb43Context | None)
- Return type:
- __iter__()¶
Iterate associated records.
- Return type:
Iterator[bytes]
- to_dict(translated=True)¶
Return dict with field values.
- Parameters:
translated (bool)
- Return type:
dict[str, Any]
- property creditor_id: str¶
Creditor id [AT-02] / identificador del acreedor [AT-02].
- property creditor_name: str¶
Creditor name [AT-03] / nombre del acreedor [AT-03].
- property creditor_reference: str¶
Creditor reference [AT-10] / referencia del acreedor [AT-10].
- property debtor_name: str¶
Debtor name [AT-14] / último deudor [AT-15].
- property mandate_reference: str¶
Mandate reference [AT-01] / referencia única del mandato [AT-01].
- property scheme_code: str¶
Scheme code [AT-20] / código de esquema [AT-20].
- class csb43.aeb43.SepaTransfer(item1, item2, item3, item4, item5, context=None)¶
SEPA transfer.
Set of five 80-bytes records
See [n43_2012] Appendix 4, section 1
- Parameters:
item1 (NestedRecord[SepaTransferItem1])
item2 (NestedRecord[SepaTransferItem2])
item3 (NestedRecord[SepaDebitItem3])
item4 (NestedRecord[SepaDebitItem4])
item5 (NestedRecord[SepaTransferItem5])
context (Aeb43Context | None)
- classmethod new(*records, context=None)¶
Return an empty/default SEPA transfer object.
- Parameters:
records (bytes | bytearray)
context (Aeb43Context | None)
- Return type:
- __iter__()¶
Iterate associated records.
- Return type:
Iterator[bytes]
- to_dict(translated=True)¶
Return dict with field values.
- Parameters:
translated (bool)
- Return type:
dict[str, Any]
- property additional_info: str¶
Additional info / campo de libre uso para información del beneficiario.
- property originator_code: str¶
Originator code [AT-02] / código del ordenante [AT-02].
- property originator_name: str¶
Originator name [AT-02] / nombre del ordenante [AT-02].
- property originator_reference: str¶
Originator reference [AT-41] / referencia del ordenante [AT-41].
- property originator_reference_party: str¶
Originator reference party [AT-08] & nombre de ‘por cuenta de’ [AT-08].
- class csb43.aeb43.Transaction(context=None, raw=None, padding=String(field_id=<Field.PADDING: 1>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>), branch_code=BranchCode(field_id=<Field.BRANCH_CODE: 2>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), document_number=String(field_id=<Field.DOCUMENT_NUMBER: 9>, padding=b'0', trim=<Trim.BOTH_BLANK: 10>, align_left=False, mode=mappingproxy({}), factory=<class 'str'>), transaction_date=Date(field_id=<Field.TRANSACTION_DATE: 3>, factory=<built-in method today of type object>), value_date=Date(field_id=<Field.VALUE_DATE: 4>, factory=<built-in method today of type object>), shared_item=Integer(field_id=<Field.SHARED_ITEM: 5>, factory=<class 'int'>), own_item=Integer(field_id=<Field.OWN_ITEM: 6>, factory=<class 'int'>), amount=Money(value_id=<Field.AMOUNT: 8>, mode_id=<Field.EXPENSE_OR_INCOME: 7>, default_mode=b'2', padding=b'0', non_negative=False, factory=<class 'decimal.Decimal'>), reference1=String(field_id=<Field.REFERENCE1: 10>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({<InformationMode.THIRD: 3>: {'padding': b'0', 'trim': <Trim.BOTH_BLANK: 10>, 'align_left': False}}), factory=<class 'str'>), reference2=String(field_id=<Field.REFERENCE2: 11>, padding=b' ', trim=<Trim.BOTH: 15>, align_left=True, mode=mappingproxy({}), factory=<class 'str'>), exchange=None, optional_items=None, sepa_transfer=None, sepa_debit=None)¶
Main transaction record.
COD 22
[es] Registro principal de movimientos
See [n43_2012] Appendix 1, section 1.2
- Parameters:
context (Aeb43Context | None)
raw (dataclasses.InitVar[Union[bytes, bytearray, NoneType]])
padding (String)
branch_code (String)
document_number (String)
transaction_date (Date)
value_date (Date)
shared_item (Integer)
own_item (Integer)
amount (Money)
reference1 (String)
reference2 (String)
exchange (NestedRecord[Exchange])
optional_items (NestedCollection[Item])
sepa_transfer (SepaTransferField)
sepa_debit (SepaDebitField)
- __iter__()¶
Iterate raw records associated to this object.
- Return type:
Iterator[bytes]
- accepts_nested_codes(record)¶
Return True if the record accepts this nested record.
- Parameters:
record (bytes)
- Return type:
bool
- append(raw)¶
Append a bytes record to the collection of dependent records.
- Parameters:
raw (bytes | bytearray)
- Return type:
None
- iter_optional_items()¶
Iterate optional items fields.
- Return type:
Iterator[str]
- to_dict(translated=True)¶
Return fields as a dict of typed values.
- Parameters:
translated (bool)
- Return type:
dict[str, Any]
- to_sepa()¶
Convert complementary items to a SEPA debit/transfer object.
- Return type:
None
shared item / concepto común (Integer[0..99])
- csb43.aeb43.get_current_context()¶
Get the context for the current scope.
- Return type:
- csb43.aeb43.read_batch(stream, context=None)¶
Read a batch of accounts from a binary stream.
- Parameters:
stream (IO[bytes])
context (Aeb43Context | None)
- Return type:
Context – [en] Contexto¶
Context object for reading AEB43 records.
- class csb43.aeb43.record.context.Aeb43Context(strict=False, silent=False, encoding='latin1', sepa=True, year_first=True, cache_fields=True, decimals=2, information_mode=InformationMode.THIRD)¶
Settings for encoded AEB43 records.
- Parameters:
strict (bool)
silent (bool)
encoding (str)
sepa (bool)
year_first (bool)
cache_fields (bool)
decimals (int)
information_mode (InformationMode)
- emit_validation_error(message)¶
Raise a validation error or emit a validation warning.
Raise ValidationException if strict or emits a ValidationWarning if not strict and not silent.
- Parameters:
message (str)
- Return type:
None
- emit_validation_warning(message)¶
Emit a warning.
- Parameters:
message (str)
- Return type:
None
- error_message(message)¶
Get a new error message in a batch context.
- Parameters:
message (str)
- Return type:
str
- new_validation_error(message)¶
Create a new validation error with message.
Context line is added to the Exception.
- Parameters:
message (str)
- Return type:
- scope(**kwargs)¶
Create a scope for this context.
- Parameters:
kwargs (Any)
- Return type:
Iterator[Aeb43Context]
- to_string(value)¶
Convert value to string.
- Parameters:
value (Any)
- Return type:
str
- cache_fields: bool = True¶
cache values from setters/getters
- decimals: int = 2¶
number of decimal places used in money amounts
- encoding: str = 'latin1'¶
string encoding use when transforming from binary files
- information_mode: InformationMode = 3¶
information mode to use in nested records. Accounts will change this value.
- sepa: bool = True¶
when sepa=True, transactions trie to interpret optional items as SEPA transfer or direct debits.
- silent: bool = False¶
if silent=True, validation warnings are not emitted
- strict: bool = False¶
raise exception when a validation fails if strict=True
- year_first: bool = True¶
dates are expected to be as year/month/day
- class csb43.aeb43.record.context.BatchContext(line=None)¶
Line context.
- Parameters:
line (int | None)
- scope()¶
Create a scope for this context.
- Return type:
Iterator[BatchContext]
- class csb43.aeb43.record.context.Contextual(*args, **kwargs)¶
Protocol for any class that has a context property.
- class csb43.aeb43.record.context.ContextualMixin¶
Provides a method that always returns a context.
- get_context()¶
Get the context for the current scope.
- Return type:
- class csb43.aeb43.record.context.InformationMode(*values)¶
Information mode.
[es] modalidad de información
See [n43_2012] Appendix 1
- csb43.aeb43.record.context.check_compatible_encoding(encoding)¶
Return True if ‘encoding’ is compatible with n43 records.
- Parameters:
encoding (str)
- Return type:
bool
- csb43.aeb43.record.context.get_batch_context()¶
Get the context for the current scope.
- Return type:
- csb43.aeb43.record.context.get_current_context()¶
Get the context for the current scope.
- Return type:
- csb43.aeb43.record.context.CONTEXT: ContextVar['Aeb43Context' | None] = <ContextVar name='CONTEXT' default=Aeb43Context(strict=False, silent=False, encoding='latin1', sepa=True, year_first=True, cache_fields=True, decimals=2, information_mode=<InformationMode.THIRD: 3>)>¶
Global ContextVar object for Aeb43Context