gold eggs backend
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s

This commit is contained in:
2026-04-15 08:59:36 +02:00
commit ab73d05ecc
359 changed files with 14415 additions and 0 deletions

View File

211
core/apps/eggs/admin.py Normal file
View File

@@ -0,0 +1,211 @@
"""
Dajngo admin panel models register
"""
from django.contrib import admin
from core.apps.eggs import models
from core.apps.eggs.models.notification import Notification
@admin.register(models.Courier)
class CourierAdmin(admin.ModelAdmin):
list_display = ["id", "user_id", "courier_name"]
def courier_name(self, obj):
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
@admin.register(models.CourierProduct)
class CourierProductAdmin(admin.ModelAdmin):
list_display = [
"id",
"courier_id",
"group_id",
"count",
"return_eggs",
"created_at",
]
@admin.register(models.CourierHistory)
class CourierHistoryAdmin(admin.ModelAdmin):
list_display = [
"id",
"courier_id",
"group_id",
"get_eggs",
"return_eggs",
"broken_eggs",
"date",
"courier_product_id",
]
@admin.register(models.Group)
class GroupAdmin(admin.ModelAdmin):
list_display = [
"id",
"product_id",
"party_id",
"entry_price",
"unit_price",
"wholesale_price",
"quantity",
"broken_eggs",
]
@admin.register(models.Invoice)
class InvoiceAdmin(admin.ModelAdmin):
list_display = ["id", "name", "price", "party_id"]
@admin.register(models.Location)
class LocationAdmin(admin.ModelAdmin):
list_display = ["id", "long", "lat", "label"]
@admin.register(models.Market)
class MarketAdmin(admin.ModelAdmin):
list_display = [
"id",
"name",
"company_name",
"user_id",
"phone",
"debt_paid",
"debt_unpaid",
]
@admin.register(models.Order)
class OrderAdmin(admin.ModelAdmin):
list_display = [
"id",
"courier_id",
"market_id",
"data",
"status",
"price",
"price_paid",
"debt",
]
@admin.register(models.OrderItems)
class OrderItemsAdmin(admin.ModelAdmin):
list_display = [
"id",
"group_id",
"count",
"discount",
"courier_product_id",
"order_id",
"sale_type",
]
@admin.register(models.Party)
class PartAdmin(admin.ModelAdmin):
list_display = [
"id",
"user_id",
"count",
"sold_count",
"remaining_count",
"benefit",
"cost",
"total_cost",
]
@admin.register(models.Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ["id", "name"]
@admin.register(models.Broken)
class BrokenAdmin(admin.ModelAdmin):
list_display = ["id", "group", "comment", "quantity", "user"]
def user(self, obj):
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
@admin.register(models.Debt)
class DebtAdmin(admin.ModelAdmin):
list_display = ["id", "market", "debt_price"]
@admin.register(models.History)
class HistoryAdmin(admin.ModelAdmin):
list_display = [
"id",
"content_type",
"object_id",
"action",
"timestamp",
"created_by",
"created_who",
"reason",
"comment",
]
# @admin.register(models.AllHistory)
# class AllHistoryAdmin(admin.ModelAdmin):
# list_display = [
# "id",
# "content_type",
# "object_id",
# "action",
# "timestamp",
# "created_by",
# "created_who",
# "reason",
# ]
@admin.register(models.AdditionalCost)
class AdditionalCostAdmin(admin.ModelAdmin):
list_display = ["id", "user", "reason", "price", "created_at"]
readonly_fields = ["created_at"]
def user(self, obj):
return f"{obj.user.first_name} {obj.user.last_name}"
@admin.register(models.Sklad)
class SkladAdmin(admin.ModelAdmin):
list_display = ["id", "user_id"]
def user_id(self, obj):
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
@admin.register(models.Monitoring)
class MonitoringAdmin(admin.ModelAdmin):
list_display = [
"id",
"content_type",
"object_id",
"action",
"timestamp",
"created_by",
"created_who",
"reason",
"comment",
"price",
]
@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
list_display = ("title", "body", "user", "is_read", "is_sending")
@admin.register(models.DailyCost)
class DailyCostAdmin(admin.ModelAdmin):
list_display = ["id", "first_cost", "second_cost", "third_cost", "created_at"]
readonly_fields = ["created_at"]

9
core/apps/eggs/apps.py Normal file
View File

@@ -0,0 +1,9 @@
from django.apps import AppConfig
class EggsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "core.apps.eggs"
def ready(self) -> None:
from core.apps.eggs import utils # noqa

View File

@@ -0,0 +1,435 @@
# Generated by Django 5.0.4 on 2024-04-23 08:54
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Group",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"entry_price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"unit_price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"wholesale_price",
models.DecimalField(decimal_places=2, max_digits=10),
),
("quantity", models.IntegerField()),
("broken_eggs", models.IntegerField()),
],
options={
"verbose_name": "Group",
"verbose_name_plural": "Groups",
"db_table": "group",
},
),
migrations.CreateModel(
name="Location",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("long", models.BigIntegerField()),
("lat", models.BigIntegerField()),
("label", models.TextField()),
],
options={
"verbose_name": "Location",
"verbose_name_plural": "Locations",
"db_table": "location",
},
),
migrations.CreateModel(
name="Product",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=255)),
],
options={
"verbose_name": "Product",
"verbose_name_plural": "Products",
"db_table": "product",
},
),
migrations.CreateModel(
name="Courier",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"user_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="couriers",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Courier",
"verbose_name_plural": "Couriers",
"db_table": "courier",
},
),
migrations.CreateModel(
name="CourierProduct",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("count", models.IntegerField()),
(
"courier_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="courier_products",
to="eggs.courier",
),
),
(
"group_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="courier_groups",
to="eggs.group",
),
),
],
options={
"verbose_name": "CourierProduct",
"verbose_name_plural": "CourierProducts",
"db_table": "courier_product",
},
),
migrations.CreateModel(
name="Market",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("name", models.CharField(max_length=255)),
(
"avatar",
models.ImageField(
blank=True, null=True, upload_to="market_avatar/"
),
),
("phone", models.CharField(max_length=20)),
(
"location",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="market_location",
to="eggs.location",
),
),
(
"user_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Market",
"verbose_name_plural": "Markets",
"db_table": "market",
},
),
migrations.CreateModel(
name="Order",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("data", models.DateField(auto_now=True)),
(
"status",
models.CharField(
choices=[
("delivery", "Delivery"),
("pending", "Pending"),
("success", "Success"),
("cancel", "Cancel"),
("done", "Done"),
],
default="pending",
max_length=255,
),
),
("comment", models.TextField(blank=True, null=True)),
(
"price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"price_paid",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"courier_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="orders",
to="eggs.courier",
),
),
(
"location_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eggs.location",
),
),
(
"market_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="orders",
to="eggs.market",
),
),
],
options={
"verbose_name": "Order",
"verbose_name_plural": "Orders",
"db_table": "order",
},
),
migrations.CreateModel(
name="Party",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"user_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="parties",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Party",
"verbose_name_plural": "Parties",
"db_table": "party",
},
),
migrations.CreateModel(
name="Invoice",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=256)),
(
"price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"party_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="invoices",
to="eggs.party",
),
),
],
options={
"verbose_name": "Invoice",
"verbose_name_plural": "Invoices",
"db_table": "invoice",
},
),
migrations.AddField(
model_name="group",
name="party_id",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="eggs.party"
),
),
migrations.CreateModel(
name="CourierHistory",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("get_eggs", models.IntegerField()),
("return_eggs", models.IntegerField(blank=True, null=True)),
("broken_eggs", models.IntegerField(blank=True, null=True)),
("date", models.DateField(auto_now=True, null=True)),
(
"group_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eggs.group",
),
),
(
"courier_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="courier_histories",
to="eggs.party",
),
),
],
options={
"verbose_name": "CourierHistory",
"verbose_name_plural": "CourierHistories",
"db_table": "courier_history",
},
),
migrations.CreateModel(
name="OrderItems",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("count", models.IntegerField()),
("discount", models.IntegerField()),
(
"courier_product_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eggs.courierproduct",
),
),
(
"product_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eggs.product",
),
),
],
options={
"verbose_name": "OrderItem",
"verbose_name_plural": "OrderItems",
"db_table": "order_item",
},
),
migrations.AddField(
model_name="group",
name="product_id",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="groups",
to="eggs.product",
),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-04-23 10:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0001_initial"),
]
operations = [
migrations.RenameField(
model_name="market",
old_name="location",
new_name="location_id",
),
]

