add item share to transaction item

This commit is contained in:
2025-09-30 15:09:05 +03:30
parent 9da506c009
commit 246363826a
6 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-09-30 08:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0074_stakeholders_default'),
]
operations = [
migrations.AddField(
model_name='posfreeproducts',
name='company_fee',
field=models.IntegerField(default=0),
),
]

View File

@@ -327,6 +327,7 @@ class POSFreeProducts(BaseModel):
)
balance = models.PositiveIntegerField(default=0)
price = models.PositiveIntegerField(default=0)
company_fee = models.IntegerField(default=0)
def __str__(self):
return f'{self.product.name}-{self.organization.name}'

View File

@@ -33,6 +33,8 @@ class POSFreeProductSerializer(serializers.ModelSerializer):
'id': instance.product.id
}
representation['total_price'] = instance.price + instance.company_fee
return representation

View File

@@ -102,7 +102,10 @@ class POSFreeProductsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSear
organization = self.get_device_organization()
device = self.get_pos_device()
request.data.update({'organization': organization.id, 'device': device.id})
request.data.update({
'organization': organization.id,
'device': device.id,
})
serializer = product_serializers.POSFreeProductSerializer(data=request.data)
if serializer.is_valid():
@@ -110,3 +113,14 @@ class POSFreeProductsViewSet(SoftDeleteMixin, viewsets.ModelViewSet, DynamicSear
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_403_FORBIDDEN)
@action(
methods=['post'],
detail=False,
url_path='set_fee',
url_name='set_fee',
name='set_fee'
)
@transaction.atomic()
def set_company_fee_on_product(self, request):
pass

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-09-30 11:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('warehouse', '0036_inventoryquotasaleitem_inventory_calculation'),
]
operations = [
migrations.AddField(
model_name='inventoryquotasaleitem',
name='item_share',
field=models.JSONField(default=dict),
),
]

View File

@@ -179,6 +179,7 @@ class InventoryQuotaSaleItem(BaseModel):
is_pre_sale = models.BooleanField(default=False)
additional = models.JSONField(default=dict)
livestock_statistic = models.JSONField(default=dict)
item_share = models.JSONField(default=dict)
inventory_calculation = models.BooleanField(default=False)
@property