← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~a-camilli/openobject-italia/7.0-stampa_liq_IVA_sommario_conti_IVA_raggruppati into lp:openobject-italia/7.0

 

Alessandro Camilli has proposed merging lp:~a-camilli/openobject-italia/7.0-stampa_liq_IVA_sommario_conti_IVA_raggruppati into lp:openobject-italia/7.0.

Requested reviews:
  OpenERP Italia core devs (openobject-italia-core-devs)

For more details, see:
https://code.launchpad.net/~a-camilli/openobject-italia/7.0-stampa_liq_IVA_sommario_conti_IVA_raggruppati/+merge/208139

PRIMA:
Nella sezione "sommario" della stampa della liquidazione, i conti iva vengono ripetuti in base ai codici iva che li utilizzano.
Per cui se l'iva 22,10 e 4 usano il conto "IVA ns debito", nel sommario viene ripetuto 3 volte il conto "IVA ns debito" con i rispettivi valori.

DOPO:
con queste modifiche i conti iva vengono raggruppati e sommati per avere una sola riga per ogni conto iva usato.
-- 
https://code.launchpad.net/~a-camilli/openobject-italia/7.0-stampa_liq_IVA_sommario_conti_IVA_raggruppati/+merge/208139
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~a-camilli/openobject-italia/7.0-stampa_liq_IVA_sommario_conti_IVA_raggruppati into lp:openobject-italia/7.0.
=== modified file 'account_vat_period_end_statement/report/vat_period_end_statement.mako'
--- account_vat_period_end_statement/report/vat_period_end_statement.mako	2013-03-16 13:18:33 +0000
+++ account_vat_period_end_statement/report/vat_period_end_statement.mako	2014-02-25 14:07:42 +0000
@@ -140,10 +140,13 @@
         <th> ${ _('Debit') }</th>
         <th> ${ _('Credit') }</th>
     </tr>
-    %for debit_line in statement.debit_vat_account_line_ids :
+    ## Vat account grouped by id
+    <% totals_by_account = {} %>
+    <% vat_accounts = account_vat_amounts("debit", statement.debit_vat_account_line_ids) %>
+    %for vat_account_id in vat_accounts :
         <tr >
-            <td>${ debit_line.account_id.name|entity }</td>
-            <td>${ formatLang(debit_line.amount)|entity }</td>
+            <td>${ vat_accounts[vat_account_id]['account_name']|entity }</td>
+            <td style="text-align:right">${ formatLang(vat_accounts[vat_account_id]['amount'])|entity }</td>
             <td></td>
         </tr>
     %endfor
@@ -153,34 +156,37 @@
         <td>${ statement.payable_vat_amount|entity }</td>
     </tr>
     -->
-    %for credit_line in statement.credit_vat_account_line_ids :
+    ## Vat account grouped by id
+    <% totals_by_account = {} %>
+    <% vat_accounts = account_vat_amounts("credit", statement.credit_vat_account_line_ids) %>
+    %for vat_account_id in vat_accounts :
         <tr >
-            <td>${ credit_line.account_id.name|entity }</td>
+            <td>${ vat_accounts[vat_account_id]['account_name']|entity }</td>
             <td></td>
-            <td>${ formatLang(credit_line.amount)|entity }</td>
+            <td style="text-align:right">${ formatLang(vat_accounts[vat_account_id]['amount'])|entity }</td>
         </tr>
     %endfor
     <!--
     <tr >
         <td>${_("Total")}</td>
-        <td>${ statement.deductible_vat_amount|entity }</td>
+        <td >${ statement.deductible_vat_amount|entity }</td>
     </tr>
     -->
     <tr >
         <td>${_("Previous Credits VAT")}</td>
         <td></td>
-        <td>${ formatLang(statement.previous_credit_vat_amount)|entity }</td>
+        <td style="text-align:right">${ formatLang(statement.previous_credit_vat_amount)|entity }</td>
     </tr>
     <tr >
         <td>${_("Previous Debits VAT")}</td>
-        <td>${ formatLang(statement.previous_debit_vat_amount)|entity }</td>
+        <td style="text-align:right">${ formatLang(statement.previous_debit_vat_amount)|entity }</td>
         <td></td>
     </tr>
     %for generic_line in statement.generic_vat_account_line_ids :
         <tr >
             <td>${ generic_line.account_id.name|entity }</td>
-            <td>${ generic_line.amount < 0 and formatLang(generic_line.amount) or ''|entity }</td>
-            <td>${ generic_line.amount > 0 and formatLang(generic_line.amount) or ''|entity }</td>
+            <td style="text-align:right">${ generic_line.amount < 0 and formatLang(generic_line.amount) or ''|entity }</td>
+            <td style="text-align:right">${ generic_line.amount > 0 and formatLang(generic_line.amount) or ''|entity }</td>
         </tr>
     %endfor
     <tr >

=== modified file 'account_vat_period_end_statement/report/vat_period_end_statement.py'
--- account_vat_period_end_statement/report/vat_period_end_statement.py	2013-06-20 09:36:52 +0000
+++ account_vat_period_end_statement/report/vat_period_end_statement.py	2014-02-25 14:07:42 +0000
@@ -68,6 +68,27 @@
             res = self._build_codes_dict(tax_code, res=res, context=context)
         return res
     
+    def _get_account_vat_amounts(self, type='credit', statement_account_line=[], context=None):
+        if context is None:
+            context = {}
+        if type == 'credit':
+            stat_line_obj = self.pool.get('statement.credit.account.line')
+        else:
+            stat_line_obj = self.pool.get('statement.debit.account.line')
+        account_amounts = {}
+        for line in statement_account_line:
+            account_id = str(line.account_id.id)
+            acc = account_amounts.get(account_id, False)
+            if not acc:
+                account_amounts[account_id] = {
+                           'account_id' : line.account_id.id,
+                           'account_name' : line.account_id.name,
+                           'amount' : line.amount
+                           }
+            else:
+                acc['amount'] += line.amount
+        return account_amounts
+    
     def find_period(self, date,context=None):
         if context is None:
             context = {}
@@ -85,6 +106,7 @@
             'time': time,
             'tax_codes_amounts': self._get_tax_codes_amounts,
             'find_period': self.find_period,
+            'account_vat_amounts': self._get_account_vat_amounts,
         })
         self.context = context