fix: 加强对账归属查询一致性
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import date
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy import extract, func, select
|
||||
from sqlalchemy import and_, extract, func, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.database import get_db
|
||||
@@ -101,7 +101,13 @@ def _reported_good_quantities(
|
||||
func.sum(ProductionReportAllocation.good_qty).label("good_qty"),
|
||||
)
|
||||
.select_from(ProductionReportAllocation)
|
||||
.join(ProductionReportItem, ProductionReportItem.id == ProductionReportAllocation.report_item_id)
|
||||
.join(
|
||||
ProductionReportItem,
|
||||
and_(
|
||||
ProductionReportItem.id == ProductionReportAllocation.report_item_id,
|
||||
ProductionReportItem.report_id == ProductionReportAllocation.report_id,
|
||||
),
|
||||
)
|
||||
.join(ProductionReport, ProductionReport.id == ProductionReportAllocation.report_id)
|
||||
.where(
|
||||
ProductionReport.status == ReportStatus.approved,
|
||||
|
||||
Reference in New Issue
Block a user