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

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



Revision: 6465
          http://sourceforge.net/p/ledger-smb/code/6465
Author:   einhverfr
Date:     2014-01-15 07:59:06 +0000 (Wed, 15 Jan 2014)
Log Message:
-----------
Balance sheet comparisons added, allows up to four reports to be run for comparison purposes, i.e. for quarterly reports.

Modified Paths:
--------------
    trunk/LedgerSMB/Report/Balance_Sheet.pm
    trunk/LedgerSMB/Scripts/reports.pm
    trunk/UI/Reports/balance_sheet.html
    trunk/UI/Reports/filters/balance_sheet.html

Modified: trunk/LedgerSMB/Report/Balance_Sheet.pm
===================================================================
--- trunk/LedgerSMB/Report/Balance_Sheet.pm	2014-01-15 03:48:59 UTC (rev 6464)
+++ trunk/LedgerSMB/Report/Balance_Sheet.pm	2014-01-15 07:59:06 UTC (rev 6465)
@@ -45,7 +45,24 @@
 
 has 'balance_sheet' => (is => 'rw', isa => 'HashRef[Any]', required => 0);
 
+=head2 comparisons
 
+An arrayref of hashrefs, each is:
+
+=over 
+
+=item through_date
+
+=item index
+
+A hashref of hashref in the form of account_number => balance
+
+=back
+
+=cut
+
+has 'comparisons' => (is => 'rw', isa => 'ArrayRef[Any]', required => 0, default => sub { return [] });
+
 =head1 STATIC METHODS
 
 =over
@@ -139,6 +156,41 @@
     $self->rows([]);
 }
 
+=head2 add_comparison($balance_sheet)
+
+Adds a comparison to the current balance sheet.  Among other things it checks 
+the sheet for new account keys and adds them.
+
+=cut
+
+sub add_comparison{
+    my ($self, $comparison) = @_;
+    my $old_sheet = $self->balance_sheet;
+    my $new_sheet = $comparison->balance_sheet;
+    my $comparisons = $self->comparisons;
+    my $idx = {};
+    for my $type (('A', 'L', 'Q')){
+        for my $line (@{$new_sheet->{$type}->{lines}}){
+            $idx->{$line->{account_number}} = $line->{balance};
+            my $found = 0;
+            for my $l2 (@{$old_sheet->{$type}->{lines}}){
+               $found = 1 if $l2->{account_number} eq $line->{account_number};
+            }
+            push @{$old_sheet->{$type}->{lines}}, 
+               {account_number => $line->{account_number},
+                    balance    => '---' } unless $found;
+        }
+    }
+    my $comparison_hash = {     to_date => $comparison->to_date,
+                                  index => $idx,
+                                 totals => {A => $new_sheet->{A}->{total},
+                                            L => $new_sheet->{L}->{total},
+                                            Q => $new_sheet->{Q}->{total},
+                                           LQ => $new_sheet->{total_LQ}, }};
+    push @$comparisons, $comparison_hash;
+    $self->comparisons($comparisons);
+}
+
 =head1 COPYRIGHT
 
 COPYRIGHT (C) 2013 The LedgerSMB Core Team.  This file may be re-used under the

Modified: trunk/LedgerSMB/Scripts/reports.pm
===================================================================
--- trunk/LedgerSMB/Scripts/reports.pm	2014-01-15 03:48:59 UTC (rev 6464)
+++ trunk/LedgerSMB/Scripts/reports.pm	2014-01-15 07:59:06 UTC (rev 6465)
@@ -163,6 +163,14 @@
 sub balance_sheet {
     my ($request) = @_;
     my $report = LedgerSMB::Report::Balance_Sheet->new(%$request);
+    $report->run_report;
+    for my $count (1 .. 3){
+        next unless $request->{"to_date_$count"};
+        $request->{to_date} = $request->{"to_date_$count"};
+        my $comparison = LedgerSMB::Report::Balance_Sheet->new(%$request);
+        $comparison->run_report;
+        $report->add_comparison($comparison);
+    }
     $report->render($request);
 }
 

Modified: trunk/UI/Reports/balance_sheet.html
===================================================================
--- trunk/UI/Reports/balance_sheet.html	2014-01-15 03:48:59 UTC (rev 6464)
+++ trunk/UI/Reports/balance_sheet.html	2014-01-15 07:59:06 UTC (rev 6465)
@@ -1,10 +1,15 @@
 <?lsmb INCLUDE 'ui-header.html' stylesheet=request.stylesheet 
-         include_stylesheet = ['UI/Reports/pnl.css']; ?>
+         include_stylesheet = ['UI/Reports/pnl.css']; 
+ comparisons = report.comparisons ?>
 <body class="financial-statement" id="balance-sheet">
 <h1><?lsmb text('Balance Sheet') ?></h1>
