Skip to content

Commit

Permalink
feat: add invoice category
Browse files Browse the repository at this point in the history
This is useful for reporting.
  • Loading branch information
nijel committed Oct 23, 2024
1 parent c353506 commit da22d93
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions weblate_web/invoices/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class InvoiceItemAdmin(admin.TabularInline):
class InvoiceAdmin(admin.ModelAdmin):
date_hierarchy = "issue_date"
autocomplete_fields = ("customer",)
list_display = ("number", "kind", "customer", "total_amount")
list_filter = ["kind"]
list_display = ("number", "kind", "category", "customer", "total_amount")
list_filter = ["kind", "category"]
search_fields = (
"customer__name",
"number",
Expand Down
25 changes: 25 additions & 0 deletions weblate_web/invoices/migrations/0008_invoice_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.1.2 on 2024-10-23 13:36

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("invoices", "0007_invoice_number"),
]

operations = [
migrations.AddField(
model_name="invoice",
name="category",
field=models.IntegerField(
choices=[
(1, "Hosting"),
(2, "Support"),
(3, "Development"),
(4, "Donation"),
],
default=1,
),
),
]
10 changes: 10 additions & 0 deletions weblate_web/invoices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ class InvoiceKind(models.IntegerChoices):
QUOTE = 90, "Quote"


class InvoiceCategory(models.IntegerChoices):
HOSTING = 1, "Hosting"
SUPPORT = 2, "Support"
DEVEL = 3, "Development"
DONATE = 4, "Donation"


class Discount(models.Model):
description = models.CharField(max_length=200, unique=True)
percents = models.IntegerField(
Expand Down Expand Up @@ -109,6 +116,9 @@ class Invoice(models.Model):
issue_date = models.DateField(default=datetime.date.today)
due_date = models.DateField(blank=True)
kind = models.IntegerField(choices=InvoiceKind)
category = models.IntegerField(
choices=InvoiceCategory, default=InvoiceCategory.HOSTING
)
customer = models.ForeignKey("payments.Customer", on_delete=models.deletion.PROTECT)
customer_reference = models.CharField(max_length=100, blank=True)
discount = models.ForeignKey(
Expand Down

0 comments on commit da22d93

Please sign in to comment.