From 71aecae8e176fef4d7d1832f4bdb59a0810c440d Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Fri, 9 Jun 2006 12:15:46 +0000
Subject: [PATCH] Delete empty accounting lines in roundDebitCredit script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7660 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../AccountingTransaction_roundDebitCredit.xml     | 14 ++++++++++++--
 bt5/erp5_accounting/bt/change_log                  |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

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 f555df6e91..d13f5e8239 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
@@ -14,7 +14,9 @@
       <dictionary>
         <item>
             <key> <string>Python_magic</string> </key>
-            <value> <string encoding="base64">O/INCg==</string> </value>
+            <value>
+              <none/>
+            </value>
         </item>
         <item>
             <key> <string>Script_magic</string> </key>
@@ -81,8 +83,15 @@ net_balance    = 0.0\n
 debit_balance  = 0.0\n
 credit_balance = 0.0\n
 \n
-for line in context.getMovementList(portal_type=context.getPortalAccountingMovementTypeList()):\n
+line_list = context.getMovementList(portal_type=context.getPortalAccountingMovementTypeList())\n
+\n
+for line in line_list:\n
   line_quantity = r_(line.getQuantity())\n
+  # Auto remove empty lines\n
+  if line_quantity == 0.0: \n
+    context.deleteContent(line.getId())\n
+    # Proceed to next line\n
+    continue\n
   line.setQuantity(line_quantity)  \n
   if line.getSourceDebit() > 0:\n
     line.setSourceDebit(r_(line.getSourceDebit()))\n
@@ -154,6 +163,7 @@ if abs(net_balance) > 0 or \\\n
                             <string>net_balance</string>
                             <string>debit_balance</string>
                             <string>credit_balance</string>
+                            <string>line_list</string>
                             <string>_getiter_</string>
                             <string>line_quantity</string>
                             <string>abs</string>
diff --git a/bt5/erp5_accounting/bt/change_log b/bt5/erp5_accounting/bt/change_log
index 734fb1c77a..5a02cea1d2 100644
--- a/bt5/erp5_accounting/bt/change_log
+++ b/bt5/erp5_accounting/bt/change_log
@@ -1,3 +1,6 @@
+2006-06-09 Kevin
+* Delete empty accounting lines in roundDebitCredit script.
+
 2006-06-08 Kevin
 * Don't create empty lines when the closing balance is generated.
 * Add direct link to the wrong transaction object when closing the accounting period.
-- 
2.30.9