How much amount of invoice is pending with us, we have to find out any order against the customer.
What is left to invoice customers' remaining sales orders
And decide the transactions as per date/second, find out whether any invoice of our customer is unmarked, and if unmarked then it has to be marked.
how to write it in MarkOpenTransaction().
i want while loop which will pick tender lines.
suppose we created sales order of 1000 invoice amount, then we will create tender of 500 check, 300 cash, 200 upi,
But now this will create a journal of 1000 invoice amount of invoice, in a tender amount 300+200 will get marked through invoice but what about that 500 by check?
public class TenderMarkingServiceClass extends SysOperationServiceBase
{
public void checkRecordMarked(InvoiceId _invoice, LedgerJournalTrans _ledgerJournalTrans,AccountNum _accountNum)
{
custvendopentransmanager manager;
CustTransOpen custTransOpen;
CustTrans custTrans;
//To mark particular invoice based on Acc num
select custTransOpen where custTransOpen.AccountNum ==_accountNum
join custTrans where custTrans.Invoice == _invoice
&& custTrans.RecId == custTransOpen.RefRecId
&& custTrans.AccountNum == custTransOpen.AccountNum;
if(custTransOpen)
{
//To check transaction line which we want to settle
manager = custvendopentransmanager::construct(_ledgerJournalTrans);
manager.updateTransMarked(custTransOpen,true);
Info(/Marked/);
}
}
public void settlementnew()
{
tender Tender;
Ledgerjournaltrans ledgerjournaltrans;
Custinvoicejour custinvoicejour;
select firstonly RecId, AccountNum, PaymentJournalNum, SalesId from Tender where Tender.SalesId == '' && Tender.PaymentJournalNum != '';
select firstonly InvoiceId from custinvoicejour where custinvoicejour.SalesId == Tender.Salesid;
if (xtsTender)
{
While select * from Ledgerjournaltrans where ledgerjournaltrans.JournalNum == Tender.PaymentJournalNum
{
this.checkRecordMarked(custinvoicejour.InvoiceId, Ledgerjournaltrans, Tender.AccountNum);
}
}
else
{
info(/Payment journal is not created for the sales order./);
}
}
///////////////////////****************///////////////
public void MarkOpenTransaction()
{
SalesTable salesTable;
CustTable custTable;
CustInvoiceJour custInvoiceJour;
CustTransOpen custTransOpen;
CustTrans custTrans;
Tender sTender;
LedgerJournalTrans ledgerJournalTrans;
//select firstOnly RecId, SalesId from salesTable order by salesTable.SalesId desc;
//select firstonly RecId, CustAccount, SalesId from salesTable join Tender
// where salesTable.SalesId == Tender.SalesId && Tender.SalesId == '';
select firstonly RecId,SalesId from salesTable where salesTable.SalesId == '';
if (salesTable)
{
select firstonly RecId, InvoiceId, InvoiceDate, InvoiceAmount
from custInvoiceJour
order by custInvoiceJour.InvoiceDate desc
where custInvoiceJour.SalesId == salesTable.SalesId;
if (custInvoiceJour)
{
select count(RecId) from custTransOpen
where custTransOpen.RefRecId == custInvoiceJour.RecId;
if (custTransOpen)
{
select firstonly custTable
where custTable.AccountNum == salesTable.CustAccount;
if(custTable)
{
select firstonly custTrans
where custTrans.Invoice == custInvoiceJour.InvoiceId
&& custTrans.AccountNum == custTable.AccountNum;
if (custTrans && custInvoiceJour.InvoiceAmount <= custTrans.AmountCur)
{
while select Tender
where Tender.SalesId == salesTable.SalesId
{
while select ledgerJournalTrans
where ledgerJournalTrans.JournalNum == Tender.PaymentJournalNum
{
//info(strFmt(/Checking records for InvoiceId: %1, JournalNum: %2, AccountNum: %3/,
// custInvoiceJour.InvoiceId, ledgerJournalTrans.JournalNum, Tender.AccountNum));
this.checkRecordMarked(custInvoiceJour.InvoiceId, ledgerJournalTrans, Tender.AccountNum);
}
}
}
}
}
}
}
else
{
info(/No invoice found for the specified SalesId./);
}
}
}