|
|
@@ -3,12 +3,12 @@ from (
|
|
|
SELECT itemid, stockid, qty FROM sa_inventoryear
|
|
|
WHERE YEAR = $year$ AND MONTH = $month$ and siteid=$siteid$
|
|
|
union all
|
|
|
- SELECT t2.itemid, t2.stockid, t1.siteid, CASE WHEN type LIKE '%入%' AND rb = 1 THEN t2.qty WHEN type LIKE '%入%' AND rb = 0 THEN - t2.qty WHEN type LIKE '%出%' AND rb = 1 THEN - t2.qty WHEN type LIKE '%出%'
|
|
|
+ SELECT t2.itemid, t2.stockid, CASE WHEN type LIKE '%入%' AND rb = 1 THEN t2.qty WHEN type LIKE '%入%' AND rb = 0 THEN - t2.qty WHEN type LIKE '%出%' AND rb = 1 THEN - t2.qty WHEN type LIKE '%出%'
|
|
|
AND rb = 0 THEN t2.qty END qty FROM st_stockbill t1
|
|
|
JOIN st_stockbill_items t2 ON t1.st_stockbillid = t2.st_stockbillid AND t1.siteid = t2.siteid
|
|
|
WHERE t1.STATUS = '审核' AND ifnull(t1.typemx, '') != '正品入库' AND t1.billdate >= $begdate$ AND t1.billdate <= $enddate$ and t1.siteid=$siteid$
|
|
|
UNION ALL
|
|
|
- SELECT t2.itemid, t2.stockid, t1.siteid, CASE WHEN type LIKE '%入%' AND rb = 1 THEN t2.qty WHEN type LIKE '%入%' AND rb = 0 THEN - t2.qty END qty FROM st_stockbill t1
|
|
|
+ SELECT t2.itemid, t2.stockid, CASE WHEN type LIKE '%入%' AND rb = 1 THEN t2.qty WHEN type LIKE '%入%' AND rb = 0 THEN - t2.qty END qty FROM st_stockbill t1
|
|
|
JOIN st_stockbill_items t2 ON t1.st_stockbillid = t2.st_stockbillid AND t1.siteid = t2.siteid
|
|
|
WHERE t1.STATUS = '审核' AND ifnull(t1.typemx, '') = '正品入库' AND ifnull(t2.amount, 0) != 0 AND t1.billdate >= $begdate$ AND t1.billdate <= $enddate$ and t1.siteid=$siteid$
|
|
|
) t
|