Hi Experts,
I have a a custom module for Pettycash management which has Journal form(ANCPettyCashPlantJournal) and journal line(ANCPettyCashPlant) forms. In Journal, I can select the bank and when i am creating lines, there should be a validation to check if the sum of all the journal lines is less than the bank credit limit(It is in bank master).
I have written my validation in validate write like this.
public boolean validateWrite()
{
boolean ret;
ret = super();
if(ret)
{
if(this.totalPCAmount(this.PlantJournalId) > abs(BankAccountTable::find(ANCPettyCashPlantJournal::find(this.PlantJournalId).BankAccount).OverDraftLimit))
{
ret = false;
warning('@ANCLabel:CreditLimitError');
}
}
}
And the method to find total line amount is below
private Amount totalPCAmount(ANCPettyCashPlantJournalId _journalId)
{
ANCPettyCashPlant pcPlantSum;
Amount total;
select sum(GrossAmount)
from pcPlantSum
where pcPlantSum.PlantJournalId == _journalId;
total = pcPlantSum.GrossAmount;
return total;
}
If I am entering a value greater than bank credit limit then its validating and giving warning messages, however when I editing the gross amount field, it is not considering the new entered value and still gives me error.
In the below example Bank credit limit is 1000. First i entered 3000 and it gave me validation error. Then I entered 500 in the same field, but it still gives me the same error. It should not give error since bank credit limit is above 500.
