summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/RP.pm26
-rw-r--r--bin/rp.pl62
-rw-r--r--templates/demo/income_statement.html46
3 files changed, 80 insertions, 54 deletions
diff --git a/LedgerSMB/RP.pm b/LedgerSMB/RP.pm
index c46ee788..4854355e 100644
--- a/LedgerSMB/RP.pm
+++ b/LedgerSMB/RP.pm
@@ -251,13 +251,16 @@ sub income_statement {
# push description onto array
- $str = ( $form->{l_heading} ) ? $form->{padding} : "";
+## $str = ( $form->{l_heading} ) ? $form->{padding} : "";
+ $str = "";
if ( $form->{$category}{$key}{charttype} eq "A" ) {
$str .=
( $form->{l_accno} )
? "$form->{$category}{$key}{accno} - $form->{$category}{$key}{description}"
: "$form->{$category}{$key}{description}";
+ $str = {account => $form->{$category}{$key}{accno}, text => $str };
+ $str->{gifi_account} = 1 if $form->{accounttype} eq 'gifi';
}
if ( $form->{$category}{$key}{charttype} eq "H" ) {
if ( $account{$category}{subtotal}
@@ -266,8 +269,10 @@ sub income_statement {
$dash = "- ";
push(
- @{ $form->{"$account{$category}{label}_account"} },
-"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}"
+ @{ $form->{"$account{$category}{label}_account"} }, {
+ text => "$account{$category}{subdescription}",
+ subtotal => 1,
+ },
);
push(
@@ -304,8 +309,10 @@ sub income_statement {
}
- $str =
-"$form->{br}$form->{bold}$form->{$category}{$key}{description}$form->{endbold}";
+ $str = {
+ text => "$form->{$category}{$key}{description}",
+ heading => 1,
+ };
$account{$category}{subthis} = $form->{$category}{$key}{this};
$account{$category}{sublast} = $form->{$category}{$key}{last};
@@ -357,11 +364,14 @@ sub income_statement {
}
}
- $str = ( $form->{l_heading} ) ? $form->{padding} : "";
+## $str = ( $form->{l_heading} ) ? $form->{padding} : "";
+ $str = "";
if ( $account{$category}{subtotal} && $form->{l_subtotal} ) {
push(
- @{ $form->{"$account{$category}{label}_account"} },
-"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}"
+ @{ $form->{"$account{$category}{label}_account"} }, {
+ text => "$account{$category}{subdescription}",
+ subtotal => 1,
+ },
);
push(
@{ $form->{"$account{$category}{labels}_this_period"} },
diff --git a/bin/rp.pl b/bin/rp.pl
index b76c610f..1a598387 100644
--- a/bin/rp.pl
+++ b/bin/rp.pl
@@ -49,6 +49,7 @@ use LedgerSMB::Template;
use LedgerSMB::PE;
use LedgerSMB::RP;
+#$form->{login} = 'test';
1;
# end of main
@@ -1019,11 +1020,6 @@ qq|rp.pl?path=$form->{path}&action=continue&accounttype=$form->{accounttype}&log
sub generate_income_statement {
- $form->{padding} = "  ";
- $form->{bold} = "<b>";
- $form->{endbold} = "</b>";
- $form->{br} = "<br>";
-
RP->income_statement( \%myconfig, \%$form );
( $form->{department} ) = split /--/, $form->{department};
@@ -1034,25 +1030,20 @@ sub generate_income_statement {
$form->{todate} = $form->current_date( \%myconfig ) unless $form->{todate};
# if there are any dates construct a where
- if ( $form->{fromdate} || $form->{todate} ) {
+ unless ( $form->{todate} ) {
+ $form->{todate} = $form->current_date( \%myconfig );
+ }
- unless ( $form->{todate} ) {
- $form->{todate} = $form->current_date( \%myconfig );
- }
+ $longtodate = $locale->date( \%myconfig, $form->{todate}, 1 );
+ $shorttodate = $locale->date( \%myconfig, $form->{todate}, 0 );
- $longtodate = $locale->date( \%myconfig, $form->{todate}, 1 );
- $shorttodate = $locale->date( \%myconfig, $form->{todate}, 0 );
+ $longfromdate = $locale->date( \%myconfig, $form->{fromdate}, 1 );
+ $shortfromdate = $locale->date( \%myconfig, $form->{fromdate}, 0 );
- $longfromdate = $locale->date( \%myconfig, $form->{fromdate}, 1 );
- $shortfromdate = $locale->date( \%myconfig, $form->{fromdate}, 0 );
-
- $form->{this_period} = "$shortfromdate<br>\n$shorttodate";
- $form->{period} =
- $locale->text('for Period')
- . qq|<br>\n$longfromdate |
- . $locale->text('To')
- . qq| $longtodate|;
- }
+ $form->{this_period_from} = $shortfromdate;
+ $form->{this_period_to} = $shorttodate;
+ # example output: 2006-01-01 To 2007-01-01
+ $form->{period} = $locale->text('[_1] To [_2]', $longfromdate, $longtodate);
if ( $form->{comparefromdate} || $form->{comparetodate} ) {
$longcomparefromdate =
@@ -1065,24 +1056,27 @@ sub generate_income_statement {
$shortcomparetodate =
$locale->date( \%myconfig, $form->{comparetodate}, 0 );
- $form->{last_period} = "$shortcomparefromdate<br>\n$shortcomparetodate";
- $form->{period} .=
- "<br>\n$longcomparefromdate "
- . $locale->text('To')
- . qq| $longcomparetodate|;
+ $form->{last_period_from} = $shortcomparefromdate;
+ $form->{last_period_to} = $shortcomparetodate;
+ $form->{compare_period} = $locale->text('[_1] To [_2]',
+ $longcomparefromdate, $longcomparetodate);
}
# setup variables for the form
- @a = qw(company address businessnumber);
- for (@a) { $form->{$_} = $myconfig{$_} }
+ my @vars = qw(company address businessnumber);
+ for (@vars) { $form->{$_} = $myconfig{$_} }
+ ##SC: START HTML
$form->{address} =~ s/\\n/<br>/g;
+ ##SC: END HTML
- $form->{templates} = $myconfig{templates};
-
- $form->{IN} = "income_statement.html";
- my $template = LedgerSMB::Template->new( user => \%myconfig,
- template => $form->{'formname'}, format => uc $form->{format} );
+ my $template = LedgerSMB::Template->new(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'income_statement',
+ format => 'HTML',
+ #no_escape => '1'
+ );
try {
$template->render($form);
$template->output(%{$form});
@@ -1096,7 +1090,6 @@ sub generate_income_statement {
sub generate_balance_sheet {
- ##SC: START HTML
RP->balance_sheet( \%myconfig, \%$form );
$form->{asofdate} = $form->current_date( \%myconfig )
@@ -1122,6 +1115,7 @@ sub generate_balance_sheet {
for (qw(company address businessnumber nativecurr login)) {
$form->{$_} = $myconfig{$_};
}
+ ##SC: START HTML
$form->{address} =~ s/\\n/<br>/g;
##SC: END HTML
diff --git a/templates/demo/income_statement.html b/templates/demo/income_statement.html
index 970769a7..03043ae6 100644
--- a/templates/demo/income_statement.html
+++ b/templates/demo/income_statement.html
@@ -35,36 +35,58 @@
</style>
</head>
+<?lsmb USE dumper(indent=0, pad="<br />") ?>
+<?lsmb BLOCK account; # Handle account labels
+ RETURN UNLESS account_data.defined;
+ IF account_data.heading; ?><br /><b><?lsmb
+ account_data.text; ?></b><?lsmb
+ ELSIF account_data.gifi_account; ?><a href="gl.pl?action=generate_report&amp;path=<?lsmb path ?>&amp;login=<?lsmb login ?>&amp;sessionid=<?lsmb sessionid ?>&amp;l_transdate=Y&amp;l_reference=Y&amp;l_description=Y&amp;l_source=Y&amp;l_debit=Y&amp;l_credit=Y&amp;l_gifi_accno=Y&amp;category=X&amp;gifi_accno=<?lsmb account_data.account ?>"><?lsmb
+ account_data.text; ?></a><?lsmb
+ ELSIF account_data.account; ?><a href="gl.pl?action=generate_report&amp;path=<?lsmb path ?>&amp;login=<?lsmb login ?>&amp;sessionid=<?lsmb sessionid ?>&amp;l_transdate=Y&amp;l_reference=Y&amp;l_description=Y&amp;l_source=Y&amp;l_debit=Y&amp;l_credit=Y&amp;l_accno=Y&amp;category=X&amp;accno=<?lsmb account_data.account ?>"><?lsmb
+ account_data.text; ?></a><?lsmb
+ ELSIF account_data.subtotal; ?><b>&nbsp;&nbsp;<?lsmb
+ account_data.text; ?></b><?lsmb
+ ELSIF account_data.current_earnings; IF l_heading ?>&nbsp;&nbsp;<?lsmb END;
+ account_data.text;
+ ELSE;
+ account_data;
+ END;
+END ?>
+
<body>
<h2 align="center">
<?lsmb company ?>
<br /><?lsmb address ?>
-<br />INCOME STATEMENT
+<br /><?lsmb text('Income Statement') ?>
+<br /><?lsmb text('for Period') ?>
<br /><?lsmb period ?>
+<?lsmb IF compare_period ?>
+<br /><?lsmb compare_period ?>
+<?lsmb END ?>
</h2>
<?lsmb IF department ?>
-<h4>Department: <?lsmb department ?></h4>
+<h4><?lsmb text('Department: [_1]', department) ?></h4>
<?lsmb END ?>
<?lsmb IF projectnumber ?>
-<h4>Project Number: <?lsmb projectnumber ?></h4>
+<h4><?lsmb text('Project Number: [_1]', projectnumber) ?></h4>
<?lsmb END ?>
<table width="100%" border="0">
<tr>
- <th width="400" align="left" colspan="2">INCOME<br /><hr width="300" size="5" align="left" noshade="noshade" /></th>
- <th><?lsmb this_period ?></th>
- <th><?lsmb last_period ?></th>
+ <th width="400" align="left" colspan="2" style="text-transform: uppercase"><?lsmb text('Income') ?><br /><hr width="300" size="5" align="left" noshade="noshade" /></th>
+ <th><?lsmb this_period_from ?><br /><?lsmb this_period_to ?></th>
+ <th><?lsmb last_period_from ?><br /><?lsmb last_period_to ?></th>
</tr>
<?lsmb FOREACH income_account ?>
<?lsmb loop_count = loop.count - 1 ?>
<tr>
<td width="4"> </td>
- <td><?lsmb income_account.${loop_count} ?></td>
+ <td><?lsmb PROCESS account account_data=income_account.${loop_count} ?></td>
<td align="right"><?lsmb income_this_period.${loop_count} ?></td>
<td align="right"><?lsmb income_last_period.${loop_count} ?></td>
</tr>
@@ -78,20 +100,20 @@
<tr valign="top">
<td> </td>
- <th align="left">TOTAL INCOME</th>
+ <th align="left" style="text-transform: uppercase"><?lsmb text('Total Income') ?></th>
<td align="right"><?lsmb total_income_this_period ?><hr noshade="noshade" size="2" /></td>
<td align="right"><?lsmb total_income_last_period ?><hr noshade="noshade" size="2" /></td>
</tr>
<tr>
- <th align="left" colspan="2">EXPENSES<br /><hr width="300" size="5" align="left" noshade="noshade" /></th>
+ <th align="left" colspan="2" style="text-transform: uppercase"><?lsmb text('Expenses') ?><br /><hr width="300" size="5" align="left" noshade="noshade" /></th>
</tr>
<?lsmb FOREACH expense_account ?>
<?lsmb loop_count = loop.count - 1 ?>
<tr>
<td> </td>
- <td><?lsmb expense_account.${loop_count} ?></td>
+ <td><?lsmb PROCESS account account_data=expense_account.${loop_count} ?></td>
<td align="right"><?lsmb expenses_this_period.${loop_count} ?></td>
<td align="right"><?lsmb expenses_last_period.${loop_count} ?></td>
</tr>
@@ -105,13 +127,13 @@
<tr valign="top">
<td> </td>
- <th align="left">TOTAL EXPENSES</th>
+ <th align="left" style="text-transform: uppercase"><?lsmb text('Total Expenses') ?></th>
<td align="right"><?lsmb total_expenses_this_period ?><br /><hr noshade="noshade" size="2" /></td>
<td align="right"><?lsmb total_expenses_last_period ?><br /><hr noshade="noshade" size="2" /></td>
</tr>
<tr valign="top">
- <th align="left" colspan="2">INCOME / (LOSS)</th>
+ <th align="left" colspan="2" style="text-transform: uppercase"><?lsmb text('Income / (Loss)') ?></th>
<td align="right"><?lsmb total_this_period ?><br /><hr noshade="noshade" size="2" /></td>
<td align="right"><?lsmb total_last_period ?><br /><hr noshade="noshade" size="2" /></td>
</tr>