| | |
| | | products := construct( Product_MPs ); |
| | | |
| | | table.GenerateColumn( owner ); |
| | | //外租库仓储费用:仓储数量/包装容量*仓储单价,在Actual inventories里取到长春外租库/大连外租库该发动机的仓储量,根据发动机号找到对应的Generation 和横纵制,在发动机成本参数表里找到对应的仓储单价和包装容量,用公式计算,月度进行汇总 |
| | | //长春外租库入库/出库费用,大连发动机的长春外租库的New supply |
| | | 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() |
| | | and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){ |
| | | //获取行 |
| | | product := pisp.Product_MP(); |
| | | productparents := product.GetAllParent(); |
| | | if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//查询产品类型是发动机 |
| | | row := table.GetRow( pisp.ProductID() ); |
| | | enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() ); |
| | | if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){ |
| | | products.Add( pisp.Product_MP() ); |
| | | traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){ |
| | | periodtime := pispip.Start().StartOfMonth().Date(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime ); |
| | | cell := selectobject( row, Cell, cell, cell.Column() = column ); |
| | | |
| | | if( isccrent or isdltoccrent){ |
| | | //在发动机成本参数表找到对应的包装容量 |
| | | enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() |
| | | and engine.Factory() = ccunit ); |
| | | if( not isnull( enginecost ) ){ |
| | | quantity := [Number]pispip.NewSupplyQuantity(); |
| | | if( isccrent ){ |
| | | cost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入 |
| | | cell.CCRentStorCost( cell.CCRentStorCost() + cost ); |
| | | }else{ |
| | | cell.CCRentQuantity( cell.CCRentQuantity() + quantity ); |
| | | //长春外租库入库费用:入库量/包装容量*入库单价 |
| | | entercost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); |
| | | //长春外租库出库费用: 出库量/包装容量*出库单价 |
| | | outcost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); |
| | | cell.CCRentInCost( cell.CCRentInCost() + entercost ); |
| | | cell.CCRentOutOfCost( cell.CCRentOutOfCost() + outcost ); |
| | | } |
| | | } |
| | | } else { |
| | | //在发动机成本参数表找到对应的包装容量 |
| | | enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() |
| | | and engine.Factory() = dlunit ); |
| | | if( not isnull( enginecost ) ){ |
| | | cost := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入 |
| | | cell.DLRentStorCost( cell.DLRentStorCost() + cost ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //在 trip plan里找到大连装配线边库到大连外租库的运输数量//大连厂内库到外租库 |
| | | traverse( owner, Unit.Lane.LaneLeg, laneleg ){ |
| | | //起始库存点是否是大连装配线边库 |
| | | // originsp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() ); |
| | | isdlspline := laneleg.OriginStockingPointID().EndsWith( '厂内库' ) and ( laneleg.OriginStockingPointID().StartsWith( '大连' ) or laneleg.OriginStockingPointID().StartsWith( 'DL' ) );//table.IsInUnit( originsp, dlline ); |
| | | isdlspline := laneleg.OriginStockingPointID().EndsWith( '厂内库' ) and ( laneleg.OriginStockingPointID().StartsWith( '大连' ) or laneleg.OriginStockingPointID().StartsWith( 'DL' ) ); |
| | | //目的地是否是大连外租库 |
| | | // destisp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() ); |
| | | isdlrent := laneleg.DestinationStockingPointID().EndsWith( '外租库' ) and ( laneleg.DestinationStockingPointID().StartsWith( '大连' ) or laneleg.DestinationStockingPointID().StartsWith( 'DL' ) );//table.IsInUnit( destisp, dlrent ); |
| | | isdlrent := laneleg.DestinationStockingPointID().EndsWith( '外租库' ) and ( laneleg.DestinationStockingPointID().StartsWith( '大连' ) or laneleg.DestinationStockingPointID().StartsWith( 'DL' ) ); |
| | | if( isdlspline and isdlrent ){ |
| | | traverse( laneleg, Trip, trip, trip.Departure().Date() < startofnextyear ){//由于需要考虑产品运输lead time,每个月的汇总数据需要推迟两天进行计算 |
| | | periodtime := trip.Departure().StartOfMonth().Date(); |
| | |
| | | cost := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//四舍五入 |
| | | cell.WerkToDLRentTransCost( cell.WerkToDLRentTransCost() + cost ); |
| | | } |
| | | // if( isccrent ){//目的地是长春外租库 |
| | | // //在发动机成本参数表找到对应的包装容量 |
| | | // enginecost := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower() |
| | | // and engine.MLB_MQB() = product.MQBMLB() |
| | | // and engine.Factory() = ccunit ); |
| | | // if( not isnull( enginecost ) ){ |
| | | // products.Add( product ); |
| | | // cell := selectobject( row, Cell, cell, cell.Column() = column ); |
| | | // cell.CCRentQuantity( cell.CCRentQuantity() + quantity ); |
| | | // //长春外租库入库费用:入库量/包装容量*入库单价 |
| | | // entercost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); |
| | | // //长春外租库出库费用: 出库量/包装容量*出库单价 |
| | | // outcost := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); |
| | | // cell.CCRentEnterCost( cell.CCRentEnterCost() + entercost ); |
| | | // cell.CCRentOutCost( cell.CCRentOutCost() + outcost ); |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //大连外租库入库费用:入库量/包装容量*入库单价,入库量等于大连工厂该产品产量减去发往长春的数量-newSupply |
| | | //大连外租库入库费用:入库量/包装容量*入库单价,入库量等于大连工厂该产品产量减去发往长春(大连的长春外租库)的数量-newSupply |
| | | traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//财务产量报表非导入 |
| | | traverse( source, FinancialProductionReport, report, not report.IsShow() ){//财务产量报表不显示 |
| | | traverse( report, FinancialProductionRow, row, row.Unit() = dlunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//财务产量报表里的大连产量, 不为0 |
| | |
| | | product := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() ); |
| | | productparents := product.GetAllParent(); |
| | | if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//查询产品类型是发动机 |
| | | //起始库存点是否是大连 |
| | | originsp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.SourceStockpoingPointID() ); |
| | | isdl := table.IsInUnit( originsp, dlunit ); |
| | | //目的地库存点是否是长春 |
| | | destisp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.TargetStockpoingPointID() ); |
| | | iscc := table.IsInUnit( destisp, ccunit ); |
| | | //起始库存点是否是大连(大连厂内库) |
| | | isdl := tprow.SourceStockpoingPointID().EndsWith( '厂内库' ) and ( tprow.TargetStockpoingPointID().StartsWith( '大连' ) or tprow.TargetStockpoingPointID().StartsWith( 'DL' ) ); |
| | | //目的地库存点是否是长春(长春外租库) |
| | | iscc := tprow.TargetStockpoingPointID().EndsWith( '外租库' ) and ( tprow.TargetStockpoingPointID().StartsWith( '长春' ) or tprow.TargetStockpoingPointID().StartsWith( 'CC' ) ); |
| | | if( isdl and iscc ){ |
| | | //查询对应的发动机成本 |
| | | enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() |
| | |
| | | salessegment := forecast.SalesSegment_MP(); |
| | | parentsalessegments := salessegment.GetAllParent(); |
| | | //是否属于长春 |
| | | iscc := salessegment.Name() = ccunit or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccunit ); |
| | | iscc := salessegment.Name().StartsWith( 'Changechun' ) or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( 'Changechun' ) ); |
| | | if( iscc ){ |
| | | product := forecast.Product_MP(); |
| | | productparents := product.GetAllParent(); |
| | |
| | | } |
| | | } |
| | | } |
| | | //外租库仓储费用:仓储数量/包装容量*仓储单价,在Actual inventories里取到长春外租库/大连外租库该发动机的仓储量,根据发动机号找到对应的Generation 和横纵制,在发动机成本参数表里找到对应的仓储单价和包装容量,用公式计算,月度进行汇总 |
| | | traverse( owner, StockingPoint_MP, stockingpoint ){ |
| | | unit := stockingpoint.Unit(); |
| | | parentunits := unit.GetAllParent(); |
| | | //是否属于长春外租库 |
| | | isccrent := stockingpoint.ID() = ccrent or unit.ID() = ccrent or exists( parentunits, Elements, punit, punit.ID() = ccrent ); |
| | | //是否属于大连外租库 |
| | | isdlrent := stockingpoint.ID() = dlrent or unit.ID() = dlrent or exists( parentunits, Elements, punit, punit.ID() = dlrent ); |
| | | if( isccrent or isdlrent ){ |
| | | traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() |
| | | and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){ |
| | | //获取行 |
| | | product := pisp.Product_MP(); |
| | | productparents := product.GetAllParent(); |
| | | if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//查询产品类型是发动机 |
| | | row := table.GetRow( pisp.ProductID() ); |
| | | enginecosts := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() ); |
| | | if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){ |
| | | products.Add( pisp.Product_MP() ); |
| | | traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){ |
| | | periodtime := pispip.Start().StartOfMonth().Date(); |
| | | periodname := periodtime.Format( "M2/D2/Y" ); |
| | | column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime ); |
| | | cell := selectobject( row, Cell, cell, cell.Column() = column ); |
| | | |
| | | if( isccrent ){ |
| | | //在发动机成本参数表找到对应的包装容量 |
| | | enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() |
| | | and engine.Factory() = ccunit ); |
| | | if( not isnull( enginecost ) ){ |
| | | cost := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入 |
| | | cell.CCRentStorCost( cell.CCRentStorCost() + cost ); |
| | | } |
| | | } else { |
| | | //在发动机成本参数表找到对应的包装容量 |
| | | enginecost := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() |
| | | and engine.Factory() = dlunit ); |
| | | if( not isnull( enginecost ) ){ |
| | | cost := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入 |
| | | cell.DLRentStorCost( cell.DLRentStorCost() + cost ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | rows := selectsortedset( table, Row, row, row.Name() ); |
| | | i := 0; |
| | | traverse( rows, Elements, e ){ |