Advertisement
bytecoded

Top Query #2 (1C)

Mar 19th, 2019
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. SELECT ALLOWED
  2. CASE
  3. WHEN SalesTurnovers.Recorder = UNDEFINED
  4. THEN NULL
  5. ELSE SalesTurnovers.Recorder
  6. END AS Recorder,
  7. SalesTurnovers.Item AS Item,
  8. SalesTurnovers.Item AS ItemWithSKU,
  9. SalesTurnovers.Item.Description AS ItemPresentation,
  10. CASE
  11. WHEN SalesTurnovers.Characteristic = VALUE(Catalog.ItemCharacteristics.EmptyRef)
  12. THEN CASE
  13. WHEN SalesTurnovers.Batch <> VALUE(Catalog.ItemBatches.EmptyRef)
  14. THEN "N/A"
  15. ELSE NULL
  16. END
  17. ELSE SalesTurnovers.Characteristic
  18. END AS Characteristic,
  19. SalesTurnovers.Characteristic AS CharacteristicGrossProfit,
  20. CASE
  21. WHEN SalesTurnovers.Batch = VALUE(Catalog.ItemBatches.EmptyRef)
  22. THEN NULL
  23. ELSE SalesTurnovers.Batch
  24. END AS Batch,
  25. SalesTurnovers.Batch AS BatchGrossProfit,
  26. SalesTurnovers.Document AS Document,
  27. SalesTurnovers.VATRate AS VATRate,
  28. SalesTurnovers.Entity AS Entity,
  29. SalesTurnovers.CustomerOrder AS CustomerOrder,
  30. SalesTurnovers.QuantityTurnover AS Quantity,
  31. SalesTurnovers.AmountTurnover AS Amount,
  32. SalesTurnovers.AmountTurnover - SalesTurnovers.VATAmountTurnover AS AmountWithoutVAT,
  33. SalesTurnovers.VATAmountTurnover AS VATAmount,
  34. SalesTurnovers.CostPriceTurnover AS CostPrice,
  35. SalesTurnovers.Item.UnitOfMeasure AS ItemUnitOfMeasure,
  36. SalesTurnovers.Item.SKU AS ItemSKU,
  37. SalesTurnovers.Document.Responsible AS Responsible,
  38. CASE
  39. WHEN SalesTurnovers.Document REFS Document.AdvancesReport
  40. THEN VALUE(Catalog.BaseUnits.EmptyRef)
  41. WHEN SalesTurnovers.Document REFS Document.InventoryReceipt
  42. THEN SalesTurnovers.Document.BaseUnit
  43. ELSE SalesTurnovers.Document.Department
  44. END AS Department,
  45. Companies.Ref AS Company,
  46. SalesTurnovers.Project AS Project,
  47. SalesTurnovers.Document.Date AS DocumentDate,
  48. SalesTurnovers.Document.Number AS DocumentNumber,
  49. SalesTurnovers.CustomerOrder.Date AS CustomerOrderDate,
  50. SalesTurnovers.CustomerOrder.Number AS CustomerOrderNumber,
  51. SalesTurnovers.WeekPeriod AS WeekPeriod,
  52. SalesTurnovers.MonthPeriod AS MonthPeriod,
  53. SalesTurnovers.QuarterPeriod AS QuarterPeriod,
  54. SalesTurnovers.HalfYearPeriod AS HalfYearPeriod,
  55. SalesTurnovers.YearPeriod AS YearPeriod
  56. FROM
  57. AccumulationRegister.Sales.Turnovers(, , Auto, ) AS SalesTurnovers
  58. LEFT JOIN Catalog.Companies AS Companies
  59. ON (Companies.Ref = SalesTurnovers.Document.Company)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement