Grouping of fields in report

Common questions about 1C:Query language, Query builder tool and Data composition schema

#1
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

I have following code:

Code
SEL ECT
   PaymentLineItems.Payment AS Payment,
   PurchaseInvoice.Date AS DatePurchase,
   PurchaseInvoice.Ref AS RefPurchase,
   PurchaseInvoice.DocumentTotalRC AS PurchaseAmount,
   PaymentLineItems.Ref.Date AS PaymentDate,
   PaymentLineItems.Ref AS RefLines,
   PurchaseInvoice.Company,
   PurchaseInvoice.Memo,
   CashDiscountSupplierLineItems.Ref AS CDRef,
   CashDiscountSupplierLineItems.CashDiscountAmount AS CDAmount
FR OM
   Document.Payment.LineItems AS PaymentLineItems
      FULL JOIN Document.PurchaseInvoice AS PurchaseInvoice
         {FULL JOIN Document.CashDiscountSupplier.LineItems AS CashDiscountSupplierLineItems
         ON (CashDiscountSupplierLineItems.Document = PurchaseInvoice.Ref)}
      ON PaymentLineItems.Document = PurchaseInvoice.Ref

and I need to get Joined fileds in one row. The idea is following: there are three types of documents - PurchaseInvoice, Payment and CashDiscount. References to PurchaseInvoice in Payment and CashDiscount are the same.

It seems to work, but I get one row double. Please download the base:

<deleted, please attach files to messages>

Report name is GoodsInBook2.

Thanks for your help

 
#2
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Additionally:

It should look like that:

Date         Company     InvoiceAmount  Payment   CashDiscount

04.04.12   Elektrolux     350,00              200,00         8,00

 
#3
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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.

 
#4
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Thanks,

Unfortunately, I still haven't managed to inlude the code suggested by you, but it doesn't matter.

You wrote:

"There are several lines in one of documents having reverences to a single payment document."

I deleted "odd" lines from documents Payment and CashDiscountSupplier so that in every of them is only one line left. But I get the same output in the table

 
#5
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

You had in both on the first line Purchase Invoice 2 and on the second Purchase Invoice 3 when you deleted odd lines you have Purchase Invoice 2 in 2 documents, you need to group them any way before joining.

 
#6
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

Maybe it was misunderstanding, I need 3 matched documents in one line. The case is:
1) There is some PurchaseInvoice
2) This PurchaseInvoice was payed (Document Payment)
3) For this PurchaseInvoice was got a CashDiscount (very similar to Payment)
4) ... I need also PurchaseReturn...., but later about it....
The Idea of this report should be:

We got a Purchase Invoice
We got a discount
The rest we payed (PurchaseInvoice - Discount - Payment = 0)

 
#7
People who like this:0Yes/0No
Interested
Rating: 11
Joined: Nov 10, 2011
Company: 1A Software e.U

bugt,

I've got what you mean... That's fine so far, cause usually a User shouldn't enter two CashDiscounts for one PurchaseInvoice. My trial client is satisfied.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.