Add support for prices on purchases

This commit is contained in:
Lukáš Kucharczyk 2023-02-18 20:53:47 +01:00
parent d4ab0596da
commit 755093845d
4 changed files with 34 additions and 1 deletions

View File

@ -1,5 +1,6 @@
## Unreleased
* Add support for purchase prices
* Add support for game editions (https://git.kucharczyk.xyz/lukas/timetracker/issues/28)
## 1.0.1 / 2023-01-30 22:17+01:00

View File

@ -25,7 +25,14 @@ class PurchaseForm(forms.ModelForm):
class Meta:
model = Purchase
fields = ["edition", "platform", "date_purchased", "date_refunded"]
fields = [
"edition",
"platform",
"date_purchased",
"date_refunded",
"price",
"price_currency",
]
class EditionForm(forms.ModelForm):

View File

@ -0,0 +1,23 @@
# Generated by Django 4.1.5 on 2023-02-18 19:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("games", "0011_rename_game_purchase_edition"),
]
operations = [
migrations.AddField(
model_name="purchase",
name="price",
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name="purchase",
name="price_currency",
field=models.CharField(default="USD", max_length=3),
),
]

View File

@ -30,6 +30,8 @@ class Purchase(models.Model):
platform = models.ForeignKey("Platform", on_delete=models.CASCADE)
date_purchased = models.DateField()
date_refunded = models.DateField(blank=True, null=True)
price = models.IntegerField(default=0)
price_currency = models.CharField(max_length=3, default="USD")
def __str__(self):
return f"{self.edition} ({self.platform})"