Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT ALLOWED
- CASE
- WHEN SalesTurnovers.Recorder = UNDEFINED
- THEN NULL
- ELSE SalesTurnovers.Recorder
- END AS Recorder,
- SalesTurnovers.Item AS Item,
- SalesTurnovers.Item AS ItemWithSKU,
- SalesTurnovers.Item.Description AS ItemPresentation,
- CASE
- WHEN SalesTurnovers.Characteristic = VALUE(Catalog.ItemCharacteristics.EmptyRef)
- THEN CASE
- WHEN SalesTurnovers.Batch <> VALUE(Catalog.ItemBatches.EmptyRef)
- THEN "N/A"
- ELSE NULL
- END
- ELSE SalesTurnovers.Characteristic
- END AS Characteristic,
- SalesTurnovers.Characteristic AS CharacteristicGrossProfit,
- CASE
- WHEN SalesTurnovers.Batch = VALUE(Catalog.ItemBatches.EmptyRef)
- THEN NULL
- ELSE SalesTurnovers.Batch
- END AS Batch,
- SalesTurnovers.Batch AS BatchGrossProfit,
- SalesTurnovers.Document AS Document,
- SalesTurnovers.VATRate AS VATRate,
- SalesTurnovers.Entity AS Entity,
- SalesTurnovers.CustomerOrder AS CustomerOrder,
- SalesTurnovers.QuantityTurnover AS Quantity,
- SalesTurnovers.AmountTurnover AS Amount,
- SalesTurnovers.AmountTurnover - SalesTurnovers.VATAmountTurnover AS AmountWithoutVAT,
- SalesTurnovers.VATAmountTurnover AS VATAmount,
- SalesTurnovers.CostPriceTurnover AS CostPrice,
- SalesTurnovers.Item.UnitOfMeasure AS ItemUnitOfMeasure,
- SalesTurnovers.Item.SKU AS ItemSKU,
- Companies.Ref AS Company,
- SalesTurnovers.Project AS Project,
- SalesTurnovers.Document.Date AS DocumentDate,
- SalesTurnovers.Document.Number AS DocumentNumber,
- SalesTurnovers.CustomerOrder.Date AS CustomerOrderDate,
- SalesTurnovers.CustomerOrder.Number AS CustomerOrderNumber,
- SalesTurnovers.WeekPeriod AS WeekPeriod,
- SalesTurnovers.MonthPeriod AS MonthPeriod,
- SalesTurnovers.QuarterPeriod AS QuarterPeriod,
- SalesTurnovers.HalfYearPeriod AS HalfYearPeriod,
- SalesTurnovers.YearPeriod AS YearPeriod,
- CASE
- WHEN SalesTurnovers.Item.Commissionable
- THEN SalesTurnovers.AmountTurnover - SalesTurnovers.VATAmountTurnover
- ELSE 0
- END AS AmountWithoutVATCI,
- CASE
- WHEN NOT SalesTurnovers.Item.Commissionable
- THEN SalesTurnovers.AmountTurnover - SalesTurnovers.VATAmountTurnover
- ELSE 0
- END AS AmountWithoutVATNCI,
- 0 AS Payment,
- SalesTurnovers.Document.Department AS Department,
- NULL AS AmountCancelled
- INTO Sales
- FROM
- AccumulationRegister.Sales.Turnovers(, , Auto, ) AS SalesTurnovers
- LEFT JOIN Catalog.Companies AS Companies
- ON SalesTurnovers.Document.Company = Companies.Ref
- UNION ALL
- SELECT
- AccountsReceivableDeferredTurnovers.Recorder,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.Document,
- NULL,
- AccountsReceivableDeferredTurnovers.Entity,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.Company,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.AmountExpense,
- AccountsReceivableDeferredTurnovers.Document.Department,
- NULL
- FROM
- AccumulationRegister.AccountsReceivableDeferred.Turnovers(, , Auto, &IncludingCheques) AS AccountsReceivableDeferredTurnovers
- WHERE
- AccountsReceivableDeferredTurnovers.Recorder REFS Document.ChequeReceipt
- UNION ALL
- SELECT
- CustomerAccountsTurnovers.Recorder,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- CustomerAccountsTurnovers.Document,
- NULL,
- CustomerAccountsTurnovers.Entity,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- CustomerAccountsTurnovers.Company,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- CustomerAccountsTurnovers.AmountExpense,
- CustomerAccountsTurnovers.Document.Department,
- NULL
- FROM
- AccumulationRegister.CustomerAccounts.Turnovers(, , Auto, ) AS CustomerAccountsTurnovers
- WHERE
- CASE
- WHEN &IncludingCheques
- THEN NOT CustomerAccountsTurnovers.Recorder.DocumentBasis REFS Document.ChequeReceipt
- ELSE TRUE
- END
- AND (CustomerAccountsTurnovers.Recorder REFS Document.PettyCashReceipt
- OR CustomerAccountsTurnovers.Recorder REFS Document.PaymentReceipt)
- UNION ALL
- SELECT
- AccountsReceivableDeferredTurnovers.Recorder,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.Document,
- NULL,
- AccountsReceivableDeferredTurnovers.Entity,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.Company,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AccountsReceivableDeferredTurnovers.Document.Department,
- AccountsReceivableDeferredTurnovers.AmountReceipt
- FROM
- AccumulationRegister.AccountsReceivableDeferred.Turnovers(, , Auto, &IncludingCheques) AS AccountsReceivableDeferredTurnovers
- WHERE
- AccountsReceivableDeferredTurnovers.Recorder REFS Document.ChequeCancellation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement