u
This commit is contained in:
@@ -54,8 +54,16 @@ export default function toggleFather(provider) {
|
||||
}
|
||||
|
||||
const stockRes = await runner.query(
|
||||
'SELECT COALESCE(SUM(l.amount), 0) AS totalStock FROM ledger l WHERE l.article_id = @articleId',
|
||||
{ articleId },
|
||||
`SELECT COALESCE(SUM(l.amount), 0) AS totalStock
|
||||
FROM ledger l
|
||||
INNER JOIN manifestarticle ma ON ma.id = l.manifestarticle_id
|
||||
INNER JOIN manifest m ON m.id = ma.manifest_id
|
||||
WHERE m.company_id = @companyId
|
||||
AND (
|
||||
ma.sku = @sku
|
||||
OR ma.sku IN (SELECT asup.sku FROM articlesupplier asup WHERE asup.article_id = @articleId)
|
||||
)`,
|
||||
{ companyId, sku, articleId },
|
||||
);
|
||||
const totalStock = Number(stockRes.rows[0]?.totalStock ?? 0);
|
||||
if (totalStock !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user