fixing DQ issues
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
# app/api/deps.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
from fastapi import Depends, HTTPException
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -17,7 +26,7 @@ def get_current_user(
|
||||
credentials: HTTPAuthorizationCredentials = Depends(security),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get current authenticated user"""
|
||||
"""Get current authenticated user."""
|
||||
# Check if credentials are provided
|
||||
if not credentials:
|
||||
raise HTTPException(status_code=401, detail="Authorization header required")
|
||||
@@ -26,7 +35,7 @@ def get_current_user(
|
||||
|
||||
|
||||
def get_current_admin_user(current_user: User = Depends(get_current_user)):
|
||||
"""Require admin user"""
|
||||
"""Require admin user."""
|
||||
return auth_manager.require_admin(current_user)
|
||||
|
||||
|
||||
@@ -35,7 +44,7 @@ def get_user_shop(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get shop and verify user ownership"""
|
||||
"""Get shop and verify user ownership."""
|
||||
shop = db.query(Shop).filter(Shop.shop_code == shop_code.upper()).first()
|
||||
if not shop:
|
||||
raise HTTPException(status_code=404, detail="Shop not found")
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/api/main.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api.v1 import admin, auth, marketplace, product, shop, stats, stock
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/api/v1/admin.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
@@ -7,8 +16,11 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_admin_user
|
||||
from app.core.database import get_db
|
||||
from app.services.admin_service import admin_service
|
||||
from models.api_models import (MarketplaceImportJobResponse, ShopListResponse,
|
||||
UserResponse)
|
||||
from models.api_models import (
|
||||
MarketplaceImportJobResponse,
|
||||
ShopListResponse,
|
||||
UserResponse,
|
||||
)
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
@@ -23,7 +35,7 @@ def get_all_users(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Get all users (Admin only)"""
|
||||
"""Get all users (Admin only)."""
|
||||
try:
|
||||
users = admin_service.get_all_users(db=db, skip=skip, limit=limit)
|
||||
return [UserResponse.model_validate(user) for user in users]
|
||||
@@ -38,7 +50,7 @@ def toggle_user_status(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Toggle user active status (Admin only)"""
|
||||
"""Toggle user active status (Admin only)."""
|
||||
try:
|
||||
user, message = admin_service.toggle_user_status(db, user_id, current_admin.id)
|
||||
return {"message": message}
|
||||
@@ -56,7 +68,7 @@ def get_all_shops_admin(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Get all shops with admin view (Admin only)"""
|
||||
"""Get all shops with admin view (Admin only)."""
|
||||
try:
|
||||
shops, total = admin_service.get_all_shops(db=db, skip=skip, limit=limit)
|
||||
|
||||
@@ -72,7 +84,7 @@ def verify_shop(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Verify/unverify shop (Admin only)"""
|
||||
"""Verify/unverify shop (Admin only)."""
|
||||
try:
|
||||
shop, message = admin_service.verify_shop(db, shop_id)
|
||||
return {"message": message}
|
||||
@@ -89,7 +101,7 @@ def toggle_shop_status(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Toggle shop active status (Admin only)"""
|
||||
"""Toggle shop active status (Admin only)."""
|
||||
try:
|
||||
shop, message = admin_service.toggle_shop_status(db, shop_id)
|
||||
return {"message": message}
|
||||
@@ -112,7 +124,7 @@ def get_all_marketplace_import_jobs(
|
||||
db: Session = Depends(get_db),
|
||||
current_admin: User = Depends(get_current_admin_user),
|
||||
):
|
||||
"""Get all marketplace import jobs (Admin only)"""
|
||||
"""Get all marketplace import jobs (Admin only)."""
|
||||
try:
|
||||
return admin_service.get_marketplace_import_jobs(
|
||||
db=db,
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/api/v1/auth.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
@@ -6,8 +15,7 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_user
|
||||
from app.core.database import get_db
|
||||
from app.services.auth_service import auth_service
|
||||
from models.api_models import (LoginResponse, UserLogin, UserRegister,
|
||||
UserResponse)
|
||||
from models.api_models import LoginResponse, UserLogin, UserRegister, UserResponse
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
@@ -17,7 +25,7 @@ logger = logging.getLogger(__name__)
|
||||
# Authentication Routes
|
||||
@router.post("/auth/register", response_model=UserResponse)
|
||||
def register_user(user_data: UserRegister, db: Session = Depends(get_db)):
|
||||
"""Register a new user"""
|
||||
"""Register a new user."""
|
||||
try:
|
||||
user = auth_service.register_user(db=db, user_data=user_data)
|
||||
return UserResponse.model_validate(user)
|
||||
@@ -30,7 +38,7 @@ def register_user(user_data: UserRegister, db: Session = Depends(get_db)):
|
||||
|
||||
@router.post("/auth/login", response_model=LoginResponse)
|
||||
def login_user(user_credentials: UserLogin, db: Session = Depends(get_db)):
|
||||
"""Login user and return JWT token"""
|
||||
"""Login user and return JWT token."""
|
||||
try:
|
||||
login_result = auth_service.login_user(db=db, user_credentials=user_credentials)
|
||||
|
||||
@@ -49,5 +57,5 @@ def login_user(user_credentials: UserLogin, db: Session = Depends(get_db)):
|
||||
|
||||
@router.get("/auth/me", response_model=UserResponse)
|
||||
def get_current_user_info(current_user: User = Depends(get_current_user)):
|
||||
"""Get current user information"""
|
||||
"""Get current user information."""
|
||||
return UserResponse.model_validate(current_user)
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/api/v1/marketplace.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
@@ -9,8 +18,7 @@ from app.core.database import get_db
|
||||
from app.services.marketplace_service import marketplace_service
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from middleware.decorators import rate_limit
|
||||
from models.api_models import (MarketplaceImportJobResponse,
|
||||
MarketplaceImportRequest)
|
||||
from models.api_models import MarketplaceImportJobResponse, MarketplaceImportRequest
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
@@ -26,7 +34,7 @@ async def import_products_from_marketplace(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Import products from marketplace CSV with background processing (Protected)"""
|
||||
"""Import products from marketplace CSV with background processing (Protected)."""
|
||||
try:
|
||||
logger.info(
|
||||
f"Starting marketplace import: {request.marketplace} -> {request.shop_code} by user {current_user.username}"
|
||||
@@ -73,7 +81,7 @@ def get_marketplace_import_status(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get status of marketplace import job (Protected)"""
|
||||
"""Get status of marketplace import job (Protected)."""
|
||||
try:
|
||||
job = marketplace_service.get_import_job_by_id(db, job_id, current_user)
|
||||
return marketplace_service.convert_to_response_model(job)
|
||||
@@ -98,7 +106,7 @@ def get_marketplace_import_jobs(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get marketplace import jobs with filtering (Protected)"""
|
||||
"""Get marketplace import jobs with filtering (Protected)."""
|
||||
try:
|
||||
jobs = marketplace_service.get_import_jobs(
|
||||
db=db,
|
||||
@@ -120,7 +128,7 @@ def get_marketplace_import_jobs(
|
||||
def get_marketplace_import_stats(
|
||||
db: Session = Depends(get_db), current_user: User = Depends(get_current_user)
|
||||
):
|
||||
"""Get statistics about marketplace import jobs (Protected)"""
|
||||
"""Get statistics about marketplace import jobs (Protected)."""
|
||||
try:
|
||||
stats = marketplace_service.get_job_stats(db, current_user)
|
||||
return stats
|
||||
@@ -139,7 +147,7 @@ def cancel_marketplace_import_job(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Cancel a pending or running marketplace import job (Protected)"""
|
||||
"""Cancel a pending or running marketplace import job (Protected)."""
|
||||
try:
|
||||
job = marketplace_service.cancel_import_job(db, job_id, current_user)
|
||||
return marketplace_service.convert_to_response_model(job)
|
||||
@@ -159,7 +167,7 @@ def delete_marketplace_import_job(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a completed marketplace import job (Protected)"""
|
||||
"""Delete a completed marketplace import job (Protected)."""
|
||||
try:
|
||||
marketplace_service.delete_import_job(db, job_id, current_user)
|
||||
return {"message": "Marketplace import job deleted successfully"}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/api/v1/product.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
@@ -8,9 +17,13 @@ from sqlalchemy.orm import Session
|
||||
from app.api.deps import get_current_user
|
||||
from app.core.database import get_db
|
||||
from app.services.product_service import product_service
|
||||
from models.api_models import (ProductCreate, ProductDetailResponse,
|
||||
ProductListResponse, ProductResponse,
|
||||
ProductUpdate)
|
||||
from models.api_models import (
|
||||
ProductCreate,
|
||||
ProductDetailResponse,
|
||||
ProductListResponse,
|
||||
ProductResponse,
|
||||
ProductUpdate,
|
||||
)
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
@@ -31,8 +44,7 @@ def get_products(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get products with advanced filtering including marketplace and shop (Protected)"""
|
||||
|
||||
"""Get products with advanced filtering including marketplace and shop (Protected)."""
|
||||
try:
|
||||
products, total = product_service.get_products_with_filters(
|
||||
db=db,
|
||||
@@ -60,8 +72,7 @@ def create_product(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new product with validation and marketplace support (Protected)"""
|
||||
|
||||
"""Create a new product with validation and marketplace support (Protected)."""
|
||||
try:
|
||||
logger.info(f"Starting product creation for ID: {product.product_id}")
|
||||
|
||||
@@ -99,8 +110,7 @@ def get_product(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get product with stock information (Protected)"""
|
||||
|
||||
"""Get product with stock information (Protected)."""
|
||||
try:
|
||||
product = product_service.get_product_by_id(db, product_id)
|
||||
if not product:
|
||||
@@ -127,8 +137,7 @@ def update_product(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Update product with validation and marketplace support (Protected)"""
|
||||
|
||||
"""Update product with validation and marketplace support (Protected)."""
|
||||
try:
|
||||
product = product_service.get_product_by_id(db, product_id)
|
||||
if not product:
|
||||
@@ -152,8 +161,7 @@ def delete_product(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Delete product and associated stock (Protected)"""
|
||||
|
||||
"""Delete product and associated stock (Protected)."""
|
||||
try:
|
||||
product = product_service.get_product_by_id(db, product_id)
|
||||
if not product:
|
||||
@@ -178,8 +186,7 @@ async def export_csv(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Export products as CSV with streaming and marketplace filtering (Protected)"""
|
||||
|
||||
"""Export products as CSV with streaming and marketplace filtering (Protected)."""
|
||||
try:
|
||||
|
||||
def generate_csv():
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
# app/api/v1/shop.py
|
||||
"""Summary description ....
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_user, get_user_shop
|
||||
from app.core.database import get_db
|
||||
from app.services.shop_service import shop_service
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from middleware.decorators import rate_limit
|
||||
from models.api_models import (MarketplaceImportJobResponse,
|
||||
MarketplaceImportRequest, ShopCreate,
|
||||
ShopListResponse, ShopProductCreate,
|
||||
ShopProductResponse, ShopResponse)
|
||||
from models.database_models import (MarketplaceImportJob, Product, Shop,
|
||||
ShopProduct, User)
|
||||
|
||||
from models.api_models import (
|
||||
ShopCreate,
|
||||
ShopListResponse,
|
||||
ShopProductCreate,
|
||||
ShopProductResponse,
|
||||
ShopResponse,
|
||||
)
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -28,7 +36,7 @@ def create_shop(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new shop (Protected)"""
|
||||
"""Create a new shop (Protected)."""
|
||||
try:
|
||||
shop = shop_service.create_shop(
|
||||
db=db, shop_data=shop_data, current_user=current_user
|
||||
@@ -50,7 +58,7 @@ def get_shops(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get shops with filtering (Protected)"""
|
||||
"""Get shops with filtering (Protected)."""
|
||||
try:
|
||||
shops, total = shop_service.get_shops(
|
||||
db=db,
|
||||
@@ -75,7 +83,7 @@ def get_shop(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get shop details (Protected)"""
|
||||
"""Get shop details (Protected)."""
|
||||
try:
|
||||
shop = shop_service.get_shop_by_code(
|
||||
db=db, shop_code=shop_code, current_user=current_user
|
||||
@@ -96,7 +104,7 @@ def add_product_to_shop(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Add existing product to shop catalog with shop-specific settings (Protected)"""
|
||||
"""Add existing product to shop catalog with shop-specific settings (Protected)."""
|
||||
try:
|
||||
# Get and verify shop (using existing dependency)
|
||||
shop = get_user_shop(shop_code, current_user, db)
|
||||
@@ -127,7 +135,7 @@ def get_shop_products(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get products in shop catalog (Protected)"""
|
||||
"""Get products in shop catalog (Protected)."""
|
||||
try:
|
||||
# Get shop
|
||||
shop = shop_service.get_shop_by_code(
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
# app/api/v1/stats.py
|
||||
"""Summary description ....
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query
|
||||
from sqlalchemy import func
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_user
|
||||
from app.core.database import get_db
|
||||
from app.services.stats_service import stats_service
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from middleware.decorators import rate_limit
|
||||
from models.api_models import (MarketplaceImportJobResponse,
|
||||
MarketplaceImportRequest,
|
||||
MarketplaceStatsResponse, StatsResponse)
|
||||
from models.database_models import (MarketplaceImportJob, Product, Shop, Stock,
|
||||
User)
|
||||
from models.api_models import (
|
||||
MarketplaceStatsResponse,
|
||||
StatsResponse,
|
||||
)
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -26,7 +31,7 @@ logger = logging.getLogger(__name__)
|
||||
def get_stats(
|
||||
db: Session = Depends(get_db), current_user: User = Depends(get_current_user)
|
||||
):
|
||||
"""Get comprehensive statistics with marketplace data (Protected)"""
|
||||
"""Get comprehensive statistics with marketplace data (Protected)."""
|
||||
try:
|
||||
stats_data = stats_service.get_comprehensive_stats(db=db)
|
||||
|
||||
@@ -48,7 +53,7 @@ def get_stats(
|
||||
def get_marketplace_stats(
|
||||
db: Session = Depends(get_db), current_user: User = Depends(get_current_user)
|
||||
):
|
||||
"""Get statistics broken down by marketplace (Protected)"""
|
||||
"""Get statistics broken down by marketplace (Protected)."""
|
||||
try:
|
||||
marketplace_stats = stats_service.get_marketplace_breakdown_stats(db=db)
|
||||
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
# app/api/v1/stock.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_user
|
||||
from app.core.database import get_db
|
||||
from app.services.stock_service import stock_service
|
||||
from app.tasks.background_tasks import process_marketplace_import
|
||||
from middleware.decorators import rate_limit
|
||||
from models.api_models import (MarketplaceImportJobResponse,
|
||||
MarketplaceImportRequest, StockAdd, StockCreate,
|
||||
StockResponse, StockSummaryResponse,
|
||||
StockUpdate)
|
||||
from models.database_models import MarketplaceImportJob, Shop, User
|
||||
from models.api_models import (
|
||||
StockAdd,
|
||||
StockCreate,
|
||||
StockResponse,
|
||||
StockSummaryResponse,
|
||||
StockUpdate,
|
||||
)
|
||||
from models.database_models import User
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -28,7 +38,7 @@ def set_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Set exact stock quantity for a GTIN at a specific location (replaces existing quantity)"""
|
||||
"""Set exact stock quantity for a GTIN at a specific location (replaces existing quantity)."""
|
||||
try:
|
||||
result = stock_service.set_stock(db, stock)
|
||||
return result
|
||||
@@ -45,7 +55,7 @@ def add_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Add quantity to existing stock for a GTIN at a specific location (adds to existing quantity)"""
|
||||
"""Add quantity to existing stock for a GTIN at a specific location (adds to existing quantity)."""
|
||||
try:
|
||||
result = stock_service.add_stock(db, stock)
|
||||
return result
|
||||
@@ -62,7 +72,7 @@ def remove_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Remove quantity from existing stock for a GTIN at a specific location"""
|
||||
"""Remove quantity from existing stock for a GTIN at a specific location."""
|
||||
try:
|
||||
result = stock_service.remove_stock(db, stock)
|
||||
return result
|
||||
@@ -79,7 +89,7 @@ def get_stock_by_gtin(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get all stock locations and total quantity for a specific GTIN"""
|
||||
"""Get all stock locations and total quantity for a specific GTIN."""
|
||||
try:
|
||||
result = stock_service.get_stock_by_gtin(db, gtin)
|
||||
return result
|
||||
@@ -96,7 +106,7 @@ def get_total_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get total quantity in stock for a specific GTIN"""
|
||||
"""Get total quantity in stock for a specific GTIN."""
|
||||
try:
|
||||
result = stock_service.get_total_stock(db, gtin)
|
||||
return result
|
||||
@@ -116,7 +126,7 @@ def get_all_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Get all stock entries with optional filtering"""
|
||||
"""Get all stock entries with optional filtering."""
|
||||
try:
|
||||
result = stock_service.get_all_stock(
|
||||
db=db, skip=skip, limit=limit, location=location, gtin=gtin
|
||||
@@ -134,7 +144,7 @@ def update_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Update stock quantity for a specific stock entry"""
|
||||
"""Update stock quantity for a specific stock entry."""
|
||||
try:
|
||||
result = stock_service.update_stock(db, stock_id, stock_update)
|
||||
return result
|
||||
@@ -151,7 +161,7 @@ def delete_stock(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a stock entry"""
|
||||
"""Delete a stock entry."""
|
||||
try:
|
||||
stock_service.delete_stock(db, stock_id)
|
||||
return {"message": "Stock entry deleted successfully"}
|
||||
|
||||
Reference in New Issue
Block a user