[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2462] trunk
- Subject: SF.net SVN: ledger-smb:[2462] trunk
- From: ..hidden..
- Date: Tue, 24 Feb 2009 23:09:32 +0000
Revision: 2462
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2462&view=rev
Author: einhverfr
Date: 2009-02-24 23:09:32 +0000 (Tue, 24 Feb 2009)
Log Message:
-----------
Correcting handling of out-of-sequence year-ends
Adding option to ignore or include year-ends in trial balance.
Modified Paths:
--------------
trunk/LedgerSMB/RP.pm
trunk/UI/rp-search.html
trunk/bin/rp.pl
Modified: trunk/LedgerSMB/RP.pm
===================================================================
--- trunk/LedgerSMB/RP.pm 2009-02-24 19:38:23 UTC (rev 2461)
+++ trunk/LedgerSMB/RP.pm 2009-02-24 23:09:32 UTC (rev 2462)
@@ -119,20 +119,6 @@
}
$sth->finish;
- $query = qq|DELETE FROM gl WHERE id = ?|;
- $sth = $dbh->prepare($query) || $form->dberror($query);
-
- $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
- my $ath = $dbh->prepare($query) || $form->dberror($query);
-
- foreach $id (@trans_id) {
- $sth->execute($id);
- $ath->execute($id);
-
- $sth->finish;
- $ath->finish;
- }
-
my $last_period = 0;
my @categories = qw(I E);
my $category;
@@ -1316,7 +1302,7 @@
sub trial_balance {
my ( $self, $myconfig, $form ) = @_;
-
+ my $year_end = $form->{ignore_yearend};
my $dbh = $form->{dbh};
my $approved = 'FALSE';
@@ -1448,7 +1434,7 @@
}
$sth->finish;
-
+ my $yearend_filter;
if (!$department_id and !$form->{gifi}){
my $datefrom = $dbh->quote($form->{fromdate});
my $dateto = $dbh->quote($form->{todate});
@@ -1459,6 +1445,16 @@
if ($dateto eq "''") {
$dateto = "NULL";
}
+ if ($year_end ne 'none'){
+ if ($year_end eq 'last'){
+ $yearend_filter = "AND (ac.transdate < coalesce($datefrom, ac.transdate) OR
+ ac.trans_id <> (select max(trans_id) FROM yearend WHERE transdate <= coalesce($dateto, 'infinity'::timestamp)))";
+ } elsif ($year_end eq 'all'){
+ $yearend_filter = "AND (y.trans_id is null or ac.transdate < coalesce($datefrom, ac.transdate))";
+ } else {
+ $form->error($locale->text('Invalid Year-end filter request!'));
+ }
+ }
$query = "SELECT c.id AS chart_id, c.accno, c.description, c.contra,
c.category,
SUM(CASE WHEN ac.transdate < $datefrom
@@ -1487,10 +1483,12 @@
select id, approved FROM ar) g
ON (g.id = ac.trans_id)
JOIN chart c ON (c.id = ac.chart_id)
+ LEFT JOIN yearend y ON (ac.trans_id = y.trans_id)
WHERE (ac.transdate <= $dateto OR $dateto IS NULL)
AND ac.approved AND g.approved
AND ($safe_project_id IS NULL
OR $safe_project_id = ac.project_id)
+ $yearend_filter
GROUP BY c.id, c.accno, c.description, c.contra,
c.category
ORDER BY c.accno";
Modified: trunk/UI/rp-search.html
===================================================================
--- trunk/UI/rp-search.html 2009-02-24 19:38:23 UTC (rev 2461)
+++ trunk/UI/rp-search.html 2009-02-24 23:09:32 UTC (rev 2462)
@@ -35,6 +35,16 @@
</td>
</tr>
<?lsmb END ?>
+<?lsmb form.report == 'trial_balance' ?>
+ <tr>
+ <th align="right"><?lsmb text('Ignore Year-ends'); ?></th>
+ <td><?lsmb PROCESS select element_data = {
+ options = form.yearend_options,
+ name = 'ignore_yearend',
+ text_attr = 'label',
+ value_attr = 'id',
+ } ?></td>
+ </tr>
</table>
</td>
</tr>
Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl 2009-02-24 19:38:23 UTC (rev 2461)
+++ trunk/bin/rp.pl 2009-02-24 23:09:32 UTC (rev 2462)
@@ -308,9 +308,9 @@
$form->{login} = 'test';
$hiddens{$_} = $form->{$_} foreach qw(path login sessionid);
$form->{yearend_options} = [
- {'last' => $locale->text('Last Only') },
- {'all' => $locale->text('All') },
- {'none' => $locale->text('None') },
+ {id => 'all', label => $locale->text('All') },
+ {id => 'last', label => $locale->text('Last Only') },
+ {id => 'none', label => $locale->text('None') },
];
##SC: Temporary commenting
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.