mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
add a TransactionType model
This commit is contained in:
parent
f3ec0836f8
commit
126686ab03
@ -7,7 +7,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin, \
|
||||
PolymorphicChildModelFilter, PolymorphicParentModelAdmin
|
||||
|
||||
from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .models.transactions import Transaction, TransactionCategory, TransactionTemplate
|
||||
from .models.transactions import Transaction, TransactionCategory, TransactionTemplate, TransactionType
|
||||
|
||||
|
||||
class AliasInlines(admin.TabularInline):
|
||||
@ -161,3 +161,11 @@ class TransactionCategoryAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
list_display = ('name', )
|
||||
list_filter = ('name', )
|
||||
|
||||
@admin.register(TransactionType)
|
||||
class TransactionTypeAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Admin customisation for TransactionTemplate
|
||||
"""
|
||||
list_display = ('name', )
|
||||
list_filter = ('name', )
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
from .notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .transactions import MembershipTransaction, Transaction, \
|
||||
TransactionCategory, TransactionTemplate
|
||||
TransactionCategory, TransactionTemplate, TransactionType
|
||||
|
||||
__all__ = [
|
||||
# Notes
|
||||
'Alias', 'Note', 'NoteClub', 'NoteSpecial', 'NoteUser',
|
||||
# Transactions
|
||||
'MembershipTransaction', 'Transaction', 'TransactionCategory', 'TransactionTemplate',
|
||||
'MembershipTransaction', 'Transaction', 'TransactionCategory', 'TransactionTemplate','TransactionType',
|
||||
]
|
||||
|
@ -76,6 +76,26 @@ class TransactionTemplate(models.Model):
|
||||
return reverse('note:template_update', args=(self.pk, ))
|
||||
|
||||
|
||||
class TransactionType(models.Model):
|
||||
"""
|
||||
Defined a recurrent transaction category
|
||||
|
||||
Example: food, softs, ...
|
||||
"""
|
||||
name = models.CharField(
|
||||
verbose_name=_("name"),
|
||||
max_length=31,
|
||||
unique=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("transaction type")
|
||||
verbose_name_plural = _("transaction types")
|
||||
|
||||
def __str__(self):
|
||||
return str(self.name)
|
||||
|
||||
|
||||
class Transaction(models.Model):
|
||||
"""
|
||||
General transaction between two :model:`note.Note`
|
||||
@ -107,7 +127,9 @@ class Transaction(models.Model):
|
||||
default=1,
|
||||
)
|
||||
amount = models.PositiveIntegerField(verbose_name=_('amount'), )
|
||||
transaction_type = models.CharField(
|
||||
transaction_type = models.ForeignKey(
|
||||
TransactionType,
|
||||
on_delete=models.PROTECT,
|
||||
verbose_name=_('type'),
|
||||
max_length=31,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user