display method to get invoice ID in purchtable

I have to get PO number and invoice number in the report and hoping to make display method on purchtable table so wanted to create a display over there

invoiceid is in vendinvoicejour table and purchtable.purchid==vendinvoicejour.purchid

so created this wanted to know isit correct ???

display public VendInvoiceId getinvoiveid()

{

VendInvoicejour vendInvoicejour;

//declare the invoice table

;

if (this.PurchStatus == PurchStatus::Invoiced || this.existInvoice() || this.isInvoiceMatched())

//if the status is invoiced or already invoiced or invoice matched then only fetch he invoice id

{

return vendInvoicejour.invoiceid;

}

return vendInvoicejour.invoiceid;

}

or this one will be ok???

//BP Deviation documented

server display AmountCur amountInvoiced()

{

VendInvoiceJour vendInvoiceJour;

;

select (InvoiceID) from vendInvoiceJour

where vendInvoiceJour.PurchId == this.PurchId;

return vendInvoiceJour.InvoiceID;

}

A couple things on this one.

First, Your method name is amountInvoiced, and return type is AmountCur but you are returning an InvoiceID.

Second, it is possible to have multiple vendInvoiceJour records associated with a purchase order. If there are multiple invoice journal records you would be retrieving the first one that is found which may not be the correct record.