<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_generaljournal">
    <t t-call="report.html_container">
        <t t-foreach="periods(docs)" t-as="o">
            <t t-call="report.internal_layout">
                <div class="page">
                    <h2>General Journal</h2>

                    <div class="row mt32">
                        <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">
                            <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>
                    <div class="row mb32">
                        <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>Journal Name</th>
                                <th>Debit</th>
                                <th>Credit</th>
                                <th>Balance</th>
                                <th t-if="display_currency(data)">Currency</th>
                            </tr>
                            <tr>
                                <th>Total:</th>
                                <th></th>
                                <th><span t-esc="formatLang(sum_debit())"/></th>
                                <th><span t-esc="formatLang(sum_credit())"/></th>
                                <th><span t-esc="formatLang(sum_credit() - sum_debit(), currency_obj=res_company.currency_id)"/></th>
                                <th t-if="display_currency(data)"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr style="font-weight: bold;">
                                <td><span t-field="o.name"/>:</td>
                                <td></td>
                                <td><span t-esc="formatLang(sum_debit_period(o.id))"/></td>
                                <td><span t-esc="formatLang(sum_credit_period(o.id))"/></td>
                                <td><span t-esc="formatLang(sum_credit_period(o.id) - sum_debit_period(o.id), currency_obj=res_company.currency_id)"/></td>
                                <td t-if="display_currency(data)"></td>
                            </tr>
                            <tr t-foreach="lines(o.id)" t-as="line">
                                <td><span t-esc="line['code']"/></td>
                                <td><span t-esc="line['name']"/></td>
                                <td><span t-esc="line['debit']"/></td>
                                <td><span t-esc="line['credit']"/></td>
                                <td><span t-esc="formatLang(line['credit'] - line['debit'], currency_obj=res_company.currency_id)"/></td>
                                
                                <td t-if="display_currency(data)">
                                    <t t-if="line['amount_currency']">
                                       <span t-esc="formatLang(line['amount_currency'])"/>
                                       <span t-esc="line['currency_code']"/>
                                    </t>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </t>
        </t>
    </t>
</template>
</data>
</openerp>
