u
This commit is contained in:
@@ -574,7 +574,30 @@ SELECT
|
||||
asup.sort,
|
||||
asup.net AS [price.net],
|
||||
asup.tax_id AS [price.taxId],
|
||||
t.rate AS [price.taxRate]
|
||||
t.rate AS [price.taxRate],
|
||||
(
|
||||
SELECT
|
||||
m.[date] AS [date],
|
||||
SUM(ma.amount - COALESCE(ma_ledger.booked_amount, 0)) AS amount
|
||||
FROM manifest m
|
||||
INNER JOIN manifestarticle ma ON ma.manifest_id = m.id
|
||||
LEFT JOIN (
|
||||
SELECT manifestarticle_id, SUM(amount) AS booked_amount
|
||||
FROM ledger
|
||||
WHERE warehouse_id IS NULL
|
||||
GROUP BY manifestarticle_id
|
||||
) ma_ledger ON ma_ledger.manifestarticle_id = ma.id
|
||||
WHERE m.company_id = a.company_id
|
||||
AND m.[type] = 'delivery'
|
||||
AND m.entity_id = asup.entity_id
|
||||
AND asup.sku IS NOT NULL
|
||||
AND asup.sku <> ''
|
||||
AND ma.sku = asup.sku
|
||||
AND (ma.amount - COALESCE(ma_ledger.booked_amount, 0)) > 0
|
||||
GROUP BY m.id, m.[date]
|
||||
ORDER BY m.[date] ASC, m.id ASC
|
||||
FOR JSON PATH
|
||||
) AS incomingJson
|
||||
FROM articlesupplier asup
|
||||
INNER JOIN entity e ON e.id = asup.entity_id
|
||||
LEFT JOIN tax t ON t.id = asup.tax_id
|
||||
|
||||
Reference in New Issue
Block a user