陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Quintiq file version 2.0
#parent: #root
StaticMethod Initialize (
  MacroPlan owner
)
{
  Description: '初始化'
  TextBody:
  [*
    // 甄兰鸽 Jul-4-2024 (created)
    owner.FinancialWeeklyReport( relflush );
    ccunit                    := FinancialWeeklyReport::GetDefaultCCUnit();
    dlunit                    := FinancialWeeklyReport::GetDefaultDLUnit();
    //allunit                   := FinancialWeeklyReport::GetDefaultAllUnit();
    defaultname               := FinancialWeeklyReport::GetDefaultName();
    startofplanning           := owner.StartOfPlanning();
    
    table                     := owner.FinancialWeeklyReport( relnew, ID := defaultname, Name := defaultname );
    //产量报表
    productiontable           := selectobject( owner, FinancialProductionSource.FinancialProductionReport, report, not report.IsImport() and not report.IsShow() );
    //销量报表
    salestable                := selectobject( owner, FinancialSalesSource.FinancialSalesReport, report, not report.IsImport() and not report.IsShow() );
    
    table.GenerateColumn( owner );
    totalproduction           := table.FinancialWeeklyRow( relnew, Name := '总产量', RowNr := 1 );
    dlproduction              := table.FinancialWeeklyRow( relnew, Name := 'DL产量', RowNr := 2 );
    ccproduction              := table.FinancialWeeklyRow( relnew, Name := 'CC产量', RowNr := 3 );
    totalsales                := table.FinancialWeeklyRow( relnew, Name := '总销量', RowNr := 4 );
    dlsales                   := table.FinancialWeeklyRow( relnew, Name := 'DL销量', RowNr := 5 );
    ccsales                   := table.FinancialWeeklyRow( relnew, Name := 'CC销量', RowNr := 6 );
    //SUM
    dlpvaluesum               := [Real]0;
    ccpvaluesum               := [Real]0;
    dlsvaluesum               := [Real]0;
    ccsvaluesum               := [Real]0;
    //累计量
    dlpvaluecumulant          := [Real]0;
    ccpvaluecumulant          := [Real]0;
    dlsvaluecumulant          := [Real]0;
    ccsvaluecumulant          := [Real]0;
    
    traverse( table, FinancialWeeklyColumn, column ){
      productioncolumn      := selectobject( productiontable, FinancialProductionColumn, pcolumn, pcolumn.Name() = column.Name() and pcolumn.Period() = column.Period() );
      salescolumn           := selectobject( salestable, FinancialSalesColumn, scolumn, scolumn.Name() = column.Name() and scolumn.Period() = column.Period() );
      
      //产量汇总
      dlpvalue              := [Real]0;
      ccpvalue              := [Real]0;
      traverse( productioncolumn, FinancialProductionCell, cell, cell.Quantity() > 0 ){
        unit                := cell.FinancialProductionRow().Unit();
        
        if( unit = dlunit ){
          dlpvalue          := dlpvalue + cell.Quantity();
          if( column.Period() = startofplanning.StartOfMonth().Date() ){
            dlpvaluecumulant := dlpvaluecumulant - cell.PlanValue();
          }
        }else if( unit = ccunit ){
          ccpvalue          := ccpvalue + cell.Quantity();
          if( column.Period() = startofplanning.StartOfMonth().Date() ){
            ccpvaluecumulant := ccpvaluecumulant - cell.PlanValue();
          }
        }
      }
      totalpcell            := column.FinancialWeeklyCell( relnew, Value := [String]( [Number]( dlpvalue + ccpvalue ) ) );
      totalproduction.FinancialWeeklyCell( relinsert, totalpcell );
      dlpcell               := column.FinancialWeeklyCell( relnew, Value := [String]( [Number]dlpvalue ) );
      dlproduction.FinancialWeeklyCell( relinsert, dlpcell );
      ccpcell               := column.FinancialWeeklyCell( relnew, Value := [String]( [Number]ccpvalue ) );
      ccproduction.FinancialWeeklyCell( relinsert, ccpcell );
      
      //销量汇总
      dlsvalue              := [Real]0;
      ccsvalue              := [Real]0;
      traverse( salescolumn, FinancialSalesCell, cell, [Real]cell.Value() > 0 ){
        unit                := cell.FinancialSalesRow().Unit();
    
        if( unit = dlunit ){
          dlsvalue          := dlsvalue + [Real]cell.Value();
        }else if( unit = ccunit ){
          ccsvalue          := ccsvalue + [Real]cell.Value();
        }
      }
      totalscell            := column.FinancialWeeklyCell( relnew, Value := [String]( dlsvalue + ccsvalue ) );
      totalsales.FinancialWeeklyCell( relinsert, totalscell );
      dlscell               := column.FinancialWeeklyCell( relnew, Value := [String]dlsvalue );
      dlsales.FinancialWeeklyCell( relinsert, dlscell );
      ccscell               := column.FinancialWeeklyCell( relnew, Value := [String]ccsvalue );
      ccsales.FinancialWeeklyCell( relinsert, ccscell );
      
      if( column.Period() < startofplanning.StartOfMonth().Date() ){
        dlpvaluecumulant    := dlpvaluecumulant + dlpvalue;
        ccpvaluecumulant    := ccpvaluecumulant + ccpvalue;
        dlsvaluecumulant    := dlsvaluecumulant + dlsvalue;
        ccsvaluecumulant    := ccsvaluecumulant + ccsvalue;
      }
      dlpvaluesum           := dlpvaluesum + dlpvalue;
      ccpvaluesum           := ccpvaluesum + ccpvalue;
      dlsvaluesum           := dlsvaluesum + dlsvalue;
      ccsvaluesum           := ccsvaluesum + ccsvalue;
    }
    sumcolumn                 := table.FinancialWeeklyColumn( relnew, Name := 'SUM' );
    cumulantcolumn            := table.FinancialWeeklyColumn( relnew, Name := '累计量' );
    proportioncolumn          := table.FinancialWeeklyColumn( relnew, Name := '占比' );
    //SUM
    totalpcellsum           := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]( [Number]( dlpvaluesum + ccpvaluesum ) ) );
    totalproduction.FinancialWeeklyCell( relinsert, totalpcellsum );
    dlpcellsum              := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]( [Number]dlpvaluesum ) );
    dlproduction.FinancialWeeklyCell( relinsert, dlpcellsum );
    ccpcellsum              := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]( [Number]ccpvaluesum ) );
    ccproduction.FinancialWeeklyCell( relinsert, ccpcellsum );
    totalscellsum           := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]( dlsvaluesum + ccsvaluesum ) );
    totalsales.FinancialWeeklyCell( relinsert, totalscellsum );
    dlscellsum              := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]dlsvaluesum );
    dlsales.FinancialWeeklyCell( relinsert, dlscellsum );
    ccscellsum              := sumcolumn.FinancialWeeklyCell( relnew, Value := [String]ccsvaluesum );
    ccsales.FinancialWeeklyCell( relinsert, ccscellsum );
    //累计量
    totalpcellcumulant      := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]( dlpvaluecumulant + ccpvaluecumulant ) );
    totalproduction.FinancialWeeklyCell( relinsert, totalpcellcumulant );
    dlpcellcumulant         := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]dlpvaluecumulant );
    dlproduction.FinancialWeeklyCell( relinsert, dlpcellcumulant );
    ccpcellcumulant         := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]ccpvaluecumulant );
    ccproduction.FinancialWeeklyCell( relinsert, ccpcellcumulant );
    totalscellcumulant      := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]( dlsvaluecumulant + ccsvaluecumulant ) );
    totalsales.FinancialWeeklyCell( relinsert, totalscellcumulant );
    dlscellcumulant         := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]dlsvaluecumulant );
    dlsales.FinancialWeeklyCell( relinsert, dlscellcumulant );
    ccscellcumulant         := cumulantcolumn.FinancialWeeklyCell( relnew, Value := [String]ccsvaluecumulant );
    ccsales.FinancialWeeklyCell( relinsert, ccscellcumulant );
    //占比
    totalpvalueproportion   := guard( ( ( dlpvaluecumulant + ccpvaluecumulant ) / ( dlpvaluesum + ccpvaluesum ) ).Format( 'N(Dec(2))' ), '0.00' );
    totalpcellproportion    := proportioncolumn.FinancialWeeklyCell( relnew, Value := totalpvalueproportion );
    totalproduction.FinancialWeeklyCell( relinsert, totalpcellproportion );
    
    dlpvalueproportion      := guard( ( dlpvaluecumulant / dlpvaluesum ).Format( 'N(Dec(2))' ), '0.00' );
    dlpcellproportion       := proportioncolumn.FinancialWeeklyCell( relnew, Value := dlpvalueproportion );
    dlproduction.FinancialWeeklyCell( relinsert, dlpcellproportion );
    
    ccpvalueproportion      := guard( ( ccpvaluecumulant / ccpvaluesum ).Format( 'N(Dec(2))' ), '0.00' );
    ccpcellproportion       := proportioncolumn.FinancialWeeklyCell( relnew, Value := ccpvalueproportion );
    ccproduction.FinancialWeeklyCell( relinsert, ccpcellproportion );
    
    totalsvalueproportion   := guard( ( ( dlsvaluecumulant + ccsvaluecumulant ) / ( dlsvaluesum + ccsvaluesum ) ).Format( 'N(Dec(2))' ), '0.00' );
    totalscellproportion    := proportioncolumn.FinancialWeeklyCell( relnew, Value := totalsvalueproportion );
    totalsales.FinancialWeeklyCell( relinsert, totalscellproportion );
    
    dlsvalueproportion      := guard( ( dlsvaluecumulant / dlsvaluesum ).Format( 'N(Dec(2))' ), '0.00' );
    dlscellproportion       := proportioncolumn.FinancialWeeklyCell( relnew, Value := dlsvalueproportion );
    dlsales.FinancialWeeklyCell( relinsert, dlscellproportion );
    
    ccsvalueproportion      := guard( ( ccsvaluecumulant / ccsvaluesum ).Format( 'N(Dec(2))' ), '0.00' );
    ccscellproportion       := proportioncolumn.FinancialWeeklyCell( relnew, Value := ccsvalueproportion );
    ccsales.FinancialWeeklyCell( relinsert, ccscellproportion );
    
    info( sumcolumn.FinancialWeeklyCell( relsize ), proportioncolumn.FinancialWeeklyCell( relsize ) );
  *]
}