本文整理匯總了Python中weboob.capabilities.bank.Transaction.rdate方法的典型用法代碼示例。如果您正苦於以下問題:Python Transaction.rdate方法的具體用法?Python Transaction.rdate怎麽用?Python Transaction.rdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weboob.capabilities.bank.Transaction
的用法示例。
在下文中一共展示了Transaction.rdate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read_card_transaction
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例2: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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: get_history
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例4: iter_history
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例5: read_cash_transaction
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例6: read_transaction
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例7: unsorted_trans
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例8: read_transaction
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例9: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
def iter_transactions(self, account):
DATE = 0
TIME = 1
NAME = 3
TYPE = 4
CURRENCY = 6
GROSS = 7
FEE = 8
NET = 9
FROM = 10
TO = 11
TRANS_ID = 12
ITEM = 15
SITE = 24
csv = self.document
for row in csv.rows:
# we filter accounts by currency
if account.get_currency(row[CURRENCY]) != account.currency:
continue
trans = Transaction(row[TRANS_ID])
# silly American locale
if re.search(r'\d\.\d\d$', row[NET]):
date = datetime.datetime.strptime(row[DATE] + ' ' + row[TIME], "%m/%d/%Y %I:%M:%S %p")
else:
date = datetime.datetime.strptime(row[DATE] + ' ' + row[TIME], "%d/%m/%Y %H:%M:%S")
trans.date = date
trans.rdate = date
line = row[NAME]
if row[ITEM]:
line += u' ' + row[ITEM]
if row[SITE]:
line += u"(" + row[SITE] + u")"
trans.raw = line
trans.label = row[NAME]
if row[TYPE].endswith(u'Credit Card') or row[TYPE].endswith(u'carte bancaire'):
trans.type = Transaction.TYPE_CARD
elif row[TYPE].endswith(u'Payment Sent') or row[TYPE].startswith(u'Paiement'):
trans.type = Transaction.TYPE_ORDER
elif row[TYPE] in (u'Currency Conversion', u'Conversion de devise'):
trans.type = Transaction.TYPE_BANK
else:
trans.type = Transaction.TYPE_UNKNOWN
# Net is what happens after the fee (0 for most users), so what is the most "real"
trans.amount = clean_amount(row[NET])
trans._gross = clean_amount(row[GROSS])
trans._fees = clean_amount(row[FEE])
trans._to = row[TO] or None
trans._from = row[FROM] or None
yield trans
示例10: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例11: iter_recent
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例12: parse
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
def parse(self):
emonths = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December']
date_format, time_format, months = self.guess_format()
for row in self.document.xpath('//table[@id="transactionTable"]/tbody/tr'):
if len(row.xpath('.//td')) < 5:
continue
amount = row.xpath('.//td[@headers="gross"]')[-1].text_content().strip()
if re.search('\d', amount):
currency = Account.get_currency(amount)
amount = AmTr.decimal_amount(amount)
else:
continue
idtext = row.xpath('.//td[@class="detailsNoPrint"]//span[@class="accessAid"]')[0] \
.text_content().replace(u'\xa0', u' ').strip().rpartition(' ')[-1]
trans = Transaction(idtext)
trans.amount = amount
trans._currency = currency
datetext = row.xpath('.//td[@class="dateInfo"]')[0].text_content().strip()
for i in range(0, 12):
datetext = datetext.replace(months[i], emonths[i])
date = dateutil.parser.parse(datetext)
trans.date = date
trans.rdate = date
trans.label = to_unicode(row.xpath('.//td[@class="emailInfo"]')[0].text_content().strip())
info = to_unicode(row.xpath('.//td[@class="paymentTypeInfo"]')[0].text_content().strip())
trans.raw = info + u' ' + trans.label
if u'Authorization' in info or u'Autorisation' in info or \
u'Order' in info:
continue
if u'Credit Card' in trans.label or u'Carte bancaire' in trans.label:
trans.type = Transaction.TYPE_CARD
elif info.startswith(u'Payment') or info.startswith(u'Paiement'):
trans.type = Transaction.TYPE_ORDER
elif u'Currency Conversion' in info or u'Conversion de devise' in info:
trans.type = Transaction.TYPE_BANK
else:
trans.type = Transaction.TYPE_UNKNOWN
yield trans
示例13: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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
示例14: iter_history_recent
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
def iter_history_recent(self, account):
self.start()
if account.id != self._account_id():
raise AccountNotFound()
self._account_link().click()
self.wait_ajax()
for span in self.find('span.cM-maximizeButton'):
span.click()
for tr in self.find('tr.payments,tr.purchase'):
trdata = lambda n: tr.find_element_by_css_selector(
'td.cT-bodyTableColumn%i span.cT-line1' % n).text
treid = tr.get_attribute('id').replace('rowID', 'rowIDExt')
tredata = {}
for tre in self.find('tr#%s' % treid):
labels = [x.text for x in tre.find_elements_by_css_selector(
'div.cT-labelItem')]
values = [x.text for x in tre.find_elements_by_css_selector(
'div.cT-valueItem')]
tredata = dict(zip(labels, values))
ref = tredata.get(u'Reference Number:', u'')
tdate = trdata(1)
pdate = tredata.get(u'Posted Date :', tdate)
desc = clean_label(trdata(2))
amount = trdata(4)
tdate = datetime.datetime.strptime(tdate, '%m-%d-%Y')
pdate = datetime.datetime.strptime(pdate, '%m-%d-%Y')
if amount.startswith(u'(') and amount.endswith(u')'):
amount = AmTr.decimal_amount(amount[1:-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
self.finish()
示例15: get_history
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import rdate [as 別名]
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