View File

@@ -0,0 +1,29 @@
# Generated by Django 5.0.4 on 2024-04-23 11:39
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0002_rename_location_market_location_id"),
]
operations = [
migrations.RemoveField(
model_name="group",
name="party_id",
),
migrations.AddField(
model_name="group",
name="party",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="groups",
to="eggs.party",
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-04-23 11:39
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0003_remove_group_party_id_group_party"),
]
operations = [
migrations.RenameField(
model_name="group",
old_name="product_id",
new_name="product",
),
]

View File

@@ -0,0 +1,33 @@
# Generated by Django 5.0.4 on 2024-04-23 11:55
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0004_rename_product_id_group_product"),
]
operations = [
migrations.RenameField(
model_name="group",
old_name="product",
new_name="product_id",
),
migrations.RemoveField(
model_name="group",
name="party",
),
migrations.AddField(
model_name="group",
name="party_id",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
to="eggs.party",
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,48 @@
# Generated by Django 5.0.4 on 2024-04-24 07:17
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0005_rename_product_group_product_id_remove_group_party_and_more",
),
]
operations = [
migrations.AddField(
model_name="party",
name="count",
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name="party",
name="sold",
field=models.DecimalField(
decimal_places=2, default=1, max_digits=10
),
preserve_default=False,
),
migrations.AddField(
model_name="party",
name="sold_price",
field=models.DecimalField(
decimal_places=2, default=1, max_digits=10
),
preserve_default=False,
),
migrations.AlterField(
model_name="group",
name="party_id",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="groups",
to="eggs.party",
),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.4 on 2024-04-24 12:46
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0006_party_count_party_sold_party_sold_price_and_more"),
]
operations = [
migrations.AlterField(
model_name="courierhistory",
name="courier_id",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="courier_histories",
to="eggs.courier",
),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.4 on 2024-04-24 10:51
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0006_party_count_party_sold_party_sold_price_and_more"),
]
operations = [
migrations.AddField(
model_name="orderitems",
name="order_id",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="order_items",
to="eggs.order",
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,13 @@
# Generated by Django 5.0.4 on 2024-04-24 12:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0007_alter_courierhistory_courier_id"),
("eggs", "0007_orderitems_order_id"),
]
operations = []

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-05-01 06:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0008_merge_20240424_1752"),
]
operations = [
migrations.AlterField(
model_name="party",
name="sold",
field=models.IntegerField(),
),
]

View File

