Hi Tharanga,
a guess: You have payment batches that have a bank set as balancing account, and of those probably one that has USD (or any currency code) set for this bank? This might be the source of the problem. Imagine this scenario:
1. You work in the payment journals. You hav ea batch selected that has a FCY bank a balancing account.
2. You have a filter set on the form, no lines are shown
3. You close the page / form
4. You open th epayment journal again and get your error.
The reason behind this is this combination:
- balancing account is a bank account with a currency
- OnOpenForm finds no entry (for whatever reason), the page/form goes into OnNewRecord() and tries to create a new one. xRec in this case is empty.... no date!
- SetupNewLine() in T81 will find an entry, and will use xRec (given as parameter LastGenJnlLine) into this function. So the date will be 0D.
- In the end, the balancing account will be validated, and you will find no exchange rate, because there is no date.
What's the workaround:
In T81, SetupNewLine() should check if there is a valid date in "Posting Date". Like this:
SetUpNewLine(LastGenJnlLine : Record "Gen. Journal Line";Balance : Decimal;BottomLine : Boolean)
GenJnlTemplate.GET("Journal Template Name");
GenJnlBatch.GET("Journal Template Name","Journal Batch Name");
GenJnlLine.SETRANGE("Journal Template Name","Journal Template Name");
GenJnlLine.SETRANGE("Journal Batch Name","Journal Batch Name");
IF GenJnlLine.FIND('-') THEN BEGIN
"Posting Date" := LastGenJnlLine."Posting Date";
"Document Date" := LastGenJnlLine."Posting Date";
"Document No." := LastGenJnlLine."Document No.";
IF BottomLine AND
(Balance - LastGenJnlLine."Balance (LCY)" = 0) AND
NOT LastGenJnlLine.EmptyLine
THEN
"Document No." := INCSTR("Document No.");
END ELSE BEGIN
"Posting Date" := WORKDATE;
"Document Date" := WORKDATE;
IF GenJnlBatch."No. Series" <> '' THEN BEGIN
CLEAR(NoSeriesMgt);
"Document No." := NoSeriesMgt.TryGetNextNo(GenJnlBatch."No. Series","Posting Date");
END;
END;
//OS001 os.jgl
if "Posting Date" = 0D then
"Posting Date" := WORKDATE;
if "Document Date" = 0D then
"Document Date" := WORKDATE;
//OS001e os.jgl
IF GenJnlTemplate.Recurring THEN
"Recurring Method" := LastGenJnlLine."Recurring Method";
"Account Type" := LastGenJnlLine."Account Type";
"Document Type" := LastGenJnlLine."Document Type";
"Source Code" := GenJnlTemplate."Source Code";
"Reason Code" := GenJnlBatch."Reason Code";
"Posting No. Series" := GenJnlBatch."Posting No. Series";
"Bal. Account Type" := GenJnlBatch."Bal. Account Type";
IF ("Account Type" IN ["Account Type"::Customer,"Account Type"::Vendor,"Account Type"::"Fixed Asset"]) AND
("Bal. Account Type" IN ["Bal. Account Type"::Customer,"Bal. Account Type"::Vendor,"Bal. Account Type"::"Fixed Asset"])
THEN
"Account Type" := "Account Type"::"G/L Account";
VALIDATE("Bal. Account No.",GenJnlBatch."Bal. Account No.");
Description := '';
This should avoid this error, because you have a valid posting date before validating the balancing account.
with best regards
Jens