renhao
2023-10-13 462215553c754d26acde8edab81b4a73f774e21e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
Method InitTestData (
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    // yypsybs Oct-7-2023 (created)
    productCodeList := selectuniquevalues( macroPlan, Product_MP, item, item.ID() );
    debuginfo( "productCodeList : " + [String]productCodeList.Size() );
    
    this.Global_MappingAnnualBudgetData( relflush );
    if( this.Global_MappingAnnualBudgetData( relsize ) = 0 ) {
      debuginfo( "create Global_MappingAnnualBudgetData test data" );
      id := 1;
      for( year := Date::ActualDate().Year() - 10; year <= Date::ActualDate().Year() + 5; year := year + 1 ) {
        for( i := 1; i <= productCodeList.Size(); i := i + 1 ) {
          productCode := productCodeList.Element( i - 1 );
          mappingAnnualBudget := this.Global_MappingAnnualBudgetData( relnew, 
                                                                      ID := [String]id,
                                                                      YearNo := [String]year,
                                                                      BusinessType := "事业部" + [String](productCode.Length() mod 3),
                                                                      ProductID := productCode);
          id := id + 1;
          for( month := 1; month <= 12; month := month + 1 ) {
            field := Reflection::FindAttribute( "Global_MappingAnnualBudgetData", "MonthlyModCapacity" + [String]month );
            field.Set( mappingAnnualBudget, [String]Real::Random( 20000.0, 30000.0 ) );
            field := Reflection::FindAttribute( "Global_MappingAnnualBudgetData", "MonthlySheetCapacity" + [String]month );
            field.Set( mappingAnnualBudget, [String]Real::Random( 20000.0, 30000.0 ) );
            field := Reflection::FindAttribute( "Global_MappingAnnualBudgetData", "MonthlySales" + [String]month );
            field.Set( mappingAnnualBudget, [String]Real::Random( 20000.0, 30000.0 ) );
          }
        }
      }
      result2 := selectset( this, Global_MappingAnnualBudgetData, item, true );
      debuginfo( "test MappingAnnualBudget size : " + [String]result2.Size() );
    }
  *]
}