woob.tools.capabilities.bank.transactions
¶
- class FrenchTransaction(id='', *args, **kwargs)[source]¶
Bases:
Transaction
Transaction with some helpers for french bank websites.
- Variables:
url – (
str
) urldate – (
date
,datetime
) Debit date on the bank statementrdate – (
date
,datetime
) Real date, when the payment has been made; usually extracted from the label or from credit card infovdate – (
date
,datetime
) Value date, or accounting date; usually for professional accountsbdate – (
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 transactioncategory – (
str
) Category of the transactionlabel – (
str
) Pretty labelamount – (
Decimal
) Net amount of the transaction, used to compute account balancecoming – (
bool
) True if the transaction is not yet bookedcard – (
str
) Card number (if any)commission – (
Decimal
) Commission part on the transaction (in account currency)gross_amount – (
Decimal
) Amount of the transaction without the commissionoriginal_amount – (
Decimal
) Original net amount (in another currency)original_currency – (
str
) Currency of the original amountcountry – (
str
) Country of transactionoriginal_commission – (
Decimal
) Original commission (in another currency)original_commission_currency – (
str
) Currency of the original commissionoriginal_gross_amount – (
Decimal
) Original gross amount (in another currency)attachments – (
list
) List of files attached to the transactioninvestments – (
list
) List of investments related to the transaction (default: [])counterparty – (
TransactionCounterparty
) Counterparty of transactionbank_transaction_code – (
BankTransactionCode
) Bank transaction code of transaction
- PATTERNS = []¶
- 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, 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
- class Date(selector=None, symbols='', replace=[], children=True, newlines=True, transliterate=False, normalize='NFC', **kwargs)[source]¶
Bases:
CleanText
- class AmericanTransaction(id='', url=NotLoaded, backend=None)[source]¶
Bases:
Transaction
Transaction with some helpers for american bank websites.
- Variables:
url – (
str
) urldate – (
date
,datetime
) Debit date on the bank statementrdate – (
date
,datetime
) Real date, when the payment has been made; usually extracted from the label or from credit card infovdate – (
date
,datetime
) Value date, or accounting date; usually for professional accountsbdate – (
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 transactioncategory – (
str
) Category of the transactionlabel – (
str
) Pretty labelamount – (
Decimal
) Net amount of the transaction, used to compute account balancecoming – (
bool
) True if the transaction is not yet bookedcard – (
str
) Card number (if any)commission – (
Decimal
) Commission part on the transaction (in account currency)gross_amount – (
Decimal
) Amount of the transaction without the commissionoriginal_amount – (
Decimal
) Original net amount (in another currency)original_currency – (
str
) Currency of the original amountcountry – (
str
) Country of transactionoriginal_commission – (
Decimal
) Original commission (in another currency)original_commission_currency – (
str
) Currency of the original commissionoriginal_gross_amount – (
Decimal
) Original gross amount (in another currency)attachments – (
list
) List of files attached to the transactioninvestments – (
list
) List of investments related to the transaction (default: [])counterparty – (
TransactionCounterparty
) Counterparty of transactionbank_transaction_code – (
BankTransactionCode
) Bank transaction code of transaction
- 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
)