@@ -0,0 +1,61 @@
# Generated by Django 5.0.4 on 2024-05-02 11:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0009_alter_party_sold"),
]
operations = [
migrations.AddField(
model_name="orderitems",
name="sale_type",
field=models.CharField(
choices=[("optom", "Optom"), ("dona", "Dona")],
default=1,
max_length=10,
),
preserve_default=False,
),
migrations.AlterField(
model_name="order",
name="price",
field=models.DecimalField(
decimal_places=2, default=0.0, max_digits=10
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
decimal_places=2, default=0.0, max_digits=10
),
),
migrations.AlterField(
model_name="party",
name="count",
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name="party",
name="price",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
migrations.AlterField(
model_name="party",
name="sold",
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name="party",
name="sold_price",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.4 on 2024-05-02 12:08
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0010_orderitems_sale_type_alter_order_price_and_more"),
]
operations = [
migrations.AlterField(
model_name="order",
name="courier_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="orders",
to="eggs.courier",
),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-05-03 07:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0011_alter_order_courier_id"),
]
operations = [
migrations.AlterField(
model_name="order",
name="data",
field=models.DateField(),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.4 on 2024-05-03 07:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0012_alter_order_data"),
]
operations = [
migrations.AlterField(
model_name="order",
name="data",
field=models.DateTimeField(auto_now_add=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.4 on 2024-05-03 10:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0013_alter_order_data"),
]
operations = [
migrations.AddField(
model_name="group",
name="date",
field=models.DateTimeField(auto_now=True),
),
migrations.AddField(
model_name="group",
name="name",
field=models.CharField(blank=True, max_length=255, null=True),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.4 on 2024-05-03 12:27
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0014_group_date_group_name"),
]
operations = [
migrations.AlterField(
model_name="group",
name="party_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="groups",
to="eggs.party",
),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0.4 on 2024-05-07 12:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0015_alter_group_party_id"),
]
operations = [
migrations.AddField(
model_name="market",
name="company_name",
field=models.CharField(default=1, max_length=255),
preserve_default=False,
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.4 on 2024-05-07 12:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0016_market_company_name"),
]
operations = [
migrations.AlterField(
model_name="location",
name="lat",
field=models.BigIntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name="location",
name="long",
field=models.BigIntegerField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.4 on 2024-05-08 09:24
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0017_alter_location_lat_alter_location_long"),
]
operations = [
migrations.AlterField(
model_name="order",
name="market_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="orders",
to="eggs.market",
),
),
]

View File

@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-05-08 12:14
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0018_alter_order_market_id"),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="courier_product_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="eggs.courierproduct",
),
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.6 on 2024-05-08 12:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0019_alter_orderitems_courier_product_id"),
]
operations = [
migrations.AlterField(
model_name="location",
name="lat",
field=models.DecimalField(
blank=True, decimal_places=25, max_digits=35, null=True
),
),
migrations.AlterField(
model_name="location",
name="long",
field=models.DecimalField(
blank=True, decimal_places=25, max_digits=35, null=True
),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-05-08 12:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0020_alter_location_lat_alter_location_long"),
]
operations = [
migrations.AlterField(
model_name="location",
name="lat",
field=models.BigIntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name="location",
name="long",
field=models.BigIntegerField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-05-08 12:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0021_alter_location_lat_alter_location_long"),
]
operations = [
migrations.AlterField(
model_name="location",
name="lat",
field=models.FloatField(blank=True, null=True),
),
migrations.AlterField(
model_name="location",
name="long",
field=models.FloatField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,42 @@
# Generated by Django 5.0.6 on 2024-05-08 13:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0022_alter_location_lat_alter_location_long"),
]
operations = [
migrations.CreateModel(
name="Broken",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("comment", models.TextField(verbose_name="Comment")),
("quantity", models.IntegerField(verbose_name="Quantity")),
(
"product",
models.ManyToManyField(
related_name="brokens", to="eggs.product"
),
),
],
options={
"verbose_name": "Broken",
"verbose_name_plural": "Brokens",
"db_table": "broken",
},
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-05-08 14:28
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0023_broken"),
]
operations = [
migrations.AddField(
model_name="broken",
name="group",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="brokens",
to="eggs.group",
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-05-08 14:50
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0024_broken_group"),
]
operations = [
migrations.RemoveField(
model_name="broken",
name="product",
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.6 on 2024-05-10 11:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0025_remove_broken_product"),
]
operations = [
migrations.AddField(
model_name="market",
name="debt_paid",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
migrations.AddField(
model_name="market",
name="debt_unpaid",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
]

View File

@@ -0,0 +1,53 @@
# Generated by Django 5.0.6 on 2024-05-10 12:27
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0026_market_debt_paid_market_debt_unpaid"),
]
operations = [
migrations.RemoveField(
model_name="orderitems",
name="product_id",
),
migrations.AddField(
model_name="orderitems",
name="group_id",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
to="eggs.group",
),
preserve_default=False,
),
migrations.CreateModel(
name="Debt",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"debt_price",
models.DecimalField(decimal_places=2, max_digits=10),
),
(
"market",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="eggs.market",
),
),
],
),
]

View File

@@ -0,0 +1,21 @@
# Generated by Django 5.0.6 on 2024-05-10 13:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0027_remove_orderitems_product_id_orderitems_group_id_and_more",
),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="discount",
field=models.IntegerField(blank=True, default=0, null=True),
),
]

View File

@@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2024-05-10 14:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0028_alter_orderitems_discount"),
]
operations = [
migrations.AddField(
model_name="order",
name="debt",
field=models.DecimalField(
decimal_places=2, default=0.0, max_digits=10
),
),
]

View File

@@ -0,0 +1,94 @@
# Generated by Django 5.0.6 on 2024-05-11 07:58
import django.core.validators
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("eggs", "0029_order_debt"),
]
operations = [
migrations.AlterField(
model_name="courierproduct",
name="count",
field=models.PositiveIntegerField(),
),
migrations.AlterField(
model_name="group",
name="broken_eggs",
field=models.IntegerField(
validators=[django.core.validators.MinValueValidator(0)]
),
),
migrations.AlterField(
model_name="group",
name="quantity",
field=models.IntegerField(
validators=[django.core.validators.MinValueValidator(0)]
),
),
migrations.AlterField(
model_name="market",
name="debt_paid",
field=models.DecimalField(
decimal_places=2,
default=0,
max_digits=10,
validators=[django.core.validators.MinValueValidator(0)],
),
),
migrations.AlterField(
model_name="market",
name="debt_unpaid",
field=models.DecimalField(
decimal_places=2,
default=0,
max_digits=10,
validators=[django.core.validators.MinValueValidator(0)],
),
),
migrations.CreateModel(
name="History",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("object_id", models.PositiveIntegerField()),
("action", models.CharField(max_length=255)),
("timestamp", models.DateTimeField(auto_now_add=True)),
(
"created_by",
models.CharField(blank=True, max_length=255, null=True),
),
(
"created_who",
models.CharField(blank=True, max_length=255, null=True),
),
(
"reason",
models.CharField(blank=True, max_length=255, null=True),
),
(
"content_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="contenttypes.contenttype",
),
),
],
options={
"ordering": ["-timestamp"],
},
),
]

View File

@@ -0,0 +1,30 @@
# Generated by Django 5.0.6 on 2024-05-11 09:51
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0030_alter_courierproduct_count_alter_group_broken_eggs_and_more",
),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name="broken",
name="user_id",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="broken_eggs",
to=settings.AUTH_USER_MODEL,
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2024-05-11 10:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0031_broken_user_id"),
]
operations = [
migrations.AddField(
model_name="history",
name="avatar",
field=models.ImageField(
blank=True, null=True, upload_to="history_avatars/"
),
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.6 on 2024-05-11 11:23
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0032_history_avatar"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name="broken",
name="user_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="broken_eggs",
to=settings.AUTH_USER_MODEL,
),
),
]

View File

@@ -0,0 +1,54 @@
# Generated by Django 5.0.6 on 2024-05-11 13:01
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("eggs", "0033_alter_broken_user_id"),
]
operations = [
migrations.CreateModel(
name="AllHistory",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("object_id", models.PositiveIntegerField()),
(
"action",
models.CharField(blank=True, max_length=255, null=True),
),
("timestamp", models.DateTimeField(auto_now_add=True)),
(
"created_by",
models.CharField(blank=True, max_length=255, null=True),
),
(
"created_who",
models.CharField(blank=True, max_length=255, null=True),
),
("reason", models.TextField(blank=True, null=True)),
(
"content_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="contenttypes.contenttype",
),
),
],
options={
"ordering": ["-timestamp"],
},
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-05-11 14:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0034_allhistory"),
]
operations = [
migrations.AddField(
model_name="history",
name="comment",
field=models.CharField(blank=True, max_length=255, null=True),
),
]

View File

@@ -0,0 +1,33 @@
# Generated by Django 5.0.6 on 2024-05-15 10:43
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0035_history_comment"),
]
operations = [
migrations.AddField(
model_name="courierproduct",
name="return_eggs",
field=models.IntegerField(
blank=True,
default=0,
null=True,
validators=[django.core.validators.MinValueValidator(0)],
verbose_name="Return eggs",
),
),
migrations.AlterField(
model_name="courierproduct",
name="count",
field=models.IntegerField(
validators=[django.core.validators.MinValueValidator(0)],
verbose_name="Count of eggs",
),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-05-16 06:32
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0036_courierproduct_return_eggs_and_more"),
]
operations = [
migrations.AddField(
model_name="courierhistory",
name="courier_product_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="courier_histories",
to="eggs.courierproduct",
),
),
]

