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

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



Revision: 6468
          http://sourceforge.net/p/ledger-smb/code/6468
Author:   einhverfr
Date:     2014-01-15 09:01:53 +0000 (Wed, 15 Jan 2014)
Log Message:
-----------
can now enter up to 3 comparison income statements.  This can be used for quarterly income statements or the like

Modified Paths:
--------------
    trunk/LedgerSMB/Report/PNL.pm
    trunk/LedgerSMB/Scripts/pnl.pm
    trunk/UI/Reports/PNL.html
    trunk/UI/Reports/filters/income_statement.html
    trunk/UI/lib/report_base.html

Modified: trunk/LedgerSMB/Report/PNL.pm
===================================================================
--- trunk/LedgerSMB/Report/PNL.pm	2014-01-15 08:47:59 UTC (rev 6467)
+++ trunk/LedgerSMB/Report/PNL.pm	2014-01-15 09:01:53 UTC (rev 6468)
@@ -152,21 +152,21 @@
 =cut
 
 sub add_comparison {
-    my ($self, $label, $from, $to) = @_;
-    my %attributes = %{ $self->meta->get_attribute_map };
-    my %new_data;
-    while (my ($name, $attribute) = each %attributes) { 
-        my $reader = $attribute->get_read_method;
-        $new_data{$name} = $self->$reader;
-    }
-    $new_data{from_date} = $from;
-    $new_data{to_date} = $to;
-    my $new_report = $self->new(%new_data);
-    my @rows = $new_report->run_report;
+    my ($self, $new_pnl) = @_;
     my $comparisons = $self->comparisons;
     $comparisons ||= [];
-    push @$comparisons, {label => $label, from_date => $from, to_date => $to}; 
-    $self->_merge_rows($label, @rows);
+    my $old_ad = $self->account_data;
+    my $new_ad = $new_pnl->account_data;
+    for my $cat (qw(I E)){
+       for my $k (keys %{$new_ad->{$cat}}){
+           $old_ad->{$cat}->{$k} ||= 0;
+       }
+    }
+    push @$comparisons, {from_date => $new_pnl->from_date, 
+                           to_date => $new_pnl->to_date,
+                      account_data => $new_pnl->account_data,
+                         }; 
+    $self->comparisons($comparisons);
 }
 
 =back

Modified: trunk/LedgerSMB/Scripts/pnl.pm
===================================================================
--- trunk/LedgerSMB/Scripts/pnl.pm	2014-01-15 08:47:59 UTC (rev 6467)
+++ trunk/LedgerSMB/Scripts/pnl.pm	2014-01-15 09:01:53 UTC (rev 6468)
@@ -35,6 +35,7 @@
 
 sub generate_income_statement {
     my ($request) = @_;
+    $ENV{LSMB_ALWAYS_MONEY} = 1;
     my $rpt;
     if ($request->{pnl_type} eq 'invoice'){
         $rpt = LedgerSMB::Report::PNL::Invoice->new(%$request);
@@ -44,7 +45,22 @@
         $rpt = LedgerSMB::Report::PNL::Product->new(%$request);
     } else {
         $rpt =LedgerSMB::Report::PNL::Income_Statement->new(%$request);
+        $rpt->run_report;
+        for my $c_per (1 .. 3) {
+            my $found = 0;
+            for (qw(from_month from_year from_date to_date interval)){
+                $request->{$_} = $request->{"${_}_$c_per"};
+                delete $request->{$_} unless defined $request->{$_};
+                $found = 1 if defined $request->{$_} and $_ ne 'interval';
+            }
+            next unless $found;
+            my $comparison = LedgerSMB::Report::PNL::Income_Statement->new(%$request);
+            $comparison->run_report;
+            $rpt->add_comparison($comparison);
+        }
     }
+    #use Data::Dumper;
+    #die '<pre>' . Dumper($rpt);
     $rpt->render($request);
 }
 

Modified: trunk/UI/Reports/PNL.html
===================================================================
--- trunk/UI/Reports/PNL.html	2014-01-15 08:47:59 UTC (rev 6467)
+++ trunk/UI/Reports/PNL.html	2014-01-15 09:01:53 UTC (rev 6468)
@@ -5,6 +5,7 @@
 <h1><?lsmb name ?></h1>
 <h2><?lsmb text('Accounting period: [_1] to [_2]', report.from_date, report.to_date); ?></h2>
 <?lsmb 
+comparisons = report.comparisons;
 IF comparisons;
     FOREACH COMP IN comparisons ?>
 <h2><?lsmb text('Compared to: [_1] to [_2]', COMP.from_date, COMP.to_date) ?>
@@ -16,7 +17,7 @@
     <tr class="sectionhead">
         <th><?lsmb text('Income Account') ?></th>
         <th><?lsmb report.from_date _ '<br /> - <br />' _ report.to_date ?></th>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <th><?lsmb COMP.from_date _ '<br /> - <br />' _ COMP.to_date ?></th>
     <?lsmb END ?>
     </tr>
@@ -33,21 +34,21 @@
                                     ?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
         ><?lsmb account_data.I.${k}.main.amount ?></a></td>
        
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount"><a href="journal.pl?sort=transdate&accno=<?lsmb k 
                                    ?>&from_date=<?lsmb COMP.from_date 
                                    ?>&to_date=<?lsmb COMP.to_date
                                    ?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
-           ><?lsmb account_data.I.${k}.${COMP.label}.amount ?></a></td>
+           ><?lsmb COMP.account_data.I.${k}.info.amount ?></a></td>
     <?lsmb END ?>
     </tr>
  <?lsmb END ?>
    <tr class="sectionfoot">
      <th><?lsmb text('Total Income') ?></th>
      <td class="amount total"><?lsmb account_data.totals.main.I ?></td>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount total">
-            <?lsmb account_data.totals.${COMP.label}.I ?></td>
+            <?lsmb COMP.account_data.totals.main.I ?></td>
     <?lsmb END ?>
    </tr>
    <tr class="separator"><td colspan="<?lsmb COLS ?>"></td></tr>
@@ -70,46 +71,45 @@
                                     ?>&to_date=<?lsmb report.to_date 
                                     ?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
         ><?lsmb account_data.E.${k}.main.amount ?></a></td>
-    <?lsmb FOREACH COMP IN comparison ?>
-        <td class="amount">
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount"><a href="journal.pl?sort=transdate&accno=<?lsmb k 
                                    ?>&from_date=<?lsmb COMP.from_date 
                                    ?>&to_date=<?lsmb COMP.to_date
                                    ?>&category=X&col_transdate=Y&col_reference=Y&col_description=Y&col_debits=Y&col_credits=Y&col_source=Y&col_accno=Y&action=search"
-	><?lsmb account_data.E.${k}.${COMP.label}.amount ?></a></td>
+	><?lsmb COMP.account_data.E.${k}.info.amount ?></a></td>
     <?lsmb END ?>
     </tr>
  <?lsmb END ?>
    <tr class="sectionfoot">
      <th><?lsmb text('Total Expense') ?></th>
      <td class="amount total"><?lsmb account_data.totals.main.E ?></td>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount total">
-            <?lsmb account_data.totals.${COMP.label}.E ?></td>
+            <?lsmb COMP.account_data.totals.main.E ?></td>
     <?lsmb END ?></tr>
    <tr class="separator"><td colspan="<?lsmb COLS ?>">&nbsp;</td></tr>
    <tr class="sectionfoot">
      <th><?lsmb text('Total Income') ?></th>
      <td class="amount"><?lsmb account_data.totals.main.I ?></td>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount">
-            <?lsmb account_data.totals.${COMP.label}.I ?></td>
+            <?lsmb COMP.account_data.totals.main.I ?></td>
     <?lsmb END ?>
    </tr>
    <tr class="reportfoot">
      <th><?lsmb text('Less Total Expense') ?></th>
      <td class="amount"><?lsmb account_data.totals.main.E ?></td>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount">
-            <?lsmb account_data.totals.${COMP.label}.E ?></td>
+            <?lsmb COMP.account_data.totals.main.E ?></td>
     <?lsmb END ?>
    </tr>
    <tr class="reportfoot">
      <th> = <?lsmb text('Net Income (Loss)') ?></th>
      <td class="amount total"><?lsmb account_data.totals.main.total ?></td>
