scottohara/loot

View on GitHub
src/schedules/views/index.html

Summary

Maintainability
Test Coverage
<table
    id="transactions"
    class="table table-striped table-bordered table-hover table-condensed"
    og-table-navigable="vm.tableActions"
>
    <thead id="transactions-header">
        <tr>
            <th class="transaction-date">Date</th>
            <th class="account">Account</th>
            <th class="details">Details</th>
            <th>Frequency</th>
            <th class="amount">Debit</th>
            <th class="amount">Credit</th>
        </tr>
    </thead>
    <tbody>
        <tr
            class="transaction"
            ng-repeat="schedule in vm.schedules"
            ng-class="::{'text-danger': schedule.next_due_date < vm.today}"
        >
            <td>
                {{::schedule.next_due_date | date:'dd/MM/yyyy'}}
                <i
                    ng-if="::schedule.auto_enter"
                    class="glyphicon glyphicon-pushpin pull-right"
                    uib-tooltip="Auto entered on due date"
                ></i>
                <div ng-if="::schedule.overdue_count > 1">
                    <small
                        ><em>({{::schedule.overdue_count}} occurences overdue)</em></small
                    >
                </div>
            </td>
            <td>{{::schedule.primary_account.name}}</td>
            <td class="details">
                <table class="table-condensed">
                    <tr>
                        <td ng-if="::schedule.payee.id" colspan="2">
                            {{::schedule.payee.name}}
                        </td>
                        <td ng-if="::schedule.security.id" colspan="2">
                            {{::schedule.security.name}}
                        </td>
                    </tr>
                    <tr>
                        <td class="category">{{::schedule.category.name}}</td>
                        <td ng-if="::schedule.transaction_type == 'Basic'" class="category">
                            {{::schedule.subcategory.name}}
                        </td>
                        <td
                            ng-if="::['Transfer', 'Subtransfer', 'SecurityTransfer', 'Dividend', 'SecurityInvestment'].indexOf(schedule.transaction_type) != -1"
                            class="category"
                        >
                            {{::schedule.account.name}}
                        </td>
                        <td
                            ng-if="::['Split', 'LoanRepayment', 'Payslip'].indexOf(schedule.transaction_type) != -1"
                        >
                            <button
                                ng-click="vm.toggleSubtransactions($event, schedule)"
                                class="btn btn-xs btn-default toggle-subtransactions"
                            >
                                <i
                                    class="glyphicon"
                                    ng-class="::{'glyphicon-chevron-down': !schedule.showSubtransactions, 'glyphicon-chevron-up': schedule.showSubtransactions}"
                                ></i>
                            </button>
                        </td>
                    </tr>
                    <tr
                        ng-if="::['Split', 'LoanRepayment', 'Payslip'].indexOf(schedule.transaction_type) != -1"
                        ng-show="schedule.showSubtransactions"
                    >
                        <td colspan="2">
                            <table class="table-condensed">
                                <thead>
                                    <tr>
                                        <th>Category</th>
                                        <th>Subcategory</th>
                                        <th>Description</th>
                                        <th class="amount">Amount</th>
                                    </tr>
                                    <tr
                                        og-table-loading="schedule.loadingSubtransactions"
                                        colspan="4"
                                    ></tr>
                                </thead>
                                <tbody>
                                    <tr ng-repeat="subtransaction in schedule.subtransactions">
                                        <td>{{::subtransaction.category.name}}</td>
                                        <td ng-if="::subtransaction.transaction_type == 'Sub'">
                                            {{::subtransaction.subcategory.name}}
                                        </td>
                                        <td
                                            ng-if="::subtransaction.transaction_type == 'Subtransfer'"
                                        >
                                            {{::subtransaction.account.name}}
                                        </td>
                                        <td>{{::subtransaction.memo}}</td>
                                        <td
                                            class="amount"
                                            ng-class="::{'text-danger': (subtransaction.amount * (subtransaction.direction == schedule.direction ? 1 : -1)) < 0}"
                                        >
                                            {{::subtransaction.amount * (subtransaction.direction ==
                                            schedule.direction ? 1 : -1) | currency}}
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="memo" colspan="2">
                            <span>{{::schedule.memo}}</span>
                        </td>
                    </tr>
                </table>
            </td>
            <td>{{::schedule.frequency}}</td>
            <td class="amount details">
                <span
                    ng-if="::schedule.direction == 'outflow' && schedule.amount"
                    ng-class="::{'text-danger': schedule.amount < 0}"
                    >{{::schedule.amount | currency | estimate:schedule.estimate}}</span
                >
            </td>
            <td class="amount details">
                <span
                    ng-if="::schedule.direction == 'inflow' && schedule.amount"
                    ng-class="::{'text-danger': schedule.amount < 0}"
                    >{{::schedule.amount | currency | estimate:schedule.estimate}}</span
                >
            </td>
        </tr>
    </tbody>
</table>