View File

@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-05-16 13:29
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0037_courierhistory_courier_product_id"),
]
operations = [
migrations.AlterField(
model_name="courierhistory",
name="courier_product_id",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="courier_histories",
to="eggs.courierproduct",
),
),
]

View File

@@ -0,0 +1,33 @@
# Generated by Django 5.0.6 on 2024-05-16 13:37
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0038_alter_courierhistory_courier_product_id"),
]
operations = [
migrations.AlterField(
model_name="courierhistory",
name="courier_product_id",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="courier_histories",
to="eggs.courierproduct",
),
),
migrations.AlterField(
model_name="courierhistory",
name="group_id",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="eggs.group",
),
),
]

View File

@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-06-19 10:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0039_alter_courierhistory_courier_product_id_and_more"),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="discount",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=5,
null=True,
),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-06-20 06:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0040_alter_orderitems_discount"),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="discount",
field=models.IntegerField(blank=True, default=0, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-06-21 10:53
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0041_alter_orderitems_discount"),
]
operations = [
migrations.AlterField(
model_name="order",
name="location_id",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="eggs.location",
),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-06-21 10:58
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0042_alter_order_location_id"),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="group_id",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="eggs.group",
),
),
]

View File

@@ -0,0 +1,64 @@
# Generated by Django 5.0.6 on 2024-06-26 09:41
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0043_alter_orderitems_group_id"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="AdditionalCost",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"name",
models.CharField(max_length=255, verbose_name="Name"),
),
(
"price",
models.DecimalField(
decimal_places=2, max_digits=10, verbose_name="Price"
),
),
(
"created_at",
models.DateTimeField(
auto_now_add=True, verbose_name="Created at"
),
),
(
"updated_at",
models.DateTimeField(
auto_now=True, verbose_name="Updated at"
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
verbose_name="User",
),
),
],
options={
"verbose_name": "Additional cost",
"verbose_name_plural": "Additional costs",
},
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.6 on 2024-06-26 09:57
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0044_additionalcost"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name="additionalcost",
name="user",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
verbose_name="User",
),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-06-26 10:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0045_alter_additionalcost_user"),
]
operations = [
migrations.RemoveField(
model_name="additionalcost",
name="name",
),
migrations.AddField(
model_name="additionalcost",
name="reason",
field=models.TextField(default=1, verbose_name="Name"),
preserve_default=False,
),
]

View File

@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-06-26 12:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0046_remove_additionalcost_name_additionalcost_reason"),
]
operations = [
migrations.AlterField(
model_name="orderitems",
name="discount",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0.0,
max_digits=10,
null=True,
),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-06-27 06:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0047_alter_orderitems_discount"),
]
operations = [
migrations.AddField(
model_name="order",
name="count",
field=models.IntegerField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,44 @@
# Generated by Django 5.0.6 on 2024-06-27 12:49
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0048_order_count"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Sklad",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"user_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="sklad",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name_plural": "Sklad",
"db_table": "sklad",
},
),
]

View File

@@ -0,0 +1,34 @@
# Generated by Django 5.0.6 on 2024-06-28 05:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0049_sklad"),
]
operations = [
migrations.AlterField(
model_name="order",
name="debt",
field=models.DecimalField(
blank=True, decimal_places=2, max_digits=10, null=True
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
blank=True, decimal_places=2, max_digits=10, null=True
),
),
migrations.AlterField(
model_name="orderitems",
name="discount",
field=models.DecimalField(
blank=True, decimal_places=2, max_digits=10, null=True
),
),
]

View File

@@ -0,0 +1,30 @@
# Generated by Django 5.0.6 on 2024-06-28 05:36
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0050_alter_order_debt_alter_order_price_paid_and_more"),
]
operations = [
migrations.AlterField(
model_name="group",
name="broken_eggs",
field=models.IntegerField(
default=0,
validators=[django.core.validators.MinValueValidator(0)],
),
),
migrations.AlterField(
model_name="group",
name="quantity",
field=models.IntegerField(
default=0,
validators=[django.core.validators.MinValueValidator(0)],
),
),
]

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2024-06-28 09:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0051_alter_group_broken_eggs_alter_group_quantity"),
]
operations = [
migrations.AlterField(
model_name="order",
name="status",
field=models.CharField(
choices=[
("pending", "Pending"),
("delivery", "Delivery"),
("success", "Success"),
("done", "Done"),
("cancel", "Cancel"),
],
default="pending",
max_length=255,
),
),
]

View File

@@ -0,0 +1,29 @@
# Generated by Django 5.0.6 on 2024-06-28 10:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0052_alter_order_status"),
]
operations = [
migrations.AddField(
model_name="order",
name="status_was",
field=models.CharField(
blank=True,
choices=[
("pending", "Pending"),
("delivery", "Delivery"),
("success", "Success"),
("done", "Done"),
("cancel", "Cancel"),
],
max_length=255,
null=True,
),
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-06-28 10:13
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0053_order_status_was"),
]
operations = [
migrations.RemoveField(
model_name="order",
name="status_was",
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.6 on 2024-06-28 11:47
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0054_remove_order_status_was"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name="history",
name="user_id",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="history",
to=settings.AUTH_USER_MODEL,
),
preserve_default=False,
),
]

View File

@@ -0,0 +1,40 @@
# Generated by Django 5.0.6 on 2024-07-01 07:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0055_history_user_id"),
]
operations = [
migrations.AlterField(
model_name="order",
name="count",
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AlterField(
model_name="order",
name="debt",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
]

View File

@@ -0,0 +1,59 @@
# Generated by Django 5.0.6 on 2024-07-04 05:35
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0056_alter_order_count_alter_order_debt_and_more"),
]
operations = [
migrations.RenameField(
model_name="party",
old_name="price",
new_name="benefit",
),
migrations.RenameField(
model_name="party",
old_name="sold_price",
new_name="cost",
),
migrations.RemoveField(
model_name="party",
name="sold",
),
migrations.AddField(
model_name="party",
name="remaining_count",
field=models.IntegerField(
default=0,
verbose_name=django.core.validators.MinValueValidator(0),
),
),
migrations.AddField(
model_name="party",
name="sold_count",
field=models.IntegerField(
default=0,
verbose_name=django.core.validators.MinValueValidator(0),
),
),
migrations.AddField(
model_name="party",
name="total_cost",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
migrations.AlterField(
model_name="party",
name="count",
field=models.IntegerField(
default=0,
verbose_name=django.core.validators.MinValueValidator(0),
),
),
]

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2024-07-06 05:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0057_rename_price_party_benefit_and_more"),
]
operations = [
migrations.AlterField(
model_name="party",
name="count",
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name="party",
name="remaining_count",
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name="party",
name="sold_count",
field=models.IntegerField(default=0),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-07-06 07:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0058_alter_party_count_alter_party_remaining_count_and_more",
),
]
operations = [
migrations.AddField(
model_name="party",
name="profit",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=10
),
),
]

