]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Bug 21 fix.
authorWill Budic <redacted>
Fri, 8 May 2020 12:30:56 +0000 (22:30 +1000)
committerWill Budic <redacted>
Fri, 8 May 2020 12:30:56 +0000 (22:30 +1000)
Current Development Check List.md
htdocs/cgi-bin/stats.cgi

index 207d0624a13569151e1de88ff08d3a92b0481eab..0b67c7e3046ed7f5fcb62369390aecda62491e9d 100644 (file)
@@ -95,7 +95,7 @@ This version is not compatible in data structure to prior versions. Data migrati
 ### v. 1.9 Encountered/Fixed
 
 * &#10004; Bug 22 - Delete selection of entries not working after a while, db fix in config page required.
-* Bug 21 - Income sum for year in stats is displayed wrong.
+* &#10004; Bug 21 - Income sum for year in stats is displayed wrong.
 * &#10004; Bug 20 - Autologin bypasses, wanted new alias login (on logoff).
 
 ### v. 1.8 Encountered/Fixed
index 8af0a8a9be6a0ca305b581cf52292ca1cc272ef6..91d512a47b955be1623d153e520697f23eb6291d 100755 (executable)
@@ -74,14 +74,29 @@ my $log_rc = selectSQL('select count(rowid) from LOG;');
 my ($stm1,$stm2) = "SELECT count(date) from LOG where date>=date('now','start of year');";
 my $log_this_year_rc = selectSQL($stm1);
 my $notes_rc = selectSQL('select count(LID) from NOTES where DOC is not null;');
+my $id;
 
 #INCOME
-$stm1 = 'SELECT sum(AMOUNT) from LOG where date>=date("now","start of year") AND AFLAG = 1;';
+$stm1 = 'select ID from CAT where NAME like "Income"';
+$id = selectSQL($stm1);
+if($id){
+    $stm1 = "SELECT sum(AMOUNT) from LOG where date>=date('now','start of year') AND (ID_CAT =$id or AFLAG=1);";
+}
+else{
+    $stm1 = 'SELECT sum(AMOUNT) from LOG where date>=date("now","start of year") AND AFLAG = 1;';
+}
 #EXPENSE
-$stm2 = 'SELECT sum(AMOUNT) from LOG where date>=date("now","start of year") AND AFLAG = 2;';
+$stm2 = 'select ID from CAT where NAME like "Expense"';
+$id = selectSQL($stm2);
+if($id){
+    $stm2 = "SELECT sum(AMOUNT) from LOG where date>=date('now','start of year') AND (ID_CAT =$id or AFLAG=2);";
+}
+else{
+    $stm2 = 'SELECT sum(AMOUNT) from LOG where date>=date("now","start of year") AND AFLAG = 2;';
+}
 
-my $expense = selectSQL($stm1);
-my $income  = selectSQL($stm2);
+my $income = selectSQL($stm1);
+my $expense= selectSQL($stm2);
 my $gross   = big_money($income - $expense);
 $expense    = big_money(sprintf("%.2f",$expense));
 $income     = big_money(sprintf("%.2f",$income));