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 ) );
|
*]
|
}
|