lazhen
2024-08-13 f6a108e67cf221fe34a2338a44c9cb7894c9e07e
_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -30,14 +30,25 @@
      traverse( source, FinancialProductionReport, report, not report.IsShow() ){//财务产量报表不显示
        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' ) ){//财务产量报表里的长春产量, 不为0
          ccrow               := table.GetRow( row.Name() );
          //查询对应的发动机成本
          enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
          traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
            //入库量/包装容量*入库单价,入库量等于长春产量
            quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
            column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
            //外租库入库费用
            ccrow.SetRentEnterCost( column, quantity );
          product             := row.Product_MP();
          products.Add( product );
          productparents      := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = '发动机' ) ){//查询产品类型是发动机
            //查询对应的发动机成本
            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccunit
                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
            if( not isnull( enginecost ) ){
              product             := row.Product_MP();
              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
                //入库量/包装容量*入库单价,入库量等于长春产量
                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
                //外租库入库费用
                ccrow.SetRentEnterCost( column, quantity );
              }
            }
          }
        }
      }
@@ -47,14 +58,24 @@
      traverse( source, FinancialSalesReport, report, not report.IsShow() ){//财务销量报表不显示
        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' ) ){//财务销量报表里的长春产量, 不为0
          ccrow               := table.GetRow( row.Name() );
          //查询对应的发动机成本
          enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
          traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
            //出库量/包装容量*出库单价,入库量等于长春销量
            quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
            column            := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
            //外租库出库费用
            ccrow.SetRentOutCost( column, quantity );
          product             := row.Product_MP();
          productparents      := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = '发动机' ) ){//查询产品类型是发动机
            //查询对应的发动机成本
            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccunit
                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
            if( not isnull( enginecost ) ){
              products.Add( product );
              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
                //出库量/包装容量*出库单价,入库量等于长春销量
                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                column            := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
                //外租库出库费用
                ccrow.SetRentOutCost( column, quantity );
              }
            }
          }
        }
      }
@@ -75,14 +96,26 @@
          column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
          traverse( trip, ProductInTrip, pit, pit.Quantity() = 0 ){
            row              := table.GetRow( pit.ProductID() );
            //在发动机成本参数表找到对应的包装容量
            enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
            //在运输成本参数表里找到发动机对应运输单价和装载容量
            transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Product() = row.Name() );
            //运输数量/包装容量/装载容量*运输单价
            quantity         := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//四舍五入
            row.SetFactoryToRentTransCost( column, quantity );
            product          := pit.Product_MP();
            productparents   := product.GetAllParent();
            if( exists( productparents, Elements, e, e.ID() = '发动机' ) ){////查询产品类型是发动机
              //在发动机成本参数表找到对应的包装容量
              enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccunit
                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
              //在运输成本参数表里找到发动机对应运输单价和装载容量
              transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = ccline
                                                and trans.Destination() = ccrent
                                                and exists( productparents, Elements, e, e.ID() = trans.Product() ) );
              if( not isnull( enginecost ) and not isnull( transcost ) ){
                products.Add( product );
                //运输数量/包装容量/装载容量*运输单价
                quantity       := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//四舍五入
                row.SetFactoryToRentTransCost( column, quantity );
              }
            }
          }
        }
      }
@@ -94,21 +127,30 @@
      if( isccrent ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() ){
          //获取行
          product            := pisp.Product_MP();
          productparents     := product.GetAllParent();
          row                := table.GetRow( pisp.ProductID() );
          //查询对应的发动机成本
          enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Product() = row.Name() );
          products.Add( pisp.Product_MP() );
          //当product planning的日期区间在需要的日期区间内
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
                    ){
            periodtime := pispip.Start().StartOfMonth().Date();
            periodname := periodtime.Format( "M2/D2/Y" );
            quantity   := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
            column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
            row.SetRentStorageCost( column, quantity );
          }
          if( exists( productparents, Elements, e, e.ID() = '发动机' ) ){////查询产品类型是发动机
            //查询对应的发动机成本
            enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccunit
                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
            if( not isnull( enginecost ) ){
              products.Add( product );
              //当product planning的日期区间在需要的日期区间内
              traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
                        ){
                periodtime := pispip.Start().StartOfMonth().Date();
                periodname := periodtime.Format( "M2/D2/Y" );
                quantity   := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入
                column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
                row.SetRentStorageCost( column, quantity );
              }
            }
          }
        }
      }
    }