marketplace refactoring
This commit is contained in:
@@ -26,7 +26,7 @@ from app.exceptions import (
|
||||
)
|
||||
from models.schemas.stock import (StockAdd, StockCreate, StockLocationResponse,
|
||||
StockSummaryResponse, StockUpdate)
|
||||
from models.database.product import Product
|
||||
from models.database.marketplace_product import MarketplaceProduct
|
||||
from models.database.stock import Stock
|
||||
from app.utils.data_processing import GTINProcessor
|
||||
|
||||
@@ -261,7 +261,7 @@ class StockService:
|
||||
)
|
||||
|
||||
# Try to get product title for reference
|
||||
product = db.query(Product).filter(Product.gtin == normalized_gtin).first()
|
||||
product = db.query(MarketplaceProduct).filter(MarketplaceProduct.gtin == normalized_gtin).first()
|
||||
product_title = product.title if product else None
|
||||
|
||||
return StockSummaryResponse(
|
||||
@@ -304,7 +304,7 @@ class StockService:
|
||||
total_quantity = sum(entry.quantity for entry in total_stock)
|
||||
|
||||
# Get product info for context
|
||||
product = db.query(Product).filter(Product.gtin == normalized_gtin).first()
|
||||
product = db.query(MarketplaceProduct).filter(MarketplaceProduct.gtin == normalized_gtin).first()
|
||||
|
||||
return {
|
||||
"gtin": normalized_gtin,
|
||||
@@ -491,14 +491,14 @@ class StockService:
|
||||
low_stock_items = []
|
||||
for entry in low_stock_entries:
|
||||
# Get product info if available
|
||||
product = db.query(Product).filter(Product.gtin == entry.gtin).first()
|
||||
product = db.query(MarketplaceProduct).filter(MarketplaceProduct.gtin == entry.gtin).first()
|
||||
|
||||
low_stock_items.append({
|
||||
"gtin": entry.gtin,
|
||||
"location": entry.location,
|
||||
"current_quantity": entry.quantity,
|
||||
"product_title": product.title if product else None,
|
||||
"product_id": product.product_id if product else None,
|
||||
"marketplace_product_id": product.marketplace_product_id if product else None,
|
||||
})
|
||||
|
||||
return low_stock_items
|
||||
|
||||
Reference in New Issue
Block a user