From bed82c6a295ef6a5dc687326c458b189ed416af5 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Tue, 2 Dec 2014 17:44:51 +0100 Subject: [PATCH] Catch cases where record['discount_amount'] = None --- magentoerpconnect/sale.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/magentoerpconnect/sale.py b/magentoerpconnect/sale.py index 8e3d385d9..5737c514f 100644 --- a/magentoerpconnect/sale.py +++ b/magentoerpconnect/sale.py @@ -992,10 +992,14 @@ class SaleOrderLineImportMapper(ImportMapper): @mapping def discount_amount(self, record): - discount_value = float(record.get('discount_amount', 0)) - if self.backend_record.catalog_price_tax_included: + discount_value = 0.0 + row_total = 0.0 + if record.get('discount_amount'): + discount_value = float(record.get('discount_amount', 0)) + if self.backend_record.catalog_price_tax_included and \ + record.get('row_total_incl_tax'): row_total = float(record.get('row_total_incl_tax', 0)) - else: + elif record.get('row_total'): row_total = float(record.get('row_total', 0)) discount = 0 if discount_value > 0 and row_total > 0: