From 84f100eaae8b3dfee4cd3b30fa0310faacea5fc3 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
Date: Fri, 12 Jun 2015 18:22:58 +0900
Subject: [PATCH] erp5_accounting: Rounding debit/credit only makes sense if
 there is SIT Line.

---
 .../AccountingTransaction_roundDebitCredit.xml             | 7 +++++++
 bt5/erp5_accounting/bt/change_log                          | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_roundDebitCredit.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_roundDebitCredit.xml
index db0e33c28f..6e4bc78c37 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_roundDebitCredit.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_roundDebitCredit.xml
@@ -78,6 +78,13 @@ for line in line_list:\n
   line.setQuantity(line_quantity)\n
   total_quantity += line_quantity\n
 \n
+# If no "line" found (eg no SIT line), then do nothing. This is in the case where a SIT\n
+# has only Invoice Line and no SIT Line. Otherwise account_type_dict will be empty =>\n
+# asset_line = None => the assert below will fail because getTotalPrice() will returns the\n
+# price of all Invoice Lines...\n
+if not line_list:\n
+  return\n
+\n
 abs_total_quantity = abs(round(total_quantity, precision))\n
 # The total quantity should be zero with a little error, if simulation has been\n
 # completely applied, because the debit and the credit must be balanced. However,\n
diff --git a/bt5/erp5_accounting/bt/change_log b/bt5/erp5_accounting/bt/change_log
index dc4fc01334..da492e1b0f 100644
--- a/bt5/erp5_accounting/bt/change_log
+++ b/bt5/erp5_accounting/bt/change_log
@@ -1,3 +1,6 @@
+2015-06-12 arnaud.fontaine
+* Rounding debit/credit only makes sense if there is SIT Line.
+
 2014-08-21 Gabriel Monnerat
 * Improve Delivery_localBuild to call invoice_builder_alarm only if exist, because in some projects this alarm does not exist
 
-- 
2.30.9