austax: Implement editing CGT cost adjustments

This commit is contained in:
RunasSudo 2023-01-07 15:11:35 +11:00
parent 0df8ccfaa1
commit 9ad5b7642e
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 22 additions and 0 deletions

View File

@ -36,6 +36,7 @@
<th>Adjustment date</th> <th>Adjustment date</th>
<th>Description</th> <th>Description</th>
<th class="text-end">Cost adjustment&nbsp;</th> <th class="text-end">Cost adjustment&nbsp;</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -49,6 +50,7 @@
<td>{{ cgt_adjustment.dt.strftime('%Y-%m-%d') }}</td> <td>{{ cgt_adjustment.dt.strftime('%Y-%m-%d') }}</td>
<td>{{ cgt_adjustment.description }}</td> <td>{{ cgt_adjustment.description }}</td>
<td class="text-end">{{ cgt_adjustment.cost_adjustment_amount().format_accounting() }}</td> <td class="text-end">{{ cgt_adjustment.cost_adjustment_amount().format_accounting() }}</td>
<td><a href="/tax/cgt-adjustments/edit?id={{ cgt_adjustment.id }}"><i class="bi bi-pencil"></i></a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -51,6 +51,26 @@ def cgt_adjustment_new():
return redirect('/tax/cgt-adjustments') return redirect('/tax/cgt-adjustments')
@app.route('/tax/cgt-adjustments/edit', methods=['GET', 'POST'])
def cgt_adjustment_edit():
if request.method == 'GET':
return render_plugin_template('austax', 'cgt_adjustments_edit.html', adjustment=db.session.get(CGTCostAdjustment, request.args['id']))
asset = Amount.parse(request.form['asset'])
adjustment = db.session.get(CGTCostAdjustment, request.args['id'])
adjustment.quantity = asset.quantity
adjustment.commodity = asset.commodity
adjustment.account = request.form['account']
adjustment.acquisition_date = datetime.strptime(request.form['acquisition_date'], '%Y-%m-%d')
adjustment.dt = datetime.strptime(request.form['dt'], '%Y-%m-%d')
adjustment.description = request.form['description']
adjustment.cost_adjustment = Amount.parse(request.form['cost_adjustment']).quantity
db.session.add(adjustment)
db.session.commit()
return redirect('/tax/cgt-adjustments')
@app.route('/tax/cgt-assets') @app.route('/tax/cgt-assets')
def cgt_assets(): def cgt_assets():
# Find all CGT asset accounts # Find all CGT asset accounts