<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_partnerbalance">
    <t t-call="report.html_container">
        <t t-call="report.internal_layout">
            <div class="page">
                <h2>Partner Balance</h2>

                <div class="row">
                    <div class="col-xs-3">
                        <strong>Chart of Accounts:</strong>
                        <p t-esc="get_account(data)"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Fiscal Year:</strong>
                        <p t-esc="get_fiscalyear(data)"/>
                    </div>
                    <div class="col-xs-3">
                        <strong>Journals:</strong>
                        <p t-esc="', '.join([ lt or '' for lt in get_journal(data) ])"/>
                    </div>
                    <div class="col-xs-3" t-if="get_partners()">
                        <strong>Partner's</strong>
                        <p t-esc="get_partners()"/>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-3">
                        <strong>Filter By:</strong>
                        <p>
                            <span t-if="data['form']['filter'] == 'filter_no'">Not filtered</span>
                            <span t-if="data['form']['filter'] == 'filter_period'">Filtered by period</span>
                            <span t-if="data['form']['filter'] == 'filter_date'">Filtered by date</span>
                            <p t-if="data['form']['filter'] == 'filter_period'">
                                Start Period: <span t-esc="get_start_period(data)"/>
                                End Period: <span t-esc="get_end_period(data)"/>
                            </p>
                            <p t-if="data['form']['filter'] == 'filter_date'">
                                Date from : <span t-esc="formatLang(get_start_date(data), date=True)"/><br />
                                Date to : <span t-esc="formatLang(get_end_date(data), date=True)"/>
                            </p>
                        </p>
                    </div>
                    <div class="col-xs-3">
                        <strong>Target Moves:</strong>
                        <p t-esc="get_target_move(data)"/>
                    </div>
                </div>

                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <th>Code</th>
                            <th>(Account/Partner) Name</th>
                            <th class="text-right">Debit</th>
                            <th class="text-right">Credit</th>
                            <th class="text-right">Balance</th>
                            <th class="text-right">In dispute</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Total:</strong></td>
                            <td></td>
                            <td class="text-right">
                                <strong t-esc="formatLang(sum_debit())"/>
                            </td>
                            <td class="text-right">
                                <strong t-esc="formatLang(sum_credit())"/>
                            </td>
                            <td class="text-right">
                                <strong t-esc="formatLang(sum_debit()-sum_credit(), currency_obj=res_company.currency_id)"/>
                            </td>
                            <td class="text-right">
                                <strong t-esc="formatLang(sum_litige(), currency_obj=res_company.currency_id)"/>
                            </td>
                        </tr>
                        <tr t-foreach="lines()" t-as="line">
                            <td t-if="line['type'] == 3">
                                <strong t-esc="line['ref']"/>
                                <span t-esc="line['code']"/>
                            </td>
                            <td t-if="line['type'] != 3">
                                <span t-esc="line['ref']"/>
                            </td>
                            <td t-if="line['type'] == 3">
                                <strong t-esc="line['name']"/>
                            </td>
                            <td t-if="line['type'] != 3">
                                <span t-esc="line['name']"/>
                            </td>
                            <td t-if="line['type'] == 3" class="text-right">
                                <strong t-esc="formatLang(line['debit'])"/>
                            </td>
                            <td t-if="line['type']!=3" class="text-right">
                                <span t-esc="formatLang(line['debit'])"/>
                            </td>
                            <td t-if="line['type']==3" class="text-right">
                                <strong t-esc="formatLang(line['credit'])"/>
                            </td>
                            <td t-if="line['type']!=3" class="text-right">
                                <span t-esc="formatLang(line['credit'])"/>
                            </td>
                            <td t-if="line['type']==3" class="text-right">
                                <strong t-esc="formatLang(line['balance'], currency_obj=res_company.currency_id)"/>
                            </td>
                            <td t-if="line['type']!=3" class="text-right">
                                <span t-esc="formatLang(line['balance'], currency_obj=res_company.currency_id)"/>
                            </td>
                            <td t-if="line['type'] == 3" class="text-right">
                                <strong t-esc="formatLang(line['enlitige'] or 0.0, currency_obj=res_company.currency_id)"/>
                            </td>
                            <td t-if="line['type']!=3" class="text-right">
                                <span t-esc="formatLang(line['enlitige'] or 0.0, currency_obj=res_company.currency_id)"/>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </t>
    </t>
</template>
</data>
</openerp>
