From 8c03b05cacb0615fdfefb9c04dd1847f1d84ec64 Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Tue, 27 Nov 2007 15:12:04 +0000
Subject: [PATCH] - change for imbrication order to update base participation
 only when changing slice. - remove an if condition wich was a mistake

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17825 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/PaySheetTransaction.py | 31 ++++++++++----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/product/ERP5/Document/PaySheetTransaction.py b/product/ERP5/Document/PaySheetTransaction.py
index c7647af49e..5ebb181347 100644
--- a/product/ERP5/Document/PaySheetTransaction.py
+++ b/product/ERP5/Document/PaySheetTransaction.py
@@ -322,8 +322,8 @@ class PaySheetTransaction(Invoice):
       variation_slice_list = model_line.getVariationCategoryList(\
                                       base_category_list=['salary_range',])
 
-      for share in variation_share_list:
-        for slice in variation_slice_list:
+      for slice in variation_slice_list:
+        for share in variation_share_list:
           cell = model_line.getCell(slice, share)
           if cell is None:
             LOG('createNotEditablePaySheetLineList : cell is None')
@@ -383,20 +383,19 @@ class PaySheetTransaction(Invoice):
                      }
           cell_list.append(new_cell)
 
-          # update base participation
-          base_participation_list = service.getBaseAmountList(base=1)
-          for base_participation in base_participation_list:
-            if quantity:
-              if base_amount_current_value_dict.has_key(base_participation):
-                old_val = base_amount_current_value_dict[base_participation]
-              else:
-                old_val = 0
-              new_val = old_val + quantity
-
-              if price:
-                if old_val != 0:
-                  new_val = round((old_val + quantity*price), precision) 
-              base_amount_current_value_dict[base_participation] = new_val
+        # update base participation
+        base_participation_list = service.getBaseAmountList(base=1)
+        for base_participation in base_participation_list:
+          if quantity:
+            if base_amount_current_value_dict.has_key(base_participation):
+              old_val = base_amount_current_value_dict[base_participation]
+            else:
+              old_val = 0
+            new_val = old_val + quantity
+
+            if price:
+              new_val = round((old_val + quantity*price), precision) 
+            base_amount_current_value_dict[base_participation] = new_val
 
       if cell_list:
         # create the PaySheetLine
-- 
2.30.9