Commit 726ef282 authored by Nicolas Delaby's avatar Nicolas Delaby

Enhance Purchase Order PrintOut with new Tax Module

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20552 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fceafecc
......@@ -108,24 +108,16 @@ def getVatId(vat_id):\n
s += \'%s: %s\' % (T_(\'VAT ID\'), vat_id)\n
return s\n
\n
def getLineVat(line):\n
vat = 0.0\n
s_m_list = line.getOrderRelatedValueList()\n
for s_m in s_m_list:\n
a_r_list = [x for x in s_m.objectValues() if x.getSpecialiseValue().getPortalType() == \'Invoicing Rule\']\n
if a_r_list:\n
a_r = a_r_list[0]\n
inv_s_m_list = a_r.objectValues()\n
if inv_s_m_list:\n
inv_s_m = inv_s_m_list[0]\n
acc_a_r_list = [x for x in inv_s_m.objectValues() if x.getSpecialiseValue().getPortalType() == \'Invoice Transaction Rule\']\n
if acc_a_r_list:\n
acc_a_r = acc_a_r_list[0]\n
acc_s_m_list = [x for x in acc_a_r.objectValues() if \'vat\' in x.getDestinationValue().getAccountType()]\n
if acc_s_m_list:\n
acc_s_m = acc_s_m_list[0]\n
vat += acc_s_m.getQuantity(0.0)\n
return vat\n
preferred_date_order = context.getPortalObject().portal_preferences.getPreferredDateOrder() or \'ymd\'\n
separator = \'/\'\n
def getOrderedDate(date):\n
if date is None:\n
return \'\'\n
pattern = separator.join(list(preferred_date_order))\n
pattern = pattern.replace(\'y\', \'%Y\')\n
pattern = pattern.replace(\'m\', \'%m\')\n
pattern = pattern.replace(\'d\', \'%d\')\n
return date.strftime(pattern)\n
\n
def getSourceReference(line):\n
category_list = line.getAcquiredCategoryList()\n
......@@ -154,6 +146,8 @@ def getSubLineList(obj):\n
sub_list = []\n
for x in obj.searchFolder(portal_type=context.getPortalOrderMovementTypeList(),\n
sort_on=[(\'int_index\', \'ascending\'), (\'reference\', \'ascending\')]):\n
if x.getPortalType() in obj.getPortalTaxMovementTypeList():\n
continue\n
sub_list.append(x)\n
sub_list.extend(getSubLineList(x))\n
return sub_list\n
......@@ -188,12 +182,11 @@ for line in getSubLineList(context):\n
\'description\': desc,\n
\'total_quantity\': line.getTotalQuantity() or \'\',\n
\'quantity_unit\': line.getQuantityUnitTitle() or (line.getResource() and line.getResourceValue().getQuantityUnitTitle()) or \'\',\n
\'stop_date\': line.getStopDate() or \'\',\n
\'stop_date\': getOrderedDate(line.getStopDate()) or \'\',\n
\'base_price\': line.getPrice() or \'\',\n
\'total_price\': line.getTotalPrice() or \'\',\n
}\n
total_price += line.getTotalPrice() or 0.0\n
total_vat += getLineVat(line)\n
line_list.append(line_dict.copy())\n
\n
data_dict = {\n
......@@ -219,6 +212,7 @@ data_dict = {\n
\'destination_email\': getEmail(context.getDestination() and context.getDestinationValue().getEmailText() or \'\'),\n
\n
\'destination_section_title\': unicode(context.getDestinationSectionTitle() or \'\', \'utf8\'),\n
\'destination_section_image_path\': context.getDestinationSectionValue().getDefaultImagePath(),\n
\'destination_section_address\': unicode(getOneLineAddress(\n
context.getDestinationSection() and context.getDestinationSectionValue().getDefaultAddressText() or \'\',\n
context.getDestinationSection() and context.getDestinationSectionValue().getDefaultAddressRegionTitle() or \'\'), \'utf8\'),\n
......@@ -234,14 +228,14 @@ data_dict = {\n
\'destination_decision_email\': getEmail(context.getDestinationDecision() and context.getDestinationDecisionValue().getEmailText() or \'\'),\n
\n
\'reference\': context.getReference() or \'\',\n
\'start_date\': context.getStartDate() or \'\',\n
\'start_date\': getOrderedDate(context.getStartDate()) or \'\',\n
\'currency\': context.getPriceCurrencyReference() or \'\',\n
\'payment_condition\': getPaymentConditionText(context),\n
\'delivery_mode\': context.getDeliveryModeTitle() or \'\',\n
\'incoterm\': context.getIncoterm() and context.getIncotermValue().getCodification() or \'\',\n
\n
\'total_price_novat\': total_price,\n
\'total_vat\': total_vat,\n
\'vat_list\': context.searchFolder(portal_type=context.getPortalTaxMovementTypeList(), order_by=\'title\'),\n
\'total_price_vat\': total_price + total_vat,\n
\'description\': getFieldAsString(context.getDescription()),\n
\n
......@@ -306,7 +300,9 @@ return data_dict\n
<string>getPhoneAndFax</string>
<string>getEmail</string>
<string>getVatId</string>
<string>getLineVat</string>
<string>preferred_date_order</string>
<string>separator</string>
<string>getOrderedDate</string>
<string>getSourceReference</string>
<string>getPaymentConditionText</string>
<string>line_list</string>
......
......@@ -204,6 +204,9 @@ AAA=</string> </value>
<style:style style:family=\'table-row\' style:name=\'Tableau3.2\'>\n
<style:table-row-properties style:row-height=\'0.75cm\'/>\n
</style:style>\n
<style:style style:family=\'table-row\' style:name=\'Tableau3.3\'>\n
<style:table-row-properties style:row-height=\'2cm\'/>\n
</style:style>\n
<style:style style:family=\'table-cell\' style:name=\'Tableau3.A2\'>\n
<style:table-cell-properties style:vertical-align=\'middle\' fo:padding=\'0cm\' fo:border=\'none\'/>\n
</style:style>\n
......@@ -293,7 +296,7 @@ AAA=</string> </value>
<table:table-cell table:style-name=\'Tableau2.A1\' office:value-type=\'string\'>\n
<div tal:omit-tag=\'\' tal:define=\'orig_string string:Supplier; en_string python:here.Base_translateString(orig_string, lang="en"); my_string python:here.Base_translateString(orig_string)\'>\n
<text:p text:style-name=\'Table_20_Heading\'>\n
<text:variable-set text:formula=\'ooow:title\' text:name=\'ds_title\' text:display=\'none\' office:string-value=\'title\' office:value-type=\'string\' tal:attributes=\'office:string-value python:data_dict["destination_section_title"]\'/>\n
<text:variable-set text:formula=\'ooow:title\' text:name=\'ds_title\' text:display=\'none\' office:value-type=\'string\' tal:attributes=\'office:string-value python:data_dict["destination_section_title"]\'/>\n
<text:variable-set text:formula=\'ooow:address\' text:name=\'ds_address\' text:display=\'none\' office:string-value=\'address\' office:value-type=\'string\' tal:attributes=\'office:string-value python:data_dict["destination_section_address"]\'/>\n
<text:variable-set text:formula=\'ooow:telfax\' text:name=\'ds_telfax\' text:display=\'none\' office:string-value=\'telfax\' office:value-type=\'string\' tal:attributes=\'office:string-value python:data_dict["destination_section_telfax"]\'/>\n
<text:variable-set text:formula=\'ooow:email\' text:name=\'ds_email\' text:display=\'none\' office:string-value=\'email\' office:value-type=\'string\' tal:attributes=\'office:string-value python:data_dict["destination_section_email"]\'/>\n
......@@ -473,33 +476,50 @@ AAA=</string> </value>
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["index"]\' tal:attributes=\'text:style-name left_style_name\'>1</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["source_reference"]\' tal:attributes=\'text:style-name style_name\'>source_ref</text:p>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["source_reference"]\'\n
tal:attributes=\'text:style-name style_name\'>source_ref</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["reference"]\' tal:attributes=\'text:style-name style_name\'>ref</text:p>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["reference"]\'\n
tal:attributes=\'text:style-name style_name\'>ref</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["description"]\' tal:attributes=\'text:style-name left_style_name\'>desc</text:p>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["description"]\'\n
tal:attributes=\'text:style-name left_style_name\'>desc</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["total_quantity"]\' tal:attributes=\'text:style-name right_style_name\'>qty</text:p>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'float\'>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["total_quantity"]\'\n
tal:attributes=\'text:style-name right_style_name\'>qty</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["quantity_unit"]\' tal:attributes=\'text:style-name style_name\'>qty_u</text:p>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["quantity_unit"]\'\n
tal:attributes=\'text:style-name style_name\'>qty_u</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["stop_date"]\' tal:attributes=\'text:style-name style_name\'>stop_date</text:p>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["stop_date"]\'\n
tal:attributes=\'text:style-name style_name\'>stop_date</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["base_price"]\' tal:attributes=\'text:style-name right_style_name\'>base_price</text:p>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'float\'>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["base_price"]\'\n
tal:attributes=\'text:style-name right_style_name\'>base_price</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\' tal:content=\'python:line_dict["total_price"]\' tal:attributes=\'text:style-name right_style_name\'>total_price</text:p>\n
<table:table-cell table:style-name=\'Tableau1.A3\' office:value-type=\'float\'>\n
<text:p text:style-name=\'Table_20_Contents\'\n
tal:content=\'python:line_dict["total_price"]\'\n
tal:attributes=\'text:style-name right_style_name\'>total_price</text:p>\n
</table:table-cell>\n
</div>\n
</table:table-row>\n
<table:table-row table:style-name=\'Tableau1.5\'>\n
<table:table-cell table:style-name=\'Tableau1.A5\' table:number-columns-spanned=\'9\' office:value-type=\'string\'>\n
<table:table-cell table:style-name=\'Tableau1.A5\'\n
table:number-columns-spanned=\'9\' office:value-type=\'string\'>\n
<table:table table:style-name=\'Tableau3\' table:name=\'Tableau3\'>\n
<table:table-column table:style-name=\'Tableau3.A\'/>\n
<table:table-column table:style-name=\'Tableau3.B\'/>\n
......@@ -537,11 +557,11 @@ AAA=</string> </value>
<text:p text:style-name=\'Table_20_Heading\'><span tal:replace=\'en_string\'/>:</text:p>\n
<text:p text:style-name=\'Table_20_Heading\' tal:condition=\'python:my_string!=en_string\'><span tal:replace=\'my_string\'/>:</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.E2\' office:value-type=\'string\'>\n
<table:table-cell table:style-name=\'Tableau3.E2\' office:value-type=\'float\'>\n
<text:p text:style-name=\'Table_20_Contents_20_Right\' tal:content=\'python:data_dict["total_price_novat"]\'>800.000,00</text:p>\n
</table:table-cell>\n
</table:table-row>\n
<table:table-row table:style-name=\'Tableau3.2\'>\n
<table:table-row table:style-name=\'Tableau3.3\'>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
......@@ -551,13 +571,31 @@ AAA=</string> </value>
<table:table-cell table:style-name=\'Tableau3.A1\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents\'/>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.D3\' office:value-type=\'string\' tal:define=\'orig_string string:VAT; en_string python:here.Base_translateString(orig_string, lang="en"); my_string python:here.Base_translateString(orig_string)\'>\n
<text:p text:style-name=\'Table_20_Heading\'><span tal:replace=\'en_string\'/>:</text:p>\n
<text:p text:style-name=\'Table_20_Heading\' tal:condition=\'python:my_string!=en_string\'><span tal:replace=\'my_string\'/>:</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.E3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents_20_Right\' tal:content=\'python:data_dict["total_vat"]\'>2000</text:p>\n
</table:table-cell>\n
<tal:block tal:define="global total_vat_list python: []">\n
<table:table-cell table:style-name=\'Tableau3.D3\'\n
office:value-type=\'string\'>\n
<tal:block tal:repeat="vat python: data_dict[\'vat_list\']">\n
<tal:block tal:define="orig_string python:vat.getResourceTitle(); en_string python:here.Base_translateString(orig_string, lang=\'en\'); my_string python:here.Base_translateString(orig_string)">\n
<text:p text:style-name=\'Table_20_Heading\'><span tal:replace=\'en_string\'/>:</text:p>\n
<text:p text:style-name=\'Table_20_Heading\'\n
tal:condition=\'python:my_string != en_string\'><span tal:replace=\'my_string\'/>:</text:p>\n
</tal:block>\n
</tal:block>\n
<text:p text:style-name=\'Table_20_Heading\'\n
tal:define="orig_string string:TAX; en_string python:here.Base_translateString(orig_string, lang=\'en\'); my_string python:here.Base_translateString(orig_string)"><span tal:replace="python: \'Total %s\' % (my_string)"/>:</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.E3\'\n
office:value-type=\'float\'\n
tal:attributes="office:value python: sum(total_vat_list)">\n
<tal:block tal:repeat="vat python: data_dict[\'vat_list\']">\n
<text:p tal:define="vat_price python: vat.getPrice() * vat.getQuantity(); any python: total_vat_list.append(vat_price)"\n
text:style-name=\'Table_20_Contents_20_Right\'\n
tal:content="vat_price">2000</text:p>\n
</tal:block>\n
<text:p text:style-name=\'Table_20_Contents_20_Right\'\n
tal:content="python: sum(total_vat_list)">2000</text:p>\n
</table:table-cell>\n
</tal:block>\n
</table:table-row>\n
<table:table-row table:style-name=\'Tableau3.2\'>\n
<table:table-cell table:style-name=\'Tableau3.A2\' office:value-type=\'string\'>\n
......@@ -573,8 +611,9 @@ AAA=</string> </value>
<text:p text:style-name=\'Table_20_Heading\'><span tal:replace=\'en_string\'/>:</text:p>\n
<text:p text:style-name=\'Table_20_Heading\' tal:condition=\'python:my_string!=en_string\'><span tal:replace=\'my_string\'/>:</text:p>\n
</table:table-cell>\n
<table:table-cell table:style-name=\'Tableau3.E3\' office:value-type=\'string\'>\n
<text:p text:style-name=\'Table_20_Contents_20_Right\' tal:content=\'python:data_dict["total_price_vat"]\'>12345</text:p>\n
<table:table-cell table:style-name=\'Tableau3.E3\' office:value-type=\'float\' tal:attributes="office:value python:data_dict[\'total_price_novat\'] + sum(total_vat_list)">\n
<text:p text:style-name=\'Table_20_Contents_20_Right\'\n
tal:content=\'python:data_dict["total_price_novat"] + sum(total_vat_list)\'>12345</text:p>\n
</table:table-cell>\n
</table:table-row>\n
<table:table-row table:style-name=\'Tableau3.1\'>\n
......
275
\ No newline at end of file
279
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment