Select
0 Score,
LSC.ID,
SP.ID Position_ID,
SP.Code Position_Code,
SP.Accessibility Position_Accessibility,
SP.Frozen Position_Frozen,
(LSC.Quantity - LSC.QuantityReserved) Quantity,
LSC.QUnit,
LSC.UnitRate,
SU.IndivisibleQuantity,
(Case When SB.ID is null then LSC.DateOfStorage$DATE
Else SB.ExpirationDate$DATE end
) as CompareStorageDate$DATE,
SB.Name StoreBatch_Name,
SP.PositionType
from
LogStorePositionsForStrat_VIEW SP
join LogStoreContentsForStrat_VIEW LSC on LSC.Parent_ID = SP.ID
join StoreUnits SU on LSC.StoreCard_ID = SU.Parent_ID
left join StoreBatches SB on LSC.StoreBatch_ID = SB.ID
where
SP.Hidden = 'N' and
SP.Store_ID = :Store_ID and
LSC.StoreCard_ID = :StoreCard_ID and
(
(LSC.StoreBatch_ID = :StoreBatch_ID) or
(:SBatch_ID_Null = 'A')
) and
(SU.Code = LSC.QUnit) and
(
:Quantity >= Cast((SU.IndivisibleQuantity * SU.UnitRate) as Numeric(15,6))
) and
(LSC.Quantity - LSC.QuantityReserved) > 0 and
(
SP.ReservedForDoc_ID = :ReservedForDoc_ID and
SP.ReservedForDocType = :ReservedForDocType
) Generated by ABRA Software a.s. 27.10.2021 16:35:19