Показать сообщение отдельно
Старый 13.06.2012, 17:44   #115  
Napalm is offline
Napalm
Участник
 
80 / 88 (3) ++++
Регистрация: 23.05.2012
Верхнюю половину метода написал один человек; нижнюю - другой, не глядя на верхнюю, и - внимание - ловко "оптимизировал" код использовав список полей. BestPractice ошибок нет - все отлично. Это из стандартного кода AX 2012.

CustWriteOff\checkForDuplicateVouchers

X++:
protected boolean checkForDuplicateVouchers(Voucher _voucher, TransDate _transDate, recId _existingCustTransRecId)
{
    boolean found;
    VendTrans vendTrans;

    // check for duplicate customer transaction
    found = (select firstonly RecId from custTrans
                where custTrans.Voucher == _voucher
                   && custTrans.TransDate == _transDate
                   && custTrans.RecId != _existingCustTransRecId).RecId != 0;

    if (found == true)
    {
        return true;
    }

    // check for duplicate vendor transactions
    select count(RecId) from vendTrans
        where vendTrans.Voucher == _voucher
           && vendTrans.TransDate == _transDate;

    found = vendTrans.ReasonRefRecId == 0 ? false : true;

    return found;
}
За это сообщение автора поблагодарили: kashperuk (5).