Some changes have been made
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-04 12:15
|
# Generated by Django 5.2.7 on 2026-02-18 08:13
|
||||||
|
|
||||||
import django.utils.timezone
|
import django.utils.timezone
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-04 12:15
|
# Generated by Django 5.2.7 on 2026-02-18 08:13
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@@ -18,11 +18,16 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='user',
|
model_name='user',
|
||||||
name='region',
|
name='region',
|
||||||
field=models.ForeignKey(blank=True, help_text='Only for managers', null=True, on_delete=django.db.models.deletion.SET_NULL, to='management.region'),
|
field=models.ForeignKey(blank=True, help_text='Faqat menejerlar uchun', null=True, on_delete=django.db.models.deletion.SET_NULL, to='management.region'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='user',
|
model_name='user',
|
||||||
name='user_permissions',
|
name='user_permissions',
|
||||||
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions'),
|
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions'),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='warehouse',
|
||||||
|
field=models.ForeignKey(blank=True, help_text='Faqat xodimlar uchun', null=True, on_delete=django.db.models.deletion.PROTECT, to='management.warehouse'),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-06 09:54
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('accounts', '0002_initial'),
|
|
||||||
('management', '0013_rename_name_device_address_remove_device_monthly_fee_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='user',
|
|
||||||
name='warehouse',
|
|
||||||
field=models.ForeignKey(blank=True, help_text='Only for employees', null=True, on_delete=django.db.models.deletion.PROTECT, to='management.warehouse'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-17 11:44
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('accounts', '0003_user_warehouse'),
|
|
||||||
('management', '0022_alter_district_region'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='user',
|
|
||||||
name='region',
|
|
||||||
field=models.ForeignKey(blank=True, help_text='Faqat menejerlar uchun', null=True, on_delete=django.db.models.deletion.SET_NULL, to='management.region'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='user',
|
|
||||||
name='warehouse',
|
|
||||||
field=models.ForeignKey(blank=True, help_text='Faqat xodimlar uchun', null=True, on_delete=django.db.models.deletion.PROTECT, to='management.warehouse'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -67,11 +67,20 @@ class ToyMovementAdmin(admin.ModelAdmin):
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
@admin.register(Income)
|
@admin.register(Income)
|
||||||
class IncomeAdmin(admin.ModelAdmin):
|
class IncomeAdmin(admin.ModelAdmin):
|
||||||
list_display = ("device", "amount", "created_by", "created_at")
|
list_display = (
|
||||||
list_filter = ("device",)
|
"warehouse",
|
||||||
search_fields = ("device__name", "created_by__phone")
|
"toys_count",
|
||||||
autocomplete_fields = ["device", "created_by",]
|
"price_per_toy",
|
||||||
readonly_fields = ("created_at",)
|
"total_amount",
|
||||||
|
"created_at",
|
||||||
|
)
|
||||||
|
|
||||||
|
list_filter = ("warehouse", "created_at")
|
||||||
|
|
||||||
|
search_fields = ("warehouse__name",)
|
||||||
|
|
||||||
|
readonly_fields = ("total_amount", "created_at")
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Expense Admin
|
# Expense Admin
|
||||||
|
|||||||
@@ -1,35 +1,18 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from ..models import Income, Device, Warehouse
|
from ..models import Income, Warehouse
|
||||||
|
|
||||||
|
|
||||||
class IncomeForm(forms.ModelForm):
|
class IncomeForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Income
|
model = Income
|
||||||
fields = ["device", "amount", "warehouse"]
|
fields = ["warehouse", "toys_count", "price_per_toy"]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.user = kwargs.pop("user", None)
|
self.user = kwargs.pop("user", None)
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
if self.user is not None:
|
# Filter warehouse by manager region
|
||||||
# Filter devices
|
if self.user and self.user.role == "manager":
|
||||||
if self.user.role == "businessman":
|
self.fields["warehouse"].queryset = Warehouse.objects.filter(
|
||||||
self.fields["warehouse"].queryset = Warehouse.objects.all()
|
region=self.user.region
|
||||||
elif self.user.role == "manager":
|
)
|
||||||
self.fields["warehouse"].queryset = Warehouse.objects.filter(region=self.user.region)
|
|
||||||
elif self.user.role == "employee":
|
|
||||||
self.fields["device"].queryset = Device.objects.filter(district__region=self.user.region)
|
|
||||||
|
|
||||||
# Remove amount for employees
|
|
||||||
if self.user.role == "employee":
|
|
||||||
self.fields.pop("amount", None)
|
|
||||||
|
|
||||||
def save(self, commit=True):
|
|
||||||
instance = super().save(commit=False)
|
|
||||||
if self.user:
|
|
||||||
instance.created_by = self.user
|
|
||||||
if getattr(self.user, "role", None) == "employee":
|
|
||||||
instance.amount = None
|
|
||||||
if commit:
|
|
||||||
instance.save()
|
|
||||||
return instance
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-04 12:15
|
# Generated by Django 5.2.7 on 2026-02-18 08:13
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
from decimal import Decimal
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
@@ -32,17 +33,58 @@ class Migration(migrations.Migration):
|
|||||||
name='Device',
|
name='Device',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(max_length=100)),
|
('address', models.CharField(max_length=100, unique=True)),
|
||||||
('toys_count', models.PositiveIntegerField(default=0)),
|
('due_date', models.DateField(blank=True, null=True)),
|
||||||
('monthly_fee', models.DecimalField(decimal_places=2, max_digits=10)),
|
('amount', models.IntegerField(blank=True, null=True)),
|
||||||
|
('is_paid', models.BooleanField(default=False)),
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
('district', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='management.district')),
|
('district', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='management.district')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Expense',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('amount', models.DecimalField(decimal_places=2, max_digits=12)),
|
||||||
|
('expense_type', models.CharField(choices=[('salary', 'Maosh'), ('utilities', 'Kommunal to‘lovlar'), ('maintenance', 'Texnik xizmat'), ('food', 'Oziq-ovqat'), ('transport', "Yo'lkira"), ('buy_toys', 'Oʻyinchoqlar sotib olish'), ('other', 'Boshqa')], default='other', max_length=20)),
|
||||||
|
('comment', models.TextField(blank=True, null=True)),
|
||||||
|
('is_confirmed', models.BooleanField(default=False)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('confirmed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='confirmed_expenses', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
||||||
|
('employee', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='salaries', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='district',
|
model_name='district',
|
||||||
name='region',
|
name='region',
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='districts', to='management.region'),
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='districts', to='management.region'),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Rent',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('address', models.CharField(max_length=100, unique=True)),
|
||||||
|
('due_date', models.DateField()),
|
||||||
|
('amount', models.IntegerField()),
|
||||||
|
('is_paid', models.BooleanField(default=False)),
|
||||||
|
('paid_at', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='created_rents', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('device', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='device_rents', to='management.device')),
|
||||||
|
('district', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='district_rents', to='management.district')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Report',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('quantity', models.PositiveIntegerField(default=0)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Warehouse',
|
name='Warehouse',
|
||||||
@@ -58,19 +100,25 @@ class Migration(migrations.Migration):
|
|||||||
name='ToyMovement',
|
name='ToyMovement',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('movement_type', models.CharField(choices=[('from_warehouse', 'Warehouse → Device'), ('to_device', 'Device refill'), ('between_warehouses', 'Warehouse → Warehouse')], max_length=30)),
|
('movement_type', models.CharField(choices=[('from_warehouse', 'Ombordan → Aparatga'), ('between_warehouses', 'Ombordan → Omborga')], max_length=30)),
|
||||||
('quantity', models.PositiveIntegerField()),
|
('quantity', models.PositiveIntegerField()),
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
||||||
('from_warehouse', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='outgoing', to='management.warehouse')),
|
('from_warehouse', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='outgoing', to='management.warehouse')),
|
||||||
('to_warehouse', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='incoming', to='management.warehouse')),
|
('to_warehouse', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='incoming', to='management.warehouse')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.CreateModel(
|
||||||
model_name='device',
|
name='Income',
|
||||||
name='warehouse',
|
fields=[
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='management.warehouse'),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('toys_count', models.PositiveIntegerField(default=0)),
|
||||||
|
('price_per_toy', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=12)),
|
||||||
|
('total_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), editable=False, max_digits=14)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='warehouse_incomes', to='management.warehouse')),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='district',
|
name='district',
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-04 12:41
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0001_initial'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='ExpenseType',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('name', models.CharField(max_length=255, unique=True)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Expense',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('amount', models.DecimalField(decimal_places=2, max_digits=12)),
|
|
||||||
('is_confirmed', models.BooleanField(default=False)),
|
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
||||||
('confirmed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='confirmed_expenses', to=settings.AUTH_USER_MODEL)),
|
|
||||||
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
|
||||||
('expense_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='expenses', to='management.expensetype')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Income',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('amount', models.DecimalField(decimal_places=2, max_digits=12)),
|
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
||||||
('confirmed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='confirmed_income', to=settings.AUTH_USER_MODEL)),
|
|
||||||
('device', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
|
||||||
('reported_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='reported_income', to=settings.AUTH_USER_MODEL)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
def load_data(apps, schema_editor):
|
|
||||||
Region = apps.get_model("management", "Region")
|
|
||||||
District = apps.get_model("management", "District")
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"Qoraqalpogʻiston Respublikasi": [
|
|
||||||
"Amudaryo tumani", "Beruniy tumani", "Chimboy tumani",
|
|
||||||
"Ellikqalʼa tumani", "Kegeyli tumani", "Moʻynoq tumani",
|
|
||||||
"Nukus tumani", "Qanlikoʻl tumani", "Qoʻngʻirot tumani",
|
|
||||||
"Qoraoʻzak tumani", "Shumanay tumani", "Taxiatosh tumani",
|
|
||||||
"Taxtakoʻpir tumani", "Toʻrtkoʻl tumani", "Xoʻjayli tumani"
|
|
||||||
],
|
|
||||||
"Andijon viloyati": [
|
|
||||||
"Andijon tumani", "Asaka tumani", "Baliqchi tumani",
|
|
||||||
"Boʻz tumani", "Buloqboshi tumani", "Izboskan tumani",
|
|
||||||
"Jalaquduq tumani", "Marhamat tumani", "Oltinkoʻl tumani",
|
|
||||||
"Paxtaobod tumani", "Qoʻrgʻontepa tumani",
|
|
||||||
"Shahrixon tumani", "Ulugʻnor tumani", "Xoʻjaobod tumani"
|
|
||||||
],
|
|
||||||
"Buxoro viloyati": [
|
|
||||||
"Buxoro tumani", "Gʻijduvon tumani", "Jondor tumani",
|
|
||||||
"Kogon tumani", "Olot tumani", "Peshku tumani",
|
|
||||||
"Qorakoʻl tumani", "Qorovulbozor tumani",
|
|
||||||
"Romitan tumani", "Shofirkon tumani", "Vobkent tumani"
|
|
||||||
],
|
|
||||||
"Fargʻona viloyati": [
|
|
||||||
"Bagʻdod tumani", "Beshariq tumani", "Dangʻara tumani",
|
|
||||||
"Fargʻona tumani", "Furqat tumani", "Oltiariq tumani",
|
|
||||||
"Qoʻshtepa tumani", "Quva tumani", "Rishton tumani",
|
|
||||||
"Soʻx tumani", "Toshloq tumani", "Uchkoʻprik tumani",
|
|
||||||
"Yozyovon tumani"
|
|
||||||
],
|
|
||||||
"Jizzax viloyati": [
|
|
||||||
"Arnasoy tumani", "Baxmal tumani", "Doʻstlik tumani",
|
|
||||||
"Forish tumani", "Gʻallaorol tumani", "Mirzachoʻl tumani",
|
|
||||||
"Paxtakor tumani", "Sharof Rashidov tumani",
|
|
||||||
"Yangiobod tumani", "Zomin tumani", "Zafarobod tumani"
|
|
||||||
],
|
|
||||||
"Xorazm viloyati": [
|
|
||||||
"Bogʻot tumani", "Gurlan tumani", "Hazorasp tumani",
|
|
||||||
"Qoʻshkoʻpir tumani", "Shovot tumani",
|
|
||||||
"Urganch tumani", "Xazorasp tumani", "Xiva tumani",
|
|
||||||
"Yangiariq tumani", "Yangibozor tumani"
|
|
||||||
],
|
|
||||||
"Namangan viloyati": [
|
|
||||||
"Chortoq tumani", "Chust tumani", "Kosonsoy tumani",
|
|
||||||
"Mingbuloq tumani", "Namangan tumani",
|
|
||||||
"Norin tumani", "Pop tumani", "Toʻraqoʻrgʻon tumani",
|
|
||||||
"Uchqoʻrgʻon tumani", "Uychi tumani", "Yangiqoʻrgʻon tumani"
|
|
||||||
],
|
|
||||||
"Navoiy viloyati": [
|
|
||||||
"Karmana tumani", "Konimex tumani", "Navbahor tumani",
|
|
||||||
"Nurota tumani", "Qiziltepa tumani",
|
|
||||||
"Tomdi tumani", "Uchquduq tumani", "Xatirchi tumani"
|
|
||||||
],
|
|
||||||
"Qashqadaryo viloyati": [
|
|
||||||
"Chiroqchi tumani", "Dehqonobod tumani",
|
|
||||||
"Gʻuzor tumani", "Kasbi tumani", "Kitob tumani",
|
|
||||||
"Koson tumani", "Mirishkor tumani", "Muborak tumani",
|
|
||||||
"Nishon tumani", "Qamashi tumani",
|
|
||||||
"Qarshi tumani", "Shahrisabz tumani",
|
|
||||||
"Yakkabogʻ tumani"
|
|
||||||
],
|
|
||||||
"Samarqand viloyati": [
|
|
||||||
"Bulungʻur tumani", "Ishtixon tumani",
|
|
||||||
"Jomboy tumani", "Kattaqoʻrgʻon tumani",
|
|
||||||
"Narpay tumani", "Nurobod tumani",
|
|
||||||
"Oqdaryo tumani", "Paxtachi tumani",
|
|
||||||
"Pastdargʻom tumani", "Payariq tumani",
|
|
||||||
"Qoʻshrabot tumani", "Samarqand tumani",
|
|
||||||
"Toyloq tumani", "Urgut tumani"
|
|
||||||
],
|
|
||||||
"Surxondaryo viloyati": [
|
|
||||||
"Angor tumani", "Bandixon tumani", "Boysun tumani",
|
|
||||||
"Denov tumani", "Jarqoʻrgʻon tumani",
|
|
||||||
"Muzrabot tumani", "Oltinsoy tumani",
|
|
||||||
"Qiziriq tumani", "Qumqoʻrgʻon tumani",
|
|
||||||
"Sariosiyo tumani", "Sherobod tumani",
|
|
||||||
"Shoʻrchi tumani", "Termiz tumani", "Uzun tumani"
|
|
||||||
],
|
|
||||||
"Sirdaryo viloyati": [
|
|
||||||
"Boyovut tumani", "Guliston tumani",
|
|
||||||
"Mirzaobod tumani", "Oqoltin tumani",
|
|
||||||
"Sayxunobod tumani", "Sardoba tumani",
|
|
||||||
"Xovos tumani"
|
|
||||||
],
|
|
||||||
"Toshkent viloyati": [
|
|
||||||
"Angren tumani", "Bekobod tumani",
|
|
||||||
"Boʻka tumani", "Boʻstonliq tumani",
|
|
||||||
"Chinoz tumani", "Ohangaron tumani",
|
|
||||||
"Oqqoʻrgʻon tumani", "Parkent tumani",
|
|
||||||
"Piskent tumani", "Quyi Chirchiq tumani",
|
|
||||||
"Yangiyoʻl tumani", "Yuqori Chirchiq tumani",
|
|
||||||
"Zangiota tumani"
|
|
||||||
],
|
|
||||||
"Toshkent shahri": [
|
|
||||||
"Bektemir tumani", "Chilonzor tumani",
|
|
||||||
"Hamza tumani", "Mirobod tumani",
|
|
||||||
"Mirzo Ulugʻbek tumani", "Olmazor tumani",
|
|
||||||
"Sergeli tumani", "Shayxontohur tumani",
|
|
||||||
"Uchtepa tumani", "Yakkasaroy tumani",
|
|
||||||
"Yashnobod tumani", "Yunusobod tumani"
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
for region_name, districts in data.items():
|
|
||||||
region, _ = Region.objects.get_or_create(name=region_name)
|
|
||||||
District.objects.bulk_create(
|
|
||||||
[District(name=d, region=region) for d in districts],
|
|
||||||
ignore_conflicts=True
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
("management", "0002_expensetype_expense_income"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(load_data),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 05:50
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0003_load_uzbekistan_regions_districts'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='device',
|
|
||||||
name='name',
|
|
||||||
field=models.CharField(max_length=100, unique=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 06:05
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0004_alter_device_name'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='toymovement',
|
|
||||||
name='from_warehouse',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='outgoing', to='management.warehouse'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='toymovement',
|
|
||||||
name='movement_type',
|
|
||||||
field=models.CharField(choices=[('from_warehouse', 'Warehouse → Device'), ('between_warehouses', 'Warehouse → Warehouse')], max_length=30),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 06:16
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0005_alter_toymovement_from_warehouse_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='device',
|
|
||||||
name='warehouse',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 07:49
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0006_remove_device_warehouse'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='expense_type',
|
|
||||||
field=models.CharField(choices=[('rent', 'Rent'), ('salary', 'Salary'), ('utilities', 'Utilities'), ('maintenance', 'Maintenance'), ('other', 'Other')], default='other', max_length=20),
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='ExpenseType',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 07:52
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0007_alter_expense_expense_type_delete_expensetype'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='expense_type',
|
|
||||||
field=models.CharField(choices=[('rent', 'Ijara'), ('salary', 'Maosh'), ('utilities', 'Kommunal to‘lovlar'), ('maintenance', 'Texnik xizmat'), ('other', 'Boshqa')], default='other', max_length=20),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 07:53
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0008_alter_expense_expense_type'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='expense_type',
|
|
||||||
field=models.CharField(choices=[('rent', 'Ijara'), ('salary', 'Maosh'), ('utilities', 'Kommunal to‘lovlar'), ('maintenance', 'Texnik xizmat'), ('food', 'Oziq-ovqat'), ('transport', "Yo'lkira"), ('other', 'Boshqa')], default='other', max_length=20),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 08:03
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0009_alter_expense_expense_type'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='expense',
|
|
||||||
name='device',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='expense',
|
|
||||||
name='employee',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='salaries', to=settings.AUTH_USER_MODEL),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='expense_type',
|
|
||||||
field=models.CharField(choices=[('rent', 'Ijara'), ('salary', 'Maosh'), ('utilities', 'Kommunal to‘lovlar'), ('maintenance', 'Texnik xizmat'), ('food', 'Oziq-ovqat'), ('transport', "Yo'lkira"), ('buy_toys', 'Oʻyinchoqlar sotib olish'), ('other', 'Boshqa')], default='other', max_length=20),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 08:04
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0010_expense_device_expense_employee_and_more'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='confirmed_by',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='confirmed_expenses', to=settings.AUTH_USER_MODEL),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-05 09:37
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0011_alter_expense_confirmed_by'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='income',
|
|
||||||
name='reported_by',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='income',
|
|
||||||
name='created_by',
|
|
||||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='created_incomes', to=settings.AUTH_USER_MODEL),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='income',
|
|
||||||
name='is_confirmed',
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='income',
|
|
||||||
name='confirmed_by',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='confirmed_incomes', to=settings.AUTH_USER_MODEL),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='income',
|
|
||||||
name='device',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='incomes', to='management.device'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-06 07:08
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0012_remove_income_reported_by_income_created_by_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RenameField(
|
|
||||||
model_name='device',
|
|
||||||
old_name='name',
|
|
||||||
new_name='address',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='device',
|
|
||||||
name='monthly_fee',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='device',
|
|
||||||
name='toys_count',
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='toymovement',
|
|
||||||
name='movement_type',
|
|
||||||
field=models.CharField(choices=[('from_warehouse', 'Ombordan → Aparatga'), ('between_warehouses', 'Ombordan → Omborga')], max_length=30),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Rent',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('address', models.CharField(max_length=100, unique=True)),
|
|
||||||
('due_date', models.DateField()),
|
|
||||||
('amount', models.IntegerField()),
|
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
||||||
('device', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='device_rents', to='management.device')),
|
|
||||||
('district', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='district_rents', to='management.district')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-06 12:15
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0013_rename_name_device_address_remove_device_monthly_fee_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='income',
|
|
||||||
name='amount',
|
|
||||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Generated by Django 6.0.2 on 2026-02-06 12:54
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0014_alter_income_amount'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='income',
|
|
||||||
name='confirmed_by',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-12 06:57
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0015_remove_income_confirmed_by'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='rent',
|
|
||||||
name='created_by',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='created_rents', to=settings.AUTH_USER_MODEL),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='rent',
|
|
||||||
name='is_paid',
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='rent',
|
|
||||||
name='paid_at',
|
|
||||||
field=models.DateTimeField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-12 09:33
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0016_rent_created_by_rent_is_paid_rent_paid_at'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='expense',
|
|
||||||
name='comment',
|
|
||||||
field=models.TextField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-12 13:27
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0017_expense_comment'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='income',
|
|
||||||
name='warehouse',
|
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='warehouse_incomes', to='management.warehouse'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-13 06:42
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0018_income_warehouse'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='expense',
|
|
||||||
name='expense_type',
|
|
||||||
field=models.CharField(choices=[('salary', 'Maosh'), ('utilities', 'Kommunal to‘lovlar'), ('maintenance', 'Texnik xizmat'), ('food', 'Oziq-ovqat'), ('transport', "Yo'lkira"), ('buy_toys', 'Oʻyinchoqlar sotib olish'), ('other', 'Boshqa')], default='other', max_length=20),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-13 09:30
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0019_alter_expense_expense_type'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='device',
|
|
||||||
name='amount',
|
|
||||||
field=models.IntegerField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='device',
|
|
||||||
name='due_date',
|
|
||||||
field=models.DateField(blank=True, null=True),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='device',
|
|
||||||
name='is_paid',
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-13 12:56
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0020_device_amount_device_due_date_device_is_paid'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Report',
|
|
||||||
fields=[
|
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('quantity', models.PositiveIntegerField(default=0)),
|
|
||||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
||||||
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
|
||||||
('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='management.device')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Generated by Django 5.2.7 on 2026-02-17 09:17
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('management', '0021_report'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='district',
|
|
||||||
name='region',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='districts', to='management.region'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
@@ -1,12 +1,30 @@
|
|||||||
|
from decimal import Decimal
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from .device import Device
|
|
||||||
|
|
||||||
class Income(models.Model):
|
class Income(models.Model):
|
||||||
device = models.ForeignKey(Device, related_name='incomes',on_delete=models.PROTECT)
|
warehouse = models.ForeignKey(
|
||||||
warehouse = models.ForeignKey("management.Warehouse", on_delete=models.PROTECT, related_name="warehouse_incomes", null=True, blank=True)
|
"management.Warehouse",
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
related_name="warehouse_incomes"
|
||||||
|
)
|
||||||
|
|
||||||
amount = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
|
toys_count = models.PositiveIntegerField(default=0)
|
||||||
|
|
||||||
|
price_per_toy = models.DecimalField(
|
||||||
|
max_digits=12,
|
||||||
|
decimal_places=2,
|
||||||
|
default=Decimal("0.00")
|
||||||
|
)
|
||||||
|
|
||||||
|
total_amount = models.DecimalField(
|
||||||
|
max_digits=14,
|
||||||
|
decimal_places=2,
|
||||||
|
editable=False,
|
||||||
|
default=Decimal("0.00")
|
||||||
|
)
|
||||||
|
|
||||||
created_by = models.ForeignKey("accounts.User", on_delete=models.PROTECT, related_name="created_incomes")
|
|
||||||
is_confirmed = models.BooleanField(default=False)
|
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
self.total_amount = self.toys_count * self.price_per_toy
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
<div class="dashboard-grid">
|
<div class="dashboard-grid">
|
||||||
<!-- View/Manage Actions -->
|
<!-- View/Manage Actions -->
|
||||||
|
<a href="{% url 'device_payment_list' %}" class="dashboard-card">
|
||||||
|
<div class="icon">🏠</div>
|
||||||
|
<div class="label">Arendalar</div>
|
||||||
|
</a>
|
||||||
<a href="{% url 'expense_list' %}" class="dashboard-card">
|
<a href="{% url 'expense_list' %}" class="dashboard-card">
|
||||||
<div class="icon">📋</div>
|
<div class="icon">📋</div>
|
||||||
<div class="label">Xarajatlar</div>
|
<div class="label">Xarajatlar</div>
|
||||||
@@ -22,6 +26,11 @@
|
|||||||
<div class="icon">🏭</div>
|
<div class="icon">🏭</div>
|
||||||
<div class="label">Omborlar</div>
|
<div class="label">Omborlar</div>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{% url 'income_list' %}" class="dashboard-card">
|
||||||
|
<div class="icon">💰</div>
|
||||||
|
<div class="label">Kirim Qo‘shish</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a href="{% url 'user_list' %}" class="dashboard-card">
|
<a href="{% url 'user_list' %}" class="dashboard-card">
|
||||||
<div class="icon">👥</div>
|
<div class="icon">👥</div>
|
||||||
<div class="label">Foydalanuvchilar</div>
|
<div class="label">Foydalanuvchilar</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}{{ title|default:"Yaratish" }}{% endblock %}
|
{% block title %}{{ title|default:"Kirim qo‘shish" }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<h2>{{ title|default:"Yaratish" }}</h2>
|
<h2>{{ title|default:"Kirim qo‘shish" }}</h2>
|
||||||
|
|
||||||
<a href="{% url 'income_list' %}" class="back-btn">
|
<a href="{% url 'income_list' %}" class="back-btn">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||||
@@ -17,18 +17,32 @@
|
|||||||
<form method="post" novalidate>
|
<form method="post" novalidate>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{% for field in form %}
|
<!-- Warehouse -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
|
<label for="{{ form.warehouse.id_for_label }}">Ombor</label>
|
||||||
{{ field }}
|
{{ form.warehouse }}
|
||||||
{% if field.help_text %}
|
{% for error in form.warehouse.errors %}
|
||||||
<small class="help-text">{{ field.help_text }}</small>
|
<div class="error">{{ error }}</div>
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
{% for error in field.errors %}
|
</div>
|
||||||
<div class="error">{{ error }}</div>
|
|
||||||
|
<!-- Toys Count -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.toys_count.id_for_label }}">O‘yinchoqlar soni</label>
|
||||||
|
{{ form.toys_count }}
|
||||||
|
{% for error in form.toys_count.errors %}
|
||||||
|
<div class="error">{{ error }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Price Per Toy -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ form.price_per_toy.id_for_label }}">Bir dona narxi</label>
|
||||||
|
{{ form.price_per_toy }}
|
||||||
|
{% for error in form.price_per_toy.errors %}
|
||||||
|
<div class="error">{{ error }}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<button type="submit" class="submit-btn">
|
<button type="submit" class="submit-btn">
|
||||||
{% if title %}{{ title }}{% else %}Saqlash{% endif %}
|
{% if title %}{{ title }}{% else %}Saqlash{% endif %}
|
||||||
@@ -85,7 +99,6 @@
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group label {
|
.form-group label {
|
||||||
@@ -110,12 +123,6 @@
|
|||||||
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
|
box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.help-text {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #6b7280;
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #ef4444;
|
color: #ef4444;
|
||||||
@@ -140,11 +147,11 @@
|
|||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile adjustments */
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
.form-container {
|
.form-container {
|
||||||
padding: 20px 16px;
|
padding: 20px 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -30,14 +30,22 @@
|
|||||||
<td>{{ device.due_date|date:"d.m.Y" }}</td>
|
<td>{{ device.due_date|date:"d.m.Y" }}</td>
|
||||||
<td class="amount-cell">{{ device.amount }}</td>
|
<td class="amount-cell">{{ device.amount }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not device.is_paid %}
|
{% if is_employee %}
|
||||||
<input type="checkbox"
|
{% if not device.is_paid %}
|
||||||
class="payment-checkbox"
|
<input type="checkbox"
|
||||||
data-device-id="{{ device.id }}"
|
class="payment-checkbox"
|
||||||
data-device-name="{{ device.address }}"
|
data-device-id="{{ device.id }}"
|
||||||
data-amount="{{ device.amount }}">
|
data-device-name="{{ device.address }}"
|
||||||
|
data-amount="{{ device.amount }}">
|
||||||
|
{% else %}
|
||||||
|
<span class="paid-badge">✅ To'langan</span>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="paid-badge">✅ To'langan</span>
|
{% if device.is_paid %}
|
||||||
|
<span class="paid-badge">✅ To'landi</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="unpaid-badge">❌ To'lanmadi</span>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -52,7 +60,8 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Confirmation Modal -->
|
<!-- Confirmation Modal (only rendered for employees) -->
|
||||||
|
{% if is_employee %}
|
||||||
<div id="confirmModal" class="modal hidden">
|
<div id="confirmModal" class="modal hidden">
|
||||||
<div class="modal-overlay"></div>
|
<div class="modal-overlay"></div>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -72,6 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.table-container {
|
.table-container {
|
||||||
@@ -170,9 +180,20 @@ input[type="checkbox"]:hover {
|
|||||||
color: #10b981;
|
color: #10b981;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
background: #d1fae5;
|
background: #d1fae5;
|
||||||
padding: 4px 8px;
|
padding: 4px 10px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unpaid-badge {
|
||||||
|
color: #dc2626;
|
||||||
|
font-weight: 600;
|
||||||
|
background: #fee2e2;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modal Styles */
|
/* Modal Styles */
|
||||||
@@ -329,6 +350,7 @@ input[type="checkbox"]:hover {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
{% if is_employee %}
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const modal = document.getElementById('confirmModal');
|
const modal = document.getElementById('confirmModal');
|
||||||
@@ -360,6 +382,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
document.querySelectorAll('.payment-checkbox').forEach(checkbox => {
|
document.querySelectorAll('.payment-checkbox').forEach(checkbox => {
|
||||||
checkbox.checked = false;
|
checkbox.checked = false;
|
||||||
});
|
});
|
||||||
|
currentDeviceId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelBtn.addEventListener('click', closeModal);
|
cancelBtn.addEventListener('click', closeModal);
|
||||||
@@ -369,7 +392,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
// Confirm payment
|
// Confirm payment
|
||||||
confirmBtn.addEventListener('click', function() {
|
confirmBtn.addEventListener('click', function() {
|
||||||
if (currentDeviceId) {
|
if (currentDeviceId) {
|
||||||
// Get CSRF token from hidden input
|
|
||||||
const csrfToken = document.getElementById('csrfToken').value;
|
const csrfToken = document.getElementById('csrfToken').value;
|
||||||
|
|
||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
@@ -397,5 +419,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -3,90 +3,67 @@
|
|||||||
{% block title %}Kirimlar{% endblock %}
|
{% block title %}Kirimlar{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2 style="margin-bottom:20px;">{{ title|default:"Kirimlar" }}</h2>
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
||||||
|
<h2 style="margin: 0;">{{ title|default:"Kirimlar" }}</h2>
|
||||||
|
|
||||||
|
{% if role == "businessman" %}
|
||||||
|
<a href="{% url 'create_income' %}"
|
||||||
|
class="btn edit"
|
||||||
|
style="padding: 12px 24px; text-decoration: none; background: #4f46e5; color: #fff; font-weight: 600; border-radius: 10px; transition: all 0.2s ease; display: inline-block; font-size: 15px;">
|
||||||
|
+ Yaratish
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
a.btn.edit:hover {
|
||||||
|
background: #4338ca;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<div class="cards-container">
|
<div class="cards-container">
|
||||||
{% for income in incomes %}
|
{% for income in incomes %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-row"><strong>Miqdor:</strong> {{ income.amount|default:"-" }}</div>
|
|
||||||
<div class="card-row"><strong>Aparat:</strong> {% if income.device %}{{ income.device.address }}{% else %}-{% endif %}</div>
|
|
||||||
<div class="card-row"><strong>Yaratgan:</strong> {{ income.created_by.get_full_name }}</div>
|
|
||||||
<div class="card-row"><strong>Yaratilgan sana:</strong> {{ income.created_at|date:"d.m.Y H:i" }}</div>
|
|
||||||
|
|
||||||
{% if role == "manager" or role == "businessman" %}
|
<div class="card-row">
|
||||||
|
<strong>Ombor:</strong> {{ income.warehouse }}
|
||||||
|
</div>
|
||||||
|
<div class="card-row">
|
||||||
|
<strong>O‘yinchoqlar soni:</strong> {{ income.toys_count }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-row">
|
||||||
|
<strong>Bir dona narxi:</strong> {{ income.price_per_toy }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-row">
|
||||||
|
<strong>Jami summa:</strong>
|
||||||
|
<span style="color: #16a34a; font-weight: 600;">
|
||||||
|
{{ income.total_amount }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-row">
|
||||||
|
<strong>Sana:</strong>
|
||||||
|
{{ income.created_at|date:"d.m.Y H:i" }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if role == "businessman" %}
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<a href="{% url 'edit_income' income.pk %}" class="btn edit">Tahrirlash</a>
|
<a href="{% url 'edit_income' income.pk %}"
|
||||||
|
class="btn edit">
|
||||||
|
Tahrirlash
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p style="text-align:center; font-style:italic;">Hech narsa topilmadi</p>
|
<p style="text-align:center; font-style:italic;">
|
||||||
|
Hech narsa topilmadi
|
||||||
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
<style>
|
|
||||||
.cards-container {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 16px 20px;
|
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 6px 16px rgba(0,0,0,0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-row {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #374151;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-row strong {
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions .btn {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 6px 10px;
|
|
||||||
border-radius: 6px;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #fff;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 13px;
|
|
||||||
margin-right: 6px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions .btn.edit { background: #4f46e5; }
|
|
||||||
.card-actions .btn.confirm { background: #10b981; }
|
|
||||||
.card-actions .btn.decline { background: #ef4444; }
|
|
||||||
|
|
||||||
.card-actions .btn:hover {
|
|
||||||
opacity: 0.85;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 640px) {
|
|
||||||
.card-row { font-size: 13px; }
|
|
||||||
.card-actions .btn { font-size: 12px; padding: 5px 8px; }
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
.cards-container { grid-template-columns: 1fr; }
|
|
||||||
.card { padding: 14px 16px; }
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
@@ -0,0 +1,261 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}ToyMovement Statistikasi{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="stats-container">
|
||||||
|
<div class="stats-header">
|
||||||
|
<h2>ToyMovement Statistikasi</h2>
|
||||||
|
<p class="subtitle">Qurilmalar bo'yicha harakat ro'yxati</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Filter Form -->
|
||||||
|
<form method="get" class="filter-form">
|
||||||
|
<div class="filter-row">
|
||||||
|
<div class="filter-group">
|
||||||
|
<label for="date_from">Boshlanish sanasi</label>
|
||||||
|
<input type="date" id="date_from" name="date_from" value="{{ date_from }}" class="filter-input">
|
||||||
|
</div>
|
||||||
|
<div class="filter-group">
|
||||||
|
<label for="date_to">Tugash sanasi</label>
|
||||||
|
<input type="date" id="date_to" name="date_to" value="{{ date_to }}" class="filter-input">
|
||||||
|
</div>
|
||||||
|
<div class="filter-group">
|
||||||
|
<label for="device">Qurilma</label>
|
||||||
|
<select id="device" name="device" class="filter-input">
|
||||||
|
<option value="">— Barchasi —</option>
|
||||||
|
{% for device in devices %}
|
||||||
|
<option value="{{ device.id }}" {% if selected_device == device.id|stringformat:"s" %}selected{% endif %}>
|
||||||
|
{{ device.address }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="filter-group filter-actions">
|
||||||
|
<button type="submit" class="btn-filter">Filtrlash</button>
|
||||||
|
<a href="{% url 'toy_movement_statistics' %}" class="btn-reset">Tozalash</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Table -->
|
||||||
|
{% if movements %}
|
||||||
|
<div class="table-wrapper">
|
||||||
|
<table class="stats-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>Qurilma</th>
|
||||||
|
<th>Miqdor</th>
|
||||||
|
<th>Sana</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for movement in movements %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ forloop.counter }}</td>
|
||||||
|
<td>{{ movement.device.address|default:"—" }}</td>
|
||||||
|
<td><span class="quantity-badge">{{ movement.quantity }}</span></td>
|
||||||
|
<td>{{ movement.created_at|date:"d.m.Y H:i" }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p class="total-count">Jami: <strong>{{ movements.count }}</strong> ta yozuv</p>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty-state">
|
||||||
|
<p>⚠️ Hech qanday ma'lumot topilmadi.</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<a href="{% url 'employee_dashboard' %}" class="back-link">← Orqaga qaytish</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.stats-container {
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 32px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 14px;
|
||||||
|
box-shadow: 0 6px 20px rgba(0,0,0,0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-header h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
margin: 0 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Filter */
|
||||||
|
.filter-form {
|
||||||
|
background: #f9fafb;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 18px 20px;
|
||||||
|
margin-bottom: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group label {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-input {
|
||||||
|
padding: 9px 12px;
|
||||||
|
border: 1.5px solid #d1d5db;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: inherit;
|
||||||
|
outline: none;
|
||||||
|
background: #fff;
|
||||||
|
transition: border-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-input:focus {
|
||||||
|
border-color: #4f46e5;
|
||||||
|
box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-filter {
|
||||||
|
padding: 9px 20px;
|
||||||
|
background: #4f46e5;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-filter:hover { background: #4338ca; }
|
||||||
|
|
||||||
|
.btn-reset {
|
||||||
|
padding: 9px 16px;
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #374151;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-reset:hover { background: #e5e7eb; }
|
||||||
|
|
||||||
|
/* Table */
|
||||||
|
.table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table thead {
|
||||||
|
background: #f3f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table th {
|
||||||
|
padding: 12px 16px;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #374151;
|
||||||
|
font-size: 13px;
|
||||||
|
border-bottom: 2px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table td {
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-bottom: 1px solid #f3f4f6;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table tbody tr:hover {
|
||||||
|
background: #f9fafb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-table tbody tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quantity-badge {
|
||||||
|
background: #dcfce7;
|
||||||
|
color: #16a34a;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total-count {
|
||||||
|
text-align: right;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px;
|
||||||
|
color: #9ca3af;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-link {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 20px;
|
||||||
|
color: #4f46e5;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-link:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.stats-container { padding: 20px 14px; }
|
||||||
|
.filter-row { flex-direction: column; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
<div class="icon">📦</div>
|
<div class="icon">📦</div>
|
||||||
<div class="label">Oʻyinchoq harakatlari</div>
|
<div class="label">Oʻyinchoq harakatlari</div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'create_report' %}" class="dashboard-card">
|
<a href="{% url 'toy_movement_statistics' %}" class="dashboard-card">
|
||||||
<div class="icon">📊</div>
|
<div class="icon">📊</div>
|
||||||
<div class="label">Yakuniy Hisobot</div>
|
<div class="label">Hisobotlar</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
<div class="dashboard-grid">
|
<div class="dashboard-grid">
|
||||||
<!-- View/Manage Actions -->
|
<!-- View/Manage Actions -->
|
||||||
|
<a href="{% url 'device_payment_list' %}" class="dashboard-card">
|
||||||
|
<div class="icon">🏠</div>
|
||||||
|
<div class="label">Arendalar</div>
|
||||||
|
</a>
|
||||||
<a href="{% url 'expense_list' %}" class="dashboard-card">
|
<a href="{% url 'expense_list' %}" class="dashboard-card">
|
||||||
<div class="icon">📋</div>
|
<div class="icon">📋</div>
|
||||||
<div class="label">Xarajatlar</div>
|
<div class="label">Xarajatlar</div>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ urlpatterns = [
|
|||||||
path("list/user/", views.user_list, name="user_list"),
|
path("list/user/", views.user_list, name="user_list"),
|
||||||
path("list/toy-movement/", views.toy_movement_list, name="toy_movement_list"),
|
path("list/toy-movement/", views.toy_movement_list, name="toy_movement_list"),
|
||||||
path("list/reports/", views.report_list, name="report_list"),
|
path("list/reports/", views.report_list, name="report_list"),
|
||||||
|
path("list/toy-movement-statistics/", views.toy_movement_statistics, name="toy_movement_statistics"),
|
||||||
# Edit
|
# Edit
|
||||||
path("edit/device/<int:pk>/", views.edit_device, name="edit_device"),
|
path("edit/device/<int:pk>/", views.edit_device, name="edit_device"),
|
||||||
path("edit/income/<int:pk>/", views.edit_income, name="edit_income"),
|
path("edit/income/<int:pk>/", views.edit_income, name="edit_income"),
|
||||||
|
|||||||
@@ -36,19 +36,21 @@ def create_device(request):
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@role_required(["employee"])
|
@role_required(["businessman"])
|
||||||
def create_income(request):
|
def create_income(request):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = IncomeForm(request.POST, user=request.user)
|
form = IncomeForm(request.POST, user=request.user)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
income = form.save(commit=False)
|
form.save()
|
||||||
if request.user.role == "employee":
|
|
||||||
income.amount = None
|
|
||||||
income.save()
|
|
||||||
return redirect("income_list")
|
return redirect("income_list")
|
||||||
else:
|
else:
|
||||||
form = IncomeForm(user=request.user)
|
form = IncomeForm(user=request.user)
|
||||||
return render(request, "common/create/income_create.html", {"form": form})
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"common/create/income_create.html",
|
||||||
|
{"form": form, "title": "Kirim qo'shish"}
|
||||||
|
)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@role_required(['manager', 'businessman'])
|
@role_required(['manager', 'businessman'])
|
||||||
|
|||||||
@@ -110,30 +110,43 @@ def toy_movement_list(request):
|
|||||||
return render(request, "common/lists/toy_movement_list.html", context)
|
return render(request, "common/lists/toy_movement_list.html", context)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@role_required(["manager", "businessman"])
|
@role_required(["businessman"])
|
||||||
def income_list(request):
|
def income_list(request):
|
||||||
|
|
||||||
if request.user.role == "businessman":
|
if request.user.role == "businessman":
|
||||||
incomes = Income.objects.all()
|
incomes = Income.objects.all()
|
||||||
elif request.user.role == "manager":
|
|
||||||
incomes = Income.objects.filter(warehouse__region=request.user.region)
|
|
||||||
|
|
||||||
return render(request, "common/create/income_create.html", {"incomes": incomes})
|
return render(
|
||||||
|
request,
|
||||||
|
"common/lists/income_list.html", # ✅ correct template
|
||||||
|
{
|
||||||
|
"incomes": incomes,
|
||||||
|
"role": request.user.role, # ✅ important
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@role_required(["employee"])
|
@role_required(["employee", "businessman", "manager"])
|
||||||
def device_payment_list(request):
|
def device_payment_list(request):
|
||||||
# Employee only sees devices in his region
|
user = request.user
|
||||||
devices = Device.objects.filter(
|
|
||||||
district__region=request.user.region
|
if user.role == "employee":
|
||||||
).order_by("due_date")
|
# Employee only sees devices in his region
|
||||||
|
devices = Device.objects.filter(
|
||||||
|
district__region=user.region
|
||||||
|
).order_by("due_date")
|
||||||
|
else:
|
||||||
|
# Businessman and manager see ALL devices
|
||||||
|
devices = Device.objects.all().order_by("due_date")
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"common/lists/device_payment_list.html",
|
"common/lists/device_payment_list.html",
|
||||||
{
|
{
|
||||||
"devices": devices,
|
"devices": devices,
|
||||||
"title": "Arendalar"
|
"title": "Arendalar",
|
||||||
|
"is_employee": user.role == "employee",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,3 +180,30 @@ def report_list(request):
|
|||||||
"title": "Hisobotlar"
|
"title": "Hisobotlar"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@role_required(["employee"])
|
||||||
|
def toy_movement_statistics(request):
|
||||||
|
movements = ToyMovement.objects.select_related("device").order_by("-created_at")
|
||||||
|
|
||||||
|
# Date filtering
|
||||||
|
date_from = request.GET.get("date_from")
|
||||||
|
date_to = request.GET.get("date_to")
|
||||||
|
device_id = request.GET.get("device")
|
||||||
|
|
||||||
|
if date_from:
|
||||||
|
movements = movements.filter(created_at__date__gte=date_from)
|
||||||
|
if date_to:
|
||||||
|
movements = movements.filter(created_at__date__lte=date_to)
|
||||||
|
if device_id:
|
||||||
|
movements = movements.filter(device_id=device_id)
|
||||||
|
|
||||||
|
devices = Device.objects.all().order_by("address")
|
||||||
|
|
||||||
|
return render(request, "common/lists/toy_movement_statistics.html", {
|
||||||
|
"movements": movements,
|
||||||
|
"devices": devices,
|
||||||
|
"date_from": date_from or "",
|
||||||
|
"date_to": date_to or "",
|
||||||
|
"selected_device": device_id or "",
|
||||||
|
})
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
# Generated by Django 5.1.3 on 2025-07-11 15:00
|
# Generated by Django 5.2.7 on 2026-02-18 08:13
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
@@ -16,7 +17,11 @@ class Migration(migrations.Migration):
|
|||||||
name='SettingsModel',
|
name='SettingsModel',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('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)),
|
||||||
('key', models.CharField(verbose_name='key')),
|
('key', models.CharField(verbose_name='key')),
|
||||||
|
('is_public', models.BooleanField(default=False, verbose_name='is public')),
|
||||||
|
('description', models.TextField(blank=True, null=True, verbose_name='description')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name': 'Settings',
|
'verbose_name': 'Settings',
|
||||||
@@ -28,8 +33,8 @@ class Migration(migrations.Migration):
|
|||||||
name='OptionsModel',
|
name='OptionsModel',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('key', models.CharField(verbose_name='key')),
|
('key', models.CharField(max_length=255, verbose_name='key')),
|
||||||
('value', models.CharField(verbose_name='value')),
|
('value', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=255, verbose_name='value'), size=None, verbose_name='value')),
|
||||||
('settings', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='shared.settingsmodel', verbose_name='settings')),
|
('settings', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='shared.settingsmodel', verbose_name='settings')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
# Generated by Django 5.1.3 on 2025-07-12 05:19
|
|
||||||
|
|
||||||
import django.contrib.postgres.fields
|
|
||||||
import django.utils.timezone
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('shared', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='settingsmodel',
|
|
||||||
name='created_at',
|
|
||||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='settingsmodel',
|
|
||||||
name='description',
|
|
||||||
field=models.TextField(blank=True, null=True, verbose_name='description'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='settingsmodel',
|
|
||||||
name='is_public',
|
|
||||||
field=models.BooleanField(default=False, verbose_name='is public'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='settingsmodel',
|
|
||||||
name='updated_at',
|
|
||||||
field=models.DateTimeField(auto_now=True),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='optionsmodel',
|
|
||||||
name='key',
|
|
||||||
field=models.CharField(max_length=255, verbose_name='key'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='optionsmodel',
|
|
||||||
name='value',
|
|
||||||
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=255, verbose_name='value'), size=None, verbose_name='value'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user