diff --git a/core/apps/finance/admin/__init__.py b/core/apps/finance/admin/__init__.py index a096b6d..b69fa20 100644 --- a/core/apps/finance/admin/__init__.py +++ b/core/apps/finance/admin/__init__.py @@ -1 +1,2 @@ -from .cash_transaction import * \ No newline at end of file +from .cash_transaction import * +from .payment_type import * \ No newline at end of file diff --git a/core/apps/finance/admin/payment_type.py b/core/apps/finance/admin/payment_type.py new file mode 100644 index 0000000..deabfa7 --- /dev/null +++ b/core/apps/finance/admin/payment_type.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +from core.apps.finance.models.payment_type import PaymentType + + +@admin.register(PaymentType) +class PaymentTypeAdmin(admin.ModelAdmin): + list_display = ['id', 'name'] \ No newline at end of file diff --git a/core/apps/finance/migrations/0002_paymenttype_cashtransaction_employees_and_more.py b/core/apps/finance/migrations/0002_paymenttype_cashtransaction_employees_and_more.py new file mode 100644 index 0000000..dd700c3 --- /dev/null +++ b/core/apps/finance/migrations/0002_paymenttype_cashtransaction_employees_and_more.py @@ -0,0 +1,45 @@ +# Generated by Django 5.2.4 on 2025-08-04 14:54 + +import django.db.models.deletion +import uuid +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('finance', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='PaymentType', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('name', models.CharField(max_length=200, unique=True)), + ], + options={ + 'verbose_name': "To'lov turi", + 'verbose_name_plural': "To'lov turlari", + }, + ), + migrations.AddField( + model_name='cashtransaction', + name='employees', + field=models.ManyToManyField(related_name='cash_transactions', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='cashtransaction', + name='status', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='cashtransaction', + name='payment_type', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='cash_transactions', to='finance.paymenttype'), + ), + ] diff --git a/core/apps/finance/models/__init__.py b/core/apps/finance/models/__init__.py index a096b6d..85454e1 100644 --- a/core/apps/finance/models/__init__.py +++ b/core/apps/finance/models/__init__.py @@ -1 +1,2 @@ -from .cash_transaction import * \ No newline at end of file +from .cash_transaction import * +from .payment_type import * \ No newline at end of file diff --git a/core/apps/finance/models/cash_transaction.py b/core/apps/finance/models/cash_transaction.py index 64dd581..5d95cee 100644 --- a/core/apps/finance/models/cash_transaction.py +++ b/core/apps/finance/models/cash_transaction.py @@ -2,15 +2,21 @@ from django.db import models from django.utils.translation import gettext_lazy as _ from core.apps.shared.models import BaseModel +from core.apps.finance.models.payment_type import PaymentType +from core.apps.accounts.models import User class CashTransaction(BaseModel): name = models.CharField(max_length=200, unique=True) + payment_type = models.ForeignKey( + PaymentType, on_delete=models.CASCADE, related_name='cash_transactions', null=True + ) + employees = models.ManyToManyField(User, related_name='cash_transactions') + status = models.BooleanField(default=False) def __str__(self): return self.name class Meta: verbose_name = _('Kassa') - verbose_name_plural = _('Kassalar') - + verbose_name_plural = _('Kassalar') \ No newline at end of file diff --git a/core/apps/finance/models/payment_type.py b/core/apps/finance/models/payment_type.py new file mode 100644 index 0000000..060a297 --- /dev/null +++ b/core/apps/finance/models/payment_type.py @@ -0,0 +1,16 @@ +from django.db import models +from django.utils.translation import gettext_lazy as _ + +from core.apps.shared.models import BaseModel + + +class PaymentType(BaseModel): + name = models.CharField(max_length=200, unique=True) + + def __str__(self): + return self.name + + class Meta: + verbose_name = _("To'lov turi") + verbose_name_plural = _("To'lov turlari") + \ No newline at end of file diff --git a/core/apps/projects/models/project.py b/core/apps/projects/models/project.py index 2204e23..cef996e 100644 --- a/core/apps/projects/models/project.py +++ b/core/apps/projects/models/project.py @@ -38,11 +38,11 @@ class Project(BaseModel): other_members = models.ManyToManyField(User, related_name='project_members') # project settings - wherehouse = models.ForeignKey( - WhereHouse, on_delete=models.CASCADE, related_name='projects', null=True + wherehouse = models.ManyToManyField( + WhereHouse, related_name='projects' ) - cash_transaction = models.ForeignKey( - CashTransaction, on_delete=models.CASCADE, related_name='projects', null=True + cash_transaction = models.ManyToManyField( + CashTransaction, related_name='projects', null=True ) currency = models.CharField(choices=[('usd', 'usd'),('uzs','uzs')], max_length=3, default='uzs') benifit_plan = models.PositiveBigIntegerField(null=True)