woob.tools.capabilities.bank.transactions

class FrenchTransaction(id='', *args, **kwargs)[source]

Bases: Transaction

Transaction with some helpers for french bank websites.

Variables:
  • url – (str) url

  • date – (date, datetime) Debit date on the bank statement

  • rdate – (date, datetime) Real date, when the payment has been made; usually extracted from the label or from credit card info

  • vdate – (date, datetime) Value date, or accounting date; usually for professional accounts

  • bdate – (date, datetime) Bank date, when the transaction appear on website (usually extracted from column date)

  • type – (int) Type of transaction, use TYPE_* constants (default: 0)

  • raw – (str) Raw label of the transaction

  • category – (str) Category of the transaction

  • label – (str) Pretty label

  • amount – (Decimal) Net amount of the transaction, used to compute account balance

  • coming – (bool) True if the transaction is not yet booked

  • card – (str) Card number (if any)

  • commission – (Decimal) Commission part on the transaction (in account currency)

  • gross_amount – (Decimal) Amount of the transaction without the commission

  • original_amount – (Decimal) Original net amount (in another currency)

  • original_currency – (str) Currency of the original amount

  • country – (str) Country of transaction

  • original_commission – (Decimal) Original commission (in another currency)

  • original_commission_currency – (str) Currency of the original commission

  • original_gross_amount – (Decimal) Original gross amount (in another currency)

  • attachments – (list) List of files attached to the transaction

  • investments – (list) List of investments related to the transaction (default: [])

  • counterparty – (TransactionCounterparty) Counterparty of transaction

  • bank_transaction_code – (BankTransactionCode) Bank transaction code of transaction

PATTERNS = []
classmethod clean_amount(text)[source]

Clean a string containing an amount.

set_amount(credit='', debit='')[source]

Set an amount value from a string.

Can take two strings if there are both credit and debit columns.

parse_date(date)[source]
parse(date, raw, vdate=None)[source]

Parse date and raw strings to create datetime.date objects, determine the type of transaction, and create a simplified label

When calling this method, you should have defined patterns (in the PATTERN class attribute) with a list containing tuples of regexp and the associated type, for example:

PATTERNS = [(re.compile(r'^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
            (re.compile(r'^PRLV (?P<text>.*)'),        FrenchTransaction.TYPE_ORDER),
            (re.compile(r'^(?P<text>.*) CARTE \d+ PAIEMENT CB (?P<dd>\d{2})(?P<mm>\d{2}) ?(.*)$'),
                                                       FrenchTransaction.TYPE_CARD)
           ]

In regexps, you can define this patterns:

  • text: part of label to store in simplified label

  • category: part of label representing the category

  • yy, mm, dd, HH, MM: date and time parts

TransactionElement[source]

alias of _TransactionElement

TransactionsElement[source]

alias of _TransactionsElement

class Date(selector=None, symbols='', replace=[], children=True, newlines=True, transliterate=False, normalize='NFC', **kwargs)[source]

Bases: CleanText

filter(date)[source]

This method has to be overridden by children classes.

classmethod Raw(*args, **kwargs)[source]
class Currency(selector=None, symbols='', replace=[], children=True, newlines=True, transliterate=False, normalize='NFC', **kwargs)[source]

Bases: CleanText

filter(text)[source]

This method has to be overridden by children classes.

class Amount(credit, debit=None, replace_dots=True)[source]

Bases: Filter

class AmericanTransaction(id='', url=NotLoaded, backend=None)[source]

Bases: Transaction

Transaction with some helpers for american bank websites.

Variables:
  • url – (str) url

  • date – (date, datetime) Debit date on the bank statement

  • rdate – (date, datetime) Real date, when the payment has been made; usually extracted from the label or from credit card info

  • vdate – (date, datetime) Value date, or accounting date; usually for professional accounts

  • bdate – (date, datetime) Bank date, when the transaction appear on website (usually extracted from column date)

  • type – (int) Type of transaction, use TYPE_* constants (default: 0)

  • raw – (str) Raw label of the transaction

  • category – (str) Category of the transaction

  • label – (str) Pretty label

  • amount – (Decimal) Net amount of the transaction, used to compute account balance

  • coming – (bool) True if the transaction is not yet booked

  • card – (str) Card number (if any)

  • commission – (Decimal) Commission part on the transaction (in account currency)

  • gross_amount – (Decimal) Amount of the transaction without the commission

  • original_amount – (Decimal) Original net amount (in another currency)

  • original_currency – (str) Currency of the original amount

  • country – (str) Country of transaction

  • original_commission – (Decimal) Original commission (in another currency)

  • original_commission_currency – (str) Currency of the original commission

  • original_gross_amount – (Decimal) Original gross amount (in another currency)

  • attachments – (list) List of files attached to the transaction

  • investments – (list) List of investments related to the transaction (default: [])

  • counterparty – (TransactionCounterparty) Counterparty of transaction

  • bank_transaction_code – (BankTransactionCode) Bank transaction code of transaction

classmethod clean_amount(text)[source]

Clean a string containing an amount.

classmethod decimal_amount(text)[source]

Convert a string containing an amount to Decimal.

sorted_transactions(iterable)[source]

Sort an iterable of transactions in reverse chronological order

merge_iterators(*iterables)[source]

Merge transactions iterators keeping sort order.

Each iterator must already be sorted in reverse chronological order.

keep_only_card_transactions(it, match_func=None)[source]

Filter iterator to keep transactions with card types.

This helper should typically be used when a banking site returns card and non-card transactions mixed on the same checking account.

Types kept are TYPE_DEFERRED_CARD and TYPE_CARD_SUMMARY. Additionally, the amount is inversed for transactions with type TYPE_CARD_SUMMARY. This is because on the deferred debit card account, summaries should be positive as the amount is debitted from checking account to credit the card account.

The match_func can be provided in case of multiple cards, to only return transactions of one card.

Parameters:

match_func (callable or None) – optional function to filter transactions further (default: None)

omit_deferred_transactions(it)[source]

Filter iterator to omit transactions with type TYPE_DEFERRED_CARD.

This helper should typically be used when a banking site returns card and non-card transactions mixed on the same checking account.