本文整理匯總了Python中weboob.capabilities.bank.Transaction._gross方法的典型用法代碼示例。如果您正苦於以下問題:Python Transaction._gross方法的具體用法?Python Transaction._gross怎麽用?Python Transaction._gross使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weboob.capabilities.bank.Transaction
的用法示例。
在下文中一共展示了Transaction._gross方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import _gross [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
示例2: iter_transactions
# 需要導入模塊: from weboob.capabilities.bank import Transaction [as 別名]
# 或者: from weboob.capabilities.bank.Transaction import _gross [as 別名]
def iter_transactions(self, account):
csv = self.document
if len(csv.header) == 42 or len(csv.header) == 43:
# Merchant multi-currency account
# 42 is for when the user can't access the balance on the website
# 43 is for full acces to the account
DATE = 0
TIME = 1
NAME = 3
TYPE = 4
if csv.header[7] == "Devise":
CURRENCY = 7
GROSS = 8
FEE = 9
NET = 10
FROM = 11
TO = 12
TRANS_ID = 13
ITEM = 16
SITE = -1
else:
CURRENCY = 6
GROSS = 7
FEE = 8
NET = 9
FROM = 10
TO = 11
TRANS_ID = 12
ITEM = 15
SITE = 24
elif len(csv.header) == 11:
# Regular multi-currency account
DATE = 0
TIME = 1
NAME = 3
TYPE = 4
CURRENCY = 6
GROSS = -1
FEE = -1
NET = 7
FROM = -1
TO = -1
TRANS_ID = -1
ITEM = -1
SITE = -1
else:
raise ValueError('CSV fields count of %i is not supported' % len(csv.header))
for row in csv.rows:
# we filter transaction currceny to match account currency, except if we don't now the account currency
# we ignore canceled transactions
if (account.balance != NotAvailable and account.get_currency(row[CURRENCY]) != account.currency) or row[NET] == '...':
continue
# analog to dict.get()
get = lambda i, v=None: row[i] if 0 <= i < len(row) else v
trans = Transaction(get(TRANS_ID, u''))
# silly American locale
if re.search(r'\d\.\d\d$', row[NET]):
date = datetime.datetime.strptime(row[DATE] + ' ' + row[TIME], "%m/%d/%Y %H:%M:%S")
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 get(ITEM):
line += u' ' + row[ITEM]
if get(SITE):
line += u"(" + row[SITE] + u")"
trans.raw = line
trans.label = row[NAME]
if row[TYPE].startswith(u'Update to eCheck') or \
row[TYPE].startswith(u'Order'):
continue
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 = AmTr.decimal_amount(row[NET])
trans._gross = AmTr.decimal_amount(get(GROSS, row[NET]))
trans._fees = AmTr.decimal_amount(get(FEE, u'0.00'))
trans._to = get(TO)
trans._from = get(FROM)
yield trans