{#  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 assertion else 'New' }} balance assertion{% endblock %}

{% block content %}
	<h1 class="h2 my-4">{{ 'Edit' if assertion else 'New' }} balance assertion</h1>
	
	<form method="POST">
		<div class="row mb-2">
			<label class="col-sm-2 col-form-label">Date</label>
			<div class="col-sm-10">
				<input type="date" class="form-control" name="dt" value="{{ assertion.dt.strftime('%Y-%m-%d') if assertion }}">
			</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="{{ assertion.description if assertion }}">
			</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="{{ assertion.account if assertion }}">
			</div>
		</div>
		<div class="row mb-4">
			<label class="col-sm-2 col-form-label">Balance</label>
			<div class="col-sm-10">
				<div class="input-group">
					<div class="input-group-text">$</div>
					<input type="number" class="form-control" name="amount" step="0.01" value="{{ assertion.balance().quantity_string() if assertion }}">
					<select class="form-select" name="sign">
						<option value="dr">Dr</option>
						<option value="cr">Cr</option>
					</select>
				</div>
			</div>
		</div>
		
		<div class="text-end">
			<button type="submit" class="btn btn-primary">Save</button>
		</div>
	</form>
{% endblock %}