From afbad399be481afbe886bc2ad1e22abbcd5df771 Mon Sep 17 00:00:00 2001 From: lazhen <17772815105@139.com> Date: 星期一, 05 八月 2024 14:56:46 +0800 Subject: [PATCH] 财务报表bug修复 --- _Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl | 128 +++++++++++++++++++++++++----------------- 1 files changed, 75 insertions(+), 53 deletions(-) diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl index 804d079..cf1176e 100644 --- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl +++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl @@ -10,9 +10,10 @@ // 鐢勫叞楦� Jun-24-2024 (created) owner.FinancialSalesSource( relflush ); products := construct( Product_MPs ); - allsalessegment := FinancialSalesReport::GetSalesSegmentAll(); + allunit := FinancialSalesReport::GetDefaultAllUnit(); + ccunit := FinancialSalesReport::GetDefaultCCUnit(); + dlunit := FinancialSalesReport::GetDefaultDLUnit(); ccsalessegment := FinancialSalesReport::GetSalesSegmentCC(); - dlsalessegment := FinancialSalesReport::GetSalesSegmentDL(); tjsalessegment := FinancialSalesReport::GetSalesSegmentTJ(); fssalessegment := FinancialSalesReport::GetSalesSegmentFS(); ccspline := FinancialSalesReport::GetStockingPointCCLine(); @@ -22,73 +23,94 @@ source := owner.FinancialSalesSource( relnew, IsImport := false, Name := FinancialSalesReport::GetDefaultName() ); table := source.FinancialSalesReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false ); showtable := source.FinancialSalesReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsImport := false, IsShow := true ); - startofplanning := owner.StartOfPlanning(); + startofplanning := owner.StartOfPlanning().Date(); //startofyear := startofplanning.StartOfYear(); startofnextyear := startofplanning.StartOfNextYear(); - search := source.FinancialSalesSearch( relnew, Unit := allsalessegment, Generation := allsalessegment, MqbMlb := allsalessegment, Power := allsalessegment ); + search := source.FinancialSalesSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit ); table.GenerateColumn( owner ); - //浠嶧orecast鏌ヨ - traverse( owner, SalesDemand.astype( Forecast ), forecast, forecast.StartDate() < startofnextyear.Date() and ( ( forecast.SalesSegmentName() = ccsalessegment and forecast.Product_MP().MQBMLB() = 'MLB' ) - or forecast.SalesSegmentName() = tjsalessegment or forecast.SalesSegmentName() = fssalessegment ) ){ - product := forecast.Product_MP(); - allrow := table.GetRow( allsalessegment, product.ID() ); - periodtime := forecast.StartDate().StartOfMonth(); - periodname := periodtime.Format( "M2/D2/Y" ); - - if( products.Find( product ) < 0 ){ - products.Add( product ); - } - // info( '------------------------', periodname, periodtime ); - column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); - // info( '------------------------', column.Name() ); + //棣栧厛鍦╢orecast鐣岄潰鏌ユ壘sales segment涓洪暱鏄ョ殑鎵�鏈夐渶姹傦紝璇嗗埆鍑篗LB鐨勬墍鏈変骇鍝侊紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲� + traverse( owner, SalesDemand.astype( Forecast ), forecast, forecast.StartDate() < startofnextyear ){ + salessegment := forecast.SalesSegment_MP(); + parentsalessegments := salessegment.GetAllParent(); + //鏄惁灞炰簬闀挎槬 + iscc := salessegment.Name() = ccsalessegment or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccsalessegment ); + //鏄惁灞炰簬澶ц繛, 鍗冲ぉ娲ュ拰浣涘北 + isdl := salessegment.Name() = tjsalessegment or salessegment.Name() = fssalessegment + or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = tjsalessegment ) + or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = fssalessegment ); //Forecast鐨凷ales Segment涓洪暱鏄ワ紝璇嗗埆鍑篗LB鐨勬墍鏈変骇鍝佹眹鎬� - if( forecast.SalesSegmentName() = ccsalessegment and product.MQBMLB() = 'MLB' ){ - // info( '------------------------', column.Name() ); - ccrow := table.GetRow( ccsalessegment, product.ID() ); - // info( '------------------------', ccrow.FinancialSalesCell( relsize ), column.FinancialSalesCell( relsize ) ); - ccrow.Initialize( column, forecast.Quantity() ); - }else if( forecast.SalesSegmentName() = tjsalessegment or forecast.SalesSegmentName() = fssalessegment ){ - //澶ц繛璐㈠姟閿�閲忥細棣栧厛鍦╢orecast鐣岄潰鏌ユ壘Sales Segment鏄ぉ娲ュ拰浣涘北鐨勬墍鏈夐渶姹傦紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲� - // info( '------------------------', column.Name() ); - dlrow := table.GetRow( dlsalessegment, product.ID() ); - // info( '------------------------', dlrow.FinancialSalesCell( relsize ), column.FinancialSalesCell( relsize ) ); - dlrow.Initialize( column, forecast.Quantity() ); + //澶ц繛璐㈠姟閿�閲忥細棣栧厛鍦╢orecast鐣岄潰鏌ユ壘Sales Segment鏄ぉ娲ュ拰浣涘北鐨勬墍鏈夐渶姹傦紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲� + if( ( iscc and forecast.Product_MP().MQBMLB() = 'MLB' ) or isdl ){ + product := forecast.Product_MP(); + //鑾峰彇鍚堣琛� + allrow := table.GetRow( allunit, product.ID() ); + //鑾峰彇宸ュ巶琛� + factoryrow := table.GetRow( ifexpr( iscc and forecast.Product_MP().MQBMLB() = 'MLB', ccunit, dlunit ), product.ID() ); + + if( products.Find( product ) < 0 ){ + products.Add( product ); + } + traverse( forecast, PlanningSalesDemandInPeriod, psdip ){ + periodtime := psdip.StartDate().StartOfMonth(); + periodname := periodtime.Format( "M2/D2/Y" ); + // info( '-------------------------', periodname, periodtime ); + column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); + // info( '-------------------------', column.Name() ); + quantity := ceil( psdip.Quantity() );//鍚戜笂鍙栨暣 + + factoryrow.Initialize( column, quantity ); + allrow.Initialize( column, quantity ); + } } - allrow.Initialize( column, forecast.Quantity() ); } //浠嶱roduct planning鏌ユ壘搴撳瓨鐐逛负闀挎槬瑁呴厤绾胯竟搴撶殑鎵�鏈塎QB浜у搧锛屽彇Total Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲� - traverse( owner, Product_MP, product, product.IsLeaf() and product.MQBMLB() = 'MQB' ){//浜у搧涓篗QB - traverse( product, ProductInStockingPoint_MP, pisp, pisp.StockingPointID() = ccspline ){//搴撳瓨鐐逛负闀挎槬瑁呴厤绾胯竟搴� - traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() >= startofplanning - and pispip.Start() < startofnextyear and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Month() ){ - periodtime := pispip.Start().StartOfMonth().Date(); - periodname := periodtime.Format( "M2/D2/Y" ); - column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); - ccrow := table.GetRow( ccsalessegment, product.ID() ); - ccrow.Initialize( column, pispip.DependentDemandAndSalesDemandQuantity() );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲� - - allrow := table.GetRow( allsalessegment, product.ID() ); - allrow.Initialize( column, pispip.DependentDemandAndSalesDemandQuantity() ); + traverse( owner, StockingPoint_MP, stockingpoint ){ + // unit := stockingpoint.Unit(); + // parentunits := unit.GetAllParent(); + //鏄惁灞炰簬闀挎槬瑁呴厤绾� + // iscc := unit.ID() = ccspline or exists( parentunits, Elements, punit, punit.ID() = ccspline ); + if( table.IsInUnit( stockingpoint, ccspline ) ){ + traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' ){//浜у搧涓篗QB + allrow := table.GetRow( allunit, pisp.ProductID() ); + ccrow := table.GetRow( ccunit, pisp.ProductID() ); + 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" ); + column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); + quantity := ceil( pispip.DependentDemandAndSalesDemandQuantity() );//鍚戜笂鍙栨暣 + + ccrow.Initialize( column, quantity );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲� + allrow.Initialize( column, quantity ); + } } } } startofnextyearlead := startofplanning.StartOfNextYear() + FinancialSalesReport::GetDefaultTripLeadingTime(); //澶ц繛璐㈠姟閿�閲忥細闀挎槬鐨勯渶姹傞渶瑕佸湪trip plan閲岄潰鎵惧埌璧峰搴撳瓨鐐逛负澶ц繛瑁呴厤绾胯竟搴擄紝鐩殑鍦颁负闀挎槬澶栫搴撶殑浜у搧锛岀敱浜庨渶瑕佽�冭檻浜у搧杩愯緭lead time锛屾瘡涓湀鐨勬眹鎬绘暟鎹渶瑕佹帹杩熶袱澶╄繘琛岃绠� - traverse( owner, Unit.Lane.LaneLeg, laneleg, laneleg.OriginStockingPointID() = dlspline and laneleg.DestinationStockingPointID() = ccrent ){ - traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead ){ - periodtime := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date(); - periodname := periodtime.Format( "M2/D2/Y" ); - - column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); - traverse( trip, ProductInTrip, pit ){ - dlrow := table.GetRow( dlsalessegment, pit.ProductID() ); - dlrow.Initialize( column, pit.Quantity() );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲� + traverse( owner, Unit.Lane.LaneLeg, laneleg ){ + //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛瑁呴厤绾胯竟搴� + originsp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() ); + isdlspline := table.IsInUnit( originsp, dlspline ); + //鐩殑鍦版槸鍚︽槸闀挎槬澶栫搴� + destisp := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() ); + isccrent := table.IsInUnit( destisp, ccrent ); + if( isdlspline and isccrent ){ + traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead ){ + periodtime := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date(); + periodname := periodtime.Format( "M2/D2/Y" ); - allrow := table.GetRow( allsalessegment, pit.ProductID() ); - allrow.Initialize( column, pit.Quantity() ); + column := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime ); + traverse( trip, ProductInTrip, pit ){ + quantity := ceil( pit.Quantity() );//鍚戜笂鍙栨暣 + dlrow := table.GetRow( dlunit, pit.ProductID() ); + dlrow.Initialize( column, quantity );//姹囨�绘暟閲� + + allrow := table.GetRow( allunit, pit.ProductID() ); + allrow.Initialize( column, quantity ); + } } } } -- Gitblit v1.9.3