From 4586d5994ee376909493f6405432c3e31584c206 Mon Sep 17 00:00:00 2001
From: Fabien Morin <fabien@nexedi.com>
Date: Thu, 15 Jan 2009 13:14:41 +0000
Subject: [PATCH] use base_application and base_contribution from model line
 instead of base_amount (from model line and from payroll service)

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

diff --git a/product/ERP5/Document/PaySheetTransaction.py b/product/ERP5/Document/PaySheetTransaction.py
index cda07f9486..823d40b982 100644
--- a/product/ERP5/Document/PaySheetTransaction.py
+++ b/product/ERP5/Document/PaySheetTransaction.py
@@ -300,7 +300,7 @@ class PaySheetTransaction(Invoice):
 
     '''
 
-    paysheet = self 
+    paysheet = self
     
     if not batch_mode and listbox is not None:
       model_line_dict = paysheet.getEditableModelLineAsDict(listbox=listbox,
@@ -319,12 +319,6 @@ class PaySheetTransaction(Invoice):
     def sortByIntIndex(a, b):
       return cmp(a.getIntIndex(), b.getIntIndex())
 
-
-    # XXX should this be recursive ? then should membership be strict
-    base_amount_list = paysheet.portal_categories['base_amount'].contentValues()
-    base_amount_list.sort(sortByIntIndex)
-
-
     # get model lines
     portal_type_list = ['Pay Sheet Model Line']
     sub_object_list = paysheet.getInheritedObjectValueList(portal_type_list)
@@ -350,9 +344,8 @@ class PaySheetTransaction(Invoice):
                                         model_line.getRelativeUrl())
       title = model_line.getTitleOrId()
       int_index = model_line.getFloatIndex()
-      base_amount_list = model_line.getBaseAmountList()
       resource = service.getRelativeUrl()
-      base_participation_list = service.getBaseAmountList()
+      base_contribution_list = model_line.getBaseContributionList()
       
       # get the service provider, either on the model line, or using the
       # annotation line reference.
@@ -484,22 +477,21 @@ class PaySheetTransaction(Invoice):
         if quantity and price:
           cell_list.append(cell_dict)
 
-          # update the base_participation
-          for base_participation in base_participation_list:
-            base_participation = 'base_amount/%s' % base_participation
+          # update the base_contribution
+          for base_contribution in base_contribution_list:
             if quantity:
-              if base_amount_dict.has_key(base_participation) and \
-                  base_amount_dict[base_participation].has_key(share):
-                old_val = base_amount_dict[base_participation][share]
+              if base_amount_dict.has_key(base_contribution) and \
+                  base_amount_dict[base_contribution].has_key(share):
+                old_val = base_amount_dict[base_contribution][share]
               else:
                 old_val = 0
               new_val = old_val + quantity
-              if not base_amount_dict.has_key(base_participation):
-                base_amount_dict[base_participation]={}
+              if not base_amount_dict.has_key(base_contribution):
+                base_amount_dict[base_contribution]={}
 
               if price:
                 new_val = round((old_val + quantity*price), precision)
-              base_amount_dict[base_participation][share] = new_val
+              base_amount_dict[base_contribution][share] = new_val
 
       if cell_list:
         # create the PaySheetLine
@@ -511,7 +503,7 @@ class PaySheetTransaction(Invoice):
                                             desc=desc,
                                             # TODO: this is base_contribution,
                                             # not base_amount
-                                            base_amount_list=base_participation_list,
+                                            base_amount_list=base_contribution_list,
                                             cell_list=cell_list,
                                             categories=categories)
         pay_sheet_line_list.append(pay_sheet_line)
-- 
2.30.9