| | |
| | | product := Product_MP::FindById( macroPlan, productId ); |
| | | stockingPoint := StockingPoint_MP::FindById( macroPlan, stockingPointId ); |
| | | account := Account_MP::FindByName( macroPlan, accountName ); |
| | | if( isnull( product ) ) { |
| | | error( "product not found" ); |
| | | } |
| | | if( isnull( stockingPoint ) ) { |
| | | error( "stocking point not found" ); |
| | | } |
| | | if( isnull( account ) ) { |
| | | error( "account not found" ); |
| | | } |
| | | result := InventoryValueAndCost::FindById( macroPlan, id ); |
| | | //if( isnull( product ) ) { |
| | | // error( "product not found" ); |
| | | //} |
| | | //if( isnull( stockingPoint ) ) { |
| | | // error( "stocking point not found" ); |
| | | //} |
| | | //if( isnull( account ) ) { |
| | | // error( "account not found" ); |
| | | //} |
| | | result := InventoryValueAndCost::FindById( macroPlan, stockingPointId,productId,start,id ); |
| | | if( not isnull( product) and not isnull( stockingPoint) and not isnull( account)){ |
| | | if( isnull( result ) ) { |
| | | result := InventoryValueAndCost::Create( id, product, stockingPoint, account, costDriver, start, cost, true ).astype( InventoryValueAndCost ); |
| | | } else if( result.ProductID() <> productId ) { |
| | | error( "cannot change product of inventory value and cost" ) |
| | | } else { |
| | | result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true ); |
| | | info( "cannot change product of inventory value and cost" ) |
| | | } |
| | | // else { |
| | | // result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true ); |
| | | // } |
| | | } |
| | | |
| | | return result; |
| | | *] |
| | | } |
| | |
| | | #parent: #root |
| | | StaticMethod FindById ( |
| | | MacroPlan macroPlan, |
| | | String productId, |
| | | String stockPointId, |
| | | Date start, |
| | | String id |
| | | ) as InventoryValueAndCost |
| | | { |
| | | TextBody: |
| | | [* |
| | | // yypsybs Aug-16-2023 (created) |
| | | value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ID() = id ); |
| | | value := select( macroPlan, Product_MP.InventoryValueAndCost, item, true, item.ProductID()=productId and item.StockingPointID() = stockPointId and item.Start() = start ); |
| | | return value; |
| | | *] |
| | | } |
| | |
| | | // yypsybs Aug-15-2023 (created) |
| | | listtodeal := selectset( this,MappingInventoryValueAndCost,item,true ); |
| | | totalcount := listtodeal.Size(); |
| | | |
| | | info( "InventoryCost has " + totalcount.AsQUILL() + " rows in total" ); |
| | | |
| | | count := 0; |
| | |
| | | if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){ |
| | | info( "Now is dealing with the " + count.AsQUILL() + "InventoryCost " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" ); |
| | | } |
| | | if( not isnull( Product_MP::FindById( this, item.ProductID() ) ) ){ |
| | | |
| | | InventoryValueAndCost::CreateOrUpdate( this, item.ID(), item.ProductID(), |
| | | item.StockingPointID(), |
| | | item.AccountName(), item.CostDriver(), item.Start(), item.Cost() ); |
| | | }else{ |
| | | info( "invaild product: " + item.ProductID().AsQUILL() ); |
| | | } |
| | | // if( not isnull( Product_MP::FindProductTypeIndex( item.ProductID() ) ) and not isnull( StockingPoint_MP :: FindStockingPointTypeIndex( item.StockingPointID()))){ |
| | | // |
| | | // }else{ |
| | | // info( "invaild product: " + item.ProductID().AsQUILL() ); |
| | | // } |
| | | } |
| | | *] |
| | | } |