You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
15 KiB

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