lazhen
2024-09-19 adfa4e3c3a15bbdfb634b49a552505d40742d046
财务产量/销量报表改动
已修改7个文件
142 ■■■■■ 文件已修改
_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl 106 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
@@ -25,7 +25,7 @@
        showrow := this.FinancialProductionRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
        
        traverse( row, FinancialProductionCell, cell, not cell.FinancialProductionColumn().IsDay() ){
          column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() );
          column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() and not column.IsDay() );
          
          sumcell  := selectobject( column, FinancialProductionCell, c, c.FinancialProductionRow() = sumrow );
          if( isnull( sumcell ) ){
_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -11,10 +11,10 @@
    owner.FPImportData( relflush );
    ccunit                    := FinancialProductionReport::GetDefaultCCUnit();
    dlunit                    := FinancialProductionReport::GetDefaultDLUnit();
    ccalineunit               := FinancialProductionReport::GetDefaultCCALineUnit();
    dlalienunit               := FinancialProductionReport::GetDefaultDLALineUnit()
    ccmplineunit              := FinancialProductionReport::GetDefaultCCMPLineUnit()
    dlmplineunit              := FinancialProductionReport::GetDefaultDLMPLineUnit();
    //ccalineunit               := FinancialProductionReport::GetDefaultCCALineUnit();
    //dlalienunit               := FinancialProductionReport::GetDefaultDLALineUnit()
    //ccmplineunit              := FinancialProductionReport::GetDefaultCCMPLineUnit()
    //dlmplineunit              := FinancialProductionReport::GetDefaultDLMPLineUnit();
    allunit                   := FinancialProductionReport::GetDefaultAllUnit();
    source                    := owner.FinancialProductionSource( relnew, IsImport := false, Name := FinancialProductionReport::GetDefaultName() );
    table                     := source.FinancialProductionReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
@@ -35,13 +35,16 @@
    //currentperiods            := table.GetCurrentPeriod( startofplanning, periods );
    table.GenerateColumn( owner );
    //取当前版本的product planning里new supply字段,分大连和长春工厂的产线,进行加总
    traverse( owner, StockingPoint_MP, stockingpoint ){
      unit                    := stockingpoint.Unit();
      parentunits             := unit.GetAllParent();
    //traverse( owner, StockingPoint_MP, stockingpoint ){
    traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '厂内库' ) ){
      iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '长春' );
      isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '大连' );
    //  unit                    := stockingpoint.Unit();
    //  parentunits             := unit.GetAllParent();
      //是否属于长春工厂
      iscc                    := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
    //  iscc                    := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
      //是否属于大连工厂
      isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
    //  isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
      if( iscc or isdl ){
        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 ) ){
_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
@@ -24,8 +24,8 @@
      if( productids.ContainsAll( productid ) ){
        showrow := this.FinancialSalesRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
        
        traverse( row, FinancialSalesCell, cell ){
          column   := selectobject( this, FinancialSalesColumn, column, column.Name() = cell.FinancialSalesColumn().Name() );
        traverse( row, FinancialSalesCell, cell, not cell.FinancialSalesColumn().IsDay() ){
          column   := selectobject( this, FinancialSalesColumn, column, column.Name() = cell.FinancialSalesColumn().Name() and not column.IsDay());
          
          sumcell  := selectobject( column, FinancialSalesCell, c, c.FinancialSalesRow() = sumrow );
          if( isnull( sumcell ) ){
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentCC.qbl
@@ -5,7 +5,8 @@
  TextBody:
  [*
    // 甄兰鸽 Jun-28-2024 (created)
    return '长春';
    //return '长春';
    return 'Changchun';
    //return 'China';
  *]
}
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentFS.qbl
@@ -5,7 +5,8 @@
  TextBody:
  [*
    // 甄兰鸽 Jun-28-2024 (created)
    return '佛山';
    //return '佛山';
    return 'Foshan';
    //return 'Germany';
  *]
}
_Main/BL/Type_FinancialSalesReport/StaticMethod_GetSalesSegmentTJ.qbl
@@ -5,7 +5,8 @@
  TextBody:
  [*
    // 甄兰鸽 Jun-28-2024 (created)
    return '天津';
    //return '天津';
    return 'Tianjin';
    //return 'USA';
  *]
}
_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
@@ -16,9 +16,9 @@
    ccsalessegment            := FinancialSalesReport::GetSalesSegmentCC();
    tjsalessegment            := FinancialSalesReport::GetSalesSegmentTJ();
    fssalessegment            := FinancialSalesReport::GetSalesSegmentFS();
    ccspline                  := FinancialSalesReport::GetStockingPointCCLine();
    dlspline                  := FinancialSalesReport::GetStockingPointDLLine();
    ccrent                    := FinancialSalesReport::GetStockingPointCCRent();
    //ccspline                  := FinancialSalesReport::GetStockingPointCCLine();
    //dlspline                  := FinancialSalesReport::GetStockingPointDLLine();
    //ccrent                    := FinancialSalesReport::GetStockingPointCCRent();
    
    source                    := owner.FinancialSalesSource( relnew, IsImport := false, Name := FinancialSalesReport::GetDefaultName() );
    table                     := source.FinancialSalesReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
@@ -37,11 +37,15 @@
      salessegment            := forecast.SalesSegment_MP();
      parentsalessegments     := salessegment.GetAllParent();
      //是否属于长春
      iscc                    := salessegment.Name() = ccsalessegment or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccsalessegment );
    //  iscc                    := salessegment.Name() = ccsalessegment or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = ccsalessegment );
      iscc                    := salessegment.Name().StartsWith( ccsalessegment ) or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( 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 );
    //  isdl                    := salessegment.Name() = tjsalessegment or salessegment.Name() = fssalessegment
    //                              or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = tjsalessegment )
    //                              or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name() = fssalessegment );
      isdl                    := salessegment.Name().StartsWith( tjsalessegment ) or salessegment.Name().StartsWith( fssalessegment )
                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( tjsalessegment ) )
                                  or exists( parentsalessegments, Elements, psalessegment, psalessegment.Name().StartsWith( fssalessegment ) );
      //Forecast的Sales Segment为长春,识别出MLB的所有产品汇总
      //大连财务销量:首先在forecast界面查找Sales Segment是天津和佛山的所有需求,每个产品按月汇总需求数量
      if( ( iscc and forecast.Product_MP().MQBMLB() = 'MLB' ) or isdl ){
@@ -69,70 +73,76 @@
        }
      }
    }
    //从Product planning查找库存点为长春装配线边库的所有MQB产品,取Total Demand字段按月汇总需求数量
    traverse( owner, StockingPoint_MP, stockingpoint ){
    //从Product planning查找库存点为长春装配线边库(CC厂内库)的所有MQB产品,取Total Demand字段按月汇总需求数量
    //从Product planning查找库存点为大连发动机的长春外租库,取New supply字段按月汇总需求数量
    //traverse( owner, StockingPoint_MP, stockingpoint ){
    traverse( owner, StockingPoint_MP, stockingpoint, ( stockingpoint.ID().StartsWith( 'CC' ) and stockingpoint.ID().EndsWith( '厂内库' ) ) or stockingpoint.ID() = '大连发动机的长春外租库' ){
      isdl                  := stockingpoint.ID() = '大连发动机的长春外租库';
    //  unit                  := stockingpoint.Unit();
    //  parentunits           := unit.GetAllParent();
      //是否属于长春装配线
    //  iscc                  := unit.ID() = ccspline or exists( parentunits, Elements, punit, punit.ID() = ccspline );
      if( table.IsInUnit( stockingpoint, ccspline ) ){
    //  if( table.IsInUnit( stockingpoint, ccspline ) ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' 
                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ){//产品为MQB
                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
                              and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ) ){//产品为MQB
          product           := pisp.Product_MP();
          allrow            := table.GetRow( allunit, product );
          ccrow             := table.GetRow( ccunit, product );
          products.Add( product );
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ){
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
                    and pispip.Period_MP().StartDate() < startofnextyear
                    and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ){
            dayperiodtime   := pispip.Start().Date();
            dayperiodname   := dayperiodtime.Format( "M2/D2/Y" );
            periodtime      := pispip.Start().StartOfMonth().Date();
            periodname      := periodtime.Format( "M2/D2/Y" );
            daycolumn       := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
            column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
            quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//四舍五入
            quantity        := ifexpr( isdl, [Number]pispip.NewSupplyQuantity(), [Number]pispip.DependentDemandAndSalesDemandQuantity() );//四舍五入
            
            ccrow.Initialize( column, quantity );//取Total Demand字段按月汇总需求数量
            ccrow.Initialize( daycolumn, quantity );
            allrow.Initialize( column, quantity );
          }
        }
    //  }
      }
    }
    startofnextyearlead       := startofplanning.StartOfNextYear() + FinancialSalesReport::GetDefaultTripLeadingTime();
    //startofnextyearlead       := startofplanning.StartOfNextYear() + FinancialSalesReport::GetDefaultTripLeadingTime();
    //大连财务销量:长春的需求需要在trip plan里面找到起始库存点为大连装配线边库,目的地为长春外租库的产品,由于需要考虑产品运输lead time,每个月的汇总数据需要推迟两天进行计算
    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 and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
    //      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
          dayperiodtime     := trip.Departure().Date();
          dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
          periodtime        := trip.Departure().StartOfMonth().Date();
          periodname        := periodtime.Format( "M2/D2/Y" );
          daycolumn         := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
          column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
          if( not isnull( column ) ){
            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
              product       := pit.Product_MP();
              products.Add( product );
              quantity      := [Number]pit.Quantity();//四舍五入
              dlrow         := table.GetRow( dlunit, pit.Product_MP() );
              dlrow.Initialize( column, quantity );//汇总数量
              dlrow.Initialize( daycolumn, quantity );
              allrow        := table.GetRow( allunit, pit.Product_MP() );
              allrow.Initialize( column, quantity );
            }
          }
        }
      }
    }
    //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 and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
    ////      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
    //      dayperiodtime     := trip.Departure().Date();
    //      dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
    //      periodtime        := trip.Departure().StartOfMonth().Date();
    //      periodname        := periodtime.Format( "M2/D2/Y" );
    //
    //      daycolumn         := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
    //      column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
    //      if( not isnull( column ) ){
    //        traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
    //          product       := pit.Product_MP();
    //          products.Add( product );
    //          quantity      := [Number]pit.Quantity();//四舍五入
    //          dlrow         := table.GetRow( dlunit, pit.Product_MP() );
    //          dlrow.Initialize( column, quantity );//汇总数量
    //          dlrow.Initialize( daycolumn, quantity );
    //
    //          allrow        := table.GetRow( allunit, pit.Product_MP() );
    //          allrow.Initialize( column, quantity );
    //        }
    //      }
    //    }
    //  }
    //}
    
    rows := selectsortedset( table, FinancialSalesRow, row, row.Name() );
    i    := 0;