{#  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 %}{{ 'Edit' if adjustment else 'New' }} CGT adjustment{% endblock %}

{% block content %}
	<h1 class="h2 my-4">{{ 'Edit' if adjustment else 'New' }} CGT adjustment</h1>
	
	<form method="POST">
		<h2 class="h3">CGT asset</h2>
		
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Acquisition date</label>
			<div class="col-sm-10">
				<input type="date" class="form-control" name="acquisition_date" value="{{ adjustment.acquisition_date.strftime('%Y-%m-%d') if adjustment else request.args.get('acquisition_date', '') }}">
			</div>
		</div>
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Account</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="account" value="{{ adjustment.account if adjustment else request.args.get('account', '') }}">
			</div>
		</div>
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Asset</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="asset" value="{{ adjustment.asset().quantity_string() if adjustment else request.args.get('asset', '') }}">
			</div>
		</div>
		
		<h2 class="h3 mt-4">CGT adjustment</h2>
		
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Adjustment date</label>
			<div class="col-sm-10">
				<input type="date" class="form-control" name="dt" value="{{ adjustment.dt.strftime('%Y-%m-%d') if adjustment }}">
			</div>
		</div>
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Description</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="description" value="{{ adjustment.description if adjustment }}">
			</div>
		</div>
		<div class="row mb-4">
			<label class="col-sm-2 col-form-label">Cost adjustment</label>
			<div class="col-sm-10">
				<input type="number" class="form-control" name="cost_adjustment" step="0.01" value="{{ adjustment.cost_adjustment_amount().quantity_string() if adjustment }}">
			</div>
		</div>
		
		<div class="text-end">
			<button type="submit" class="btn btn-primary">Save</button>
		</div>
	</form>
{% endblock %}