[MODULE] +v1.1.0 from https://www.odoo.com/apps/7.0/account_financial_report_webkit/
[burette/account_financial_report_webkit.git] / report / templates / account_report_partner_balance.mako
1 ## -*- coding: utf-8 -*-
2 <!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <style type="text/css">
6 ${css}
7
8 .list_table .act_as_row {
9 margin-top: 10px;
10 margin-bottom: 10px;
11 font-size:10px;
12 }
13
14 .account_line {
15 font-weight: bold;
16 font-size: 15px;
17 background-color:#F0F0F0;
18 }
19
20 .account_line .act_as_cell {
21 height: 30px;
22 vertical-align: bottom;
23 }
24
25 </style>
26 </head>
27 <body>
28 <%!
29 def amount(text):
30 return text.replace('-', '&#8209;') # replace by a non-breaking hyphen (it will not word-wrap between hyphen and numbers)
31
32 def display_line(all_comparison_lines):
33 return any([line.get('balance') for line in all_comparison_lines])
34 %>
35
36 <%setLang(user.lang)%>
37
38 <%
39 initial_balance_text = {'initial_balance': _('Computed'), 'opening_balance': _('Opening Entries'), False: _('No')}
40 %>
41
42 <div class="act_as_table data_table">
43 <div class="act_as_row labels">
44 <div class="act_as_cell">${_('Chart of Account')}</div>
45 <div class="act_as_cell">${_('Fiscal Year')}</div>
46 <div class="act_as_cell">
47 %if filter_form(data) == 'filter_date':
48 ${_('Dates Filter')}
49 %else:
50 ${_('Periods Filter')}
51 %endif
52 </div>
53 <div class="act_as_cell">${_('Accounts Filter')}</div>
54 <div class="act_as_cell">${_('Partners Filter')}</div>
55 <div class="act_as_cell">${_('Target Moves')}</div>
56 <div class="act_as_cell">${_('Initial Balance')}</div>
57 </div>
58 <div class="act_as_row">
59 <div class="act_as_cell">${ chart_account.name }</div>
60 <div class="act_as_cell">${ fiscalyear.name if fiscalyear else '-' }</div>
61 <div class="act_as_cell">
62 ${_('From:')}
63 %if filter_form(data) == 'filter_date':
64 ${formatLang(start_date, date=True) if start_date else u'' }
65 %else:
66 ${start_period.name if start_period else u''}
67 %endif
68 ${_('To:')}
69 %if filter_form(data) == 'filter_date':
70 ${ formatLang(stop_date, date=True) if stop_date else u'' }
71 %else:
72 ${stop_period.name if stop_period else u'' }
73 %endif
74 </div>
75 <div class="act_as_cell">
76 %if accounts(data):
77 ${', '.join([account.code for account in accounts(data)])}
78 %else:
79 ${_('All')}
80 %endif
81 </div>
82 <div class="act_as_cell">${display_partner_account(data)}</div>
83 <div class="act_as_cell">${ display_target_move(data) }</div>
84 <div class="act_as_cell">${ initial_balance_text[initial_balance_mode] }</div>
85 </div>
86 </div>
87
88 %for index, params in enumerate(comp_params):
89 <div class="act_as_table data_table">
90 <div class="act_as_row">
91 <div class="act_as_cell">${_('Comparison %s') % (index + 1,)} (${"C%s" % (index + 1,)})</div>
92 <div class="act_as_cell">
93 %if params['comparison_filter'] == 'filter_date':
94 ${_('Dates Filter:')}&nbsp;${formatLang(params['start'], date=True) }&nbsp;-&nbsp;${formatLang(params['stop'], date=True) }
95 %elif params['comparison_filter'] == 'filter_period':
96 ${_('Periods Filter:')}&nbsp;${params['start'].name}&nbsp;-&nbsp;${params['stop'].name}
97 %else:
98 ${_('Fiscal Year :')}&nbsp;${params['fiscalyear'].name}
99 %endif
100 </div>
101 <div class="act_as_cell">${ _('Initial Balance:')} ${ initial_balance_text[params['initial_balance_mode']] }</div>
102 </div>
103 </div>
104 %endfor
105
106 %for current_account in objects:
107 <%
108 partners_order = current_account.partners_order
109
110 # do not display accounts without partners
111 if not partners_order:
112 continue
113
114 comparisons = current_account.comparisons
115
116 # in multiple columns mode, we do not want to print accounts without any rows
117 if comparison_mode in ('single', 'multiple'):
118 all_comparison_lines = [comp['partners_amounts'][partner_id[1]]
119 for partner_id in partners_order
120 for comp in comparisons]
121 if not display_line(all_comparison_lines):
122 continue
123
124 current_partner_amounts = current_account.partners_amounts
125
126 total_initial_balance = 0.0
127 total_debit = 0.0
128 total_credit = 0.0
129 total_balance = 0.0
130 if comparison_mode in ('single', 'multiple'):
131 comparison_total = {}
132 for i, comp in enumerate(comparisons):
133 comparison_total[i] = {'balance': 0.0}
134 %>
135
136 <div class="account_title bg" style="margin-top: 20px; font-size: 12px; width: 690px;">${current_account.code} - ${current_account.name}</div>
137
138 <div class="act_as_table list_table">
139
140 <div class="act_as_thead">
141 <div class="act_as_row labels">
142 ## account name
143 <div class="act_as_cell" style="width: 80px;">${_('Account / Partner Name')}</div>
144 ## code
145 <div class="act_as_cell first_column" style="width: 20px;">${_('Code / Ref')}</div>
146 %if comparison_mode == 'no_comparison':
147 %if initial_balance_mode:
148 ## initial balance
149 <div class="act_as_cell amount" style="width: 30px;">${_('Initial Balance')}</div>
150 %endif
151 ## debit
152 <div class="act_as_cell amount" style="width: 30px;">${_('Debit')}</div>
153 ## credit
154 <div class="act_as_cell amount" style="width: 30px;">${_('Credit')}</div>
155 %endif
156 ## balance
157 <div class="act_as_cell amount" style="width: 30px;">
158 %if comparison_mode == 'no_comparison' or not fiscalyear:
159 ${_('Balance')}
160 %else:
161 ${_('Balance %s') % (fiscalyear.name,)}
162 %endif
163 </div>
164 %if comparison_mode in ('single', 'multiple'):
165 %for index in range(nb_comparison):
166 <div class="act_as_cell amount" style="width: 30px;">
167 %if comp_params[index]['comparison_filter'] == 'filter_year' and comp_params[index].get('fiscalyear', False):
168 ${_('Balance %s') % (comp_params[index]['fiscalyear'].name,)}
169 %else:
170 ${_('Balance C%s') % (index + 1,)}
171 %endif
172 </div>
173 %if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
174 <div class="act_as_cell amount" style="width: 30px;">${_('Difference')}</div>
175 <div class="act_as_cell amount" style="width: 30px;">${_('% Difference')}</div>
176 %endif
177 %endfor
178 %endif
179 </div>
180 </div>
181
182 <div class="act_as_tbody">
183
184 %for (partner_code_name, partner_id, partner_ref, partner_name) in partners_order:
185 <%
186 partner = current_partner_amounts.get(partner_id, {})
187
188 # in single mode, we have to display all the partners
189 # even if their balance is 0.0 because the initial balance
190 # should match with the previous year closings
191
192 # in multiple columns mode, we do not want to print partners
193 # which have a balance at 0.0 in each comparison column
194 if comparison_mode in ('single', 'multiple'):
195 all_comparison_lines = [comp['partners_amounts'][partner_id]
196 for comp in comparisons
197 if comp['partners_amounts'].get(partner_id)]
198 if not display_line(all_comparison_lines):
199 continue
200
201 total_initial_balance += partner.get('init_balance', 0.0)
202 total_debit += partner.get('debit', 0.0)
203 total_credit += partner.get('credit', 0.0)
204 total_balance += partner.get('balance', 0.0)
205 %>
206 <div class="act_as_row lines">
207 <div class="act_as_cell">${partner_name if partner_name else _('Unallocated') }</div>
208 <div class="act_as_cell first_column">${partner_ref if partner_ref else ''}</div>
209 %if comparison_mode == 'no_comparison':
210 %if initial_balance_mode:
211 <div class="act_as_cell amount">${formatLang(partner.get('init_balance', 0.0)) | amount}</div>
212 %endif
213 <div class="act_as_cell amount">${formatLang(partner.get('debit', 0.0)) | amount}</div>
214 <div class="act_as_cell amount">${formatLang(partner.get('credit', 0.0)) | amount}</div>
215 %endif
216 <div class="act_as_cell amount">${formatLang(partner['balance'] if partner else 0.0) | amount}</div>
217
218 %if comparison_mode in ('single', 'multiple'):
219 %for i, comp in enumerate(comparisons):
220 <%
221 comp_partners = comp['partners_amounts']
222 balance = diff = percent_diff = 0
223 if comp_partners.get(partner_id):
224 balance = comp_partners[partner_id]['balance']
225 diff = comp_partners[partner_id]['diff']
226 percent_diff = comp_partners[partner_id]['percent_diff']
227 comparison_total[i]['balance'] += balance
228 %>
229 <div class="act_as_cell amount">${formatLang(balance) | amount}</div>
230 %if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
231 <div class="act_as_cell amount">${formatLang(diff) | amount}</div>
232 <div class="act_as_cell amount">
233 %if percent_diff is False:
234 ${ '-' }
235 %else:
236 ${int(round(percent_diff)) | amount} &#37;
237 %endif
238 </div>
239 %endif
240 %endfor
241 %endif
242 </div>
243 %endfor
244
245 </div>
246 <div class="act_as_tfoot" style="margin-top:5px;">
247 <div class="act_as_row labels" style="font-weight: bold; font-size: 11x;">
248 ## account name
249 <div class="act_as_cell">${current_account.name}</div>
250 ## code
251 <div class="act_as_cell first_column">${current_account.code}</div>
252 %if comparison_mode == 'no_comparison':
253 %if initial_balance_mode:
254 ## opening balance
255 <div class="act_as_cell amount">${formatLang(total_initial_balance) | amount}</div>
256 %endif
257 ## debit
258 <div class="act_as_cell amount">${formatLang(total_debit) | amount}</div>
259 ## credit
260 <div class="act_as_cell amount">${formatLang(total_credit and total_credit * -1 or 0.0) | amount}</div>
261 %endif
262 ## balance
263 <div class="act_as_cell amount">${formatLang(total_balance) | amount}</div>
264
265 %if comparison_mode in ('single', 'multiple'):
266 %for i, comp in enumerate(comparisons):
267 <%
268 comp_account = comp['account']
269 diffs = compute_diff(total_balance, comparison_total[i]['balance'])
270 %>
271 <div class="act_as_cell amount">${formatLang(comparison_total[i]['balance']) | amount}</div>
272 %if comparison_mode == 'single': ## no diff in multiple comparisons because it shows too data
273 <div class="act_as_cell amount">${formatLang(diffs['diff']) | amount}</div>
274 <div class="act_as_cell amount">
275 %if diffs['percent_diff'] is False:
276 ${ '-' }
277 %else:
278 ${int(round(diffs['percent_diff'])) | amount} &#37;
279 %endif
280 </div>
281 %endif
282 %endfor
283 %endif
284 </div>
285 </div>
286 </div>
287
288 %endfor
289
290 </body>
291 </html>