Expanding on billing models
Add module for management/admin frontend
This commit is contained in:
parent
7b463c04ac
commit
0c98928b18
13 changed files with 88 additions and 12 deletions
24
core/migrations/0002_profile.py
Normal file
24
core/migrations/0002_profile.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 4.1 on 2022-08-06 06:56
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Profile',
|
||||||
|
fields=[
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('first_name', models.CharField(max_length=128)),
|
||||||
|
('last_name', models.CharField(max_length=128)),
|
||||||
|
('display_name', models.CharField(max_length=128)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,2 +1,7 @@
|
||||||
from .auth import User
|
from .auth import User
|
||||||
from .profiles import Profile
|
from .profiles import Profile
|
||||||
|
from .businesses import Chain, Restaurant
|
||||||
|
from .geo import Location
|
||||||
|
from .media import Image
|
||||||
|
from .reservation import Reservation
|
||||||
|
from .layout import Room, Table
|
|
@ -1,22 +1,49 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
|
from .profiles import Profile
|
||||||
|
|
||||||
|
|
||||||
class ExpenseTypeChoices(models.IntegerChoices):
|
class ExpenseTypeChoices(models.IntegerChoices):
|
||||||
|
"""Defines different types of expenses
|
||||||
|
"""
|
||||||
MONTHLY_FEE = (0, _("Monthly Fee"))
|
MONTHLY_FEE = (0, _("Monthly Fee"))
|
||||||
SUPPORT = (1, _("Support"))
|
SUPPORT = (1, _("Support"))
|
||||||
DEVELOPMENT = (2, _("Custom Development"))
|
DEVELOPMENT = (2, _("Custom Development"))
|
||||||
COMMISSION = (3, _("Commission"))
|
COMMISSION = (3, _("Commission"))
|
||||||
CONTRIBUTION = (4, _("Contribution"))
|
CONTRIBUTION = (4, _("Contribution"))
|
||||||
|
OTHER = (99, _("Various Expenses"))
|
||||||
|
|
||||||
class RelatedModelChoices(models.IntegerChoices):
|
|
||||||
CHAIN = (0, _("Chain"))
|
|
||||||
RESTAURANT = (1, _("Restaurant"))
|
|
||||||
ROOM = (2, _("Room"))
|
|
||||||
TABLE = (3, _("Table"))
|
|
||||||
|
|
||||||
|
|
||||||
class Expense(models.Model):
|
class Expense(models.Model):
|
||||||
expense_type = models.IntegerField(choices=ExpenseTypeChoices.choices(), null=True, blank=True)
|
"""Contains information on an individual expense to be invoiced
|
||||||
|
|
||||||
|
By relation to an Invoice model, this is simultaneously an invoice item
|
||||||
|
"""
|
||||||
|
expense_type = models.IntegerField(
|
||||||
|
choices=ExpenseTypeChoices.choices, null=True, blank=True)
|
||||||
text = models.CharField(max_length=256)
|
text = models.CharField(max_length=256)
|
||||||
|
payer = models.ForeignKey(Profile, models.PROTECT)
|
||||||
|
|
||||||
|
"""Of course, an Expense needs
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""An activity leading to an expense can have a starting and ending date
|
||||||
|
(the day a reservation was made in case of per-reservation commissions,
|
||||||
|
or the month for which a monthly fee is due) - but this is optional.
|
||||||
|
"""
|
||||||
|
datetime_from = models.DateTimeField(null=True, blank=True)
|
||||||
|
datetime_to = models.DateTimeField(null=True, blank=True)
|
||||||
|
|
||||||
|
"""An expense can be related to any other object in the database – for
|
||||||
|
example, it can be related to a Reservation object for a per-reservation
|
||||||
|
commission, to a Restaurant object for its monthly fee, or to a Profile
|
||||||
|
object for a per-user fee. This also allows easy reverse lookups to find
|
||||||
|
out which expenses have occurred for which object. This is optional.
|
||||||
|
"""
|
||||||
|
object_type = models.ForeignKey(
|
||||||
|
ContentType, on_delete=models.CASCADE, null=True)
|
||||||
|
object_id = models.PositiveIntegerField(null=True, blank=True)
|
||||||
|
related_object = GenericForeignKey('object_type', 'object_id', null=True)
|
||||||
|
|
3
management/admin.py
Normal file
3
management/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
management/apps.py
Normal file
6
management/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ManagementConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'management'
|
0
management/migrations/__init__.py
Normal file
0
management/migrations/__init__.py
Normal file
3
management/models.py
Normal file
3
management/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
3
management/tests.py
Normal file
3
management/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
management/views.py
Normal file
3
management/views.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
|
@ -6,6 +6,7 @@ geopy
|
||||||
django-countries[pyuca]
|
django-countries[pyuca]
|
||||||
pillow
|
pillow
|
||||||
django-phonenumber-field[phonenumbers]
|
django-phonenumber-field[phonenumbers]
|
||||||
|
django-money
|
||||||
|
|
||||||
# For S3
|
# For S3
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,9 @@ INSTALLED_APPS = [
|
||||||
'phonenumber_field',
|
'phonenumber_field',
|
||||||
|
|
||||||
'core',
|
'core',
|
||||||
|
'myrestaurant',
|
||||||
|
'management',
|
||||||
|
'public',
|
||||||
]
|
]
|
||||||
|
|
||||||
AUTH_USER_MODEL = "core.User"
|
AUTH_USER_MODEL = "core.User"
|
||||||
|
@ -51,7 +53,7 @@ ROOT_URLCONF = 'restoroo.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [BASE_DIR / "templates"],
|
'DIRS': [BASE_DIR / "frontend/templates"],
|
||||||
'APP_DIRS': False,
|
'APP_DIRS': False,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
|
|
@ -17,5 +17,4 @@ from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue