{#  DrCr: Web-based double-entry bookkeeping framework
    Copyright (C) 2022–2023  Lee Yingtong Li (RunasSudo)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#}

{% extends 'base.html' %}
{% block title %}CGT assets{% endblock %}

{% block content %}
	<h1 class="h2 mt-4">CGT assets</h1>
	
	<table class="table">
		<thead>
			<tr>
				<th style="border-bottom-width:0"></th>
				<th style="border-bottom-width:0"></th>
				<th style="border-bottom-width:0"></th>
				<th style="border-left-width:1px" colspan="2">Acquisition</th>
				<th style="border-left-width:1px" colspan="2">Adjustment</th>
				<th class="d-print-none"></th>
				<th style="border-left-width:1px" colspan="2">Disposal</th>
				<th style="border-bottom-width:0;border-left-width:1px"></th>
			</tr>
			<tr>
				<th>Account</th>
				<th>Asset</th>
				<th class="text-end">Units</th>
				<th style="border-left-width:1px">Date</th>
				<th class="text-end">Value</th>
				<th style="border-left-width:1px" class="text-end">b/f&nbsp;</th>
				<th class="text-end">{{ eofy_date.year }}</th>
				<th class="d-print-none"></th>
				<th style="border-left-width:1px">Date</th>
				<th class="text-end">Value</th>
				<th style="border-left-width:1px" class="text-end">Gain&nbsp;</th>
			</tr>
		</thead>
		<tbody>
			{% for asset in assets %}
				<tr>
					<td>{{ asset.account }}</td>
					<td>{{ asset.commodity_name() }}</td>
					<td class="text-end">{{ asset.format('hide') }}</td>
					<td style="border-left-width:1px">{{ asset.acquisition_date.strftime('%Y-%m-%d') }}</td>
					<td class="text-end">{{ asset.as_cost().format() }}</td>
					<td style="border-left-width:1px" class="text-end">{{ asset.cost_adjustment().format_accounting() if asset.cost_adjustments }}</td>
					<td>{# TODO #}</td>
					<td class="text-center d-print-none"><a href="/tax/cgt-adjustments/new?account={{ asset.account }}&asset={{ asset.quantity_string() }}&acquisition_date={{ asset.acquisition_date.strftime('%Y-%m-%d') }}"><i class="bi bi-plus-lg text-muted"></i></a></td>
					<td style="border-left-width:1px">{{ asset.disposal_date.strftime('%Y-%m-%d') if asset.disposal_date else '' }}</td>
					<td class="text-end">{{ asset.disposal_value.format() if asset.disposal_value else '' }}</td>
					<td style="border-left-width:1px" class="text-end">{% if asset.disposal_date %}{{ asset.gain().format_accounting() }}{% endif %}</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}