本文整理匯總了Python中weboob.capabilities.bank.Transaction類的典型用法代碼示例。如果您正苦於以下問題:Python Transaction類的具體用法?Python Transaction怎麽用?Python Transaction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Transaction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_history
def get_history(self, account):
if not account._consultable:
raise NotImplementedError()
offset = 0
next_page = True
while next_page:
r = self.open('/transactionnel/services/applications/operations/get/%(number)s/%(nature)s/00/%(currency)s/%(startDate)s/%(endDate)s/%(offset)s/%(limit)s' %
{'number': account._number,
'nature': account._nature,
'currency': account.currency,
'startDate': '2000-01-01',
'endDate': date.today().strftime('%Y-%m-%d'),
'offset': offset,
'limit': 50
})
next_page = False
offset += 50
for op in r.json()['content']['operations']:
next_page = True
t = Transaction()
t.id = op['id']
t.amount = Decimal(str(op['montant']))
t.date = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation'))/1000)
t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit'))/1000)
t.vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation')))/1000)
if 'categorie' in op:
t.category = op['categorie']
t.label = op['libelle']
t.raw = ' '.join([op['libelle']] + op['details'])
yield t
示例2: iter_transactions
def iter_transactions(self):
for row in self.doc.xpath('//tr/th[@headers='
'"postedHeader transactionDateHeader"]/..'):
tdate = row.xpath('th[@headers="postedHeader '
'transactionDateHeader"]/text()')[0]
pdate = row.xpath('td[@headers="postedHeader '
'postingDateHeader"]/text()')[0]
desc = row.xpath('td[@headers="postedHeader '
'descriptionHeader"]/span/text()')[0]
ref = row.xpath('td[@headers="postedHeader '
'descriptionHeader"]/text()')[0]
amount = row.xpath('td[@headers="postedHeader '
'amountHeader"]/text()')[0]
tdate = datetime.datetime.strptime(tdate, '%m/%d/%y')
pdate = datetime.datetime.strptime(pdate, '%m/%d/%y')
desc = clean_label(desc)
ref = re.match('.*<REFERENCE ([^>]+)>.*', ref).group(1)
if amount.startswith('+'):
amount = AmTr.decimal_amount(amount[1:])
else:
amount = -AmTr.decimal_amount(amount)
trans = Transaction(ref)
trans.date = tdate
trans.rdate = pdate
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = amount
yield trans
示例3: read_transaction
def read_transaction(self, pos, date_from, date_to):
startPos = pos
pos, tdate = self.read_date(pos)
pos, pdate = self.read_date(pos)
# Early check to call read_multiline_desc() only when needed.
if tdate is None:
return startPos, None
pos, desc = self.read_multiline_desc(pos)
pos, amount = self.read_amount(pos)
if desc is None or amount is None:
return startPos, None
else:
# Sometimes one date is missing.
pdate = pdate or tdate
tdate = closest_date(tdate, date_from, date_to)
pdate = closest_date(pdate, date_from, date_to)
trans = Transaction()
trans.date = tdate
trans.rdate = pdate
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = -amount
return pos, trans
示例4: unsorted_trans
def unsorted_trans(self):
for jnl in self.doc['accountDetailsAndActivity']['accountActivity'] \
['postedTransactionJournals']:
tdate = jnl['columns'][0]['activityColumn'][0]
label = jnl['columns'][1]['activityColumn'][0]
amount = jnl['columns'][3]['activityColumn'][0]
xdescs = dict((x['label'], x['value'][0])
for x in jnl['extendedDescriptions'])
pdate = xdescs['Posted Date :']
ref = xdescs.get('Reference Number:') or ''
if amount.startswith('(') and amount.endswith(')'):
amount = AmTr.decimal_amount(amount[1:-1])
else:
amount = -AmTr.decimal_amount(amount)
label = clean_label(label)
trans = Transaction(ref)
trans.date = datetime.strptime(tdate, '%m-%d-%Y')
trans.rdate = datetime.strptime(pdate, '%m-%d-%Y')
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = label
trans.label = label
trans.amount = amount
yield trans
示例5: read_card_transaction
def read_card_transaction(self, pos, date_from, date_to):
INDENT_CHARGES = 520
startPos = pos
pos, tdate = self.read_date(pos)
pos, pdate_layout = self.read_layout_tm(pos)
pos, pdate = self.read_date(pos)
pos, ref_layout = self.read_layout_tm(pos)
pos, ref = self.read_ref(pos)
pos, desc = self.read_multiline_desc(pos)
pos, amount = self.read_indent_amount(
pos,
range_minus = (INDENT_CHARGES, 9999),
range_plus = (0, INDENT_CHARGES))
if tdate is None or pdate_layout is None or pdate is None \
or ref_layout is None or ref is None or desc is None or amount is None:
return startPos, None
else:
tdate = closest_date(tdate, date_from, date_to)
pdate = closest_date(pdate, date_from, date_to)
trans = Transaction(ref)
trans.date = tdate
trans.rdate = pdate
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = amount
return pos, trans
示例6: read_cash_transaction
def read_cash_transaction(self, pos, date_from, date_to):
INDENT_BALANCE = 520
INDENT_WITHDRAWAL = 470
startPos = pos
pos, date = self.read_date(pos)
pos, _ = self.read_star(pos)
pos, desc = self.read_multiline_desc(pos)
pos, amount = self.read_indent_amount(
pos,
range_plus = (0, INDENT_WITHDRAWAL),
range_minus = (INDENT_WITHDRAWAL, INDENT_BALANCE),
range_skip = (INDENT_BALANCE, 9999))
if desc is None or date is None or amount is None:
return startPos, None
else:
date = closest_date(date, date_from, date_to)
trans = Transaction(u'')
trans.date = date
trans.rdate = date
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = amount
return pos, trans
示例7: read_transaction
def read_transaction(self, pos, date_from, date_to):
startPos = pos
pos, tdate = self.read_date(pos)
pos, pdate_layout = self.read_layout_td(pos)
pos, pdate = self.read_date(pos)
pos, ref_layout = self.read_layout_td(pos)
pos, ref = self.read_ref(pos)
pos, desc_layout = self.read_layout_td(pos)
pos, desc = self.read_text(pos)
pos, amount_layout = self.read_layout_td(pos)
pos, amount = self.read_amount(pos)
if tdate is None or pdate is None \
or desc is None or amount is None or amount == 0:
return startPos, None
else:
tdate = closest_date(tdate, date_from, date_to)
pdate = closest_date(pdate, date_from, date_to)
desc = u' '.join(desc.split())
trans = Transaction(ref or u'')
trans.date = tdate
trans.rdate = pdate
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = amount
return pos, trans
示例8: iter_history
def iter_history(self, account):
if account.id not in self.histories:
histories = []
self.open('/user/%s/project/%s/activity' % (self.users['userId'], account.number), method="OPTIONS")
for activity in [acc for acc in self.request('/user/%s/project/%s/activity' % (self.users['userId'], account.number), headers=self.request_headers)['activities'] \
if acc['details'] is not None]:
m = re.search(u'([\d\,]+)(?=[\s]+€|[\s]+euro)', activity['details'])
if "Souscription" not in activity['title'] and not m:
continue
t = Transaction()
t.label = "%s - %s" % (" ".join(activity['type'].split("_")), activity['title'])
t.date = Date().filter(activity['date'])
t.type = Transaction.TYPE_BANK
amount = account._startbalance if not m else "-%s" % m.group(1) if "FRAIS" in activity['type'] else m.group(1)
t.amount = CleanDecimal(replace_dots=True).filter(amount)
histories.append(t)
self.histories[account.id] = histories
return self.histories[account.id]
示例9: iter_history
def iter_history(self, account):
for hist in self.doc['operationsIndividuelles']:
if len(hist['instructions']) > 0:
if self.belongs(hist['instructions'], account):
tr = Transaction()
tr.amount = self.get_amount(hist['instructions'], account)
tr.rdate = datetime.strptime(hist['dateComptabilisation'].split('T')[0], '%Y-%m-%d')
tr.date = tr.rdate
tr.label = hist['libelleOperation'] if 'libelleOperation' in hist else hist['libelleCommunication']
tr.type = Transaction.TYPE_UNKNOWN
# Bypassed because we don't have the ISIN code
# tr.investments = []
# for ins in hist['instructions']:
# inv = Investment()
# inv.code = NotAvailable
# inv.label = ins['nomFonds']
# inv.description = ' '.join([ins['type'], ins['nomDispositif']])
# inv.vdate = datetime.strptime(ins.get('dateVlReel', ins.get('dateVlExecution')).split('T')[
# 0], '%Y-%m-%d')
# inv.valuation = Decimal(ins['montantNet'])
# inv.quantity = Decimal(ins['nombreDeParts'])
# inv.unitprice = inv.unitvalue = Decimal(ins['vlReel'])
# tr.investments.append(inv)
yield tr
示例10: get_history
def get_history(self, account):
if not account._consultable:
raise NotImplementedError()
offset = 0
next_page = True
seen = set()
while next_page:
r = self.api_open(
"/transactionnel/services/applications/operations/get/%(number)s/%(nature)s/00/%(currency)s/%(startDate)s/%(endDate)s/%(offset)s/%(limit)s"
% {
"number": account._number,
"nature": account._nature,
"currency": account.currency,
"startDate": "2000-01-01",
"endDate": date.today().strftime("%Y-%m-%d"),
"offset": offset,
"limit": 50,
}
)
next_page = False
offset += 50
transactions = []
for op in reversed(r.json()["content"]["operations"]):
next_page = True
t = Transaction()
if op["id"] in seen:
raise ParseError("There are several transactions with the same ID, probably an infinite loop")
t.id = op["id"]
seen.add(t.id)
t.amount = Decimal(str(op["montant"]))
t.date = date.fromtimestamp(op.get("dateDebit", op.get("dateOperation")) / 1000)
t.rdate = date.fromtimestamp(op.get("dateOperation", op.get("dateDebit")) / 1000)
t.vdate = date.fromtimestamp(op.get("dateValeur", op.get("dateDebit", op.get("dateOperation"))) / 1000)
if "categorie" in op:
t.category = op["categorie"]
t.label = op["libelle"]
t.raw = " ".join([op["libelle"]] + op["details"])
transactions.append(t)
# Transactions are unsorted
for t in sorted(transactions, key=lambda t: t.rdate, reverse=True):
yield t
示例11: get_history
def get_history(self, account):
if not account._consultable:
raise NotImplementedError()
if account._univers != self.current_univers:
self.move_to_univers(account._univers)
offset = 0
next_page = True
seen = set()
while next_page:
r = self.api_open('/transactionnel/services/applications/operations/get/%(number)s/%(nature)s/00/%(currency)s/%(startDate)s/%(endDate)s/%(offset)s/%(limit)s' %
{'number': account._number,
'nature': account._nature,
'currency': account.currency,
'startDate': '2000-01-01',
'endDate': date.today().strftime('%Y-%m-%d'),
'offset': offset,
'limit': 50
})
next_page = False
offset += 50
transactions = []
for op in reversed(r.json()['content']['operations']):
next_page = True
t = Transaction()
if op['id'] in seen:
raise ParseError('There are several transactions with the same ID, probably an infinite loop')
t.id = op['id']
seen.add(t.id)
t.amount = Decimal(str(op['montant']))
t.date = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation'))/1000)
t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit'))/1000)
t.vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation')))/1000)
if 'categorie' in op:
t.category = op['categorie']
t.label = op['libelle']
t.raw = ' '.join([op['libelle']] + op['details'])
transactions.append(t)
# Transactions are unsorted
for t in sorted(transactions, key=lambda t: t.rdate, reverse=True):
yield t
示例12: iter_transactions
def iter_transactions(self):
for li in self.doc.xpath('//section[@class="transactions"]//div/li'):
date = li.xpath('p[@data-type="date"]//text()')[0].strip()
label = li.xpath('p[@data-type="description"]//text()')[0].strip()
amount = li.xpath('p[@data-type="amount"]//text()')[0].strip()
t = Transaction()
t.date = datetime.strptime(date, '%m/%d/%Y')
t.rdate = datetime.strptime(date, '%m/%d/%Y')
t.type = Transaction.TYPE_UNKNOWN
t.raw = unicode(label)
t.label = unicode(label)
t.amount = -AmTr.decimal_amount(amount)
yield t
示例13: iter_recent
def iter_recent(self):
records = json.loads(self.doc.xpath(
'//div[@id="completedActivityRecords"]//input[1]/@value')[0])
recent = [x for x in records if x['PDF_LOC'] is None]
for rec in sorted(recent, ActivityPage.cmp_records, reverse=True):
desc = u' '.join(rec['TRANS_DESC'].split())
trans = Transaction((rec['REF_NUM'] or u'').strip())
trans.date = ActivityPage.parse_date(rec['TRANS_DATE'])
trans.rdate = ActivityPage.parse_date(rec['POST_DATE'])
trans.type = Transaction.TYPE_UNKNOWN
trans.raw = desc
trans.label = desc
trans.amount = -AmTr.decimal_amount(rec['TRANS_AMOUNT'])
yield trans
示例14: iter_history
def iter_history(self, account):
# Load i18n for type translation
self.i18np.open(lang1=self.LANG, lang2=self.LANG).load_i18n()
# For now detail for each account is not available. History is global for all accounts and very simplist
data = {'clang': self.LANG,
'ctcc': self.CTCC,
'login': self.username,
'session': self.sessionId}
for trans in self.historyp.open(data=data).get_transactions():
t = Transaction()
t.id = trans["referenceOperationIndividuelle"]
t.date = datetime.strptime(trans["dateHeureSaisie"], "%d/%m/%Y")
t.rdate = datetime.strptime(trans["dateHeureSaisie"], "%d/%m/%Y")
t.type = Transaction.TYPE_DEPOSIT if trans["montantNetEuro"] > 0 else Transaction.TYPE_PAYBACK
t.raw = trans["typeOperation"]
try:
t.label = self.i18n["OPERATION_TYPE_" + trans["casDeGestion"]]
except KeyError:
t.label = self.i18n["OPERATION_TYPE_TOTAL_" + trans["casDeGestion"]]
t.amount = Decimal(trans["montantNetEuro"]).quantize(Decimal('.01'))
yield t
示例15: iter_transactions
def iter_transactions(self):
for ntrans in reversed(self.doc.xpath('//TRANSACTION')):
desc = u' '.join(ntrans.xpath(
'TRANSDESCRIPTION/text()')[0].split())
tdate = u''.join(ntrans.xpath('TRANSACTIONDATE/text()'))
pdate = u''.join(ntrans.xpath('POSTDATE/text()'))
# Skip transactions which are not posted,
# because they are not accounted for in balance calculation.
if not pdate:
continue
t = Transaction()
t.date = datetime.strptime(tdate, '%m/%d/%Y')
t.rdate = datetime.strptime(pdate, '%m/%d/%Y')
t.type = Transaction.TYPE_UNKNOWN
t.raw = desc
t.label = desc
t.amount = -AmTr.decimal_amount(ntrans.xpath('AMOUNT/text()')[0])
yield t