austax: Add links to CGT assets report
This commit is contained in:
parent
a4faca5ea8
commit
46b041d9dc
@ -50,12 +50,12 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for asset in assets %}
|
{% for asset in assets %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ asset.account }}</td>
|
<td><a href="/account-transactions?account={{ asset.account }}&commodity-detail=1">{{ asset.account }}</a></td>
|
||||||
<td>{{ asset.commodity_name() }}</td>
|
<td>{{ asset.commodity_name() }}</td>
|
||||||
<td class="text-end">{{ asset.format('hide') }}</td>
|
<td class="text-end">{{ asset.format('hide') }}</td>
|
||||||
<td style="border-left-width:1px">{{ asset.acquisition_date.strftime('%Y-%m-%d') }}</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 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 style="border-left-width:1px" class="text-end">{{ asset.cost_adjustment().format_accounting(link="/tax/cgt-adjustments?account={}&commodity={}&quantity={}&acquisition_date={:%Y-%m-%d}".format(asset.account, asset.commodity, asset.quantity, asset.acquisition_date)) if asset.cost_adjustments }}</td>
|
||||||
<td>{# TODO #}</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 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 style="border-left-width:1px">{{ asset.disposal_date.strftime('%Y-%m-%d') if asset.disposal_date else '' }}</td>
|
||||||
|
@ -29,7 +29,17 @@ from math import copysign
|
|||||||
|
|
||||||
@app.route('/tax/cgt-adjustments')
|
@app.route('/tax/cgt-adjustments')
|
||||||
def cgt_adjustments():
|
def cgt_adjustments():
|
||||||
adjustments = db.session.scalars(db.select(CGTCostAdjustment).order_by(CGTCostAdjustment.dt, CGTCostAdjustment.account)).all()
|
adjustments = db.select(CGTCostAdjustment).order_by(CGTCostAdjustment.dt, CGTCostAdjustment.account)
|
||||||
|
if 'account' in request.args:
|
||||||
|
adjustments = adjustments.where(CGTCostAdjustment.account == request.args['account'])
|
||||||
|
if 'quantity' in request.args:
|
||||||
|
adjustments = adjustments.where(CGTCostAdjustment.quantity == request.args['quantity'])
|
||||||
|
if 'commodity' in request.args:
|
||||||
|
adjustments = adjustments.where(CGTCostAdjustment.commodity == request.args['commodity'])
|
||||||
|
if 'acquisition_date' in request.args:
|
||||||
|
adjustments = adjustments.where(CGTCostAdjustment.acquisition_date == datetime.strptime(request.args['acquisition_date'], '%Y-%m-%d'))
|
||||||
|
|
||||||
|
adjustments = db.session.scalars(adjustments).all()
|
||||||
return render_plugin_template('austax', 'cgt_adjustments.html', cgt_adjustments=adjustments)
|
return render_plugin_template('austax', 'cgt_adjustments.html', cgt_adjustments=adjustments)
|
||||||
|
|
||||||
@app.route('/tax/cgt-adjustments/new', methods=['GET', 'POST'])
|
@app.route('/tax/cgt-adjustments/new', methods=['GET', 'POST'])
|
||||||
|
@ -122,11 +122,18 @@ class Amount:
|
|||||||
else:
|
else:
|
||||||
return Markup('{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
|
return Markup('{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
|
||||||
|
|
||||||
def format_accounting(self):
|
def format_accounting(self, link=None):
|
||||||
if self.quantity >= 0:
|
if self.quantity >= 0:
|
||||||
return Markup('{:,.{dps}f} '.format(self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
|
text = '{:,.{dps}f}'.format(self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' ')
|
||||||
|
space = ' '
|
||||||
else:
|
else:
|
||||||
return Markup('({:,.{dps}f})'.format(-self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
|
text = '({:,.{dps}f})'.format(-self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' ')
|
||||||
|
space = ''
|
||||||
|
|
||||||
|
if link is None:
|
||||||
|
return Markup(text + space)
|
||||||
|
else:
|
||||||
|
return Markup('<a href="{}">{}</a>{}'.format(link, text, space))
|
||||||
|
|
||||||
def quantity_string(self):
|
def quantity_string(self):
|
||||||
if self.commodity == '$':
|
if self.commodity == '$':
|
||||||
|
Loading…
Reference in New Issue
Block a user