{% extends "base.html" %}

{% block title %}
	&raquo; MOP Contracts &raquo; {{bill.batch.contract.name}} &raquo;
 	Batches &raquo; {{bill.batch.reference}} &raquo; {{bill.reference}}
{% endblock %}

{% block nav %}
	<a href="/e/mop_contracts">MOP Contracts</a> &raquo; 
	<a
			href="/e/mop_contracts/{{bill.batch.contract.id}}"
			>{{bill.batch.contract.name}}</a> &raquo; 
	<a href="/e/mop_batches?mop_contract_id={{bill.batch.contract.id}}">Batches</a>
	&raquo; 
	<a href="/e/mop_batches/{{bill.batch.id}}">{{bill.batch.reference}}</a>
	&raquo; {{bill.reference}}
	[<a href="/e/mop_bills/{{bill.id}}/edit">edit</a>]
{% endblock %}

{% block content %}
	<table>
		<thead>
			<caption>Bill</caption>	
			<tr>
				<th>Supply</th>
				<th>Reference</th>
				<th>Account</th>
				<th>Issue Date</th>
				<th>From</th>
				<th>To</th>
				<th>kWh</th>
				<th>Net</th>
				<th>VAT</th>
				<th>Gross</th>
				<th>Type</th>
				<th>Check</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><a href="/e/supplies/{{bill.supply.id}}">Supply</a></td>
				<td>{{bill.reference}}</td>
				<td>{{bill.account}}</td>
				<td>{{bill.issue_date.strftime('%Y-%m-%d %H:%M')}}</td>
				<td>{{bill.start_date|hh_format }}</td>
				<td>{{bill.finish_date|hh_format }}</td>
				<td>{{bill.kwh}}</td>
				<td>{{bill.net}}</td>
				<td>{{bill.vat}}</td>
				<td>{{bill.gross}}</td>
				<td>
					<a
							href="/bill_types/{{bill.bill_type.id}}"
							title="{{bill.bill_type.description}}">{{bill.bill_type.code}}</a>
				</td>
				<td><a href="/reports/111?bill_id={{bill.id}}">Check</a></td>
			</tr>
		</tbody>
	</table>

	<h2>Breakdown</h2>	

	<pre>{%- for line in raw_lines -%}
		{{line}}<br>
	{%- endfor -%}</pre>

	<table>
		<thead>
			<tr>
				<th>element</th>
				{% for col in column_list %}
					<th>{{col}}</th>
				{% endfor %}
			</tr>  
		</thead>
		<tbody>
			{% for row in row_list %}
				<tr>
					<td>{{row}}</td>
					{% for col in column_list %}
						<td>{{grid[row][col]}}</td>
					{% endfor %}
				</tr>
			{% endfor %}
		</tbody>
	</table>

	<br>
	<pre>
		{{bill.breakdown}}
	</pre>	

{% endblock %}
