Generate payment transaction if there aren't any. Part of #1684
This commit is contained in:
parent
c7a4da7f6e
commit
df53b12d4f
1 changed files with 24 additions and 2 deletions
|
|
@ -113,8 +113,30 @@ class OrderNewPage(AmazonPage):
|
||||||
pmt.method = u'GIFT CARD'
|
pmt.method = u'GIFT CARD'
|
||||||
pmt.amount = -self.gift()
|
pmt.amount = -self.gift()
|
||||||
yield pmt
|
yield pmt
|
||||||
for trans in self.transactions():
|
transactions = list(self.transactions())
|
||||||
yield trans
|
if transactions:
|
||||||
|
for t in transactions:
|
||||||
|
yield t
|
||||||
|
else:
|
||||||
|
for method in self.paymethods():
|
||||||
|
pmt = Payment()
|
||||||
|
pmt.date = self.order_date()
|
||||||
|
pmt.method = method
|
||||||
|
pmt.amount = self.grand_total()
|
||||||
|
yield pmt
|
||||||
|
break
|
||||||
|
|
||||||
|
def paymethods(self):
|
||||||
|
for root in self.doc.xpath('//h5[contains(text(),"Payment Method")]'):
|
||||||
|
alt = root.xpath('../div/img/@alt')[0]
|
||||||
|
span = root.xpath('../div/span/text()')[0]
|
||||||
|
digits = re.match(r'[^0-9]*([0-9]+)[^0-9]*', span).group(1)
|
||||||
|
yield u'%s %s' % (alt, digits)
|
||||||
|
|
||||||
|
def grand_total(self):
|
||||||
|
return AmTr.decimal_amount(self.doc.xpath(
|
||||||
|
u'//span[contains(text(),"Grand Total:")]/..'
|
||||||
|
u'/following-sibling::div[1]/span/text()')[0].strip())
|
||||||
|
|
||||||
def date_num(self):
|
def date_num(self):
|
||||||
return u' '.join(self.doc.xpath(
|
return u' '.join(self.doc.xpath(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue