hongji.li
2023-11-03 d6bd7a69bc31efa79b21c7be12ba9547a921c251
_Main/BL/Type_GlobalDTOTable/Method_CreateCapacityAndSaleBudgeTestData#500.qbl
文件名从 _Main/BL/Type_GlobalDTOTable/Method_InitTestDataByYear.qbl 修改
@@ -1,38 +1,29 @@
Quintiq file version 2.0
#parent: #root
Method InitTestDataByYear (
  MacroPlan macroPlan,
Method CreateCapacityAndSaleBudgeTestData (
  GlobalOTDSOP globalOTDSOP,
  const GlobalOTDTable globalOTDTable,
  CapacityAndSaleBudgeFilterYears years,
  CapacityAndSaleBudgeFilterBusinessTypes businessTypes,
  CapacityAndSaleBudgeFilterPlaceOfProductionOfArrays placeOfProductionOfArrays,
  Product_MPs product_MPs
)
{
  TextBody:
  [*
    product_MPs := selectset( product_MPs, Elements, tempPMP, tempPMP.IsLeaf() and not tempPMP.IsSystem() );
    this.Global_MappingAnnualBudgetData( relflush );
    
    product_MPs := selectset( product_MPs, Elements, tempPMP, tempPMP.IsLeaf() and not tempPMP.IsSystem() );
    if ( years.Size() = 0 ) {
      years := selectset( globalOTDSOP, CapacityAndSaleBudgeFilterYear, tempCASBFY, 
                          tempCASBFY.YearNo() = Date::ActualDate().Year()     or
                          tempCASBFY.YearNo() = Date::ActualDate().Year() - 1 or
                          tempCASBFY.YearNo() = Date::ActualDate().Year() + 1
                          tempCASBFY.YearNo() = Date::ActualDate().Year()
                         );
    }
    if ( businessTypes.Size() = 0 ) {
      businessTypes := selectset( globalOTDSOP, CapacityAndSaleBudgeFilterBusinessType, tempCASBFBT, true );
    }
    if ( placeOfProductionOfArrays.Size() = 0 ) {
      placeOfProductionOfArrays := selectset( globalOTDSOP, CapacityAndSaleBudgeFilterPlaceOfProductionOfArray, tempCASBFPOPOA, true );
    }
    businessTypes             := selectuniquevalues( globalOTDTable, Global_MappingProduct_MP, tempGMPMP, true, tempGMPMP.BusinessType() );
    placeOfProductionOfArrays := selectuniquevalues( globalOTDTable, Global_MappingOperation, tempGMO, true, tempGMO.OrganCode() );
    
    traverse ( years, Elements, year ) {
    traverse ( years, Elements, year, businessTypes.Size() > 0 and placeOfProductionOfArrays.Size() > 0 ) {
      traverse ( product_MPs, Elements, pmp ) {
        businessType             := businessTypes.Element( Number::Random( 0, businessTypes.Size() - 1 ) ).BusinessType();
        placeOfProductionOfArray := placeOfProductionOfArrays.Element( Number::Random( 0, placeOfProductionOfArrays.Size() - 1 ) ).PlaceOfProductionOfArray();
        businessType             := businessTypes.Element( Number::Random( 0, businessTypes.Size() - 1 ) );
        placeOfProductionOfArray := placeOfProductionOfArrays.Element( Number::Random( 0, placeOfProductionOfArrays.Size() - 1 ) );
        mappingAnnualBudget := this.Global_MappingAnnualBudgetData( relnew, 
                                                                    ID           := OS::GenerateGUIDAsString(),
                                                                    YearNo       := [String]year.YearNo(),