diff --git a/apps/treasury/__init__.py b/apps/treasury/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/treasury/api/__init__.py b/apps/treasury/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/treasury/apps.py b/apps/treasury/apps.py new file mode 100644 index 00000000..5f7f6dc9 --- /dev/null +++ b/apps/treasury/apps.py @@ -0,0 +1,11 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django.apps import AppConfig +from django.db.models.signals import pre_save, post_save, post_delete +from django.utils.translation import gettext_lazy as _ + + +class TreasuryConfig(AppConfig): + name = 'treasury' + verbose_name = _('Treasury') diff --git a/apps/treasury/migrations/__init__.py b/apps/treasury/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/treasury/models.py b/apps/treasury/models.py new file mode 100644 index 00000000..51974ec0 --- /dev/null +++ b/apps/treasury/models.py @@ -0,0 +1,113 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django.db import models +from django.utils.translation import gettext_lazy as _ + + +class Billing(models.Model): + id = models.PositiveIntegerField( + primary_key=True, + verbose_name=_("Billing identifier"), + ) + + subject = models.CharField( + max_length=255, + verbose_name=_("Subject"), + ) + + description = models.TextField( + verbose_name=_("Description") + ) + + name = models.CharField( + max_length=255, + verbose_name=_("Name"), + ) + + address = models.TextField( + verbose_name=_("Address"), + ) + + date = models.DateField( + auto_now_add=True, + verbose_name=_("Place"), + ) + + acquitted = models.BooleanField( + verbose_name=_("Acquitted"), + ) + + place = models.CharField( + max_length=255, + default="Cachan", + verbose_name=_("Place"), + ) + + my_name = models.CharField( + max_length=255, + default="BDE ENS Cachan", + verbose_name=_("My name"), + ) + + my_address_street = models.CharField( + max_length=255, + default="61 avenue du Président Wilson", + verbose_name=_("My street address"), + ) + + my_city = models.CharField( + max_length=255, + default="94230 Cachan", + verbose_name=_("My city"), + ) + + bank_code = models.IntegerField( + default=30003, + verbose_name=_("Bank code"), + ) + + desk_code = models.IntegerField( + default=3894, + verbose_name=_("Desk code"), + ) + + account_number = models.IntegerField( + default=37280662, + verbose_name=_("Account number"), + ) + + rib_key = models.SmallIntegerField( + default=14, + verbose_name=_("RIB Key") + ) + + bic = models.CharField( + max_length=16, + default="SOGEFRPP", + verbose_name=_("BIC Code") + ) + + +class Product(models.Model): + billing = models.ForeignKey( + Billing, + on_delete=models.PROTECT, + ) + + designation = models.CharField( + max_length=255, + verbose_name=_("Designation"), + ) + + quantity = models.PositiveIntegerField( + verbose_name=_("Quantity") + ) + + amount = models.PositiveIntegerField( + verbose_name=_("Unit price") + ) + + @property + def total(self): + return self.quantity * self.amount diff --git a/apps/treasury/tables.py b/apps/treasury/tables.py new file mode 100644 index 00000000..b0b4f1db --- /dev/null +++ b/apps/treasury/tables.py @@ -0,0 +1,20 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django_tables2 import tables + +from .models import Billing + + +class BillingTable(tables.Table): + class Meta: + attrs = { + 'class': 'table table-condensed table-striped table-hover' + } + model = Billing + template_name = 'django_tables2/bootstrap4.html' + fields = ('id', 'name', 'subject', 'acquitted', ) + row_attrs = { + 'class': 'table-row', + 'data-href': lambda record: record.pk + } \ No newline at end of file diff --git a/apps/treasury/urls.py b/apps/treasury/urls.py new file mode 100644 index 00000000..7cd68ec0 --- /dev/null +++ b/apps/treasury/urls.py @@ -0,0 +1,11 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django.urls import path + +from .views import BillingListView + +app_name = 'treasury' +urlpatterns = [ + path('billing/', BillingListView.as_view(), name='billing'), +] diff --git a/apps/treasury/views.py b/apps/treasury/views.py new file mode 100644 index 00000000..435f8cdb --- /dev/null +++ b/apps/treasury/views.py @@ -0,0 +1,16 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django.contrib.auth.mixins import LoginRequiredMixin +from django_tables2 import SingleTableView + +from .models import Billing +from .tables import BillingTable + + +class BillingListView(LoginRequiredMixin, SingleTableView): + """ + List existing Billings + """ + model = Billing + table_class = BillingTable diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 0694390d..d85071c5 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -61,6 +61,7 @@ INSTALLED_APPS = [ 'activity', 'member', 'note', + 'treasury', 'api', 'logs', ] diff --git a/note_kfet/urls.py b/note_kfet/urls.py index da2f9d6c..80808bbe 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -13,6 +13,7 @@ urlpatterns = [ # Include project routers path('note/', include('note.urls')), + path('treasury/', include('treasury.urls')), # Include Django Contrib and Core routers path('i18n/', include('django.conf.urls.i18n')), diff --git a/templates/base.html b/templates/base.html index d57dab89..88ad67f9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -81,6 +81,9 @@ SPDX-License-Identifier: GPL-3.0-or-later