Commit 00c48041 authored by Jérome Perrin's avatar Jérome Perrin

complete source/destination section independance


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5602 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 59711c9e
...@@ -93,7 +93,7 @@ transaction_simulation_state = request[\'transaction_simulation_state\']\n ...@@ -93,7 +93,7 @@ transaction_simulation_state = request[\'transaction_simulation_state\']\n
transaction_portal_type = request[\'transaction_portal_type\']\n transaction_portal_type = request[\'transaction_portal_type\']\n
from_date = request.get(\'from_date\', None)\n from_date = request.get(\'from_date\', None)\n
\n \n
N_ = context.Base_TranslateString\n N_ = context.Base_translateString\n
\n \n
params = {\n params = {\n
\'sort_on\' : \'delivery.start_date\',\n \'sort_on\' : \'delivery.start_date\',\n
...@@ -102,94 +102,123 @@ params = {\n ...@@ -102,94 +102,123 @@ params = {\n
\'section_category\' : transaction_section_category,\n \'section_category\' : transaction_section_category,\n
\'portal_type\': transaction_portal_type,\n \'portal_type\': transaction_portal_type,\n
}\n }\n
\n
if from_date:\n if from_date:\n
params[\'from_date\'] = from_date\n params[\'from_date\'] = from_date\n
\n \n
result=[]\n result=[]\n
journal_total_debit = 0\n journal_total_debit = 0\n
journal_total_credit = 0\n journal_total_credit = 0\n
\n
for transaction in context\\\n for transaction in context\\\n
.AccountingTransactionModule_zGetAccountingTransactionList(\n .AccountingTransactionModule_zGetAccountingTransactionList(\n
selection_params = params, selection=None, **params):\n selection_params = params, selection=None, **params):\n
transaction = transaction.getObject()\n transaction = transaction.getObject()\n
lines = []\n \n
transaction_dict={ \'date\' : context.Base_FormatDate(transaction.getStartDate()),\n destination_section = transaction.getDestinationSectionValue()\n
\'description\' : N_("${transaction_title} (Transaction Reference = ${transaction_source_reference},\\n Creation Date = ${creation_date} \\n Currency = ${currency_title})" ,\n we_are_destination = destination_section is not None and (\'group/%s\' %\n
mapping = { "transaction_title": unicode(transaction.getTitle() or \'\', \'utf8\'),\n destination_section.getGroup(\'\')).startswith(transaction_section_category)\n
"transaction_source_reference": unicode(transaction.getSourceReference() or \'\', \'utf8\'),\n source_section = transaction.getSourceSectionValue()\n
"creation_date" : context.Base_FormatDate(transaction.getCreationDate()),\n we_are_source = (source_section is not None) and (\'group/%s\' %\n
"currency_title" : transaction.getResourceTitle() or \'\'}),\n source_section.getGroup(\'\')).startswith(transaction_section_category)\n
\'lines\' : lines, }\n \n
if we_are_source :\n
specific_reference = transaction.getSourceReference()\n
date = transaction.getStartDate()\n
else :\n
specific_reference = transaction.getDestinationReference()\n
date = transaction.getStopDate()\n
\n \n
result.append(transaction_dict)\n lines = []\n
transaction_lines = transaction.contentValues(\n transaction_dict={\n
filter = {\'portal_type\' : context.getPortalAccountingMovementTypeList()})\n \'date\' : context.Base_FormatDate( date ),\n
\'description\' : N_("${transaction_title} (Transaction Reference "+\n
"= ${transaction_reference},\\n Creation Date = "+\n
"${creation_date} \\n Currency = ${currency_title})" ,\n
mapping = { "transaction_title": unicode(transaction.getTitle()\n
or \'\', \'utf8\'),\n
"transaction_reference": unicode(\n
specific_reference or \'\', \'utf8\'),\n
"creation_date" : context.Base_FormatDate(\n
transaction.getCreationDate()),\n
"currency_title" : transaction.getResourceTitle() or \'\'\n
}),\n
\'lines\' : lines, }\n
\n
result.append(transaction_dict)\n
transaction_lines = transaction.contentValues(\n
filter = {\'portal_type\' : context.getPortalAccountingMovementTypeList()})\n
\n \n
transaction_lines.sort(lambda x,y: cmp(y.getObject().getSourceDebit(),\n if we_are_source :\n
x.getObject().getSourceDebit()))\n transaction_lines.sort(lambda x,y: cmp(\n
for line in transaction_lines :\n y.getObject().getSourceInventoriatedTotalAssetPrice(),\n
line = line.getObject()\n x.getObject().getSourceInventoriatedTotalAssetPrice()))\n
debtor = (line.getSourceDebit() > line.getSourceCredit())\n else :\n
account = line.getSourceValue()\n transaction_lines.sort(lambda x,y: cmp(\n
if account is None: continue\n y.getObject().getDestinationInventoriatedTotalAssetPrice(),\n
if account.isMemberOf( \'account_type/asset/cash\' ) :\n x.getObject().getDestinationInventoriatedTotalAssetPrice()))\n
account_description = "%s (%s)"%(\n \n
line.getSourceTitle(),\n for line in transaction_lines :\n
line.getSourcePaymentTitle())\n line = line.getObject()\n
elif account.getAccountType() in (\n if we_are_source :\n
\'asset/receivable\',\n debtor = (line.getSourceInventoriatedTotalAssetPrice() > 0)\n
\'liability/payable\'):\n account = line.getSourceValue()\n
account_description = "%s (%s)"%(\n if account is None: continue\n
line.getSourceTitle(),\n if account.isMemberOf( \'account_type/asset/cash\' ) :\n
line.getDestinationSectionTitle())\n account_description = "%s (%s)"%(\n
else :\n line.getSourceTitle(),\n
account_description = line.getSourceTitle()\n line.getSourcePaymentTitle())\n
lines.append({\n elif account.getAccountType() in (\n
\'debtor\' : debtor,\n \'asset/receivable\',\n
\'account_gap_id\' : account.Account_getGapId(),\n \'liability/payable\'):\n
\'account_name\' : account_description,\n account_description = "%s (%s)"%(\n
\'amount\' : debtor and (line.getSourceDebit() \\\n line.getSourceTitle(),\n
- line.getSourceCredit()) \\\n line.getDestinationSectionTitle())\n
or (line.getSourceCredit() \\\n else :\n
- line.getSourceDebit())\n account_description = line.getSourceTitle()\n
})\n lines.append({\n
if debtor :\n \'debtor\' : debtor,\n
journal_total_debit += line.getSourceDebit()\n \'account_gap_id\' : account.Account_getGapId(),\n
else:\n \'account_name\' : account_description,\n
journal_total_credit += line.getSourceCredit()\n \'amount\' : debtor and (\n
\n line.getSourceInventoriatedTotalAssetDebit()) \\\n
# internal mouvements, ie when we are destination and source\n or ( line.getSourceInventoriatedTotalAssetCredit())\n
# FIXME: here we should check only if we are destination.\n })\n
if line.getDestinationSection() == line.getSourceSection() :\n if debtor :\n
debtor = (line.getDestinationDebit() > line.getDestinationCredit())\n journal_total_debit += line.getSourceInventoriatedTotalAssetDebit()\n
account = line.getDestinationValue()\n else:\n
if account is None : continue\n journal_total_credit += line.getSourceInventoriatedTotalAssetCredit()\n
if account.isMemberOf( \'account_type/asset/cash\' ) :\n \n
account_description = "%s (%s)"%(\n if we_are_destination :\n
line.getDestinationTitle(),\n debtor = (line.getDestinationInventoriatedTotalAssetDebit() >\n
line.getDestinationPaymentTitle())\n line.getDestinationInventoriatedTotalAssetCredit())\n
elif account.getAccountType() in (\n account = line.getDestinationValue()\n
\'asset/receivable\',\n if account is None : continue\n
\'liability/payable\'):\n if account.isMemberOf( \'account_type/asset/cash\' ) :\n
account_description = "%s (%s)"%(\n account_description = "%s (%s)"%(\n
line.getDestinationTitle(),\n line.getDestinationTitle(),\n
line.getSourceSectionTitle())\n line.getDestinationPaymentTitle())\n
else :\n elif account.getAccountType() in (\n
account_description = line.getDestinationTitle()\n \'asset/receivable\',\n
lines.append({\n \'liability/payable\'):\n
\'debtor\' : debtor,\n account_description = "%s (%s)"%(\n
\'account_gap_id\' : account.Account_getGapId(),\n line.getDestinationTitle(),\n
\'account_name\' : account_description,\n line.getSourceSectionTitle())\n
\'amount\' : debtor and (line.getDestinationDebit() \\\n else :\n
- line.getDestinationCredit()) \\\n account_description = line.getDestinationTitle()\n
or (line.getDestinationCredit() \\\n lines.append({\n
- line.getDestinationDebit())\n \'debtor\' : debtor,\n
})\n \'account_gap_id\' : account.Account_getGapId(),\n
if debtor :\n \'account_name\' : account_description,\n
journal_total_debit += line.getSourceDebit()\n \'amount\' : debtor and (\n
else:\n line.getDestinationInventoriatedTotalAssetDebit()) \\\n
journal_total_credit += line.getSourceCredit()\n or ( line.getDestinationInventoriatedTotalAssetCredit())\n
\n })\n
if debtor :\n
journal_total_debit += line.getDestinationInventoriatedTotalAssetDebit()\n
else:\n
journal_total_credit += line.getDestinationInventoriatedTotalAssetCredit()\n
\n
return result + [{ "journal_total_debit": journal_total_debit,\n return result + [{ "journal_total_debit": journal_total_debit,\n
"journal_total_credit": journal_total_credit }]\n "journal_total_credit": journal_total_credit }]\n
# vim: syntax=python\n # vim: syntax=python\n
...@@ -211,7 +240,7 @@ return result + [{ "journal_total_debit": journal_total_debit,\n ...@@ -211,7 +240,7 @@ return result + [{ "journal_total_debit": journal_total_debit,\n
</item> </item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalAccountingTransactionList</string> </value> <value> <string>Script (Python):/erp5/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalAccountingTransactionList</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -260,6 +289,12 @@ return result + [{ "journal_total_debit": journal_total_debit,\n ...@@ -260,6 +289,12 @@ return result + [{ "journal_total_debit": journal_total_debit,\n
<string>_getiter_</string> <string>_getiter_</string>
<string>_apply_</string> <string>_apply_</string>
<string>transaction</string> <string>transaction</string>
<string>destination_section</string>
<string>we_are_destination</string>
<string>source_section</string>
<string>we_are_source</string>
<string>specific_reference</string>
<string>date</string>
<string>lines</string> <string>lines</string>
<string>unicode</string> <string>unicode</string>
<string>transaction_dict</string> <string>transaction_dict</string>
......
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