Hi André,
Thanks for your prompt response.
I'm currently working on a task where I need to get a vendor Account number from the user. Fetch the last invoiced purchase order details against the vendor account number and also get related data from the "Date of amount settled", Total amount settled for the invoice, mode of payment, payment journal number with date, last invoiced purchase order total amount with invoiceId.
So far, I have completed the following :
* Last invoiced purchase order Details against the vendor account number.
* Date and total amount settled for the invoice.
* Mode of payment for Invoice.
* Last invoiced purchase order total amount with invoiceId.
So, I'm having difficulty getting the payment journal number with the date. Below I've inserted the code for your reference,
public void vendinvoice1(Args args)
{
PurchTable purchTable;
PurchLine purchLine;
VendTable vendTable;
VendTrans vendTrans;
InventTable inventTable;
Inventsum inventsum;
InventDim inventDim;
InventSite inventSite;
VendInvoiceInfoTable vendInvoiceInfoTable;
VendInvoiceJour vendInvoiceJour;
VendPaymModeTable vendPaymModeTable;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
UserInfo userInfo;
VendAccount vendAccount;
Voucher _Voucher;
PurchId purchid;
LedgerJournalId ledgerJournalId;
DialogField A;
Dialog dialog;
dialog = new Dialog("Vendor Details"); // Field - EDT, Label
A = dialog.addField(extendedTypeStr(VendAccount), "Vendor Id : ");
dialog.run();
select firstonly purchLine order by CreatedDateTime desc join vendTable where purchLine.VendAccount == A.value() && PurchLine.PurchStatus == PurchStatus::Invoiced;
info(strFmt("VendAccount : %1 -- PurchId : %2 -- PurchStatus : %3", purchLine.VendAccount, purchLine.PurchId, purchLine.PurchStatus));
select vendTrans join vendInvoiceJour where vendTrans.Voucher == vendInvoiceJour.LedgerVoucher && vendTrans.AccountNum == A.value();
info(strFmt("VoucherNum : %1",vendInvoiceJour.LedgerVoucher));
_Voucher = "10APINV000010951";
select firstOnly ledgerJournalTable join vendTrans where ledgerJournalTable.OriginalJournalNum == ledgerJournalTable.JournalNum && vendTrans.Voucher == "10APINV000010951";
info(strFmt("JournalNum : %1",ledgerJournalTable.JournalNum));
purchid = "10P029245";
if(purchTable::find(purchid).PurchStatus == PurchStatus::Invoiced)
{
select firstOnly vendInvoiceJour where vendInvoiceJour.PurchId == PurchId;
info(strFmt("InvoiceAmount: %1 -- InvoiceDate: %2 -- InvoiceId: %3 -- PurchId: %4",vendInvoiceJour.InvoiceAmount, vendInvoiceJour.InvoiceDate, vendInvoiceJour.InvoiceId, vendInvoiceJour.PurchId));
//select firstOnly purchLine where purchLine.PurchId == PurchId ;
//info(strFmt("PurchId: %1 -- ItemId: %2 -- QtyOrdered: %3",purchLine.PurchId, purchLine.ItemId, purchLine.QtyOrdered));
info(strFmt("SiteId: %1 -- User: %2 -- AccountNo: %3 -- PaymentMode: %4 -- WarehouseId: %5",InventDim::find(purchLine::find(purchid,1).InventDimId).InventSiteId, HcmWorker::worker2Name(HcmWorker::userId2Worker(purchLine::find(purchid,1).createdBy))
, purchLine::find(purchid,1).Vendaccount, vendTable::find(purchLine::find(purchid,1).VendAccount).PaymMode, InventDim::find(purchLine::find(purchid,1).InventDimId).wMSLocationId));
info(strFmt("PurchId: %1 -- ItemId: %2 -- QtyOrdered: %3",purchLine::find(Purchid,1).PurchId, purchLine::find(Purchid,1).ItemId, purchLine::find(Purchid,1).QtyOrdered));
}
else
{
throw error("Given Purchase Order is not yet invoiced");
}
}
Please let me know your thoughts to take things forward.
Thanks in Advance,
KK.