fix --> bug of transactions dashboard with free visibility scope on queryset
This commit is contained in:
@@ -12,7 +12,14 @@ from apps.warehouse.models import InventoryQuotaSaleTransaction, InventoryQuotaS
|
||||
class TransactionDashboardService:
|
||||
|
||||
@staticmethod
|
||||
def get_dashboard(org: Organization, start_date: str = None, end_date: str = None, status: str = None):
|
||||
def get_dashboard(
|
||||
org: Organization,
|
||||
free_visibility_tr_objects=None,
|
||||
free_visibility_tr_item_objects=None,
|
||||
start_date: str = None,
|
||||
end_date: str = None,
|
||||
status: str = None
|
||||
):
|
||||
|
||||
orgs_child = get_all_org_child(org=org)
|
||||
orgs_child.append(org)
|
||||
@@ -23,13 +30,18 @@ class TransactionDashboardService:
|
||||
items = InventoryQuotaSaleItem.objects.all().select_related("gov_product", "free_product")
|
||||
|
||||
else:
|
||||
transactions = InventoryQuotaSaleTransaction.objects.filter(
|
||||
seller_organization__in=orgs_child
|
||||
)
|
||||
|
||||
items = InventoryQuotaSaleItem.objects.filter(
|
||||
transaction__seller_organization__in=orgs_child
|
||||
).select_related("gov_product", "free_product")
|
||||
if free_visibility_tr_objects:
|
||||
transactions = free_visibility_tr_objects
|
||||
items = InventoryQuotaSaleItem.objects.filter(
|
||||
transaction__in=transactions
|
||||
).select_related("gov_product", "free_product")
|
||||
else:
|
||||
transactions = InventoryQuotaSaleTransaction.objects.filter(
|
||||
seller_organization__in=orgs_child
|
||||
)
|
||||
items = InventoryQuotaSaleItem.objects.filter(
|
||||
transaction__seller_organization__in=orgs_child
|
||||
).select_related("gov_product", "free_product")
|
||||
|
||||
# filter queryset (transactions & items) by date
|
||||
if start_date and end_date:
|
||||
|
||||
Reference in New Issue
Block a user