OCA/l10n-italy

View on GitHub
account_vat_period_end_statement/views/report_vatperiodendstatement.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!-- Document -->
        <template id="report_vatperiodendstatement_document">
            <t t-call="l10n_it_account.internal_layout">
                <div class="page">

                    <!-- Periods detail -->
                    <t t-foreach="statement.period_ids" t-as="period">
                        <h3>
                            <span>Summary</span>
                            <span t-esc="period.name"/>
                        </h3>

                        <!-- Purchase -->
                        <t t-set="tax_code_amounts"
                           t-value="tax_codes_amounts(period.id, [l.tax_code_id.id for l in statement.credit_vat_account_line_ids])"/>
                        <t t-set="tax_code_type" t-value="'credit'"/>
                        <t t-set="tax_code_section" t-value="'purchase'"/>
                        <t t-call="account_vat_period_end_statement.report_vatperiodendstatement_tax_code"/>

                        <!-- Sale -->
                        <t t-set="tax_code_amounts"
                           t-value="tax_codes_amounts(period.id, [l.tax_code_id.id for l in statement.debit_vat_account_line_ids])"/>
                        <t t-set="tax_code_type" t-value="'debit'"/>
                        <t t-set="tax_code_section" t-value="'sale'"/>
                        <t t-call="account_vat_period_end_statement.report_vatperiodendstatement_tax_code"/>
                    </t>

                    <!-- Total Compentence -->
                    <t t-set="total_statement" t-value="(0)"/>

                    <h3>Total Statement</h3>

                    <table class="table table-condensed">
                        <!-- tot debit -->
                        <t t-set="vat_accounts"
                           t-value="account_vat_amounts('debit', statement.debit_vat_account_line_ids)"/>
                        <t t-foreach="vat_accounts" t-as="account_id">
                            <tr>
                                <td class="text-right">Total debit vat</td>
                                <td class="text-right">
                                    <span t-esc="formatLang(vat_accounts[account_id]['amount'])"/>
                                </td>
                            </tr>
                            <!-- sum -->
                            <t t-set="total_statement"
                               t-value="(total_statement + vat_accounts[account_id]['amount'])"/>
                        </t>

                        <!-- tot credit -->
                        <t t-set="vat_accounts"
                           t-value="account_vat_amounts('credit', statement.credit_vat_account_line_ids)"/>
                        <t t-foreach="vat_accounts" t-as="account_id">
                            <tr>
                                <td class="text-right">Total credit vat</td>
                                <td class="text-right">
                                    <span t-esc="formatLang(vat_accounts[account_id]['amount'])"/>
                                </td>
                            </tr>
                            <!-- sum -->
                            <t t-set="total_statement"
                               t-value="(total_statement + ( -1 * vat_accounts[account_id]['amount']))"/>
                        </t>

                        <!-- tot statement -->
                        <tr>
                            <td class="text-right">
                                <strong>Total Statement</strong>
                            </td>
                            <td class="text-right">
                                <strong>
                                    <span t-esc="formatLang(total_statement)"/>
                                </strong>
                            </td>
                        </tr>
                    </table>

                    <!-- To pay -->
                    <t t-set="total_to_pay" t-value="(total_statement)"/>
                    <table class="table table-condensed">
                        <!-- previous credit -->
                        <tr>
                            <td class="text-right">Previous credit vat</td>
                            <td class="text-right">
                                <span t-esc="formatLang(statement.previous_credit_vat_amount)"/>
                            </td>
                            <!-- sum -->
                            <t t-set="total_to_pay"
                               t-value="(total_to_pay - statement.previous_credit_vat_amount)"/>
                        </tr>
                        <!-- previous debit -->
                        <tr>
                            <td class="text-right">Previous debit vat</td>
                            <td class="text-right">
                                <span t-esc="formatLang(statement.previous_debit_vat_amount)"/>
                            </td>
                            <!-- sum -->
                            <t t-set="total_to_pay"
                               t-value="(total_to_pay + statement.previous_debit_vat_amount)"/>
                        </tr>

                        <!-- ...Other tot debit/credit -->
                        <t t-foreach="statement.generic_vat_account_line_ids"
                           t-as="generic_vat">
                            <tr>
                                <td class="text-right">
                                    <span t-esc="generic_vat.account_id.name"/>
                                </td>
                                <td class="text-right">
                                    <span t-esc="formatLang(generic_vat.amount*-1)"/>
                                </td>
                                <!-- sum -->
                                <t t-set="total_to_pay"
                                   t-value="(total_to_pay + (generic_vat.amount*-1))"/>
                            </tr>
                        </t>

                        <!-- Total to pay -->
                        <tr>
                            <span t-if="(total_to_pay >= 0)">
                                <td class="text-right">
                                    <strong>Total To Pay</strong>
                                </td>
                                <td class="text-right">
                                    <strong>
                                        <span t-esc="formatLang(total_to_pay)"/>
                                    </strong>
                                </td>
                            </span>

                            <span t-if="not (total_to_pay >= 0)">
                                <td class="text-right">
                                    <strong>Total Credit</strong>
                                </td>
                                <td class="text-right">
                                    <strong>
                                        <span t-esc="formatLang((total_to_pay * -1))"/>
                                    </strong>
                                </td>
                            </span>
                        </tr>
                    </table>
                    <!-- payment info -->
                    <t t-if="statement.payment_ids">
                        <br/>

                        <table class="table table-condensed">
                            <t t-foreach="statement.payment_ids" t-as="payment_line">
                                <tr>
                                    <!--td t-esc="Importo versato (Estremi del versamento: data ' + payment_line.date + payment_line.journal_id.name)" /-->
                                    <td t-esc="'Importo versato (Estremi del versamento: data '+ time.strftime('%d/%m/%Y', time.strptime(payment_line.date, '%Y-%m-%d')) + ' - ' +payment_line.journal_id.name+')'"/>
                                    <td class="text-right"
                                        t-esc="formatLang(payment_line.debit)"/>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        Reverse charge: comprende RevCharge, Op.SM,
                                        Op.Vat., Op.FUE, Beni UE in Italia, Beni FUE in
                                        Italia, Cell., Microproc.
                                        Operazioni UE: Servizi Si Intra, Servizi No
                                        Intra, Beni UE, Rev.Charge UE, Cell. UE,
                                        Microproc. UE
                                    </td>
                                </tr>
                            </t>
                        </table>
                    </t>
                </div>
            </t>

        </template>

        <!-- Tax Code -->
        <template id="report_vatperiodendstatement_tax_code">

            <t t-set="total_vat" t-value="(0)"/>
            <t t-set="total_vat_deductible" t-value="(0)"/>
            <t t-set="total_vat_undeductible" t-value="(0)"/>
            <t t-set="total_base" t-value="(0)"/>


            <h4>
                <span t-if="(tax_code_section == 'sale')">Sale</span>
                <span t-if="(tax_code_section == 'purchase')">Purchase</span>
            </h4>
            <table class="table table-condensed">
                <thead>
                    <tr class="text-center">
                        <th style="width:10%;">Vat code</th>
                        <th style="width:30%;">Description</th>
                        <th style="width:15%;" class="text-right">Base</th>
                        <th style="width:15%;" class="text-right">Vat</th>
                        <span t-if="(tax_code_type == 'credit')">
                            <th style="width:15%;" class="text-right">Deductible</th>
                            <th style="width:15%;" class="text-right">Undeductible</th>
                        </span>
                        <span t-if="not (tax_code_type == 'credit')">
                            <th style="width:15%;"></th>
                            <th style="width:15%;"></th>
                        </span>
                    </tr>
                </thead>
                <t t-foreach="tax_code_amounts" t-as="tax_code">
                    <!-- Prepare values -->
                    <t t-set="code" t-value="(tax_code_amounts[tax_code]['code'])"/>
                    <t t-set="tax_code_base"
                       t-value="(tax_code_amounts[tax_code]['base'])"/>
                    <t t-set="tax_code_vat"
                       t-value="(tax_code_amounts[tax_code]['vat'])"/>
                    <t t-set="tax_code_vat_deductible"
                       t-value="(tax_code_amounts[tax_code]['vat_deductible'])"/>
                    <t t-set="tax_code_vat_undeductible"
                       t-value="(tax_code_amounts[tax_code]['vat_undeductible'])"/>
                    <!-- Credit have negative values : in the report will be positive -->
                    <span t-if="(tax_code_type == 'credit')">
                        <t t-set="tax_code_base" t-value="(-1 * tax_code_base)"/>
                        <t t-set="tax_code_vat" t-value="(-1 * tax_code_vat)"/>
                        <t t-set="tax_code_vat_deductible"
                           t-value="(-1 * tax_code_vat_deductible)"/>
                        <t t-set="tax_code_vat_undeductible"
                           t-value="(-1 * tax_code_vat_undeductible)"/>
                    </span>
                    <!-- print values  -->
                    <tr>
                        <td>
                            <span t-esc="code"/>
                        </td>
                        <td>
                            <span t-esc="tax_code"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="formatLang(tax_code_base)"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="formatLang(tax_code_vat)"/>
                        </td>
                        <span t-if="(tax_code_type == 'credit')">
                            <td class="text-right">
                                <span t-esc="formatLang(tax_code_vat_deductible)"/>
                            </td>
                            <td class="text-right">
                                <span t-esc="formatLang(tax_code_vat_undeductible)"/>
                            </td>
                        </span>
                        <span t-if="not (tax_code_type == 'credit')">
                            <td></td>
                            <td></td>
                        </span>
                    </tr>
                    <!-- sum total  -->
                    <t t-set="total_vat" t-value="(total_vat + tax_code_vat)"/>
                    <t t-set="total_base" t-value="(total_base + tax_code_base)"/>
                    <t t-set="total_vat_deductible"
                       t-value="(total_vat_deductible + tax_code_vat_deductible)"/>
                    <t t-set="total_vat_undeductible"
                       t-value="(total_vat_undeductible + tax_code_vat_undeductible)"/>
                </t>

                <!-- total -->
                <tr>
                    <td></td>
                    <td class="text-right">
                        <strong>Total</strong>
                    </td>
                    <td class="text-right">
                        <strong>
                            <span t-esc="formatLang(total_base)"/>
                        </strong>
                    </td>
                    <td class="text-right">
                        <strong>
                            <span t-esc="formatLang(total_vat)"/>
                        </strong>
                    </td>
                    <span t-if="(tax_code_type == 'credit')">
                        <td class="text-right">
                            <strong>
                                <span t-esc="formatLang(total_vat_deductible)"/>
                            </strong>
                        </td>
                        <td class="text-right">
                            <strong>
                                <span t-esc="formatLang(total_vat_undeductible)"/>
                            </strong>
                        </td>
                    </span>
                    <span t-if="not (tax_code_type == 'credit')">
                        <td></td>
                        <td></td>
                    </span>
                </tr>
            </table>

        </template>

        <!-- Main -->
        <template id="report_vatperiodendstatement">
            <t t-call="report.html_container">

                <t t-set="title" t-value="'Vat End Period Statement'"/>
                <t t-foreach="doc_ids" t-as="doc_id">
                    <t t-set="statement" t-value="statement(doc_id)"/>
                    <t t-set="l10n_it_count_fiscal_page_base"
                       t-value="l10n_it_count_fiscal_page_base(doc_id)"/>
                    <t t-call="account_vat_period_end_statement.report_vatperiodendstatement_document"/>
                </t>
            </t>
        </template>
    </data>
</openerp>