lazhen
2024-10-10 7edeca2ed3587a88d7f94cacf05e49c8db610fb0
_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
@@ -35,11 +35,11 @@
    traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '外租库' ) ){
    //  unit                    := stockingpoint.Unit();
    //  parentunits             := unit.GetAllParent();
      //是否属于长春外租库
      //是否属于长春外租库用于长春外租库仓储费用
      isccrent                := stockingpoint.ID().StartsWith( '长春' ) or stockingpoint.ID().StartsWith( 'CC' );
      //是否属于大连发动机的长春外租库
      //是否属于大连发动机的长春外租库用于长春入库/出库费用
      isdltoccrent            := stockingpoint.ID().StartsWith( '大连发动机的长春' );
      //是否属于大连外租库
      //是否属于大连外租库用于大连外租库仓储费用
      isdlrent                := stockingpoint.ID().StartsWith( '大连' ) or stockingpoint.ID().StartsWith( 'DL' );
      if( isccrent or isdlrent ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
@@ -63,16 +63,15 @@
                  enginecost  := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
                                                     and engine.Factory() = ccfactory );
                   if( not isnull( enginecost ) ){
                     quantity :=   [Number]pispip.NewSupplyQuantity();
                     if( isccrent ){
                       cost        := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
                       cell.CCRentStorCost( cell.CCRentStorCost() + cost );
                       cost        := ceil( pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
                       cell.CCRentStorCost( cell.CCRentStorCost() + cost );//长春外租库仓储费用
                     }else{
                       cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
                       //长春外租库入库费用:入库量/包装容量*入库单价
                       entercost  := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                       cell.CCRentQty( cell.CCRentQty() + pispip.NewSupplyQuantity() );
                       //长春外租库入库费用:入库量/包装容量*入库单价
                       entercost  := ceil( pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                       //长春外租库出库费用: 出库量/包装容量*出库单价
                       outcost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice();
                       outcost    := ceil( pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice();
                       cell.CCRentInCost( cell.CCRentInCost() + entercost );
                       cell.CCRentOutOfCost( cell.CCRentOutOfCost() + outcost );
                     }
@@ -82,8 +81,8 @@
                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
                                                     and engine.Factory() = dlfactory  );
                   if( not isnull( enginecost ) ){
                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );
                     cost        := ceil( [Number]pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );//大连外租库仓储费用
                   }
                }
              }   
@@ -242,18 +241,23 @@
          enginecosts         := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() 
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccfactory );
          //在运输成本参数表里找到发动机对应运输单价和装载容量
          transcosts           := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.Origin() = '长春外租库'
                                                  and trans.Destination() = '客户库'
                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '发动机', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
          if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
            products.Add( forecast.Product_MP() );
            row               := table.GetRow( forecast.ProductID() );
            traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() > 0 ){
              enginecost      := selectobject( enginecosts, Elements, engine, engine.StartDate() <= psdip.StartDate() and engine.EndDate() >= psdip.StartDate() );
              transcost       := selectobject( transcosts, Elements, trans, trans.StartDate() <= psdip.StartDate() and trans.EndDate() >= psdip.StartDate() );
              if( not isnull( enginecost ) ){
                periodtime    := psdip.StartDate().StartOfMonth();
                periodname    := periodtime.Format( "M2/D2/Y" );
          //      info( '-------------------------', periodname, periodtime );
                column         := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
          //      info( '-------------------------', column.Name() );
                cost           := ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                cost           := ceil( ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
                cell           := selectobject( row, Cell, cell, cell.Column() = column );
                cell.CCShorTransCost( cell.CCShorTransCost() + cost );
              }
@@ -269,7 +273,7 @@
      e.RowNr( i );
      i := i + 1;
    }
    info( '-------------------------------------end---------------------------------' );
    info( '-------------------------------------end----------------------------------' );
    //
    showtable.Generate( search, products );
  *]