-<h2><?lsmb text('Through date:') _ ' ' _ report.to_date ?></h2>
 <?lsmb # TODO:  header hierarchy handling ?>
 <table>
+<tr class="report-head">
+<th colspan="2"><?lsmb text('Through date:') _ ' ' _ report.to_date ?></th>
+<?lsmb FOREACH c IN comparisons ?>
+<th><?lsmb c.to_date ?></th>
+<?lsmb END; ?>
 <tr class="section-head">
    <th colspan="2"><?lsmb text('Assets') ?></th>
 </tr>
@@ -13,10 +18,16 @@
        ?>&accno=<?lsmb line.account_number ?>"
        ><?lsmb line.account_number _ ' - ' _ line.account_desc ?></a></th>
     <td class="amount"><?lsmb line.balance ?> </td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.index.${line.account_number} ?></td>
+    <?lsmb END; ?>
 </tr>
 <?lsmb END ?>
 <tr class="total"><th><?lsmb text('Total Assets') ?></th>
     <td class="amount"><?lsmb report.balance_sheet.A.total ?></td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.totals.A ?></td>
+    <?lsmb END; ?>
 </tr>
 <tr class="section-head">
    <th colspan="2"><?lsmb text('Liabilities') ?></th>
@@ -26,10 +37,16 @@
        ?>&accno=<?lsmb line.account_number ?>"
        ><?lsmb line.account_number _ ' - ' _ line.account_desc ?></a></th>
     <td class="amount"><?lsmb line.balance ?> </td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.index.${line.account_number} ?></td>
+    <?lsmb END; ?>
 </tr>
 <?lsmb END ?>
 <tr class="total"><th><?lsmb text('Total Liabilities') ?></th>
     <td class="amount"><?lsmb report.balance_sheet.L.total ?></td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.totals.L ?></td>
+    <?lsmb END ?>
 </tr>
 <tr class="section-head">
    <th colspan="2"><?lsmb text('Equity') ?></th>
@@ -39,17 +56,27 @@
        ?>&accno=<?lsmb account_number ?>"
        ><?lsmb IF line.account_number; line.account_number _ ' - '; END; line.account_desc ?></a></th>
     <td class="amount"><?lsmb line.balance ?> </td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.index.${line.account_number} ?></td>
+    <?lsmb END; ?>
 </tr>
 <?lsmb END ?>
 <tr class="total"><th><?lsmb text('Total Equity') ?></th>
     <td class="amount"><?lsmb report.balance_sheet.Q.total ?></td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.totals.Q ?></td>
+    <?lsmb END ?>
 </tr>
 <tr class="total"><th><?lsmb text('Total Liabilities Plus Equity') ?></th>
     <td class="amount"><?lsmb report.balance_sheet.total_LQ ?></td>
+    <?lsmb FOREACH c IN comparisons ?>
+    <td class="amount"><?lsmb c.totals.LQ ?></td>
+    <?lsmb END ?>
 </tr>
 </table>
 
-<h2>Key Ratios</h2>
+<h2><?lsmb text('Key Ratios'); ?></h2>
+<h2><?lsmb text('First column only') ?></h2>
 <table>
 <tr><th><?lsmb text('Assets to Liabilities') ?></th>
     <td><?lsmb report.balance_sheet.ratios.AL ?></td>

Modified: trunk/UI/Reports/filters/balance_sheet.html
===================================================================
--- trunk/UI/Reports/filters/balance_sheet.html	2014-01-15 03:48:59 UTC (rev 6464)
+++ trunk/UI/Reports/filters/balance_sheet.html	2014-01-15 07:59:06 UTC (rev 6465)
@@ -3,6 +3,7 @@
 <body class="<?lsmb dojo_theme ?>">
 <div class="listtop"><?lsmb text('Balance Sheet') ?></div>
 <form action="reports.pl" method="get">
+<div class="inputrow">
 <?lsmb 
 PROCESS input element_data = {
            label = text('Through date') #'
@@ -10,7 +11,21 @@
            value = to_date
            class = 'date'
             size = 12
-}; 
+};
+?></div>
+<div class="subsection"><h3><?lsmb text('Enter up to 3 comparison dates') ?></h3></div>
+<?lsmb FOR ct IN [1, 2, 3]; ?>
+<div class="inputrow"><?lsmb 
+PROCESS input element_data = {
+           label = text('Through date') #'
+            name = 'to_date_' _ ct
+           value = to_date
+           class = 'date'
+            size = 12
+};
+?></div>
+<?lsmb
+END;
 PROCESS button element_data = {
             text = text('Generate')
             name = 'action'

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