set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[STP_Sys_CheckGoodInfoForCreateSellInvoice] ( @GoodSysCode int , @Size int, @WareHouse int, @Color int, @Serial nvarchar(100), @QTY float, @Price money, @IgnoreAvailability bit, @IgnorLowPrice bit ) AS declare @Type int,@MaxQuantity Float,@MinQuantity Float,@MinPrice Money,@MaxPrice money,@HasSerial bit ------------------------------------- forosh bish az mojodi if @IgnoreAvailability=0 BEGIN SELECT @Type=Type, @HasSerial=SerialNo FROM StockTbl WHERE (GoodSyscode = @goodsyscode) if @type =4 return else if @HasSerial =1 SELECT @MaxQuantity= QTY FROM VW_Sys_GoodRemainDetail WHERE (GoodSysCode = @goodsyscode) AND (SerialNo = @serial) AND (ISNULL(WareHouse, 0) = ISNULL(@warehouse, 0)) else SELECT @MaxQuantity= QTY FROM VW_Sys_GoodRemainDetail WHERE (ISNULL(WareHouse, 0) = ISNULL(@warehouse, 0)) AND (ISNULL(Size, 0) = ISNULL(@size, 0)) AND (ISNULL(Color, 0) = ISNULL(@color, 0)) AND (GoodSysCode = @goodsyscode) set @MaxQuantity=ISNULL(@MaxQuantity, 0) if @Qty>@MaxQuantity and @IgnoreAvailability=0 begin raiserror (50603,16,1) return end END ---------------------------- forosh zir ghimat v balaye ghimat if @IgnorLowPrice=0 BEGIN SELECT @MinPrice = LastFee FROM VWGoodSimpleLastSummary WHERE (GoodSysCode = @goodsyscode) SELECT @MaxPrice = SalePrice1 , @Type=Type FROM StockTbl WHERE (GoodSysCode = @goodsyscode) if @type = 4 Begin if (@Price > @MaxPrice) begin raiserror (50611,16,1) return end End Else Begin if ((@Price < @MinPrice) or (@Price > @MaxPrice)) begin raiserror (50611,16,1) return end End END -----------------------------------Froosh dar mahdoodeh gheimat 4 va 5 if [dbo].[FunCheckUserIsLimitedPrice]()>0 Begin SELECT @MinPrice = SalePrice4 FROM StockTbl WHERE (GoodSysCode = @goodsyscode) SELECT @MaxPrice = SalePrice5 FROM StockTbl WHERE (GoodSysCode = @goodsyscode) if @Price<@MinPrice or @Price>@MaxPrice begin raiserror (50611,16,1) return end End --------------------------------------------------------------------------------------------------------------------- return