Показать сообщение отдельно
Старый 20.08.2010, 14:01   #11  
Wamr is offline
Wamr
----------------
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
 
1,737 / 868 (32) +++++++
Регистрация: 15.01.2002
Адрес: Москва
Записей в блоге: 7
вот к чему в конечном итоге приводит любовь к "хорошей идеи"
X++:
    while select
    sum(Qty), sum(costAmountPosted), sum(costAmountAdjustment) from InventTrans
    group by ItemId
    where
    (!itemId || InventTrans.ItemId == itemId)
    &&
    (
        (
            !dateFrom
            ||
            (
                InventTrans.DatePhysical > dateFrom
                ||
                (
                    isTime
                    &&
                    (
                        InventTrans.DatePhysical == dateFrom &&
                        (
                            InventTrans.GM_DatePhysical > dateFrom
                            ||
                            (
                                InventTrans.GM_DatePhysical == dateFrom &&
                                InventTrans.AX_TimePhysical >= timeFrom
                            )
                        )
                    )
                )
            )
        )
        &&
        (
            !dateTo
            ||
            (
                InventTrans.DatePhysical < dateTo
                ||
                (
                    isTime
                    &&
                    (
                        InventTrans.DatePhysical == dateTo &&
                        (
                            InventTrans.GM_DatePhysical < dateTo
                            ||
                            (
                                InventTrans.GM_DatePhysical == dateTo &&
                                InventTrans.AX_TimePhysical < timeTo
                            )
                        )
                    )
                )
            )
        )
    )
    &&
    (
        InventTrans.StatusReceipt == StatusReceipt::Purchased ||
        InventTrans.StatusReceipt == StatusReceipt::Received ||
        InventTrans.StatusIssue == StatusIssue::Sold ||
        InventTrans.StatusIssue == StatusIssue::Deducted
    )
    && InventTrans.TransType == InventTransType::Sales
    join salesTable group by GM_SalesOperationType where
    salesTable.SalesId == inventTrans.TransRefId
    join inventDim group by inventDimDefect where
    inventDim.inventDimId == inventTrans.inventDimId &&
    (!defect || inventDim.inventDimDefect == defect)
    exists join GM_CalcInventLocationOperational where
    dataAreaAdmin ||
    (!dataAreaAdmin && GM_CalcInventLocationOperational.InventLocationId == inventDim.InventLocationId)
    exists join GM_CalcInventLocationAdministrative where
    (
        (
            dataAreaAdmin &&
            GM_CalcInventLocationAdministrative.CalcInventLocation == GM_CalcInventLocation &&
            GM_CalcInventLocationAdministrative.InventLocationId == inventDim.InventLocationId
        )
        ||
        (
            !dataAreaAdmin &&
            GM_CalcInventLocationAdministrative.InventLocationId == GM_CalcInventLocationOperational.AdministrativeInventLocationId &&
            GM_CalcInventLocationAdministrative.CalcInventLocation == GM_CalcInventLocation
        )
    )
За это сообщение автора поблагодарили: fed (5), Lemming (5), gl00mie (2).