austax: Show current year CGT adjustments on CGT assets report
This commit is contained in:
parent
8c1cb00bda
commit
3d09e4f34f
@ -17,6 +17,8 @@
|
|||||||
from drcr.database import db
|
from drcr.database import db
|
||||||
from drcr.models import Amount
|
from drcr.models import Amount
|
||||||
|
|
||||||
|
from .reports import eofy_date
|
||||||
|
|
||||||
class CGTAsset(Amount):
|
class CGTAsset(Amount):
|
||||||
def __init__(self, quantity, commodity, account, acquisition_date):
|
def __init__(self, quantity, commodity, account, acquisition_date):
|
||||||
super().__init__(quantity, commodity)
|
super().__init__(quantity, commodity)
|
||||||
@ -36,9 +38,21 @@ class CGTAsset(Amount):
|
|||||||
return self.commodity[:self.commodity.index('{')].strip()
|
return self.commodity[:self.commodity.index('{')].strip()
|
||||||
|
|
||||||
def cost_adjustment(self):
|
def cost_adjustment(self):
|
||||||
# TODO: brought forward vs current period
|
|
||||||
return Amount(sum(a.cost_adjustment for a in self.cost_adjustments), '$')
|
return Amount(sum(a.cost_adjustment for a in self.cost_adjustments), '$')
|
||||||
|
|
||||||
|
def cost_adjustment_brought_forward(self):
|
||||||
|
date1 = eofy_date()
|
||||||
|
date1 = date1.replace(year=date1.year - 1)
|
||||||
|
|
||||||
|
return Amount(sum(a.cost_adjustment for a in self.cost_adjustments if a.dt <= date1), '$')
|
||||||
|
|
||||||
|
def cost_adjustment_current_period(self):
|
||||||
|
date1 = eofy_date()
|
||||||
|
date1 = date1.replace(year=date1.year - 1)
|
||||||
|
date2 = eofy_date()
|
||||||
|
|
||||||
|
return Amount(sum(a.cost_adjustment for a in self.cost_adjustments if a.dt > date1 and a.dt <= date2), '$')
|
||||||
|
|
||||||
def gain(self):
|
def gain(self):
|
||||||
return self.disposal_value - (self.as_cost() + self.cost_adjustment())
|
return self.disposal_value - (self.as_cost() + self.cost_adjustment())
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@
|
|||||||
<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(link=url_for('cgt_adjustments', account=asset.account, commodity=asset.commodity, quantity=asset.quantity, acquisition_date=asset.acquisition_date.strftime('%Y-%m-%d'))) if asset.cost_adjustments }}</td>
|
<td style="border-left-width:1px" class="text-end">{{ asset.cost_adjustment_brought_forward().format_accounting(link=url_for('cgt_adjustments', account=asset.account, commodity=asset.commodity, quantity=asset.quantity, acquisition_date=asset.acquisition_date.strftime('%Y-%m-%d'))) if asset.cost_adjustment_brought_forward().quantity != 0 }}</td>
|
||||||
<td>{# TODO #}</td>
|
<td class="text-end">{{ asset.cost_adjustment_current_period().format_accounting(link=url_for('cgt_adjustments', account=asset.account, commodity=asset.commodity, quantity=asset.quantity, acquisition_date=asset.acquisition_date.strftime('%Y-%m-%d'))) if asset.cost_adjustment_current_period().quantity != 0 }}</td>
|
||||||
<td class="text-center d-print-none"><a href="{{ url_for('cgt_adjustment_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="{{ url_for('cgt_adjustment_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>
|
||||||
<td class="text-end">{{ asset.disposal_value.format() if asset.disposal_value else '' }}</td>
|
<td class="text-end">{{ asset.disposal_value.format() if asset.disposal_value else '' }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user