[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6575] trunk



Revision: 6575
          http://sourceforge.net/p/ledger-smb/code/6575
Author:   einhverfr
Date:     2014-01-21 08:26:09 +0000 (Tue, 21 Jan 2014)
Log Message:
-----------
Totals now automatically added to most reports, closing bug 907

Modified Paths:
--------------
    trunk/LedgerSMB/Report/Trial_Balance.pm
    trunk/LedgerSMB/Report.pm
    trunk/css/ledgersmb.css

Modified: trunk/LedgerSMB/Report/Trial_Balance.pm
===================================================================
--- trunk/LedgerSMB/Report/Trial_Balance.pm	2014-01-21 06:32:56 UTC (rev 6574)
+++ trunk/LedgerSMB/Report/Trial_Balance.pm	2014-01-21 08:26:09 UTC (rev 6575)
@@ -214,6 +214,7 @@
 
 sub run_report {
     my ($self) = @_;
+    $self->manual_totals('1');
     my @rawrows = $self->exec_method({funcname => 'trial_balance__generate'});
     my $total_debits;
     my $total_credits;

Modified: trunk/LedgerSMB/Report.pm
===================================================================
--- trunk/LedgerSMB/Report.pm	2014-01-21 06:32:56 UTC (rev 6574)
+++ trunk/LedgerSMB/Report.pm	2014-01-21 08:26:09 UTC (rev 6575)
@@ -140,6 +140,16 @@
 
 has show_subtotals => (is => 'rw', isa => 'Bool');
 
+=has manual_totals
+
+Defaults to false.  Shows totals for all numeric (but not int) columns.  
+Typically this would be set to true in the run_report function if manual 
+totals are used.
+
+=cut
+
+has manual_totals => (is => 'rw', isa => 'Bool');
+
 =item buttons 
 
 Buttons to show at the bottom of the screen
@@ -205,27 +215,34 @@
         @$rows = reverse @$rows;
     }
     $self->rows($rows);
-    if ($self->show_subtotals){
-        my @newrows;
-        my $subtotals = {html_class => 'subtotal'};
-        for my $col ({eval $self->subtotal_on}){
-           $subtotals->{$col} = 0;
+    my $total_row = {html_class => 'listtotal'};
+    my $col_val = undef;
+    my $old_subtotal = {};
+    my @newrows;
+    for my $r (@{$self->rows}){
+        for my $k (keys %$r){
+            if (eval { $r->{$k}->isa('LedgerSMB::PGNumber') }){
+                $total_row->{$k} ||= LedgerSMB::PGNumber->from_input('0');
+                $total_row->{$k}->badd($r->{$k});
+            }
+            
         }
-        my $col_val = undef;
-        for my $r (@{$self->rows}){
-            if (defined $col_val and ($col_val ne $r->{$self->order_by})){
-                push @newrows, $subtotals;
-                $subtotals = {html_class => 'subtotal'};
-                for my $col ({eval $self->subtotal_on}){
-                    $subtotals->{$col} = 0;
-                }
+        if ($self->show_subtotals and defined $col_val and 
+            ($col_val ne $r->{$self->order_by})
+         ){
+            my $subtotals = {html_class => 'listsubtotal'};
+            for my $k (keys %$total_row){
+                $subtotals->{$k} = $total_row->{$k}->copy 
+                        unless $subtotals->{k};
+                $subtotals->{$k}->bsub($old_subtotal->{$k}) 
+                        if ref $old_subtotal->{$k};
             }
-            for my $col ({eval $self->subtotal_on}){
-                $subtotals->{$col} += $r->{$col};
-            }
-            push @newrows, $r;
-        }
-   } 
+            push @newrows, $subtotals;
+         }
+         push @newrows, $r;
+    }
+    push @newrows, $total_row unless $self->manual_totals;
+    $self->rows(\@newrows);
     # Rendering
 
     if (!defined $self->format){

Modified: trunk/css/ledgersmb.css
===================================================================
--- trunk/css/ledgersmb.css	2014-01-21 06:32:56 UTC (rev 6574)
+++ trunk/css/ledgersmb.css	2014-01-21 08:26:09 UTC (rev 6575)
@@ -169,8 +169,8 @@
   text-decoration: none; color: white; font-weight: bold}
 .listrow1, table.dynatable tr:nth-child(odd) { font-size: 10pt; background-color: #e6e6fa; color: black; vertical-align: top; }
 .listrow0, table.dynatable tr:nth-child(even) { font-size: 10pt; background-color: #ffe4e1; color: black; vertical-align: top; }
-.listsubtotal { font-size: 10pt; background-color: #5a7d9b; color: white; }
-.listtotal { font-size: 10pt; background-color: #004d99; color: white; }
+.listsubtotal, table.dynatable tr.sublisttotal { font-size: 10pt; background-color: #5a7d9b; color: white; }
+.listtotal, table.dynatable tr.listtotal { font-size: 10pt; background-color: #004d99; color: white; font-weight: bold}
 
 textarea {
   font-family: Verdana, Arial, Helvetica, sans-serif;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits