Main mistake is that the report is generated on documents, not on their register records. The accumulation registers should be used to accumulate amounts you need.
For your case doubles are the result of
{FULL JOIN Document.CashDiscountSupplier.LineItems AS CashDiscountSupplierLineItems
ON (CashDiscountSupplierLineItems.Document = PurchaseInvoice.Ref)}
There are several lines in one of documents having reverences to a single payment document. You need to use
| Code |
|---|
SELECT
MIN(CashDiscountSupplierLineItems.Ref),
SUM(CashDiscountSupplierLineItems.CashDiscountAmount),
CashDiscountSupplierLineItems.Document
FROM
Document.CashDiscountSupplier.LineItems AS CashDiscountSupplierLineItems
GROUP BY
CashDiscountSupplierLineItems.Document |
instead of Document.CashDiscountSupplier.LineItems, but this causes the database to perform too much operations for large data.
For visual settings of the report you can use:
1) Selected Fields tab to define the list of fields and set an order, also use the Set Name item in the right mouse button menu for selected fields.
2) To convert the date + time into date you can use the Conditional Appearance tab and set the format for your field.