idafx / IDA-Framework

Intelligence Data Analytics Framework
http://ida2.krimnet.com
11 stars 3 forks source link

data entry quarter: cummulative for half 2 and year not correct #3

Closed rajaiskandar closed 14 years ago

rajaiskandar commented 14 years ago

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

idafx commented 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:

    }
rajaiskandar commented 14 years ago

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

idafx commented 14 years ago

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;
rajaiskandar commented 14 years ago

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

towfx commented 14 years ago

cumulative quarter to half fixed, but cumulative balance still need work (and should be filed in another issue post).

http://ida2.krimnet.com/report/actual/half/10376/detail?y1=2008&y2=2010&val=actual&ver=actual&dec=0&level=1

rajaiskandar commented 14 years ago

oppp... still not ok for sum. supposed to be : half1 = quarter1 + quarter2 half2 = quarter3 + quarter4 year = half1 + half2

towfx commented 14 years ago

updated.