Expanding on billing models

Add module for management/admin frontend
This commit is contained in:
Kumi 2022-08-08 09:38:37 +00:00
parent 7b463c04ac
commit 0c98928b18
Signed by: kumi
GPG key ID: ECBCC9082395383F
13 changed files with 88 additions and 12 deletions

View 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)),
],
),
]

View file

@ -1,2 +1,7 @@
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

View file

@ -1,22 +1,49 @@
from django.db import models
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):
"""Defines different types of expenses
"""
MONTHLY_FEE = (0, _("Monthly Fee"))
SUPPORT = (1, _("Support"))
DEVELOPMENT = (2, _("Custom Development"))
COMMISSION = (3, _("Commission"))
CONTRIBUTION = (4, _("Contribution"))
class RelatedModelChoices(models.IntegerChoices):
CHAIN = (0, _("Chain"))
RESTAURANT = (1, _("Restaurant"))
ROOM = (2, _("Room"))
TABLE = (3, _("Table"))
OTHER = (99, _("Various Expenses"))
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)
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
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
management/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ManagementConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'management'

View file

3
management/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
management/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
management/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -6,6 +6,7 @@ geopy
django-countries[pyuca]
pillow
django-phonenumber-field[phonenumbers]
django-money
# For S3

View file

@ -30,7 +30,9 @@ INSTALLED_APPS = [
'phonenumber_field',
'core',
'myrestaurant',
'management',
'public',
]
AUTH_USER_MODEL = "core.User"
@ -51,7 +53,7 @@ ROOT_URLCONF = 'restoroo.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / "templates"],
'DIRS': [BASE_DIR / "frontend/templates"],
'APP_DIRS': False,
'OPTIONS': {
'context_processors': [

View file

@ -17,5 +17,4 @@ from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]