add some fields to transaction & sale item
This commit is contained in:
@@ -3,7 +3,8 @@ from apps.warehouse.models import (
|
||||
InventoryEntry,
|
||||
InventoryQuotaSaleTransaction,
|
||||
InventoryQuotaSaleItem,
|
||||
ExtraSale
|
||||
ExtraSale,
|
||||
QuotaPreSaleItem
|
||||
)
|
||||
from apps.product.models import QuotaDistribution
|
||||
from apps.core.models import SystemConfig
|
||||
@@ -87,7 +88,34 @@ def create_extra_sale(
|
||||
sale_item.quota_distribution.warehouse_balance = 0
|
||||
sale_item.quota_distribution.save()
|
||||
|
||||
# set transaction as free sale
|
||||
transaction.free_sale_state = True
|
||||
transaction.save()
|
||||
|
||||
# set sale item as extra sale
|
||||
sale_item.is_extra = True
|
||||
sale_item.save()
|
||||
|
||||
return extra_sale
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def create_pre_sale(
|
||||
transaction: InventoryQuotaSaleTransaction,
|
||||
sale_item: InventoryQuotaSaleItem
|
||||
) -> typing.Any:
|
||||
"""
|
||||
:param transaction
|
||||
:param sale_item
|
||||
Create pre_sale for distributions
|
||||
"""
|
||||
|
||||
if sale_item.quota_distribution.pre_sale:
|
||||
# create pre sale
|
||||
pre_sale = QuotaPreSaleItem.objects.create(
|
||||
transaction=transaction,
|
||||
sale_item=sale_item,
|
||||
distribution=sale_item.quota_distribution,
|
||||
weight=sale_item.weight
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user