[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2455] trunk
- Subject: SF.net SVN: ledger-smb:[2455] trunk
- From: ..hidden..
- Date: Thu, 19 Feb 2009 20:26:57 +0000
Revision: 2455
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2455&view=rev
Author: einhverfr
Date: 2009-02-19 20:26:57 +0000 (Thu, 19 Feb 2009)
Log Message:
-----------
Correcting approval bugs found in another round of testing
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Reconciliation.pm
trunk/UI/reconciliation/approved.html
trunk/scripts/recon.pl
trunk/sql/modules/Reconciliaton.sql
Modified: trunk/LedgerSMB/DBObject/Reconciliation.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-02-19 19:26:51 UTC (rev 2454)
+++ trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-02-19 20:26:57 UTC (rev 2455)
@@ -145,7 +145,7 @@
# the user should be embedded into the $self object.
my $report_id = shift @_;
- my $code = $self->exec_method(funcname=>'report_approve', args=>[$report_id]); # user
+ my $code = $self->exec_method(funcname=>'reconciliation__report_approve', args=>[$report_id]); # user
if ($code == 0) { # no problem.
return $code;
@@ -155,6 +155,7 @@
$self->error("User $self->{user}->{name} cannot approve report, must be a different user.");
}
+ $self->{dbh}->commit;
}
sub new_report {
@@ -225,13 +226,6 @@
return $code[0]->{'correct'};
}
-sub get_report {
-
- my $self = shift @_;
-
- return $self->exec_method(funcname=>'reconciliation__report', args=>[$self->{report_id}]);
-}
-
sub get_corrections {
my $self = shift @_;
Modified: trunk/UI/reconciliation/approved.html
===================================================================
--- trunk/UI/reconciliation/approved.html 2009-02-19 19:26:51 UTC (rev 2454)
+++ trunk/UI/reconciliation/approved.html 2009-02-19 20:26:57 UTC (rev 2455)
@@ -1,28 +1,5 @@
-<div>
- <center>
- Bank statement for <?lsmbaccount?> on <?lsmbdate?> has been approved!
- </center>
-</div>
-
-<table border=0 style="opacity:50%;">
-
- <tr>
- <td>Clear date</td>
- <td>Transaction Type</td>
- <td>Our Balance</td>
- <td>Their Balance</td>
- <td>Error Corrections</td>
- <td>Error Code</td>
- </tr>
-
- <?lsmb FOREACH row = records ?>
- <tr>
- <td><?lsmb row.clear_time ?></td>
- <td><?lsmb row.transaction_type ?> </td>
- <td><?lsmb row.our_balance ?></td>
- <td><?lsmb row.their_balance?></td>
- <td><?lsmb row.corrections ?></td>
- <td><?lsmb row.errorcode ?></td>
- </tr>
- <?lsmb END ?>
-</table>
\ No newline at end of file
+<?lsmb PROCESS 'ui-header.html' ?>
+<?lsmb PROCESS 'elements.html' ?>
+<h1><?lsmb text('Report Approved') ?></h1>
+</body>
+</html>
Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl 2009-02-19 19:26:51 UTC (rev 2454)
+++ trunk/scripts/recon.pl 2009-02-19 20:26:57 UTC (rev 2455)
@@ -119,6 +119,7 @@
@$cols = qw(select account end_date their_total approved submitted);
my $recon =$search;
for my $row(@results){
+
my $act = undef;
for (@acts){
if ($_->{id} == $row->{chart_id}){
@@ -390,19 +391,19 @@
# we need a report_id for this.
- my $recon = LedgerSMB::DBObject::Reconciliation->new(base => request, copy=> 'all');
+ my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request, copy=> 'all');
my $template;
my $code = $recon->approve($request->{report_id});
if ($code == 0) {
$template = LedgerSMB::Template->new( user => $user,
- template => 'reconciliation/approve', language => $user->{language},
+ template => 'reconciliation/approved', language => $user->{language},
format => 'HTML',
path=>"UI"
);
- return $template->render();
+ return $template->render($recon);
}
else {
@@ -415,12 +416,7 @@
format => 'HTML',
path=>"UI"
);
- return $template->render(
- {
- entries=>$recon->get_report($request->{report_id}),
- total=>$recon->get_total($request->{report_id}),
- error_code => $code
- }
+ return $template->render($recon
);
}
}
Modified: trunk/sql/modules/Reconciliaton.sql
===================================================================
--- trunk/sql/modules/Reconciliaton.sql 2009-02-19 19:26:51 UTC (rev 2454)
+++ trunk/sql/modules/Reconciliaton.sql 2009-02-19 20:26:57 UTC (rev 2455)
@@ -73,6 +73,7 @@
completed cr_report_line;
total_errors INT;
in_user TEXT;
+ ac_entries int[];
BEGIN
in_user := current_user;
@@ -84,16 +85,40 @@
-- filed it. This may require clunkier syntax..
--
- insert into cr_report_approval (report_id, approved_by)
- values (in_report_id,
- (select entity_id from users where username = SESSION_USER));
+ ac_entries := '{}';
update cr_report set approved = 't'
where id = in_report_id;
+
+ FOR current_row IN
+ select as_array(ac.entry_id) as entries
+ FROM acc_trans ac
+ JOIN transactions t on (ac.trans_id = t.id)
+ JOIN (select id, entity_credit_account::text as ref, 'ar' as table FROM ar
+ UNION
+ select id, entity_credit_account::text, 'ap' as table FROM ap
+ UNION
+ select id, reference, 'gl' as table FROM gl) gl
+ ON (gl.table = t.table_name AND gl.id = t.id)
+ LEFT JOIN cr_report_line rl ON (rl.report_id = in_report_id
+ AND ((rl.ledger_id = ac.trans_id
+ AND ac.voucher_id IS NULL)
+ OR (rl.voucher_id = ac.voucher_id)))
+ WHERE ac.cleared IS FALSE
+ AND ac.chart_id = (select chart_id from cr_report where id = in_report_id)
+ GROUP BY gl.ref, ac.source, ac.transdate,
+ ac.memo, ac.voucher_id, gl.table
+ HAVING count(rl.report_id) > 0
+ LOOP
+ ac_entries := ac_entries || current_row.entries;
+ END LOOP;
+
+ UPDATE acc_trans SET cleared = TRUE
+ where entry_id = any(ac_entries);
return 1;
END;
-$$ language 'plpgsql';
+$$ language 'plpgsql' security definer;
CREATE OR REPLACE FUNCTION reconciliation__new_report_id (in_chart_id int,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.