fix for fees for selling.

fix for taxfree amount.
add description to transactions.
This commit is contained in:
2021-05-12 06:54:32 +02:00
parent 2818d9c11f
commit 68c26eb924
7 changed files with 70 additions and 3 deletions
+4 -1
View File
@@ -87,7 +87,7 @@ class Calc:
# calculate all fees. # calculate all fees.
with connection.cursor() as cursor: with connection.cursor() as cursor:
sql = """SELECT SUM(crypto_fee) as crypto_fee, SUM(fiat_fee) as fiat_fee FROM `transaction` WHERE crypto_currency=%s and owner_id=%s and transaction_type in ('T','B')""" sql = """SELECT SUM(crypto_fee) as crypto_fee, SUM(fiat_fee) as fiat_fee FROM `transaction` WHERE crypto_currency=%s and owner_id=%s"""
cursor.execute(sql, [crypto, userid]) cursor.execute(sql, [crypto, userid])
fees = cursor.fetchone() fees = cursor.fetchone()
if fees[0]: if fees[0]:
@@ -137,7 +137,10 @@ class Calc:
if bought[0]: if bought[0]:
out["bought_recently"] = bought[0] out["bought_recently"] = bought[0]
amount_within_past_year = Decimal(bought[0]) amount_within_past_year = Decimal(bought[0])
if amount_kept > amount_within_past_year:
amount_available_to_sell = amount_kept - amount_within_past_year amount_available_to_sell = amount_kept - amount_within_past_year
else:
amount_available_to_sell = 0
out["bought_tax_free"] = None out["bought_tax_free"] = None
out["value_tax_free"] = None out["value_tax_free"] = None
if rateEUR: if rateEUR:
+1 -1
View File
@@ -37,7 +37,7 @@ class ImportBtcDe:
if trade['trading_pair'].upper().endswith(f): if trade['trading_pair'].upper().endswith(f):
t.fiat_currency = f t.fiat_currency = f
t.owner = Owner t.owner = Owner
t.crypto_amount = Decimal(trade['amount_currency_to_trade']) t.crypto_amount = Decimal(trade['amount_currency_to_trade'])-Decimal(trade['amount_currency_to_trade'])
t.crypto_fee = Decimal(trade['fee_currency_to_trade']) t.crypto_fee = Decimal(trade['fee_currency_to_trade'])
t.fiat_amount = Decimal(trade['volume_currency_to_pay']) t.fiat_amount = Decimal(trade['volume_currency_to_pay'])
t.fiat_fee = Decimal(trade['fee_currency_to_pay']) t.fiat_fee = Decimal(trade['fee_currency_to_pay'])
@@ -0,0 +1,44 @@
# Generated by Django 3.2.2 on 2021-05-11 20:30
import apps.transactions.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('transactions', '0005_auto_20210511_1638'),
]
operations = [
migrations.AddField(
model_name='transaction',
name='description',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='transaction',
name='crypto_amount',
field=apps.transactions.models.NonscientificDecimalField(blank=True, decimal_places=10, max_digits=24, null=True),
),
migrations.AlterField(
model_name='transaction',
name='crypto_fee',
field=apps.transactions.models.NonscientificDecimalField(blank=True, decimal_places=10, max_digits=24, null=True),
),
migrations.AlterField(
model_name='transaction',
name='exchange_rate',
field=apps.transactions.models.NonscientificDecimalField(decimal_places=10, max_digits=24),
),
migrations.AlterField(
model_name='transaction',
name='fiat_amount',
field=apps.transactions.models.NonscientificDecimalField(blank=True, decimal_places=10, max_digits=24, null=True),
),
migrations.AlterField(
model_name='transaction',
name='fiat_fee',
field=apps.transactions.models.NonscientificDecimalField(blank=True, decimal_places=10, max_digits=24, null=True),
),
]
+1
View File
@@ -40,6 +40,7 @@ class Transaction(models.Model):
fiat_fee = NonscientificDecimalField(max_digits=24, decimal_places=10, null=True, blank=True) fiat_fee = NonscientificDecimalField(max_digits=24, decimal_places=10, null=True, blank=True)
date_valid = models.DateTimeField('date transfered') date_valid = models.DateTimeField('date transfered')
transaction_type = models.CharField(max_length=1, choices=TRANSACTION_TYPES, default='B') transaction_type = models.CharField(max_length=1, choices=TRANSACTION_TYPES, default='B')
description = models.CharField(max_length=100, null=True, blank=True)
class Meta: class Meta:
db_table = "transaction" db_table = "transaction"
+7
View File
@@ -98,6 +98,13 @@
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Description:</label>
<div class="col-sm-4">
{{ form.description }}
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-1 col-form-label"></label> <label class="col-sm-1 col-form-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
+7
View File
@@ -92,6 +92,13 @@
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Description:</label>
<div class="col-sm-4">
{{ form.description }}
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-1 col-form-label"></label> <label class="col-sm-1 col-form-label"></label>
<div class="col-sm-4"> <div class="col-sm-4">
+5
View File
@@ -20,6 +20,11 @@
</thead> </thead>
<tbody> <tbody>
{% for transaction in transactions %} {% for transaction in transactions %}
{% if transaction.description and transaction.description != '' %}
<tr>
<td colspan="5">{{ transaction.description }}:</td>
</tr>
{% endif %}
<tr> <tr>
<td>{{ transaction.date_valid }}</td> <td>{{ transaction.date_valid }}</td>
<td>{{ transaction.crypto_amount|floatformat:3 }} <td>{{ transaction.crypto_amount|floatformat:3 }}