Hi Sukrut,
I have added the example with steps. Please check.
1) Inside addCustVendTransOpen method of CustVendPaymProposal , I need to skip
using existing payment proposal line and go to else part to create new proposal line so I have modified if condition by adding "&& !invalidPaymModeGroup" as below. However to know if it is an invalid group for current _custVendTransOpen which is part of method parameter, I also need data of previous invoices that are part of given proposal line(as in step 2). invalidPaymModeGroup Boolean is set as per step 2.
if (paymentProposalLineMap.exists(hashKey) && !invalidPaymModeGroup)
{
paymProposalLine.RecId = paymentProposalLineMap.lookup(hashKey);
if (canUseCustVendPaymProposalLineSetBasedInsert)
{
paymProposalLine.TmpRecId = paymProposalLine.RecId;
}
}
2) The addCustVendTransOpen method keeps inserting invoices of given payment proposal line inside SpecTransInsertTmp towards end of method using below line.
this.insertSpecTrans(custVendTrans, _custVendTransOpen, paymProposalLine, _paymAmountInvoiceCur, cashDiscToTake);
So, towards beginning of addCustVendTransOpen method I needed to find all the invoices that were inserted in SpecTransInsertTmp with same payment proposal recid as SpecRecId and custVendTransOpen as refRecId . From that I can get custVendTrans to get invoice Ids. however, I cannot query temp table here and also I cannot get previous invoices in generateKey or buildPaymProposalLine method as invoiceId is directly assigned on proposal line only if method of payment has period set to Invoice. I need to do something like below to query previous invoices for current proposal line but unable to get previous invoices for it in addCustVendTransOpen method. If I get invoices then I can set my Boolean invalidPaymModeGroup before the if condition in Step 1 .
int hashKey = paymProposalLine.generateHashKey();
CustVendPaymProposalLine localCustVendPaymProposalLine;
boolean invalidPaymModeGroup = false;
CustVendTransOpen localCustVendTransOpen;
CustVendTrans localCustVendTrans;
RecId paymProposalLookupRecId;
SpecTransInsertTmp localSpecTrans;
CustVendTransOpenData localCustVendTransOpenData;
paymProposalLookupRecId = paymentProposalLineMap.exists(hashKey) ?
paymentProposalLineMap.lookup(hashKey) : 0;
while select localCustVendTransOpen
join localSpecTrans
where localCustVendTransOpen.RecId == localSpecTrans.RefRecId
&& localCustVendTransOpen.TableId == localSpecTrans.RefTableId
&& localCustVendTransOpen.DataAreaId == localSpecTrans.RefCompany
&& localSpecTrans.SpecCompany == localCustVendPaymProposalLine.DataAreaId
&& localSpecTrans.SpecTableId == localCustVendPaymProposalLine.TableId
&& localSpecTrans.SpecRecId == paymProposalLookupRecId
{
custVendTransOpenData = CustVendTransOpenData::construct(localCustVendTransOpen);
localCustVendTrans = custVendTransOpenData.custVendTrans();
if (localCustVendTrans.Invoice)
maxInvoiceChar = localCustVendTrans.Invoice+'_';
}
maxInvoiceChar = maxInvoiceChar + custVendTrans.Invoice;
if (maxInvoiceChar != null && strLen(maxInvoiceChar) < requiredLimit)
{
invalidPaymModeGroup = true;
}