renhao
2023-09-12 84b69cf17a12522dc7cd3f186e7e2f38f0c11062
库存持有成本修改
已修改3个文件
60 ■■■■■ 文件已修改
_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventoryValueAndCost/StaticMethod_CreateOrUpdate.qbl
@@ -23,23 +23,27 @@
    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( result ) ) {
    //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 );
      } else if( result.ProductID() <> productId ) {
        info( "cannot change product of inventory value and cost" )
      }
    //  else {
    //    result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true );
    //  }
    }
    return result;
  *]
}
_Main/BL/Type_InventoryValueAndCost/StaticMethod_FindById.qbl
@@ -2,13 +2,16 @@
#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;
  *]
}
_Main/BL/Type_MacroPlan/Method_MappingInventoryValueAndCostData.qbl
@@ -7,21 +7,24 @@
    // yypsybs Aug-15-2023 (created)
    listtodeal := selectset( this,MappingInventoryValueAndCost,item,true );
    totalcount := listtodeal.Size();
    info( "InventoryCost has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
    traverse( listtodeal, Elements, item ) {
      count := count + 1;
      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() + "%" );
        count := count + 1;
        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(),
        InventoryValueAndCost::CreateOrUpdate( this, item.ID(), item.ProductID(),
                                                 item.StockingPointID(), 
                                                 item.AccountName(), item.CostDriver(), item.Start(), item.Cost() );
      }else{
        info( "invaild product: " + item.ProductID().AsQUILL() );
        }
                                                 item.AccountName(), item.CostDriver(), item.Start(), item.Cost());
    //  if( not isnull( Product_MP::FindProductTypeIndex( item.ProductID() ) )  and not isnull( StockingPoint_MP :: FindStockingPointTypeIndex( item.StockingPointID()))){
    //
    //  }else{
    //    info( "invaild product: " + item.ProductID().AsQUILL() );
    //    }
    }
  *]
}