add - sharing & company fee to pos free products
This commit is contained in:
34
apps/core/migrations/0009_wage.py
Normal file
34
apps/core/migrations/0009_wage.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-11-05 13:06
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0008_systemconfig_quota'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Wage',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('create_date', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modify_date', models.DateTimeField(auto_now=True)),
|
||||||
|
('creator_info', models.CharField(max_length=100, null=True)),
|
||||||
|
('modifier_info', models.CharField(max_length=100, null=True)),
|
||||||
|
('trash', models.BooleanField(default=False)),
|
||||||
|
('key', models.CharField(max_length=100, null=True)),
|
||||||
|
('value', models.CharField(max_length=100, null=True)),
|
||||||
|
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_createddby', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_modifiedby', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
from django.db import models
|
|
||||||
from django.conf import settings
|
|
||||||
from crum import get_current_user
|
from crum import get_current_user
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
from .manager import SoftDeleteManager
|
from .manager import SoftDeleteManager
|
||||||
|
|
||||||
|
|
||||||
@@ -66,3 +67,15 @@ class SystemConfig(BaseModel):
|
|||||||
return cls.objects.get(key=key).value
|
return cls.objects.get(key=key).value
|
||||||
except cls.DoesNotExist:
|
except cls.DoesNotExist:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
class Wage(BaseModel):
|
||||||
|
key = models.CharField(max_length=100, null=True)
|
||||||
|
value = models.CharField(max_length=100, null=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get(cls, key, quota_identity=None, default=None):
|
||||||
|
try:
|
||||||
|
return cls.objects.get(key=key).value
|
||||||
|
except cls.DoesNotExist:
|
||||||
|
return default
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from apps.product import models as product_models
|
|
||||||
from apps.pos_device.models import POSFreeProducts
|
|
||||||
from apps.authentication.api.v1.serializers.serializer import OrganizationTypeSerializer
|
from apps.authentication.api.v1.serializers.serializer import OrganizationTypeSerializer
|
||||||
|
from apps.pos_device.models import POSFreeProducts
|
||||||
|
from apps.product import models as product_models
|
||||||
from apps.product.exceptions import FreePOSProductUniqueCheck
|
from apps.product.exceptions import FreePOSProductUniqueCheck
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +40,21 @@ class POSFreeProductSerializer(serializers.ModelSerializer):
|
|||||||
}
|
}
|
||||||
|
|
||||||
representation['total_price'] = instance.price + instance.company_fee
|
representation['total_price'] = instance.price + instance.company_fee
|
||||||
|
representation['main_shaba'] = instance.organization.bank_information.all().first().sheba # noqa
|
||||||
|
|
||||||
|
main_company = product_models.Organization.objects.get(
|
||||||
|
national_unique_id='1111111111'
|
||||||
|
)
|
||||||
|
main_company_bank_account = main_company.bank_information.first()
|
||||||
|
representation['sharing'] = {
|
||||||
|
"organization_name": main_company.name,
|
||||||
|
"bank_account": {
|
||||||
|
"credit_card": main_company_bank_account.card,
|
||||||
|
"sheba": main_company_bank_account.sheba,
|
||||||
|
"account": main_company_bank_account.account
|
||||||
|
},
|
||||||
|
"amount": instance.company_fee
|
||||||
|
}
|
||||||
|
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user