From 9b24f552667e4ad577c50a047b6f711ff57cb6ef Mon Sep 17 00:00:00 2001 From: Oleg Plakhotniuk Date: Sat, 30 May 2015 15:46:46 -0500 Subject: [PATCH] [vicsec] Handle new numbers notation. Closes #1956 --- modules/vicsec/browser.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/vicsec/browser.py b/modules/vicsec/browser.py index a5204348..d68a500b 100644 --- a/modules/vicsec/browser.py +++ b/modules/vicsec/browser.py @@ -85,11 +85,13 @@ class OrderPage(VicSecPage): for tr in self.doc.xpath('//tbody[@class="payment-summary"]' '//th[text()="Payment Summary"]/../../../tbody/tr'): method = tr.xpath('td[1]/text()')[0] - amount = tr.xpath('td[2]')[0].text_content().strip() + amnode = tr.xpath('td[2]')[0] + amsign = -1 if amnode.xpath('em') else 1 + amount = amnode.text_content().strip() pmt = Payment() pmt.date = self.order_date() pmt.method = unicode(method) - pmt.amount = AmTr.decimal_amount(amount) + pmt.amount = amsign * AmTr.decimal_amount(amount) yield pmt def items(self): @@ -137,10 +139,13 @@ class OrderPage(VicSecPage): return dcnt + subt + rett - items def payment_part(self, which): + # The numbers notation on VS is super wierd. + # Sometimes negative amounts are represented by element. for node in self.doc.xpath('//tbody[@class="payment-summary"]' '//td[contains(text(),"%s")]/../td[2]' % which): - x = node.text_content().strip() - return Decimal(0) if x == u'FREE' else AmTr.decimal_amount(x) + strv = node.text_content().strip() + v = Decimal(0) if strv == u'FREE' else AmTr.decimal_amount(strv) + return -v if node.xpath('em') and v > 0 else v return Decimal(0)