JOIN for matching of receipts with salesinvoices

Accounting and inventory IFRS/GAAP suite for SMB. General questions. See 1C:AccountingSuite details

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

I try to make a report where I need a table with sales invoices and in the same row date and amount of receipts. If I write a code:

Code
SEL ECT
   ReceiptLineItems.Ref,
   ReceiptLineItems.Payment,
   ReceiptLineItems.Ref.Date,
   SalesInvoice.Ref AS Ref1
FR OM
   Document.Receipt.LineItems AS ReceiptLineItems
      LEFT JOIN Document.SalesInvoice AS SalesInvoice
      ON ReceiptLineItems.Document = SalesInvoice.Ref


I get all Lines of receipt to the salesinvoice, also Lines to another salesinvoice, if the sales invoice was "mentioned" in the document receipt.
Where can be an error?

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

Joined:
Company:

You have wrong order of joined tables, if you need SalesInvoices with Payments you need to place SalesInvoices first in FROM clause and then join payments to it:

Code
SELECT
    ReceiptLineItems.Ref,
    ReceiptLineItems.Payment,
    ReceiptLineItems.Ref.Date,
    SalesInvoice.Ref AS Ref1
FROM
   Document.SalesInvoice AS SalesInvoice
        LEFT JOIN Document.Receipt.LineItems AS ReceiptLineItems 
        ON ReceiptLineItems.Document = SalesInvoice.Ref

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Mar 15, 2012
Company: no

May be you need this:

Code
SEL ECT
   COUNT(DISTINCT ReceiptLineItems.Ref),
   ReceiptLineItems.Ref.Date,
   ReceiptLineItems.Document AS Ref1
FR OM
   Document.Receipt.LineItems AS ReceiptLineItems
GROUP BY
   ReceiptLineItems.Ref.Date,
   ReceiptLineItems.Document

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

bugt,

it hasn't fixed the problem, I have the same output table.

Mikhail, primarely I need a list of all sales invoices, and information with date of payment (receipt). But it doesn't work

 
#5
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

use OUTER JOIN (left, right). You can google how to use it.

 
#6
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Jul 29, 2011
Company: 1C Company

Lioudmila, there might be some issues with grouping in your report. I emailed to you a sample database where it all works.

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

Yes, Konstantin, there was an error in grouping of fields. This way it works:

Code
SEL ECT
   ReceiptLineItems.Ref AS Receipt,
   ReceiptLineItems.Payment,
   SalesInvoice.Ref AS Invoice,
   SalesInvoice.DocumentTotalRC AS InvoiceAmount,
   ReceiptLineItems.Ref.Date AS PaymentDate
FR OM
   Document.Receipt.LineItems AS ReceiptLineItems
      LEFT JOIN Document.SalesInvoice AS SalesInvoice
      ON ReceiptLineItems.Document = SalesInvoice.Ref


But I have one more question: how can I change the query in order to get all invoices, even if they are not payed?

 
#8
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

FULL OUTER JOIN? I bet it helps.

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

Yep! Thanks, Alexey!

 
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.