From 687a0bd93382a153595fb306ec2b66414a956efc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 6 Mar 2008 15:23:23 +0000
Subject: [PATCH] 2008-03-06 jerome * API change:
 PaySheetTransaction_getMovementList was returning the total price as
 "xxx_quantity" on brains. It now returns quantity, price and total_price
 respectivly.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19735 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ySheetTransaction_getListBoxColumnList.xml |  2 +-
 .../PaySheetTransaction_getMovementList.xml   | 24 +++++++++++--------
 .../PaySheetTransaction_view/listbox.xml      | 16 ++++++-------
 ...=> listbox_employee_share_total_price.xml} |  2 +-
 ...=> listbox_employer_share_total_price.xml} |  2 +-
 bt5/erp5_payroll/bt/change_log                |  3 +++
 bt5/erp5_payroll/bt/revision                  |  2 +-
 7 files changed, 29 insertions(+), 22 deletions(-)
 rename bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/{listbox_employee_share_quantity.xml => listbox_employee_share_total_price.xml} (97%)
 rename bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/{listbox_employer_share_quantity.xml => listbox_employer_share_total_price.xml} (97%)

diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getListBoxColumnList.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getListBoxColumnList.xml
index fd96465e37..219eed127a 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getListBoxColumnList.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getListBoxColumnList.xml
@@ -92,7 +92,7 @@ else:\n
 for model_line in context.contentValues(portal_type=\'Pay Sheet Line\'):\n
   for tax_category in model_line.getTaxCategoryValueList():\n
     price = (tax_category.getId()+\'_price\', tax_category.getTitle()+\' Rate\')\n
-    quantity = (tax_category.getId()+\'_quantity\', \n
+    quantity = (tax_category.getId()+\'_total_price\', \n
                 tax_category.getTitle()+\' Amount\')\n
     if price not in column_list:\n
       column_list.append(price)\n
diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.xml
index 1e43899b99..c6a188d48e 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getMovementList.xml
@@ -93,8 +93,11 @@ for paysheet_line in paysheet_line_list:\n
   base_application_list = paysheet_line.getBaseAmountTitleList()\n
   translated_base_application_list = [str(N_(x)) for x in base_application_list]\n
   base_application_list = \', \'.join(translated_base_application_list)\n
-  payroll_service = paysheet_line.getResourceValue()\n
-  base_participation_list = payroll_service.getBaseAmountList()\n
+  payroll_service = paysheet_line.getResourceValue(portal_type=\'Payroll Service\')\n
+  if payroll_service is not None:\n
+    base_participation_list = payroll_service.getBaseAmountList()\n
+  else:\n
+    base_participation_list = []\n
   causality = paysheet_line.getCausality()\n
 \n
   base_list = [str(N_(base_application)) for base_application in \\\n
@@ -112,6 +115,10 @@ for paysheet_line in paysheet_line_list:\n
   indice = 0\n
 \n
   object_dict = {}\n
+  if cartesian_product == [[]] or cartesian_product == []:\n
+    line_list.append(paysheet_line)\n
+    continue\n
+\n
   for tuple in cartesian_product:\n
     indice += 1\n
     share_dict = {}\n
@@ -122,10 +129,10 @@ for paysheet_line in paysheet_line_list:\n
     quantity = cell.getQuantity()\n
     base = quantity\n
 \n
-    price = cell.getPrice()\n
-    share_dict[cell.getTaxCategory()+\'_price\'] = price\n
-    share_dict[cell.getTaxCategory()+\'_quantity\'] = round(quantity*price,\n
-        precision)\n
+    share_dict[cell.getTaxCategory()+\'_price\'] = cell.getPrice()\n
+    share_dict[cell.getTaxCategory()+\'_quantity\'] = cell.getQuantity()\n
+    share_dict[cell.getTaxCategory()+\'_total_price\'] = \\\n
+                    round(cell.getTotalPrice(), precision)\n
 \n
     tuple_dict = {}\n
     for item in tuple:\n
@@ -163,10 +170,8 @@ for paysheet_line in paysheet_line_list:\n
     line_list.append(paysheet_line.asContext(**object_dict[\'no_slice\']))\n
 \n
 \n
-#return printed\n
 \n
 # sort results\n
-\n
 def sortByTitleAscending(x, y):\n
   return cmp(x.getTitle(), y.getTitle())\n
 \n
@@ -264,6 +269,7 @@ return line_list\n
                             <string>str</string>
                             <string>translated_base_application_list</string>
                             <string>payroll_service</string>
+                            <string>None</string>
                             <string>base_participation_list</string>
                             <string>causality</string>
                             <string>base_application</string>
@@ -273,7 +279,6 @@ return line_list\n
                             <string>base_category</string>
                             <string>list</string>
                             <string>cartesian_product</string>
-                            <string>None</string>
                             <string>previous_share</string>
                             <string>indice</string>
                             <string>object_dict</string>
@@ -284,7 +289,6 @@ return line_list\n
                             <string>cell</string>
                             <string>quantity</string>
                             <string>base</string>
-                            <string>price</string>
                             <string>_write_</string>
                             <string>round</string>
                             <string>tuple_dict</string>
diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox.xml
index 9de52f1b70..3563084787 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox.xml
@@ -63,17 +63,17 @@
             <value>
               <dictionary>
                 <item>
-                    <key>                 <string>all_columns</string> </key>
+                    <key> <string>all_columns</string> </key>
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>columns</string> </key>
+                    <key> <string>columns</string> </key>
                     <value>
                       <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
                     </value>
                 </item>
                 <item>
-                    <key>                 <string>editable_columns</string> </key>
+                    <key> <string>editable_columns</string> </key>
                     <value>
                       <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
                     </value>
@@ -87,19 +87,19 @@
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>list_method</string> </key>
+                    <key> <string>list_method</string> </key>
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>portal_types</string> </key>
+                    <key> <string>portal_types</string> </key>
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>selection_name</string> </key>
+                    <key> <string>selection_name</string> </key>
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>sort</string> </key>
+                    <key> <string>sort</string> </key>
                     <value> <string></string> </value>
                 </item>
                 <item>
@@ -107,7 +107,7 @@
                     <value> <string></string> </value>
                 </item>
                 <item>
-                    <key>                 <string>title</string> </key>
+                    <key> <string>title</string> </key>
                     <value> <string></string> </value>
                 </item>
               </dictionary>
diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_quantity.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_total_price.xml
similarity index 97%
rename from bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_quantity.xml
rename to bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_total_price.xml
index 1ecc017d08..3e8c840625 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_quantity.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employee_share_total_price.xml
@@ -19,7 +19,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>listbox_employee_share_quantity</string> </value>
+            <value> <string>listbox_employee_share_total_price</string> </value>
         </item>
         <item>
             <key> <string>message_values</string> </key>
diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_quantity.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_total_price.xml
similarity index 97%
rename from bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_quantity.xml
rename to bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_total_price.xml
index bc4b967a91..64b8db0300 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_quantity.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_view/listbox_employer_share_total_price.xml
@@ -19,7 +19,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>listbox_employer_share_quantity</string> </value>
+            <value> <string>listbox_employer_share_total_price</string> </value>
         </item>
         <item>
             <key> <string>message_values</string> </key>
diff --git a/bt5/erp5_payroll/bt/change_log b/bt5/erp5_payroll/bt/change_log
index 6fbbde4cf0..4b4235d70d 100644
--- a/bt5/erp5_payroll/bt/change_log
+++ b/bt5/erp5_payroll/bt/change_log
@@ -1,3 +1,6 @@
+2008-03-06 jerome
+* API change: PaySheetTransaction_getMovementList was returning the total price as "xxx_quantity" on brains. It now returns quantity, price and total_price respectivly.
+
 2008-02-14 fabien
 * correct some script : context was used instead paysheet, so results were wrong
 
diff --git a/bt5/erp5_payroll/bt/revision b/bt5/erp5_payroll/bt/revision
index b7c52fb181..cc4f7f3feb 100644
--- a/bt5/erp5_payroll/bt/revision
+++ b/bt5/erp5_payroll/bt/revision
@@ -1 +1 @@
-212
\ No newline at end of file
+218
\ No newline at end of file
-- 
2.30.9