Skip to content

Instantly share code, notes, and snippets.

@vkostyanetsky
Created December 1, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkostyanetsky/f4423dcfb28d4a27039c7310c13c3a73 to your computer and use it in GitHub Desktop.
Save vkostyanetsky/f4423dcfb28d4a27039c7310c13c3a73 to your computer and use it in GitHub Desktop.
SELECT
<...>
FROM
TTReturns AS ReturnsTable
LEFT JOIN AccumulationRegister.Inventory AS TableSales
ON
ReturnsTable.Item = TableSales.Item
AND ReturnsTable.Characteristic = TableSales.Characteristic
AND ReturnsTable.Batch = TableSales.Batch
AND ReturnsTable.OrderSales = TableSales.OrderSales
AND ReturnsTable.SalesDocument = TableSales.SalesDocument
AND ReturnsTable.GLAccount_GL = TableSales.GLAccount_GL
AND ReturnsTable.CostObject = TableSales.CostObject
AND ReturnsTable.VATRate = TableSales.VATRate
AND TableSales.Entity = &Entity
AND TableSales.CorrGLAccount_GL = &EmptyAccount_GL
AND TableSales.RecordType = VALUE(AccumulationRecordType.Expense)
AND NOT TableSales.Return
GROUP BY
<...>
HAVING
(CAST(SUM(TableSales.Amount) - ReturnsTable.Amount AS NUMBER(15, 2))) <> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment