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

SF.net SVN: ledger-smb:[5852] trunk/LedgerSMB/Report/Balance_Sheet.pm



Revision: 5852
          http://sourceforge.net/p/ledger-smb/code/5852
Author:   einhverfr
Date:     2013-05-21 13:39:39 +0000 (Tue, 21 May 2013)
Log Message:
-----------
Balance sheet perl module, not fully tested but it does parse withotu errors

Modified Paths:
--------------
    trunk/LedgerSMB/Report/Balance_Sheet.pm

Modified: trunk/LedgerSMB/Report/Balance_Sheet.pm
===================================================================
--- trunk/LedgerSMB/Report/Balance_Sheet.pm	2013-05-21 12:15:14 UTC (rev 5851)
+++ trunk/LedgerSMB/Report/Balance_Sheet.pm	2013-05-21 13:39:39 UTC (rev 5852)
@@ -37,6 +37,15 @@
 
 has 'headings' => (is => 'rw', isa => 'HashRef[Any]', required => 0);
 
+=head2 balance_sheet
+
+This is the hashref that holds the main balance sheet data structure
+
+=cut
+
+has 'balance_sheet' => (is => 'rw', isa => 'HashRef[Any]', required => 0);
+
+
 =head1 STATIC METHODS
 
 =over
@@ -61,6 +70,8 @@
     return [];
 }
 
+
+
 =item name
 
 Returns the localized string 'Balance Sheet'
@@ -87,6 +98,42 @@
 
 =head2 run_report()
 
+This sets rows to an empty hashref, and sets balance_sheet to the structure of 
+the balance sheet. 
+
+=cut
+
+sub run_report {
+    my ($self) = @_;
+    my @headings = $self->exec_method({funcname => 'account__all_headings'});
+    my $head = {};
+    $head->{$_->{accno}} = $_ for (@headings);
+    my @lines = $self->exec_method({funcname => 'report__balance_sheet'});
+   
+    my $sheet = {A => { # Assets
+                       lines => [], 
+                       total => 0, },
+                 L => { # Liabilities 
+                       lines => [], 
+                       total => 0, },
+                 Q => { # Equity 
+                       lines => [], 
+                       total => 0, },
+                 ratios => {},
+    };
+    for my $ref(@lines){
+        my $cat = $ref->{account_category};
+        push @{$sheet->{$cat}->{lines}},  $ref;
+        $sheet->{$cat}->{total} += $ref->{balance}; 
+    }
+    $sheet->{ratios}->{AL} = $sheet->{A}->{total} / $sheet->{L}->{total};
+    $sheet->{ratios}->{AQ} = $sheet->{A}->{total} / $sheet->{Q}->{total};
+    $sheet->{ratios}->{QL} = $sheet->{Q}->{total} / $sheet->{L}->{total};
+    $self->headings($head);
+    $self->balance_sheet($sheet);
+    $self->rows([]);
+}
+
 =head1 COPYRIGHT
 
 COPYRIGHT (C) 2013 The LedgerSMB Core Team.  This file may be re-used under the

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