[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2522] trunk
- Subject: SF.net SVN: ledger-smb:[2522] trunk
- From: ..hidden..
- Date: Mon, 23 Mar 2009 17:11:06 +0000
Revision: 2522
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2522&view=rev
Author: einhverfr
Date: 2009-03-23 17:11:06 +0000 (Mon, 23 Mar 2009)
Log Message:
-----------
Some refactoring/bug fixes to handling of import files from the bank
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Reconciliation.pm
trunk/LedgerSMB/Reconciliation/CSV.pm
trunk/scripts/recon.pl
trunk/sql/modules/Reconciliaton.sql
Modified: trunk/LedgerSMB/DBObject/Reconciliation.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-03-22 00:15:15 UTC (rev 2521)
+++ trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-03-23 17:11:06 UTC (rev 2522)
@@ -133,9 +133,9 @@
my $self = shift @_;
my $csv = LedgerSMB::Reconciliation::CSV->new(base=>$self);
- $csv->process($self, 'csv_file');
+ $self->{import_entries} = $csv->process($self, 'csv_file');
- return $self->{entries};
+ return $self->{import_entries};
}
sub approve {
@@ -162,7 +162,6 @@
my $self = shift @_;
my $total = shift @_;
my $month = shift @_;
- my $entries = shift @_; # expects an arrayref.
# Total is in here somewhere, too
@@ -174,7 +173,6 @@
# Now that we have this, we need to create the internal report representation.
# Ideally, we OUGHT to not return anything here, save the report number.
- $self->add_entries($entries);
$self->{dbh}->commit;
@@ -183,7 +181,7 @@
sub add_entries {
my $self = shift;
- my ($entries) = @_;
+ my $entries = $self->{import_entries};
for my $entry ( @{$entries} ) {
# Codes:
@@ -199,7 +197,7 @@
$code = $self->exec_method(
funcname=>'reconciliation__add_entry',
args=>[
- $report_id,
+ $self->{report_id},
$entry->{scn},
$self->{user},
$entry->{cleared_date},
@@ -208,6 +206,7 @@
);
$entry{report_id} = $report_id;
}
+ $self->{dbh}->commit;
}
sub correct_entry {
Modified: trunk/LedgerSMB/Reconciliation/CSV.pm
===================================================================
--- trunk/LedgerSMB/Reconciliation/CSV.pm 2009-03-22 00:15:15 UTC (rev 2521)
+++ trunk/LedgerSMB/Reconciliation/CSV.pm 2009-03-23 17:11:06 UTC (rev 2522)
@@ -33,13 +33,14 @@
my $func = "parse_" . $recon->{chart_id};
if ($self->can($func)){
@entries = $self->can($func)->($self,$contents);
- @{$self->{recon_entries}} = @entries;
+ @{$self->{entries}} = @entries;
+
$self->{file_upload} = 1;
}
else {
$self->{file_upload} = 0;
}
- return $self->{file_upload};
+ return $self->{entries};
}
sub is_error {
Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl 2009-03-22 00:15:15 UTC (rev 2521)
+++ trunk/scripts/recon.pl 2009-03-23 17:11:06 UTC (rev 2522)
@@ -337,8 +337,9 @@
sub _display_report {
my $recon = shift;
$recon->get();
- $recon->add_entries($recon->import_file()) if !$recon->{submitted};
+ $recon->add_entries($recon->import_file('csv_file')) if !$recon->{submitted};
$recon->{can_approve} = $recon->is_allowed_role({allowed_roles => ['recon_supervisor']});
+ $recon->get();
$template = LedgerSMB::Template->new(
user=> $user,
template => 'reconciliation/report',
Modified: trunk/sql/modules/Reconciliaton.sql
===================================================================
--- trunk/sql/modules/Reconciliaton.sql 2009-03-22 00:15:15 UTC (rev 2521)
+++ trunk/sql/modules/Reconciliaton.sql 2009-03-23 17:11:06 UTC (rev 2522)
@@ -165,7 +165,9 @@
lid INT;
in_count int;
t_scn TEXT;
+ t_uid int;
BEGIN
+ t_uid := person__get_my_entity_id();
IF in_scn = '' THEN
t_scn := NULL;
ELSE
@@ -178,9 +180,9 @@
IF in_count = 0 THEN
INSERT INTO cr_report_line
- (report_id, scn, their_balance, our_balance, clear_time)
+ (report_id, scn, their_balance, our_balance, clear_time, "user")
VALUES
- (in_report_id, t_scn, in_amount, 0, in_date);
+ (in_report_id, t_scn, in_amount, 0, in_date, t_uid);
ELSIF in_count = 1 THEN
UPDATE cr_report_line
SET their_balance = in_amount, clear_time = in_date
@@ -222,23 +224,24 @@
END IF;
ELSE -- scn IS NULL, check on amount instead
SELECT count(*) INTO in_count FROM cr_report_line
- WHERE report_id = in_report_id AND amount = in_amount
- AND their_balance = 0 and posted_date = in_date;
+ WHERE report_id = in_report_id AND our_balance = in_amount
+ AND their_balance = 0 and post_date = in_date;
IF in_count = 0 THEN -- no match
INSERT INTO cr_report_line
- (report_id, scn, their_balance, our_balance, clear_time)
+ (report_id, scn, their_balance, our_balance, clear_time,
+ "user")
VALUES
- (in_report_id, t_scn, in_amount, 0, in_date);
+ (in_report_id, t_scn, in_amount, 0, in_date, t_uid);
ELSIF in_count = 1 THEN -- perfect match
UPDATE cr_report_line SET their_balance = in_amount,
clear_time = in_date
- WHERE report_id = in_report_id AND amount = in_amount
+ WHERE report_id = in_report_id AND our_balance = in_amount
AND their_balance = 0;
ELSE -- more than one match
SELECT min(id) INTO lid FROM cr_report_line
- WHERE report_id = in_report_id AND amount = in_amount
- AND their_balance = 0 and posted_date = in_date;
+ WHERE report_id = in_report_id AND our_balance = in_amount
+ AND their_balance = 0 and post_date = in_date;
UPDATE cr_report_line SET their_balance = in_amount,
clear_time = in_date
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.