View File

@@ -0,0 +1,72 @@
# Generated by Django 5.0.6 on 2024-07-06 07:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0059_party_profit"),
]
operations = [
migrations.AlterField(
model_name="party",
name="benefit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="count",
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AlterField(
model_name="party",
name="profit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="remaining_count",
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AlterField(
model_name="party",
name="sold_count",
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AlterField(
model_name="party",
name="total_cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
),
),
]

View File

@@ -0,0 +1,67 @@
# Generated by Django 5.0.6 on 2024-07-06 13:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0060_alter_party_benefit_alter_party_cost_and_more"),
]
operations = [
migrations.AlterField(
model_name="debt",
name="debt_price",
field=models.DecimalField(decimal_places=2, max_digits=20),
),
migrations.AlterField(
model_name="group",
name="entry_price",
field=models.DecimalField(decimal_places=2, max_digits=20),
),
migrations.AlterField(
model_name="group",
name="unit_price",
field=models.DecimalField(decimal_places=2, max_digits=20),
),
migrations.AlterField(
model_name="group",
name="wholesale_price",
field=models.DecimalField(decimal_places=2, max_digits=20),
),
migrations.AlterField(
model_name="invoice",
name="price",
field=models.DecimalField(decimal_places=2, max_digits=20),
),
migrations.AlterField(
model_name="order",
name="debt",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
migrations.AlterField(
model_name="order",
name="price",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=20
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
]

View File

@@ -0,0 +1,60 @@
# Generated by Django 5.0.6 on 2024-07-06 13:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0061_alter_debt_debt_price_alter_group_entry_price_and_more",
),
]
operations = [
migrations.AlterField(
model_name="party",
name="benefit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="profit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="total_cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=20,
null=True,
),
),
]

View File

@@ -0,0 +1,111 @@
# Generated by Django 5.0.6 on 2024-07-06 13:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0062_alter_party_benefit_alter_party_cost_and_more"),
]
operations = [
migrations.AlterField(
model_name="debt",
name="debt_price",
field=models.DecimalField(decimal_places=2, max_digits=30),
),
migrations.AlterField(
model_name="group",
name="entry_price",
field=models.DecimalField(decimal_places=2, max_digits=30),
),
migrations.AlterField(
model_name="group",
name="unit_price",
field=models.DecimalField(decimal_places=2, max_digits=30),
),
migrations.AlterField(
model_name="group",
name="wholesale_price",
field=models.DecimalField(decimal_places=2, max_digits=30),
),
migrations.AlterField(
model_name="invoice",
name="price",
field=models.DecimalField(decimal_places=2, max_digits=30),
),
migrations.AlterField(
model_name="order",
name="debt",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.AlterField(
model_name="order",
name="price",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=30
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="benefit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="profit",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.AlterField(
model_name="party",
name="total_cost",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
]

View File

@@ -0,0 +1,21 @@
# Generated by Django 5.0.6 on 2024-07-08 11:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"eggs",
"0063_alter_debt_debt_price_alter_group_entry_price_and_more",
),
]
operations = [
migrations.AddField(
model_name="order",
name="stock_updated",
field=models.BooleanField(default=False),
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-07-08 11:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("eggs", "0064_order_stock_updated"),
]
operations = [
migrations.RemoveField(
model_name="order",
name="stock_updated",
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.7 on 2024-07-10 11:25
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0065_remove_order_stock_updated"),
]
operations = [
migrations.AddField(
model_name="debt",
name="created_at",
field=models.DateTimeField(
auto_now_add=True, default=django.utils.timezone.now
),
preserve_default=False,
),
migrations.AddField(
model_name="debt",
name="updated_at",
field=models.DateTimeField(auto_now=True),
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 5.0.7 on 2024-07-20 05:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0066_debt_created_at_debt_updated_at"),
]
operations = [
migrations.AlterField(
model_name="order",
name="debt",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=30
),
),
migrations.AlterField(
model_name="order",
name="price_paid",
field=models.DecimalField(
decimal_places=2, default=0, max_digits=30
),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.7 on 2024-07-22 13:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0067_alter_order_debt_alter_order_price_paid"),
]
operations = [
migrations.AlterField(
model_name="market",
name="avatar",
field=models.ImageField(
blank=True,
default="market_avatar/default.png",
null=True,
upload_to="market_avatar/",
),
),
]

View File

@@ -0,0 +1,89 @@
# Generated by Django 5.0.7 on 2024-07-23 11:35
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0002_remove_content_type_name"),
("eggs", "0068_alter_market_avatar"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddField(
model_name="broken",
name="price",
field=models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
migrations.CreateModel(
name="Monitoring",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("object_id", models.PositiveIntegerField()),
("action", models.CharField(max_length=255)),
("timestamp", models.DateTimeField(auto_now_add=True)),
(
"created_by",
models.CharField(blank=True, max_length=255, null=True),
),
(
"created_who",
models.CharField(blank=True, max_length=255, null=True),
),
(
"comment",
models.CharField(blank=True, max_length=255, null=True),
),
(
"reason",
models.CharField(blank=True, max_length=255, null=True),
),
(
"price",
models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=30,
null=True,
),
),
(
"content_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="contenttypes.contenttype",
),
),
(
"user_id",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="monitoring",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"ordering": ["-timestamp"],
},
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0.7 on 2024-07-25 02:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0069_broken_price_monitoring"),
]
operations = [
migrations.AddField(
model_name="party",
name="broken_eggs",
field=models.IntegerField(blank=True, default=0, null=True),
),
migrations.AddField(
model_name="party",
name="courier_eggs",
field=models.IntegerField(blank=True, default=0, null=True),
),
]

View File

@@ -0,0 +1,60 @@
# Generated by Django 5.1 on 2024-08-29 06:42
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0070_party_broken_eggs_party_courier_eggs"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Notification",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"title",
models.CharField(max_length=255, verbose_name="Title"),
),
("body", models.TextField(verbose_name="Body")),
(
"is_read",
models.BooleanField(default=False, verbose_name="Is read"),
),
(
"is_sending",
models.BooleanField(
default=False, verbose_name="Is sending"
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="notifications",
to=settings.AUTH_USER_MODEL,
verbose_name="User",
),
),
],
options={
"verbose_name": "Notification",
"verbose_name_plural": "Notifications",
},
),
]

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.8 on 2024-08-29 08:56
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("eggs", "0071_notification"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name="notification",
name="user",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="notifications",
to=settings.AUTH_USER_MODEL,
verbose_name="User",
),
),
]

View File

