

CREATE PROCEDURE dbo.GetOrderGoodAmountInfo  
(  
 @intLanguage INT=0,  
 @SystemDate NVARCHAR(50),  
 @SystemDay NVARCHAR(50),  
 @SystemTime NVARCHAR(50),  
 @Level11 INT,  
 @Level12 INT,  
 @Level21 INT,  
 @Level22 INT ,  
 @Inventory1 INT ,  
 @Inventory2 INT  
)  
AS  
  
DECLARE @TimeTitle NVARCHAR(10)  
IF @intLanguage=0  
 SET @TimeTitle=N' ساعت : '  
ELSE  
 SET @TimeTitle=N'Time: '  
  
Declare @AccountYear Smallint  
Set @AccountYear = dbo.Get_AccountYear()  
  
SELECT  [Code], [vw_Good].[Level1], [vw_Good].[Level2],    
     Case @intLanguage When 0 then [Name]  
      Else [LatinName] end as [Name],  
     Case @intLanguage When 0 then  [NamePrn]  
      Else [LatinNamePrn] End as [NamePrn],   
     Case @intLanguage When 0 then [Level1Description]  
      Else [Level1LatinDescription] end as [Level1Name],  
     Case @intLanguage When 0 then  [Level2Description]  
      Else [Level2LatinDescription] End as [Level2Name],   
   
  [BarCode], [Unit], [Model], [Weight], [OrderPoint], [MinValue], [MaxValue], [NumberOfUnit], [ProductCompany], [SellPrice],   
 [BuyPrice], [BtnAscDefault], [UnitDescription], [GoodType] , [FirstMojodi] , [LossAmount],[Mojodi] , [MojodiControl] , [TypeDescription]  
 ,[BuyAmount],[saleAmount],[LossAmount],    @SystemDay + ' ' + @SystemDate +' '+@TimeTitle+ @SystemTime AS Sysdate  
 , tInventory_Good.[InventoryNo], tInventory.Description as Inventoryname  
  
FROM [dbo].[vw_Good]    
  
   Inner Join tInventory_Level1 On tInventory_Level1.Level1 = vw_Good.Level1   
   Inner Join tInventory On tInventory.Branch = tInventory_Level1.Branch And  tInventory.InventoryNo = tInventory_Level1.InventoryNo  
   Inner Join tInventory_Good On vw_Good.Code = tInventory_Good.GoodCode   
  
  
 Where  [vw_Good].[Level1] >= @Level11 And [vw_Good].[Level1] <= @Level12    
       And  [vw_Good].[Level2] >= @Level21 And [Level2] <= @Level22      
                         And  OrderPoint >= Mojodi  
                         And  [GoodType] <> 2 And [GoodType] <> 4  
     And  tInventory_Good.[InventoryNo] >= @Inventory1  
    And  tInventory_Good.[InventoryNo] <= @Inventory2  
   And tInventory.Branch = tInventory_Good.Branch   
   And tInventory.InventoryNo = tInventory_Good.InventoryNo  
   And  tInventory_Good.AccountYear = dbo.Get_AccountYear()
GO
