| Author | 
                                
                                 Topic  | 
                            
                            
                                    | 
                                         folumike 
                                        Starting Member 
                                         
                                        
                                        24 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-05-20 : 15:24:30
                                            
  | 
                                             
                                            
                                            | I am developing an application with vb6 and mssql 2000. I need to get inventory/stock valuation. In the process, i need to calculate using array: Date,Inv#,Qty for val, Cost Price. Then get the average price. See below:Declare i,jk,mk = 0i=1Do while k<=TotQty  ie TotQty = total quantityk = k + Qty(i)if k < TotQty or k = TotQty Thenj = [Qty(i) * CostPrice(i) + jelsek > TotQtym = TotQty - (k - Qty(i))j =[[m * costprice(i)] + jend ifwendAvgPrice j/TotQtyPlease help me out. You can give a sample code in whichever way.Thanks | 
                                             
                                         
                                     | 
                            
       
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-20 : 15:40:11
                                          
  | 
                                         
                                        
                                          | are you looking for t-sql or vb code?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     folumike 
                                    Starting Member 
                                     
                                    
                                    24 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-20 : 18:07:54
                                          
  | 
                                         
                                        
                                          Any onequote: Originally posted by visakh16 are you looking for t-sql or vb code?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
    | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-20 : 19:30:31
                                          
  | 
                                         
                                        
                                          | hmm...your posted code is a bit confusing. i cant see whats initial value of j. also whats AvgPrice j/TotQty?it would be better if you can post some sample data and explain what you want as output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     folumike 
                                    Starting Member 
                                     
                                    
                                    24 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-21 : 17:08:47
                                          
  | 
                                         
                                        
                                          TotQty = Balance as at dateSee table belowDate       |    QtyForValuation   | APInv#     |  CostPrice------------------------------------------------------------BegBalDate | BegBal(QtySupplied)  | 'BegBal'   | BegPrice  |  J1APDate(1)  | QtyReceived - QtySup |  Inv#      | ItemPrice |  .     .      |           .          |    .       |     .     |  .     .      |           .          |    .       |     .     |  .APDate(n)  |           n          |    n       |     n     |  JnDeclare i, j , k, mk = 0i = 1i=1Do while k<=TotQty ie TotQty = total quantityk = k + Qty(i)if k < TotQty or k = TotQty Thenj = [Qty(i) * CostPrice(i) + jelsek > TotQtym = TotQty - (k - Qty(i))j =[[m * costprice(i)] + jend ifwendAvgPrice =  j/TotQtyNOTEI want to do the valuation and then get the Average price (AvgPrice) as at the selected date.Which is the array vakue divided by TotQtyAvgPrice =  j/TotQtyTotQty = Balance as at dateJ is the value for the arrayquote: Originally posteod by visakh16 hmm...your posted code is a bit confusing. i cant see whats initial value of j. also whats AvgPrice j/TotQty?it would be better if you can post some sample data and explain what you want as output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
    | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     folumike 
                                    Starting Member 
                                     
                                    
                                    24 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-21 : 17:30:22
                                          
  | 
                                         
                                        
                                          from the table below, Initial values of J are the Begining balances such as opening stock date (BegBal Date), Opeining stock, Price for the opening stock(cost pricequote: Originally posted by folumike TotQty = Balance as at dateSee table belowDate       |    QtyForValuation   | APInv#     |  CostPrice------------------------------------------------------------12/jun/2011| 30                   | 'BegBal'   | 70.00     |  J1APDate(1)  | 28                   |  Inv#      | 75.00      |  .     .      |           .          |    .       |     .     |  .     .      |           .          |    .       |     .     |  .APDate(n)  |           n          |    n       |     n     |  JnJ is an array to find stock valuation price as at the selected date.Output is  Average Price = Jn divided by current stock balancee.g. AvgPrice = Jn/TotQtyfor example;     AvgPrice = Jn/45Declare i, j , k, mk = 0i = 1i=1Do while k<=TotQty ie TotQty = total quantityk = k + Qty(i)if k < TotQty or k = TotQty Thenj = [Qty(i) * CostPrice(i) + jelsek > TotQtym = TotQty - (k - Qty(i))j =[[m * costprice(i)] + jend ifwendAvgPrice =  j/TotQtyNOTEI want to do the valuation and then get the Average price (AvgPrice) as at the selected date.Which is the array vakue divided by TotQtyAvgPrice =  j/TotQtyTotQty = Balance as at dateJ is the value for the arrayquote: Originally posteod by visakh16 hmm...your posted code is a bit confusing. i cant see whats initial value of j. also whats AvgPrice j/TotQty?it would be better if you can post some sample data and explain what you want as output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
  
    | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     folumike 
                                    Starting Member 
                                     
                                    
                                    24 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-21 : 18:05:48
                                          
  | 
                                         
                                        
                                          I dont know how to explain further since I cant sent graphics. Or can you give me a sample code on how to calculate inventory valuation price and how to calculate its average price[quote]Originally posted by folumike from the table below, Initial values of J are the Begining balances such as opening stock date (BegBal Date), Opeining stock, Price for the opening stock(cost price[quote]Originally posted by folumike TotQty = Balance as at dateSee table belowDate       |    QtyForValuation   | APInv#     |  CostPrice------------------------------------------------------------12/jun/2011| 30                   | 'BegBal'   | 70.00     |  J1APDate(1)  | 28                   |  Inv#      | 75.00      |  .     .      |           .          |  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                     | 
                                  
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 |