Class CustStatisticsUS.calcTotals(), error in sys layer?


Did you ever notice this strange query in this method :


while SELECT recId, TransDate, Voucher, AmountCur, AmountMST FROM custTrans
where custTrans.AccountNum == custTable.AccountNum &&
custTrans.TransDate >= tmpStatPer.StartDate &&
custTrans.TransDate <= tmpStatPer.EndDate &&
// custTrans.amountCur < 0 &&
custTrans.Invoice == ‘’
exists join ledgerTrans
where ledgerTrans.TransDate == custTrans.TransDate &&
ledgerTrans.Voucher == custTrans.Voucher &&
(ledgerTrans.Posting == LedgerPostingType::CustPayment ||
ledgerTrans.Posting == LedgerPostingType::CustBalance)
bankAccountTrans = BankAccountTrans::find(ledgerTrans.PaymReference);

if (!bankAccountTrans || bankAccountTrans.BankTransType != BankParameters::find().nsfTransactionType)


We have an exist join there, so the query will not return records for the table LedgerTrans. But the first step into the while select looks for the value in ledgerTrans.PaymReference.

The line
bankAccountTrans = BankAccountTrans::find(ledgerTrans.PaymReference);
return always the same record. PaymReference is always empty so Axapta return the first BankAccountTrans record found with PaymReference=’’.

I was told by an user that there is some problem with the statistics. Someone can help me with this one? How can I correct this error to see after if my data problem is gone ?

Thanks !!