lazhen
2024-08-02 23eddf3d7adcdd2994c97c611dd2dd83895e38f3
财务产量报表修改
已添加2个文件
已修改6个文件
167 ■■■■■ 文件已修改
_Main/BL/Type_FinancialProductionReport/Method_GetCurrentPeriod.qbl 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/Method_GetRowByUnit.qbl 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/StaticMethod_GetDefaultCCUnit.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/StaticMethod_GetDefaultDLUnit.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventorySummaryReport/StaticMethod_GetDefaultCCUnit.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_InventorySummaryReport/StaticMethod_GetDefaultDLUnit.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_FinancialProductionReport/Method_GetCurrentPeriod.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
Quintiq file version 2.0
#parent: #root
Method GetCurrentPeriod (
  Date startofplanning,
  Period_MPs periods
) as owning Period_MPs
{
  Description: '获取当前月的计划周期---------------废弃'
  TextBody:
  [*
    // ç”„兰鸽 Aug-2-2024 (created)
    //开始日期到下个月的间隔天数
    currentperiods            := construct( Period_MPs );
    startofnextmonth          := startofplanning.StartOfNextMonth();
    //特殊情况,当开始日期正好是这个月第一天, åˆ™ç›´æŽ¥ä½¿ç”¨TimeUnit为月的数据
    if( startofplanning.StartOfMonth() = startofplanning ){
      period                  := selectobject( periods, Elements, period, period.TimeUnit() = Translations::MP_GlobalParameters_Month() and period.StartDate() = startofplanning );
      currentperiods.Add( period );
    } else if( startofplanning.StartOfWeek() = startofplanning ){
      //特殊情况,当开始日期正好是这个周第一天, åˆ™ç›´æŽ¥ä½¿ç”¨TimeUnit为周的数据, è·¨å‘¨æ—¶ä½¿ç”¨day
      traverse( periods, Elements, period, ( period.TimeUnit() =  Translations::MP_GlobalParameters_Week() and period.StartDate() < startofnextmonth )
                or (  period.TimeUnit() =  Translations::MP_GlobalParameters_Day() and period.EndDate() = startofnextmonth ) ){
        currentperiods.Add( period );
      }
    } else {
      duration                := startofplanning.StartOfNextMonth() - startofplanning;
      //如果计划开始日期到下个月小于7天,则可以直接使用Period的TimeUnit为天的数据
      if( duration <= 7 ){
        i := 1;
        traverse( periods, Elements, period, period.TimeUnit() = Translations::MP_GlobalParameters_Day() and i < duration ){
          currentperiods.Add( period );
          i ++;
        }
      }else{
        //反之需要在加上Period的TimeUnit为周的数据
        day := startofplanning;
        while( day < startofnextmonth ){
          if( day = day.StartOfWeek() ){
            period     := selectobject( periods, Elements, cperiod, cperiod.TimeUnit() = Translations::MP_GlobalParameters_Week() and cperiod.StartDate() = day );
            day        := period.EndDate();
            currentperiods.Add( period );
          } else {
            period     := selectobject( periods, Elements, cperiod, cperiod.TimeUnit() = Translations::MP_GlobalParameters_Day() and cperiod.StartDate() = day );
            day        := period.EndDate();
            currentperiods.Add( period );
          }
        }
      }
    }
    return &currentperiods;
  *]
}
_Main/BL/Type_FinancialProductionReport/Method_GetRowByUnit.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
Quintiq file version 2.0
#parent: #root
Method GetRowByUnit (
  String product,
  String unit
) as FinancialProductionRow
{
  Description: '根据工厂获取行'
  TextBody:
  [*
    // ç”„兰鸽 Aug-2-2024 (created)
    row := selectobject( this, FinancialProductionRow, row, row.Name() = product and row.Unit() = unit );
    if( isnull( row ) ){
      //初始化单元格
      row := this.FinancialProductionRow( relnew, Name := product, Unit := unit );
      traverse( this, FinancialProductionColumn, column ){
        row.Initialize( column, unit );
      }
    }
    return row;
  *]
}
_Main/BL/Type_FinancialProductionReport/StaticMethod_GetDefaultCCUnit.qbl
@@ -5,7 +5,7 @@
  TextBody:
  [*
    // ç”„兰鸽 Jun-25-2024 (created)
    return '长春';
    return '长春工厂';
    //return 'Assembly Plant (France)';
  *]
}
_Main/BL/Type_FinancialProductionReport/StaticMethod_GetDefaultDLUnit.qbl
@@ -5,7 +5,7 @@
  TextBody:
  [*
    // ç”„兰鸽 Jun-25-2024 (created)
    return '大连';
    return '大连工厂';
    //return 'Assembly Plant (Spain)';
  *]
}
_Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl
@@ -2,7 +2,7 @@
#parent: #root
Method Initialize (
  FinancialProductionColumn column,
  Real quantity
  Number quantity
)
{
  TextBody:
@@ -10,7 +10,7 @@
    // ç”„兰鸽 Jun-24-2024 (created)
    cell := selectobject( this, FinancialProductionCell, cell, cell.FinancialProductionColumn() = column );
          
    value := [Real]cell.Value() + quantity;
    value := [Number]cell.Value() + quantity;
    cell.Value( [String]value );
  *]
}
_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -14,66 +14,54 @@
    source                    := owner.FinancialProductionSource( relnew, IsImport := false, Name := FinancialProductionReport::GetDefaultName() );
    table                     := source.FinancialProductionReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
    showtable                 := source.FinancialProductionReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsImport := false, IsShow := true );
    startofplanning           := owner.StartOfPlanning();
    startofnextmonth          := owner.StartOfPlanning().StartOfNextMonth();
    startofyear               := startofplanning.StartOfYear();
    startofplanning           := owner.StartOfPlanning().Date();
    //startofnextmonth          := startofplanning.StartOfNextMonth();
    startofnextyear           := startofplanning.StartOfNextYear();
    
    search                    := source.FinancialProductionSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
    
    products                  := construct( Product_MPs );
    //需要的日期区间, å‘¨å’Œå¤©çš„只需要当前月
    //periods                   := selectset( owner, Period_MP, period, not period.IsHistorical()
    //                                        and period.StartDate() < startofnextmonth
    //                                        and period.TimeUnit() <> Translations::MP_GlobalParameters_Quarter()
    //                                        );
    //获取当前月需要的Period
    //currentperiods            := table.GetCurrentPeriod( startofplanning, periods );
    table.GenerateColumn( owner );
    traverse( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and not isnull( pisp.StockingPoint_MP() ) and ( pisp.StockingPoint_MP().UnitID() = ccunit or pisp.StockingPoint_MP().UnitID() = dlunit ) ){
      unit := pisp.StockingPoint_MP().UnitID();
      info( unit, pisp.ProductID() );
      ccrow := null( FinancialProductionRow );
      dlrow := null( FinancialProductionRow );
      allrow := selectobject( table, FinancialProductionRow, row, row.Name() = pisp.ProductID() and row.Unit() = allunit );
      if( unit = ccunit ){
        ccrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := unit );
      }else{
        dlrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := unit );
      }
      if( isnull( allrow ) ){
    //取当前版本的product planning里new supply字段,分大连和长春工厂的产线,进行加总
    traverse( owner, StockingPoint_MP, stockingpoint ){
      unit         := stockingpoint.Unit();
      parentunits  := unit.GetAllParent();
      //是否属于长春工厂
      iscc         := unit.ID() = ccunit or exists( parentunits, Elements, punit, punit.ID() = ccunit );
      //是否属于大连工厂
      isdl         := unit.ID() = dlunit or exists( parentunits, Elements, punit, punit.ID() = dlunit );
      if( iscc or isdl ){
        traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() ){
          //获取工厂行
          factoryrow := table.GetRowByUnit( pisp.ProductID(), ifexpr( iscc, ccunit, dlunit ) );
          //获取合计行
          allrow     := table.GetRowByUnit( pisp.ProductID(), allunit );
        products.Add( pisp.Product_MP() );
        allrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := allunit );
      }
      for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
        periodtime := start.Date();
        periodname := periodtime.Format( "M2/D2/Y" );
        column := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime );
        if( not isnull( ccrow ) ){
          ccrow.Initialize( column, ccunit );
        }
        if( not isnull( dlrow ) ){
          dlrow.Initialize( column, dlunit );
        }
        if( not exists( allrow, FinancialProductionCell, allcell, allcell.FinancialProductionColumn() = column ) ){
          allrow.Initialize( column, allunit );
        }
      }
      traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() >= startofplanning
                and ( ( pispip.Start() < startofnextmonth and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() )
                      or ( pispip.Start() < startofnextyear and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Month() ) ) ){
          //当product planning的日期区间在需要的日期区间内
          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear
    //                and ( ( pispip.Period_MP().StartDate().StartOfMonth() = startofplanning.StartOfMonth() and currentperiods.Find( pispip.Period_MP() ) >= 0 )
    //                 or ( pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Month() and pispip.Period_MP().StartDate() < startofnextyear ) )
                    ){
        periodtime := pispip.Start().StartOfMonth().Date();
        periodname := periodtime.Format( "M2/D2/Y" );
            quantity   := ceil( pispip.NewSupplyQuantity() );//向上取整
        
        column := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime );
        
        if( not isnull( ccrow ) ){
          ccrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
        }
        if( not isnull( dlrow ) ){
          dlrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
        }
        allrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
            factoryrow.Initialize( column, quantity );
            allrow.Initialize( column, quantity );
      }
    }
      }
    }
    rows := selectsortedset( table, FinancialProductionRow, row, row.Name() );
    i    := 0;
    traverse( rows, Elements, e ){
_Main/BL/Type_InventorySummaryReport/StaticMethod_GetDefaultCCUnit.qbl
@@ -5,7 +5,7 @@
  TextBody:
  [*
    // ç”„兰鸽 Jun-28-2024 (created)
    return '长春';
    return '长春工程';
    //return 'Assembly Plant (France)';
  *]
}
_Main/BL/Type_InventorySummaryReport/StaticMethod_GetDefaultDLUnit.qbl
@@ -5,7 +5,7 @@
  TextBody:
  [*
    // ç”„兰鸽 Jun-28-2024 (created)
    return '大连';
    return '大连工厂';
    //return 'Assembly Plant (Spain)';
  *]
}