@@ -0,0 +1,29 @@
# Generated by Django 5.0.8 on 2024-09-11 04:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('eggs', '0072_alter_notification_user'),
]
operations = [
migrations.CreateModel(
name='DailyCost',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('first_cost', models.DecimalField(decimal_places=2, max_digits=40)),
('second_cost', models.DecimalField(decimal_places=2, max_digits=40)),
('third_cost', models.DecimalField(decimal_places=2, max_digits=40)),
],
options={
'verbose_name': 'Daily Cost',
'verbose_name_plural': 'Daily Costs',
'db_table': 'daily_costs',
},
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0.8 on 2025-11-04 09:49
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('eggs', '0073_dailycost'),
]
operations = [
migrations.AlterField(
model_name='debt',
name='market',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='debts', to='eggs.market'),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0.8 on 2025-11-21 11:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('eggs', '0074_alter_debt_market'),
]
operations = [
migrations.AddField(
model_name='debt',
name='debt_type',
field=models.CharField(choices=[('added', 'Added'), ('lost', 'Lost')], default='lost', max_length=255),
),
]

View File

View File

@@ -0,0 +1,21 @@
from .additional_cost import * # noqa
from .all_history import * # noqa
from .broken import * # noqa
from .courier import * # noqa
from .courier_history import * # noqa
from .courier_product import * # noqa
from .debt import * # noqa
from .group import * # noqa
from .history import * # noqa
from .invoice import * # noqa
from .location import * # noqa
from .market import * # noqa
from .monitoring import * # noqa
from .order import * # noqa
from .order_item import * # noqa
from .order_item import * # noqa
from .party import * # noqa
from .product import * # noqa
from .sklad import * # noqa
from .notification import * # noqa
from .daily_cost import * # noqa

View File

@@ -0,0 +1,25 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from core.http.models import User
class AdditionalCost(models.Model):
user = models.ForeignKey(
to=User,
verbose_name=_("User"),
on_delete=models.CASCADE,
null=True,
blank=True,
)
reason = models.TextField(_("Name"))
price = models.DecimalField(_("Price"), max_digits=10, decimal_places=2)
created_at = models.DateTimeField(_("Created at"), auto_now_add=True)
updated_at = models.DateTimeField(_("Updated at"), auto_now=True)
class Meta:
verbose_name = _("Additional cost")
verbose_name_plural = _("Additional costs")
def __str__(self):
return self.reason

View File

@@ -0,0 +1,17 @@
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
class AllHistory(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey("content_type", "object_id")
action = models.CharField(max_length=255, null=True, blank=True)
timestamp = models.DateTimeField(auto_now_add=True)
created_by = models.CharField(max_length=255, null=True, blank=True)
created_who = models.CharField(max_length=255, null=True, blank=True)
reason = models.TextField(null=True, blank=True)
class Meta:
ordering = ["-timestamp"]

View File

@@ -0,0 +1,50 @@
from django.db import models
from core.apps.eggs.models import group
from core.http.models import AbstractBaseModel
from core.http.models.user import User
class Broken(AbstractBaseModel):
user_id = models.ForeignKey(
to=User,
on_delete=models.CASCADE,
related_name="broken_eggs",
null=True,
blank=True,
)
group = models.ForeignKey(
group.Group, on_delete=models.CASCADE, related_name="brokens"
)
comment = models.TextField(verbose_name="Comment")
quantity = models.IntegerField(verbose_name="Quantity")
price = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
def save(self, *args, **kwargs):
is_new = self.pk is None
if is_new:
if self.group.quantity < self.quantity:
raise ValueError(
"Quantity cannot be greater than group quantity"
)
self.group.quantity -= self.quantity
self.group.party_id.remaining_count -= self.quantity
self.group.broken_eggs += self.quantity
self.group.party_id.profit -= (
self.group.entry_price * self.quantity
)
self.group.party_id.broken_eggs += self.quantity
self.price = self.group.entry_price * self.quantity
self.group.save()
self.group.party_id.save()
super().save(*args, **kwargs)
def __str__(self):
return self.comment
class Meta:
verbose_name = "Broken"
verbose_name_plural = "Brokens"
db_table = "broken"

View File

@@ -0,0 +1,21 @@
"""
Courier model
"""
from django.db import models
from core.http.models import base
from core.http.models.user import User
class Courier(base.AbstractBaseModel):
user_id = models.ForeignKey(
to=User, on_delete=models.CASCADE, related_name="couriers"
)
def __str__(self):
return f"Courier - {self.user_id}"
class Meta:
verbose_name = "Courier"
verbose_name_plural = "Couriers"
db_table = "courier"

View File

@@ -0,0 +1,39 @@
"""
Couirier History model
"""
from django.db import models
from core.apps.eggs.models import courier, courier_product, group
from core.http.models import base
class CourierHistory(base.AbstractBaseModel):
courier_id = models.ForeignKey(
to=courier.Courier,
on_delete=models.CASCADE,
related_name="courier_histories",
)
courier_product_id = models.ForeignKey(
to=courier_product.CourierProduct,
on_delete=models.SET_NULL,
related_name="courier_histories",
null=True, # Allow NULL values
)
group_id = models.ForeignKey(
to=group.Group,
on_delete=models.SET_NULL,
null=True, # Allow NULL values
)
get_eggs = models.IntegerField()
return_eggs = models.IntegerField(null=True, blank=True)
broken_eggs = models.IntegerField(null=True, blank=True)
date = models.DateField(auto_now=True, null=True, blank=True)
def __str__(self) -> str:
return f"{self.courier_id}, {self.group_id}"
class Meta:
verbose_name = "CourierHistory"
verbose_name_plural = "CourierHistories"
db_table = "courier_history"

View File

@@ -0,0 +1,42 @@
"""
Courier Product model
"""
from django.core.validators import MinValueValidator
from django.db import models
from core.apps.eggs.models import courier, group
from core.http.models import base
class CourierProduct(base.AbstractBaseModel):
group_id = models.ForeignKey(
to=group.Group, on_delete=models.CASCADE, related_name="courier_groups"
)
count = models.IntegerField(
validators=[MinValueValidator(0)], verbose_name="Count of eggs"
)
courier_id = models.ForeignKey(
to=courier.Courier,
on_delete=models.CASCADE,
related_name="courier_products",
)
return_eggs = models.IntegerField(
default=0,
verbose_name="Return eggs",
validators=[MinValueValidator(0)],
null=True,
blank=True,
)
def clean(self):
if self.count < 0:
raise ValueError("Count must be greater than 0")
def __str__(self):
return f"Courier - {self.courier_id}, group_id - {self.group_id}"
class Meta:
verbose_name = "CourierProduct"
verbose_name_plural = "CourierProducts"
db_table = "courier_product"

View File

@@ -0,0 +1,14 @@
from django.db import models
from core.http.models import AbstractBaseModel
class DailyCost(AbstractBaseModel):
first_cost = models.DecimalField(max_digits=40, decimal_places=2)
second_cost = models.DecimalField(max_digits=40, decimal_places=2)
third_cost = models.DecimalField(max_digits=40, decimal_places=2)
class Meta:
verbose_name = "Daily Cost"
verbose_name_plural = "Daily Costs"
db_table = "daily_costs"

View File

@@ -0,0 +1,78 @@
from django.db import models
from rest_framework.exceptions import ValidationError
from core.http.models import AbstractBaseModel
class DebtTypeEnum(models.TextChoices):
ADDED = "added"
LOST = "lost"
class Debt(AbstractBaseModel):
market = models.ForeignKey(
to="Market", on_delete=models.CASCADE, related_name="debts"
)
debt_price = models.DecimalField(max_digits=30, decimal_places=2)
debt_type = models.CharField(
max_length=255,
choices=DebtTypeEnum.choices,
default=DebtTypeEnum.LOST.value,
)
def save(self, *args, **kwargs):
if self.pk is None:
if self.debt_type == DebtTypeEnum.ADDED.value:
# self.market.debt_paid -= self.debt_price
self.market.debt_unpaid += self.debt_price
elif self.debt_type == DebtTypeEnum.LOST.value:
if self.debt_price > self.market.debt_unpaid:
raise ValueError(
"Debt price cannot be greater than unpaid debt."
)
self.market.debt_paid += self.debt_price
self.market.debt_unpaid -= self.debt_price
else:
raise ValidationError(
detail={"debt_type": "invlaid debt_type"}
)
self.market.save()
super().save(*args, **kwargs)
def __str__(self):
return f"{self.debt_price} - {self.market.name}"
# from django.db import models
# from django.core.exceptions import ValidationError
#
#
# class Debt(AbstractBaseModel):
# market = models.ForeignKey(to="Market", on_delete=models.CASCADE)
# order = models.ForeignKey(to="Order", on_delete=models.CASCADE)
# debt_price = models.DecimalField(max_digits=30, decimal_places=2)
#
# def save(self, *args, **kwargs):
# if self.pk is None:
# if self.debt_price > self.market.debt_unpaid:
# raise ValidationError("Debt price cannot be greater than unpaid debt.")
#
# self.market.debt_paid += self.debt_price
# self.market.debt_unpaid -= self.debt_price
# self.market.save()
#
# self.order.price_paid += self.debt_price
# self.order.debt -= self.debt_price
# self.order.save()
#
# order_items = OrderItems.objects.filter(order_id=self.order.id)
# for item in order_items:
# party = item.courier_product_id.group_id.party_id
# if party:
# party.benefit += self.debt_price
# party.save()
#
# super().save(*args, **kwargs)
#
# def __str__(self):
# return f"{self.debt_price} - {self.market.name} - {self.order.id}"

View File

@@ -0,0 +1,52 @@
"""
Groups model
"""
from django.core.validators import MinValueValidator
from django.db import models
from core.apps.eggs.models import party
from core.apps.eggs.models import product
from core.http.models import base
class Group(base.AbstractBaseModel):
product_id = models.ForeignKey(
to=product.Product, on_delete=models.CASCADE, related_name="groups"
)
party_id = models.ForeignKey(
to=party.Party,
on_delete=models.CASCADE,
related_name="groups",
blank=True,
null=True,
)
entry_price = models.DecimalField(max_digits=30, decimal_places=2)
unit_price = models.DecimalField(max_digits=30, decimal_places=2)
wholesale_price = models.DecimalField(max_digits=30, decimal_places=2)
quantity = models.IntegerField(
validators=[MinValueValidator(0)], default=0
)
broken_eggs = models.IntegerField(
validators=[MinValueValidator(0)], default=0
)
date = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=255, blank=True, null=True)
def clean(self):
if self.quantity < 0:
raise ValueError("Quantity can't be negative")
# def save(self, *args, **kwargs):
# self.party_id.count += self.quantity
# self.party_id.price += self.entry_price * self.quantity
# self.party_id.save()
# super().save(*args, **kwargs)
def __str__(self) -> str:
return f"{self.product_id}, Quantity - {self.quantity}"
class Meta:
verbose_name = "Group"
verbose_name_plural = "Groups"
db_table = "group"

