Показать сообщение отдельно
Старый 28.07.2010, 13:48   #21  
novic is offline
novic
Axapta Retail User
Axapta Retail User
 
168 / 25 (0) +++
Регистрация: 14.04.2005
Кстати вот это не всегда совпадает с данными ОСВ

[QUOTE=Silphidae;228846]Спасибо большое.
Вот так совпадает с данными ОСВ:
X++:
select sum(AmountMST) from custTrans 
where custTrans.AccountNum == "2545" 
        && custTrans.TransDate <= 30\06\2010
        && custTrans.PostingProfile == "76.20" 
exists join ledgerTrans
      where ledgerTrans.AccountNum == "76.20.00" &&
               ledgerTrans.Voucher == custTrans.Voucher &&
               ledgerTrans.TransDate == custTrans.TransDate;
может пробежать в цикле custTrans.PostingProfile asc

что-то вроде
X++:
    while select custTransLoc
        order by PostingProfile asc
        where custTransLoc.AccountNum == "7713076301" &&
                custTransLoc.TransDate <= 01\01\2010
    {
        if( profile != custTransLoc.PostingProfile)
        {
            profile = custTransLoc.PostingProfile;

            select sum(AmountMST) from custTrans  
            where custTrans.AccountNum == "7713076301"
                    && custTrans.TransDate <= 01\01\2010
                    && custTrans.PostingProfile == profile
            exists join ledgerTrans
                  where ledgerTrans.AccountNum == profile
                           ledgerTrans.Voucher == custTrans.Voucher &&
                           ledgerTrans.TransDate == custTrans.TransDate;

            amount += custTrans.AmountMST;
        }
    }