fixing DQ issues

This commit is contained in:
2025-09-14 15:47:38 +02:00
parent 3eb18ef91e
commit 0ce708cf09
27 changed files with 430 additions and 214 deletions

View File

@@ -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"}