Validation on Trade Agreement Journal Line Posting
Q: How to add Trade agreement Journal Line Posting Validation?
Case Study:
In My Case of Trade Agreement at the time of journal line posting check the line in the journal on the basis of six fields relation, ItemRelation, AccountRelation, Currency, InventSiteId, InventLocationId. First, I have to get the line which record have the highest FromDate in the journal and Iterate in the Journal Table Any Record Field Data match with the above mention field data change the ToDate to one day Previous Date.
Form:
Trade Agreement Journal Lines:
Post Button:
[ExtensionOf(classStr(PriceDiscAdmCheckPost))]
final class PriceDiscAdmCheckPost_Extension
{
void postJournal()
{
next postJournal();
str jornalNum = journalNum;
PriceDiscAdmTrans priceDiscAdmTrans,localPriceDiscAdmTrans,delRecordLocalPriceDiscAdmTrans;
InventDim localInventDim,delRecordLocalInventDim;
while select * from localPriceDiscAdmTrans
order by JournalNum,relation,ItemRelation,AccountRelation,Currency,FromDate desc
join inventDimId,InventSiteId,InventLocationId from localInventDim
where localPriceDiscAdmTrans.InventDimId == localInventDim.inventDimId && localPriceDiscAdmTrans.JournalNum == jornalNum
{
ttsBegin;
while select forupdate * From delRecordLocalPriceDiscAdmTrans
join inventDimId,InventSiteId,InventLocationId from delRecordLocalInventDim
where delRecordLocalPriceDiscAdmTrans.InventDimId == delRecordLocalInventDim.inventDimId
&& delRecordLocalPriceDiscAdmTrans.relation == localPriceDiscAdmTrans.relation && delRecordLocalPriceDiscAdmTrans.ItemRelation == localPriceDiscAdmTrans.ItemRelation
&& delRecordLocalPriceDiscAdmTrans.AccountRelation == localPriceDiscAdmTrans.AccountRelation && delRecordLocalPriceDiscAdmTrans.Currency == localPriceDiscAdmTrans.Currency
&& delRecordLocalInventDim.InventSiteId == localInventDim.InventSiteId && delRecordLocalInventDim.InventLocationId == localInventDim.InventLocationId
{
if(delRecordLocalPriceDiscAdmTrans.FromDate < localPriceDiscAdmTrans.FromDate && delRecordLocalPriceDiscAdmTrans.RecId != localPriceDiscAdmTrans.RecId)
{
delRecordLocalPriceDiscAdmTrans.ToDate = delRecordLocalPriceDiscAdmTrans.ToDate - 1;
delRecordLocalPriceDiscAdmTrans.update();
}
}
ttsCommit;
}
}
}
Comments
Post a Comment