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

[n43_2012] (1,2,3,4,5,6,7,8,9)

Información normalizada de cuenta corriente SEPA (2012), Serie normas y procedimientos bancarios nº 43. Confederación Española de Cajas de Ahorros. Asociación Española de Banca.

@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:
__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).

account_number: String = ''

account number / número de cuenta (String[10])

Type:

field

bank_code: String = ''

bank code / clave de la entidad (String[4])

Type:

field

branch_code: String = ''

branch code / clave de oficina (String[4])

Type:

field

currency: Currency = Currency(alpha_3='EUR', name='Euro', numeric='978')

currency / divisa (Currency)

Type:

field

final_date: Date = datetime.date(2026, 5, 24)

final date / fecha final (Date)

Type:

field

information_mode: InformationModeField = 3

information mode / modalidad de información (Integer[1..3])

Type:

field

initial_balance: Money = Decimal('0')

initial balance / importe saldo inicial (Money[12.2])

Type:

field

initial_date: Date = datetime.date(2026, 5, 24)

initial date / fecha inicial (Date)

Type:

field

padding: String = ''

padding / libre uso (String[3])

Type:

field

short_name: String = ''

short name / nombre abreviado (String[26])

Type:

field

class csb43.aeb43.Batch(context=None, accounts=None, summary=None)

A batch of transactions grouped by accounts.

Parameters:
__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])

summary: SummaryField[EndOfFile] = None

summary record / registro de recuento (EndOfFile)

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:
account_number: String = ''

account number / número de cuenta (String[10])

bank_code: String = ''

bank code / clave de la entidad (String[4])

branch_code: String = ''

branch code / clave de oficina origen (String[4])

currency: Currency = Currency(alpha_3='EUR', name='Euro', numeric='978')

currency / divisa (Currency)

Type:

field

expense: Money = Decimal('0')

expense / total importes en el Debe (Money[12.2])

expense_entries: Integer = 0

expense entries / número de apuntes en el Debe (Integer)

final_balance: Money = Decimal('0')

final balance / importe saldo final (Money[12.2])

Type:

field

income: Money = Decimal('0')

income / total importes en el Haber (Money[12.2])

income_entries: Integer = 0

income entries / número de apuntes en el Haber (Integer)

padding: String = ''

padding / libre uso (String[4])

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)

padding: String = ''

padding / libre uso (String[54])

total_records: Integer = 0

total number of records / número total de registros (Integer)

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:
amount: Money = Decimal('0')

transaction amount in the original currency / import en divisa origen (Money[12.2])

original_currency: Currency = Currency(alpha_3='EUR', name='Euro', numeric='978')

original currency / divisa origen del movimiento (Currency)

padding: String = ''

unused space in record / libre (String[59])

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_debit

  • csb43.aeb43.sepa_transfer

See [n43_2012] Appendix 1, section 1.3

Parameters:
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

item1: String = ''

item #1 / [es] concepto 1 (String[38])

item2: String = ''

item #2 / [es] concepto 2 (String[38])

record_code: Integer = 1

sequence code for complementary item record / [es] código de registro (Integer[1..5])

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:
classmethod new(*records, context=None)

Return an empty/default SEPA direct debit object.

Parameters:
Return type:

SepaDebit

__iter__()

Iterate associated records.

Return type:

Iterator[bytes]

as_optional_items()

Convert to vanilla complementary items.

Return type:

Iterator[Item]

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:
classmethod new(*records, context=None)

Return an empty/default SEPA transfer object.

Parameters:
Return type:

SepaTransfer

__iter__()

Iterate associated records.

Return type:

Iterator[bytes]

as_optional_items()

Convert to conventional vanilla items.

Return type:

Iterator[Item]

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:
__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

amount: Money = Decimal('0')

transaction amont / importe (Money[12.2])

branch_code: String = ''

branch code / clave de oficina origen (String[4])

document_number: String = ''

document number / número de documento (String[10])

own_item: Integer = 0

own item / concepto propio (Integer[0..999])

padding: String = ''

padding / libre uso (String[4])

reference1: String = ''

reference 1 / referencia 1 (String[12])

reference2: String = ''

reference 2 / referencia 2 (String[16])

shared_item: Integer = 0

shared item / concepto común (Integer[0..99])

transaction_date: Date = datetime.date(2026, 5, 24)

date of transaction / fecha de operación (Date)

value_date: Date = datetime.date(2026, 5, 24)

effective date / fecha de valor (Date)

csb43.aeb43.get_current_context()

Get the context for the current scope.

Return type:

Aeb43Context

csb43.aeb43.read_batch(stream, context=None)

Read a batch of accounts from a binary stream.

Parameters:
Return type:

Batch

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:

ValidationException

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:

Aeb43Context

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:

BatchContext

csb43.aeb43.record.context.get_current_context()

Get the context for the current scope.

Return type:

Aeb43Context

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