-    <?lsmb FOREACH COMP IN comparison ?>
+    <?lsmb FOREACH COMP IN comparisons ?>
         <td class="amount total">
-            <?lsmb account_data.totals.${COMP.label}.total ?></td>
+            <?lsmb COMP.account_data.totals.main.total ?></td>
     <?lsmb END ?>
    </tr>
 </tbody>

Modified: trunk/UI/Reports/filters/income_statement.html
===================================================================
--- trunk/UI/Reports/filters/income_statement.html	2014-01-15 08:47:59 UTC (rev 6467)
+++ trunk/UI/Reports/filters/income_statement.html	2014-01-15 09:01:53 UTC (rev 6468)
@@ -11,15 +11,6 @@
 <table width="100%">
   <tr><th class="listtop"><?lsmb text('Income Statement') ?></th></tr>
   <tr><td> </td></tr>
-  <tr>
-    <td>
-      <table>
-       <?lsmb PROCESS business_classes;
-       PROCESS date_row; # TODO add comparisons ?>
-       </tr>
-    </table>
-  </td>
-</tr>
 <tr>
   <td>
     <table>
@@ -68,6 +59,20 @@
       </table>
     </td>
   </tr>
+  <tr>
+    <td>
+      <table>
+       <?lsmb PROCESS business_classes;
+       PROCESS date_row; # TODO add comparisons ?>
+       <tr>
+       <th colspan="7"><?lsmb text('Enter up to 3 date ranges for comparison') ?></th>
+       </tr>
+       <?lsmb FOREACH c IN [1, 2, 3];
+              PROCESS date_row SUFFIX='_' _ c; 
+              END ?>
+    </table>
+  </td>
+</tr>
   <tr><td><hr size="3" noshade="noshade" /></td></tr>
 </table>
 <?lsmb PROCESS button element_data = {

Modified: trunk/UI/lib/report_base.html
===================================================================
--- trunk/UI/lib/report_base.html	2014-01-15 08:47:59 UTC (rev 6467)
+++ trunk/UI/lib/report_base.html	2014-01-15 09:01:53 UTC (rev 6468)
@@ -90,13 +90,13 @@
 	  <th align="right"><?lsmb text('From') ?></th>
 	  <td><?lsmb PROCESS input element_data = {
                class="date" 
-               name="from_date" 
+               name="from_date" _ SUFFIX 
                size="11" 
                title=datestyle } ?></td>
 	  <th align="right"><?lsmb text('To') ?></th>
 	  <td><?lsmb PROCESS input element_data = {
                  class="date" 
-                 name="to_date" 
+                 name="to_date" _ SUFFIX 
                  size="11" 
                  title=datestyle } ?></td>
 	</tr>
@@ -109,34 +109,34 @@
         all_months.unshift({});
         all_years.unshift({}); 
         PROCESS select element_data = {
-               name = "from_month"
+               name = "from_month" _ SUFFIX
                options = all_months
         } ?>
 
 	<?lsmb PROCESS select element_data = {
-               name="from_year"
+               name="from_year" _ SUFFIX
                options = all_years
                text_attr = "date_get_all_years"
                value_attr = "date_get_all_years"
         } ?>
 	<?lsmb PROCESS input element_data = {
-               name="interval"
+               name="interval" _ SUFFIX
                class="radio"
                type="radio"
                value="none" 
                checked="checked" } ?>&nbsp;<?lsmb text('Current') ?>
 	<?lsmb PROCESS input element_data = { 
-               name="interval" 
+               name="interval"  _ SUFFIX
                class="radio" 
                type="radio" 
                value="month" } ?>&nbsp;<?lsmb text('Month') ?>
 	<?lsmb PROCESS input element_data = {
-               name="interval"
+               name="interval" _ SUFFIX
                class="radio"
                type="radio"
                value="quarter" } ?>&nbsp;<?lsmb text('Quarter') ?>
         <?lsmb PROCESS input element_data = {
-               name="interval"
+               name="interval" _ SUFFIX
                class="radio"
                type="radio"
                value="year" } ?>&nbsp;<?lsmb text('Year') ?>

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