fix - device pre register & exception handling with json response
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
# Django secrets
|
# Django secrets
|
||||||
SECRET_KEY=django-insecure-@0apn-lk85pfw=z00x2ib$w9#rwz8%2v4i_n^^9jz-m9b+y55*
|
SECRET_KEY=django-insecure-@0apn-lk85pfw=z00x2ib$w9#rwz8%2v4i_n^^9jz-m9b+y55*
|
||||||
DEBUG=False
|
DEBUG=0
|
||||||
ALLOWED_HOSTS=localhost,127.0.0.1,https://rasadyar.net/,https://localhost:9200,https://api.rasadyaar.net,https://api.dam.rasadyaar.net',https://dam.rasadyar.net',http://localhost:3000',http://192.168.88.130:3000',https://rasaddam-front.liara.run',ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa
|
ALLOWED_HOSTS=localhost,127.0.0.1,https://rasadyar.net/,https://localhost:9200,https://api.rasadyaar.net,https://api.dam.rasadyaar.net',https://dam.rasadyar.net',http://localhost:3000',http://192.168.88.130:3000',https://rasaddam-front.liara.run',ns0ck4ksk0koks8ksw0ss08g.31.7.78.133.sslip.io' # noqa
|
||||||
ENV_NAME=DEV
|
ENV_NAME=DEV
|
||||||
|
|
||||||
# Database secrets
|
# Database secrets
|
||||||
DB_HOST=31.7.78.133
|
DB_HOST=31.7.78.133
|
||||||
DB_PORT=14352
|
DB_PORT=14352
|
||||||
DB_NAME=Production
|
DB_NAME=Development
|
||||||
DB_USERNAME=postgres
|
DB_USERNAME=postgres
|
||||||
DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV
|
DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ if not os.getenv("RUNNING_IN_DOCKER"):
|
|||||||
SECRET_KEY = os.environ.get("SECRET_KEY")
|
SECRET_KEY = os.environ.get("SECRET_KEY")
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = bool(os.environ.get("DEBUG", default=0))
|
# DEBUG = bool(os.environ.get("DEBUG", default=0))
|
||||||
|
DEBUG = os.getenv("DEBUG", "True").lower() in ("1", "true", "yes")
|
||||||
|
|
||||||
ASGI_APPLICATION = "Rasaddam_Backend.asgi.application" # noqa
|
ASGI_APPLICATION = "Rasaddam_Backend.asgi.application" # noqa
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-11-09 11:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('authentication', '0048_alter_bankaccountinformation_account_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bankaccountinformation',
|
||||||
|
name='account',
|
||||||
|
field=models.CharField(blank=True, max_length=25, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bankaccountinformation',
|
||||||
|
name='card',
|
||||||
|
field=models.CharField(blank=True, max_length=25, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bankaccountinformation',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(blank=True, max_length=150, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='bankaccountinformation',
|
||||||
|
name='sheba',
|
||||||
|
field=models.CharField(blank=True, max_length=30, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -78,6 +78,10 @@ class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFi
|
|||||||
organization = get_organization_by_user(request.user)
|
organization = get_organization_by_user(request.user)
|
||||||
request.data.update({'organization': organization.id})
|
request.data.update({'organization': organization.id})
|
||||||
|
|
||||||
|
# ser device preregister to true
|
||||||
|
# if device create in web panel, set to true for recognize by pos device
|
||||||
|
request.data.update({'pre_registered': True})
|
||||||
|
|
||||||
# create device
|
# create device
|
||||||
serializer = self.serializer_class(data=request.data)
|
serializer = self.serializer_class(data=request.data)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
|
|||||||
28
apps/product/services/quota_distribution_service.py
Normal file
28
apps/product/services/quota_distribution_service.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from django.db.models import Sum
|
||||||
|
|
||||||
|
from apps.product import models as product_models
|
||||||
|
|
||||||
|
|
||||||
|
class QuotaDistributionService:
|
||||||
|
"""
|
||||||
|
Service layer to manage multiple quota distributions as one unified entity.
|
||||||
|
Used for organization-based views and POS operations.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, quota, organization):
|
||||||
|
self.quota = quota
|
||||||
|
self.organization = organization
|
||||||
|
self.distribution = product_models.QuotaDistribution.objects.filter(
|
||||||
|
quota=quota,
|
||||||
|
assigned_organization=organization,
|
||||||
|
quota__is_closed=False,
|
||||||
|
warehouse_entry__gt=0
|
||||||
|
).first()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_weight(self):
|
||||||
|
return self.distribution.aggregate(
|
||||||
|
total=Sum('weight')
|
||||||
|
)['total'] or 0
|
||||||
|
|
||||||
|
pass
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-11-09 11:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('warehouse', '0040_inventoryquotasaleitem_base_price_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='payer_cart',
|
||||||
|
field=models.CharField(blank=True, max_length=50, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='rancher_fullname',
|
||||||
|
field=models.CharField(blank=True, max_length=150, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='rancher_mobile',
|
||||||
|
field=models.CharField(blank=True, max_length=25, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='ref_num',
|
||||||
|
field=models.CharField(blank=True, max_length=50, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='result_text',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='inventoryquotasaletransaction',
|
||||||
|
name='terminal',
|
||||||
|
field=models.CharField(blank=True, max_length=50, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -66,8 +66,8 @@ class InventoryQuotaSaleTransaction(BaseModel):
|
|||||||
related_name='transactions',
|
related_name='transactions',
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
rancher_fullname = models.CharField(max_length=150, null=True)
|
rancher_fullname = models.CharField(max_length=150, null=True, blank=True)
|
||||||
rancher_mobile = models.CharField(max_length=25, null=True)
|
rancher_mobile = models.CharField(max_length=25, null=True, blank=True)
|
||||||
pos_device = models.ForeignKey(
|
pos_device = models.ForeignKey(
|
||||||
Device,
|
Device,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
@@ -119,10 +119,10 @@ class InventoryQuotaSaleTransaction(BaseModel):
|
|||||||
)
|
)
|
||||||
transaction_status = models.CharField(choices=status_type, max_length=25, null=True)
|
transaction_status = models.CharField(choices=status_type, max_length=25, null=True)
|
||||||
transaction_status_code = models.IntegerField(default=0)
|
transaction_status_code = models.IntegerField(default=0)
|
||||||
result_text = models.TextField(null=True)
|
result_text = models.TextField(null=True, blank=True)
|
||||||
ref_num = models.CharField(max_length=50, null=True)
|
ref_num = models.CharField(max_length=50, null=True, blank=True)
|
||||||
terminal = models.CharField(max_length=50, null=True)
|
terminal = models.CharField(max_length=50, null=True, blank=True)
|
||||||
payer_cart = models.CharField(max_length=50, null=True)
|
payer_cart = models.CharField(max_length=50, null=True, blank=True)
|
||||||
pos_date = models.PositiveBigIntegerField(default=0)
|
pos_date = models.PositiveBigIntegerField(default=0)
|
||||||
transaction_date = models.DateTimeField(auto_now_add=True, null=True)
|
transaction_date = models.DateTimeField(auto_now_add=True, null=True)
|
||||||
free_sale_state = models.BooleanField(default=False)
|
free_sale_state = models.BooleanField(default=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user