Closed rajaiskandar closed 14 years ago
anyone can spot what wrong in the code below?
switch (Item::info('cumm', $this->item_id, $this->dataset_id)) {
case 'normal':
case 'sum':
$this->half1 = $this->quarter1+$this->quarter2;
$this->half2 = $this->half1+$this->quarter1+$this->quarter2;
$this->total = $this->half2;
break;
case 'average';
case 'avg':
$this->half1 = ($this->quarter1+$this->quarter2)/2;
$this->half2 = ($this->half1+$this->quarter1+$this->quarter2)/4;
$this->total = $this->half2;
break;
case 'balance':
$this->half1 = $this->quarter2;
$this->half2 = $this->quarter4;
$this->total = $this->half2;
break;
default:
}
ok spotted the problem :
case 'sum':
$this->half1 = $this->quarter1+$this->quarter2;
$this->half2 = $this->quarter3+$this->quarter4;
$this->total = $this->half1+$this->half2;
break;
case 'average';
case 'avg':
$this->half1 = ($this->quarter1+$this->quarter2)/2;
$this->half2 = ($this->quarter3+$this->quarter4)/2;
$this->total = ($this->half1+$this->half2)/2;
break;
case 'balance':
$this->half1 = $this->quarter2;
$this->half2 = $this->quarter4;
$this->total = $this->half2;
break;
the balance is not satisfactory, it should be something like :
if qtr1 = 110, qtr2 = 120, qtr3 = 130, qtr4=140 then half1=120, half2=140, year=140
if qtr1 = 110, qtr2 = 120, qtr3 = 130, qtr4=0 then half1=120, half2=130, year=130
if qtr1 = 110, qtr2 = 120, qtr3 = 0, qtr4=0 then half1=120, half2=120, year=120
if qtr1 = 110, qtr2 = 0, qtr3 = 0, qtr4=0 then half1=110, half2=110, year=110
if qtr1 = 0, qtr2 = 0, qtr3 = 0, qtr4=0 then half1=0, half2=0, year=0
there are mistakes in SUM & AVERAGE,
based on symptom: Half 2 not showing correct figure, instead showing double of half 1
error!
case 'sum':
$this->half2 = $this->half1+$this->quarter1+$this->quarter2;
supposed to be:
case 'sum':
$this->half2 = $this->half1+$this->quarter3+$this->quarter4;
correction: half2 should show only the sum for quarter 3 and quarter4
refer to my post : http://github.com/idafx/IDA-Framework/issues/issue/3#issue/3/comment/184334
cumulative quarter to half fixed, but cumulative balance still need work (and should be filed in another issue post).
oppp... still not ok for sum. supposed to be : half1 = quarter1 + quarter2 half2 = quarter3 + quarter4 year = half1 + half2
updated.
there is a problem in the cummulative for half 2 and year when updating data through the quarter data entry
quarter data entry : OK http://ida2.krimnet.com/report/actual/quarter/10376/detail?y1=2008&y2=2009&val=actual&ver=actual&dec=0&level=2
quarter report : OK http://ida2.krimnet.com/report/actual/quarter/10376/detail?y1=2008&y2=2009&val=actual&ver=actual&dec=0&level=1
half-year report : NOT OK - Half 2 not showing correct figure, instead showing double of half 1 http://ida2.krimnet.com/report/actual/half/10376/detail?y1=2008&y2=2010&val=actual&ver=actual&dec=0&level=1
year report : NOT OK - year not showing correct figure, instead showing doubel of half 1 http://ida2.krimnet.com/report/actual/year/10376/detail