v1.0
This commit is contained in:
		@@ -94,7 +94,9 @@ async def get_stocks_data(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    mix_stock_first_subquery = (
 | 
					    mix_stock_first_subquery = (
 | 
				
			||||||
        select(
 | 
					        select(
 | 
				
			||||||
            func.sum(SupplierProduct.supplier_stock).label('master_stock'),
 | 
					            func.sum(func.greatest(SupplierProduct.supplier_stock - SupplierProduct.sold_today, 0))
 | 
				
			||||||
 | 
					            .label(
 | 
				
			||||||
 | 
					                'master_stock'),
 | 
				
			||||||
            SupplierProduct.product_id.label('product_id')
 | 
					            SupplierProduct.product_id.label('product_id')
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .select_from(
 | 
					        .select_from(
 | 
				
			||||||
@@ -180,7 +182,7 @@ async def get_stocks_data(
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        .where(
 | 
					        .where(
 | 
				
			||||||
            SupplierProduct.supplier_id.in_(supplier_ids),
 | 
					            SupplierProduct.supplier_id.in_(supplier_ids),
 | 
				
			||||||
            SupplierProduct.supplier_stock > 0
 | 
					            (SupplierProduct.supplier_stock - SupplierProduct.sold_today) > 0
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .group_by(
 | 
					        .group_by(
 | 
				
			||||||
            Product.id
 | 
					            Product.id
 | 
				
			||||||
@@ -190,7 +192,7 @@ async def get_stocks_data(
 | 
				
			|||||||
    slaves_stock_first_subquery = (
 | 
					    slaves_stock_first_subquery = (
 | 
				
			||||||
        select(
 | 
					        select(
 | 
				
			||||||
            ProductRelation.master_product_id.label('product_id'),
 | 
					            ProductRelation.master_product_id.label('product_id'),
 | 
				
			||||||
            func.sum(SupplierProduct.supplier_stock).label('slaves_stock')
 | 
					            func.sum(func.greatest(SupplierProduct.supplier_stock - SupplierProduct.sold_today)).label('slaves_stock')
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .select_from(
 | 
					        .select_from(
 | 
				
			||||||
            ProductRelation
 | 
					            ProductRelation
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user