From 81efbc5ecdf292799c866a18516eccbad565a3ae Mon Sep 17 00:00:00 2001 From: wbudic Date: Tue, 10 Aug 2021 00:10:21 +1000 Subject: [PATCH] Implemented auto sum for ammount field. Bug 35 fixed. --- Current Development Check List.md | 6 +++--- htdocs/cgi-bin/main.cgi | 13 +++---------- htdocs/cgi-bin/wsrc/main.js | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index 524369a..a83468c 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -6,8 +6,8 @@ ### New Development -* Bug 35. SQL migration, version update, not working for PG based databases. -* JS - Event, on expense sum in log numbers found at beginning of lines. +* ✔ Bug 35. SQL migration, version update, not working for PG based databases. +* ✔ JS - Event, on expense sum in log numbers found at beginning of lines. * ✔ Update to CNF v.2.2, branch to $RELEASE_VER = 2.3, Earth Stage initial. * Plugins * Perl files enabled by being including them in main.cnf file under the <>> list, and placed in the plugins directory. @@ -207,7 +207,7 @@ between 2018-08-22 04:13:55 **Moon Stable** production release and this ### v. 2.2 Encountered/Fixed -* Bug 35, Migration and version updating SQL is wrong for PG database, it doesn't have rowid's. +* ✔ Bug 35, Migration and version updating SQL is wrong for PG database, it doesn't have rowid's. * Bug 34, DB fix in config, removes associated RTF documents, for some reason. * ✔ Bug 33 Changing session timeout in config to an lib. background unparsable format cause unrecoverable system error. * i.e. Putting +1hr instead of +1h. diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 95dc496..9bec9d6 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -239,7 +239,6 @@ while ( my @row = $st->fetchrow_array() ) { } $td_cat .= "
  • $row[1]
  • "; $td_itm_cnt++; - } if($td_itm_cnt<5){#fill spacing. for (my $i=0;$i<5-$td_itm_cnt;$i++){ @@ -280,7 +279,6 @@ qq(
    my @keywords = split /\W/, $rs_keys; if ($prm_vc && $prm_vc != $prm_xc) { - if(@vc_lst){ $stmS .= $prm_aa; foreach (@vc_lst){ @@ -440,12 +438,14 @@ sub buildLog { my $ct = $hshCats{$cid}; #ID_CAT my $dt = DateTime::Format::SQLite->parse_datetime( $row[$i++] ); #LOG.DATE my $log = $row[$i++]; #LOG.LOG - my $rtf = $row[$i++]; #ID_RTF since v.1.8 but just RTF from v.2.1 + my $rtf = $row[$i++]; #ID_RTF since v.1.8 but just RTF from v.2.1 my $am = $row[$i++]; #LOG.AMOUNT my $af = $row[$i++]; #AFLAG -> Asset as 0, Income as 1, Expense as 2 my $sticky = $row[$i++]; #Sticky to top my $pid = $row[$i++]; #PID actual log ID in View. + $am =~ s/^\D|\,//g; #trim if it is money sql data type formated. + if ( $af == 1 ) { #AFLAG Income, assets are neutral. $sum += $am; } @@ -691,13 +691,6 @@ sub buildLog { ); } - - # - #
    - #
    - #
    - $log_rc += 1; if ( $rec_limit > 0 && $log_rc == $rec_limit ) { diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index 59da595..2c87725 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -102,6 +102,30 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { offsetX: 5, showTimeout: 100 }); + $('#am').click(function(e){ + e.preventDefault(); + let v = $('#am').val(); + if(v.length==0 || v==0.00){ + const regex = /^\D*\d+\.*\d*/gm; + let str = $('#el').val(); + let m; let tot = 0; + + while ((m = regex.exec(str)) !== null) { + if (m.index === regex.lastIndex) { + regex.lastIndex++; + } + m.forEach( (match, groupIndex) => { + //console.log(`Found match, group ${groupIndex}: ${match}`); + tot += parseFloat(`${match}`.replace(/^\$/g,'')); + + }); + } + $('#am').val(tot); + + } + + + }); $('#sss_xc').poshytip({ content: "When checked, system will try to remember your view mode while in session.", @@ -273,6 +297,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { } }).mouseleave(function(e){$("#cat_desc").hide();}); + $( "#dlgValidation" ).dialog({ dialogClass: "alert", buttons: [ -- 2.34.1