aboutsummaryrefslogtreecommitdiffstats
path: root/tmpl/transactions_by_year.html
blob: 4c6d3733e0278247cfeeee0fe0833b55dc5aea20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>[% config.sitename %]: Transactions for [% year %]</title>
        [%- INCLUDE head.html -%]
        [% INCLUDE head_chart.html %]
    </head>
    <body>
        [%- INCLUDE body_top.html -%]
        <h1 id='mgnavt'><a href="index.html">treasurer</a> » year : [% year %]</h1>

        <div class="content">
            <h1>Mageia.Org accounts transactions for year [% year %]</h1>
            <h2>Summary</h2>
            <ul>
                <li>
                <b>Start balance</b>: [% transactions.by_year.$year.start_balance %] Euros
                </li>
                <li>
                <b>End balance</b>: [% transactions.by_year.$year.end_balance %] Euros
                </li>
                <li>
                <b>Revenues</b>: [% transactions.by_year.$year.revenues %] Euros
                </li>
                <li>
                <b>Expenses</b>: [% transactions.by_year.$year.expenses %] Euros
                </li>
            </ul>
            <h2>By category</h2>

            [%-
            SET ca_expenses = [];
            SET ca_expenses_names = [];
            SET ca_revenues = [];
            SET ca_revenues_names = [];

            IF transactions.by_year.$year.ca_revenues;
                FOREACH ca IN transactions.by_year.$year.ca_revenues.keys;
                        ca_revenues.push(ca);
                        ca_revenues_names.push(transactions.by_ca.$ca.c_name);
                END;
            END;
            IF transactions.by_year.$year.ca_expenses;
                FOREACH ca IN transactions.by_year.$year.ca_expenses.keys;
                        ca_expenses.push(ca);
                        ca_expenses_names.push(transactions.by_ca.$ca.c_name);
                END;
            END;
            -%]
            <h3>Expenses</h3>
            [% IF ca_expenses.size > 1 %]
            <canvas id="expenses_ca_bar_chart" height="300" width="[% 80 + ca_expenses.size * 65 %]"></canvas>

            <script>

                var barChartDataExpenses = {
                    labels : ["[% ca_expenses_names.join('","') %]"],
                    datasets : [
                    {
                        fillColor : "#e51b1b",
                        strokeColor : "#f11111",
                        data: [
                        [%- FOR ca IN ca_expenses -%]
                        [%- transactions.by_year.$year.ca_expenses.$ca -%]
                        [%- IF ! loop.last() -%],[%- END -%]
                        [%- END %]]
                    }
                    ]
                }

                var myLine = new Chart(document.getElementById("expenses_ca_bar_chart").getContext("2d")).Bar(barChartDataExpenses);

            </script>
            [% END %]
            <ul>
                [%- FOR ca IN ca_expenses %]
                <li><b><a href="c_[% ca %].html">[% transactions.by_ca.$ca.c_name %]</a></b>: [% transactions.by_year.$year.ca_expenses.$ca %] Euros</li>
                [%- END -%]
            </ul>

            <h3>Revenues</h3>
            [% IF ca_revenues.size > 1 %]
            <canvas id="revenues_ca_bar_chart" height="300" width="[% 80 + ca_revenues.size * 65 %]"></canvas>

            <script>
                var barChartDataRevenues = {
                    labels : ["[% ca_revenues_names.join('","') %]"],
                    datasets : [
                    {
                        fillColor : "#151f79",
                        strokeColor : "#101333",
                        data: [
                        [%- FOR ca IN ca_revenues -%]
                        [%- transactions.by_year.$year.ca_revenues.$ca -%]
                        [%- IF ! loop.last() -%],[%- END -%]
                        [%- END %]]
                    }
                    ]
                }

                var myLine = new Chart(document.getElementById("revenues_ca_bar_chart").getContext("2d")).Bar(barChartDataRevenues);

            </script>
            [% END %]
            <ul>
                [%- FOR ca IN ca_revenues %]
                <li><b><a href="c_[% ca %].html">[% transactions.by_ca.$ca.c_name %]</a></b>: [% transactions.by_year.$year.ca_revenues.$ca %] Euros</li>
                [%- END -%]
            </ul>

            <h2>Monthly reports</h2>

            <canvas id="accounts_history_bar_chart" height="250" width="[% 80 + transactions.by_year.$year.months.size * 65 %]"></canvas>

            <script>

                var barChartData = {
                    labels : ["[% transactions.by_year.$year.months.sort.join('","') %]"],
                    datasets : [
                    {
                        fillColor : "#151f79",
                        strokeColor : "#101333",
                        data : [
                        [%- FOR month IN transactions.by_year.$year.months.sort -%]
                        [%- transactions.by_month.$month.revenues -%]
                        [%- IF ! loop.last() -%],[%- END -%]
                        [%- END %]]
                    },
                    {
                        fillColor : "#e51b1b",
                        strokeColor : "#f11111",
                        data: [
                        [%- FOR month IN transactions.by_year.$year.months.sort -%]
                        [%- transactions.by_month.$month.expenses -%]
                        [%- IF ! loop.last() -%],[%- END -%]
                        [%- END %]]
                    }
                    ]

                }

                var myLine = new Chart(document.getElementById("accounts_history_bar_chart").getContext("2d")).Bar(barChartData);

            </script>

            <ul>
                [%- FOR month IN transactions.by_month.keys.sort -%]
                [%- IF transactions.by_month.$month.year == year -%]
                <li><a href="m_[% month %].html">[% month %]</a></li>

                [%- END -%]
                [%- END -%]
            </ul>
            <h2>Details</h2>
            <table border="1">
                <tr>
                    <th>Date</th>
                    <th>Amount</th>
                    <th>Account</th>
                    <th>Who</th>
                    <th>Notes</th>
                    <th>Category</th>
                </tr>
                [%- USE date(format='%Y/%m/%d') -%]
                [% FOR tra IN transactions.by_year.$year.transactions.sort('date').reverse %]
                [%- INCLUDE tra_row.html %]
                [%- END -%]
            </table>
        </div>
    </body>
</html>