add party model

This commit is contained in:
behruz-dev
2025-08-21 10:17:59 +05:00
parent 15ef725e91
commit 7e2e62d48c
6 changed files with 104 additions and 2 deletions

View File

@@ -1,2 +1,3 @@
from .order import *
from .order_offer import *
from .order_offer import *
from .party import *

View File

@@ -6,6 +6,7 @@ from core.apps.products.models import Product, Unity
from core.apps.projects.models import Project, ProjectFolder
from core.apps.accounts.models import User
from core.apps.wherehouse.models import WhereHouse
from core.apps.counterparty.models import Counterparty
class Order(BaseModel):
@@ -34,6 +35,14 @@ class Order(BaseModel):
quantity = models.PositiveBigIntegerField(default=1)
status = models.CharField(max_length=20, choices=STATUS, default="NEW")
employee = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders', null=True)
unit_amount = models.PositiveBigIntegerField(default=0, null=True, blank=True)
counterparty = models.ForeignKey(
Counterparty, on_delete=models.SET_NULL, null=True, blank=True, related_name='order'
)
currency = models.CharField(
choices=[('uzs', 'uzs'), ('usd', 'usd')], default='uzs', null=True, blank=True, max_length=3
)
total_price = models.PositiveBigIntegerField(default=0, null=True, blank=True)
def __str__(self):
return f"{self.product} {self.unity} quantity order"

View File

@@ -0,0 +1,25 @@
from django.db import models
from core.apps.shared.models import BaseModel
from core.apps.orders.models.order import Order
from core.apps.accounts.models import User
class Party(BaseModel):
orders = models.ManyToManyField(Order, related_name='parties', null=True, blank=True)
mediator = models.ForeignKey(User, on_delete=models.CASCADE, related_name='parties')
delivery_date = models.DateField()
payment_date = models.DateField()
comment = models.TextField(null=True, blank=True)
audit = models.CharField(
max_length=20, choices=[('CHECKED', 'tekshirildi'),('PROCESS', 'jarayonda')],
null=True, blank=True
)
audit_comment = models.TextField(null=True, blank=True)
def __str__(self):
return f'{self.mediator.full_name} {self.delivery_date}'
class Meta:
verbose_name = 'Partiya'
verbose_name_plural = 'Partiyalar'