View File

@@ -0,0 +1,26 @@
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from core.http.models import User
class History(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey("content_type", "object_id")
action = models.CharField(max_length=255)
user_id = models.ForeignKey(
to=User, on_delete=models.CASCADE, related_name="history"
)
avatar = models.ImageField(
upload_to="history_avatars/", null=True, blank=True
)
timestamp = models.DateTimeField(auto_now_add=True)
created_by = models.CharField(max_length=255, null=True, blank=True)
created_who = models.CharField(max_length=255, null=True, blank=True)
comment = models.CharField(max_length=255, null=True, blank=True)
reason = models.CharField(max_length=255, null=True, blank=True)
class Meta:
ordering = ["-timestamp"]

View File

@@ -0,0 +1,23 @@
"""
Invoice model
"""
from django.db import models
from core.apps.eggs.models import party
class Invoice(models.Model):
name = models.CharField(max_length=256)
price = models.DecimalField(max_digits=30, decimal_places=2)
party_id = models.ForeignKey(
to=party.Party, on_delete=models.CASCADE, related_name="invoices"
)
def __str__(self) -> str:
return f"{self.name}, {self.price}"
class Meta:
verbose_name = "Invoice"
verbose_name_plural = "Invoices"
db_table = "invoice"

View File

@@ -0,0 +1,21 @@
"""
Location model
"""
from django.db import models
from core.http.models import base
class Location(base.AbstractBaseModel):
long = models.FloatField(null=True, blank=True)
lat = models.FloatField(null=True, blank=True)
label = models.TextField()
def __str__(self) -> str:
return f"{self.long}, {self.lat}"
class Meta:
verbose_name = "Location"
verbose_name_plural = "Locations"
db_table = "location"

View File

@@ -0,0 +1,48 @@
"""
Market model
"""
from django.core.validators import MinValueValidator
from django.db import models
from core.apps.eggs.models import location
from core.http.models import base
from core.http.models.user import User
class Market(base.AbstractBaseModel):
name = models.CharField(max_length=255)
company_name = models.CharField(max_length=255)
user_id = models.ForeignKey(to=User, on_delete=models.CASCADE)
avatar = models.ImageField(
upload_to="market_avatar/",
blank=True,
null=True,
default="market_avatar/default.png",
)
phone = models.CharField(max_length=20)
location_id = models.ForeignKey(
to=location.Location,
on_delete=models.CASCADE,
related_name="market_location",
)
debt_paid = models.DecimalField(
max_digits=10,
decimal_places=2,
default=0,
validators=[MinValueValidator(0)],
)
debt_unpaid = models.DecimalField(
max_digits=10,
decimal_places=2,
default=0,
validators=[MinValueValidator(0)],
)
def __str__(self):
return f"{self.name} - {self.phone}"
class Meta:
verbose_name = "Market"
verbose_name_plural = "Markets"
db_table = "market"

View File

@@ -0,0 +1,26 @@
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from core.http.models import User
class Monitoring(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey("content_type", "object_id")
action = models.CharField(max_length=255)
user_id = models.ForeignKey(
to=User, on_delete=models.CASCADE, related_name="monitoring"
)
timestamp = models.DateTimeField(auto_now_add=True)
created_by = models.CharField(max_length=255, null=True, blank=True)
created_who = models.CharField(max_length=255, null=True, blank=True)
comment = models.CharField(max_length=255, null=True, blank=True)
reason = models.CharField(max_length=255, null=True, blank=True)
price = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
class Meta:
ordering = ["-timestamp"]

View File

@@ -0,0 +1,25 @@
from django.db import models
from core.http.models import AbstractBaseModel
class Notification(AbstractBaseModel):
title = models.CharField(max_length=255, verbose_name="Title")
body = models.TextField(verbose_name="Body")
user = models.ForeignKey(
"http.User",
on_delete=models.CASCADE,
related_name="notifications",
verbose_name="User",
null=True,
blank=True,
)
is_read = models.BooleanField(default=False, verbose_name="Is read")
is_sending = models.BooleanField(default=False, verbose_name="Is sending")
def __str__(self) -> str:
return self.title
class Meta:
verbose_name = "Notification"
verbose_name_plural = "Notifications"

View File

@@ -0,0 +1,55 @@
"""
Order model
"""
from django.db import models, transaction
from django.db.models import F
from core.apps.eggs.models import Location, courier, location, market
from core.http.models import base
class Order(base.AbstractBaseModel):
STATUS_CHOICES = (
("pending", "Pending"),
("delivery", "Delivery"),
("success", "Success"),
("done", "Done"),
("cancel", "Cancel"),
)
courier_id = models.ForeignKey(
to=courier.Courier,
on_delete=models.CASCADE,
related_name="orders",
null=True,
blank=True,
)
market_id = models.ForeignKey(
to=market.Market,
on_delete=models.CASCADE,
related_name="orders",
null=True,
blank=True,
)
data = models.DateTimeField(auto_now_add=True)
status = models.CharField(
max_length=255, choices=STATUS_CHOICES, default="pending"
)
comment = models.TextField(blank=True, null=True)
price = models.DecimalField(max_digits=30, decimal_places=2, default=0)
price_paid = models.DecimalField(
max_digits=30, decimal_places=2, default=0
)
debt = models.DecimalField(max_digits=30, decimal_places=2, default=0)
location_id = models.ForeignKey(
Location, on_delete=models.CASCADE, null=True
)
count = models.IntegerField(null=True, blank=True, default=0)
def __str__(self):
return f"Order - {self.id}, status - {self.status}"
class Meta:
verbose_name = "Order"
verbose_name_plural = "Orders"
db_table = "order"

View File

@@ -0,0 +1,43 @@
"""
Order Items model
"""
import decimal
from django.db import models
from core.apps.eggs.models import courier_product, group, order
from core.http.models import base
class OrderItems(base.AbstractBaseModel):
SALE_TYPE_CHOICES = (
("optom", "Optom"),
("dona", "Dona"),
)
group_id = models.ForeignKey(
group.Group, on_delete=models.CASCADE, null=True
)
count = models.IntegerField()
discount = models.DecimalField(
max_digits=10, decimal_places=2, null=True, blank=True
)
courier_product_id = models.ForeignKey(
to=courier_product.CourierProduct,
on_delete=models.CASCADE,
null=True,
blank=True,
)
order_id = models.ForeignKey(
order.Order, on_delete=models.CASCADE, related_name="order_items"
)
sale_type = models.CharField(max_length=10, choices=SALE_TYPE_CHOICES)
def __str__(self):
return f"Product - {self.group_id}, count - {self.count}"
class Meta:
verbose_name = "OrderItem"
verbose_name_plural = "OrderItems"
db_table = "order_item"

View File

@@ -0,0 +1,85 @@
"""
Party model
"""
from django.db import models
from django.db.models import Sum
from core.http.models import base
from core.http.models.user import User
class Party(base.AbstractBaseModel):
user_id = models.ForeignKey(
to=User, on_delete=models.CASCADE, related_name="parties"
)
# umumiy soni
count = models.IntegerField(default=0, null=True, blank=True)
# sotilgan soni
sold_count = models.IntegerField(default=0, null=True, blank=True)
# qolgan soni
remaining_count = models.IntegerField(default=0, null=True, blank=True)
# tushum
benefit = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
# foyda
profit = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
# partiya narxi
cost = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
# umumiy narxi
total_cost = models.DecimalField(
max_digits=30, decimal_places=2, default=0, null=True, blank=True
)
broken_eggs = models.IntegerField(default=0, null=True, blank=True)
courier_eggs = models.IntegerField(default=0, null=True, blank=True)
@staticmethod
def get_total_benefit():
return Party.objects.aggregate(
total_count=Sum("count"), # umumiy mahsulot soni
total_sold_count=Sum(
"sold_count"
), # umumiy sotilgan mahsulot soni
total_remaining_count=Sum(
"remaining_count"
), # umumiy qolgan mahsulot soni
total_broken_eggs=Sum("broken_eggs"), # umumiy singan soni
total_courier_eggs=Sum(
"courier_eggs"
), # umumiy kuryerlar tomonidan olingan soni
)
def clean(self):
if self.count < 0:
raise ValueError("Count can't be negative")
if self.sold_count < 0:
raise ValueError("Sold count can't be negative")
if self.remaining_count < 0:
raise ValueError("Remaining count can't be negative")
if self.benefit < 0:
raise ValueError("Benefit can't be negative")
if self.cost < 0:
raise ValueError("Cost can't be negative")
if self.total_cost < 0:
raise ValueError("Total cost can't be negative")
def update_total_cost(self):
total_invoice_price = (
self.invoices.aggregate(Sum("price"))["price__sum"] or 0
)
self.total_cost = self.cost + total_invoice_price
self.profit -= total_invoice_price
self.save()
def __str__(self):
return f"User - {self.user_id}, price - {self.benefit}"
class Meta:
verbose_name = "Party"
verbose_name_plural = "Parties"
db_table = "party"

View File

@@ -0,0 +1,19 @@
"""
Product model
"""
from django.db import models
from core.http.models import base
class Product(base.AbstractBaseModel):
name = models.CharField(max_length=255)
def __str__(self):
return f"Product - {self.name}"
class Meta:
verbose_name = "Product"
verbose_name_plural = "Products"
db_table = "product"

Some files were not shown because too many files have changed in this diff Show More