Amazon module: skip 'Not yet shipped' orders. Fixes #1699
This commit is contained in:
parent
70cf2db1ea
commit
f2ea735c78
1 changed files with 26 additions and 31 deletions
|
|
@ -75,19 +75,22 @@ class HistoryPage(AmazonPage):
|
|||
) if x.startswith('year-')]
|
||||
|
||||
|
||||
class OrderNewPage(AmazonPage):
|
||||
is_here = u'//*[contains(text(),"Ordered on")]'
|
||||
|
||||
def order(self):
|
||||
class OrderPage(AmazonPage):
|
||||
def shouldSkip(self):
|
||||
# Reports only fully shipped and delivered orders, because they have
|
||||
# finalized payment amounts.
|
||||
# Payment for not yet shipped orders may change, and is not always
|
||||
# available.
|
||||
for s in [u'Not Yet Shipped', u'Preparing for Shipment',
|
||||
u'Shipping now', u'In transit']:
|
||||
if self.doc.xpath(u'//*[contains(text(),"%s")]' % s):
|
||||
return None
|
||||
return bool([x for s in [u'Not Yet Shipped', u'Not yet shipped',
|
||||
u'Preparing for Shipment', u'Shipping now', u'In transit']
|
||||
for x in self.doc.xpath(u'//*[contains(text(),"%s")]' % s)])
|
||||
|
||||
|
||||
class OrderNewPage(OrderPage):
|
||||
is_here = u'//*[contains(text(),"Ordered on")]'
|
||||
|
||||
def order(self):
|
||||
if not self.shouldSkip():
|
||||
order = Order(id=self.order_number())
|
||||
order.date = self.order_date()
|
||||
order.tax = self.tax()
|
||||
|
|
@ -207,19 +210,11 @@ class OrderNewPage(AmazonPage):
|
|||
yield itm
|
||||
|
||||
|
||||
class OrderOldPage(AmazonPage):
|
||||
class OrderOldPage(OrderPage):
|
||||
is_here = u'//*[contains(text(),"Amazon.com order number")]'
|
||||
|
||||
def order(self):
|
||||
# Reports only fully shipped and delivered orders, because they have
|
||||
# finalized payment amounts.
|
||||
# Payment for not yet shipped orders may change, and are not always
|
||||
# available.
|
||||
for s in [u'Not Yet Shipped', u'Preparing for Shipment',
|
||||
u'Shipping now']:
|
||||
if self.doc.xpath(u'//b[contains(text(),"%s")]' % s):
|
||||
return None
|
||||
|
||||
if not self.shouldSkip():
|
||||
order = Order(id=self.order_number())
|
||||
order.date = self.order_date()
|
||||
order.tax = self.tax()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue