<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <template id="report_bank_statement_summary_doc">
        <t t-call="web.external_layout">
            <t t-set="o"
               t-value="o.with_context({'lang':o.company_id.partner_id.lang})"/>
            <div class="page">
                <p style='text-align:center;'>
                    Reconciliation Summary
                </p>
                <h5 style='text-align:center;'>
                    <span>Period Ending</span>
                    <span t-field="o.ending_date"/>
                </h5>
                <div class="row" t-if="not o.account_id.currency_id">
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Initial Balance:</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.starting_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Deposits &amp; Credits-</span>
                                        <span t-field="o.sum_of_debits_lines"/>
                                        items
                                    </b>
                                </td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_debits"
                                          t-field="o.sum_of_debits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_debits_cur"
                                          t-field="o.sum_of_debits_cur"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Checks &amp; Payments-</span>
                                        <span t-field="o.sum_of_credits_lines"/>
                                        items
                                    </b>
                                </td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_credits"
                                          t-field="o.sum_of_credits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_credits_cur"
                                          t-field="o.sum_of_credits_cur"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Total Cleared Transactions</span>
                                    </b>
                                </td>
                                <td class="text-right">
                                    <span t-esc="o.sum_of_debits - o.sum_of_credits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <span t-esc="o.sum_of_debits_cur - o.sum_of_credits_cur"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Cleared Balance</span>
                                    </b>
                                </td>
                                <td class="text-right">
                                    <span t-field="o.cleared_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <span t-field="o.cleared_balance_cur"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <b>
                                        <span t-field="o.cleared_balance_cur"
                                              t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                    </b>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Ending Balance:</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.ending_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div class="row" t-if="o.account_id.currency_id">
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Initial Balance:</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.starting_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Ending Balance:</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.ending_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Cleared Transactions</span>
                                    </b>
                                </td>
                                <td></td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Deposits &amp; Credits-</span>
                                        <span t-field="o.sum_of_debits_lines"/>
                                        items
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_debits"
                                          t-field="o.sum_of_debits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Checks &amp; Payments-</span>
                                        <span t-field="o.sum_of_credits_lines"/>
                                        items
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-if="o.sum_of_credits"
                                          t-field="o.sum_of_credits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td></td>
                                <td>
                                    <b>
                                        <span>Total Cleared Transactions</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-esc="o.sum_of_debits - o.sum_of_credits"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Cleared Balance</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.cleared_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                                <td class="text-right">
                                    <span t-field="o.cleared_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="table table-condensed">
                        <tbody class="invoice_tbody">
                            <tr>
                                <td>
                                    <b>
                                        <span>Ending Balance:</span>
                                    </b>
                                </td>
                                <td></td>
                                <td class="text-right">
                                    <span t-field="o.ending_balance"
                                          t-options='{"widget": "monetary", "display_currency": o.account_id.currency_id}'/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

            </div>
        </t>
    </template>

    <template id="report_bank_statement_summary">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="o">
                <t
                        t-call="account_banking_reconciliation.report_bank_statement_summary_doc"
                        t-lang="o.company_id.partner_id.lang"/>
            </t>
        </t>
    </template>

</odoo>
