[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2521] trunk
- Subject: SF.net SVN: ledger-smb:[2521] trunk
- From: ..hidden..
- Date: Sun, 22 Mar 2009 00:15:16 +0000
Revision: 2521
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2521&view=rev
Author: einhverfr
Date: 2009-03-22 00:15:15 +0000 (Sun, 22 Mar 2009)
Log Message:
-----------
Reconciliation bank file fixes
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Reconciliation.pm
trunk/LedgerSMB/DBObject.pm
trunk/LedgerSMB/Reconciliation/CSV.pm
trunk/LedgerSMB/Template/HTML.pm
trunk/LedgerSMB.pm
trunk/UI/reconciliation/report.html
trunk/scripts/recon.pl
Modified: trunk/LedgerSMB/DBObject/Reconciliation.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/LedgerSMB/DBObject/Reconciliation.pm 2009-03-22 00:15:15 UTC (rev 2521)
@@ -132,21 +132,8 @@
my $self = shift @_;
- # We need to know what the format is, for the text file. We should have a set of formats
- # for the given file, listed in the DB, or based on modules available.
- #
- # Probably based on modules.
-
- # my $module = 'LedgerSMB/Reconciliaton/CSV/'.$self->{file_format};
- # require $module."pm";
- # my $obj_name = $module;
- # $obj_name =~ s/\//::/g;
- # my $parser = $obj_name::new(base=>$self);
-
- # $self->filename is currently a lie. There's no facility in the LSMB
- # design to accomadate an uploaded file.
my $csv = LedgerSMB::Reconciliation::CSV->new(base=>$self);
- $csv->process();
+ $csv->process($self, 'csv_file');
return $self->{entries};
}
@@ -346,7 +333,6 @@
$self->{account} = $_->{name};
}
}
- $self->debug({file => '/tmp/recon'});
$self->{format_amount} = sub { return $self->format_amount(@_); };
}
Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/LedgerSMB/DBObject.pm 2009-03-22 00:15:15 UTC (rev 2521)
@@ -73,10 +73,12 @@
my $attr;
if (lc($mode) eq 'base'){
- $self->merge($base, keys => ['dbh', '_roles', '_user', '_locale']);
+ $self->merge($base, keys => ['dbh', '_roles', '_user', '_locale',
+ '_request']);
}
elsif (lc($mode) eq 'list'){
- $self->merge($base, keys => ['dbh', '_roles', '_user', '_locale']);
+ $self->merge($base, keys => ['dbh', '_roles', '_user', '_locale',
+ '_request']);
$self->merge($base, keys => ..hidden..);
}
else {
Modified: trunk/LedgerSMB/Reconciliation/CSV.pm
===================================================================
--- trunk/LedgerSMB/Reconciliation/CSV.pm 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/LedgerSMB/Reconciliation/CSV.pm 2009-03-22 00:15:15 UTC (rev 2521)
@@ -3,42 +3,43 @@
package LedgerSMB::Reconciliation::CSV;
-use base qw/LedgerSMB/;
+use base qw/LedgerSMB::DBObject::Reconciliation/;
opendir (DCSV, 'LedgerSMB/Reconciliation/CSV/Formats');
for my $format (readdir(DCSV)){
- do "LedgerSMB/Reconciliation/CSV/Formats/$format";
+ if ($format !~ /^\./){
+ do "LedgerSMB/Reconciliation/CSV/Formats/$format";
+ }
};
sub load_file {
my $self = shift @_;
- my $filename = shift @_;
+ my $fieldname = shift @_;
+
my $contents;
- do {
-
- local $/; # I think this is the right way to outrageously cheat
- open(FH,$filename);
- $contents = <FH>;
- };
+ my $handle = $self->{_request}->upload($fieldname);
+ $contents = join("\n", <$handle>);
return $contents;
}
sub process {
+ my $self = shift @_;
# thoroughly implementation-dependent, so depends on helper-functions
- my $self = shift @_;
- my $contents = $self->load_file($self->{csv_filename});
- my $func = "process_$self->{accno}";
- my $func =~ s/-/_/g;
- @entries = eval{&$func($self, $contents)};
- if (!$!){
+ my ($recon, $fldname) = @_;
+ my $contents = $self->load_file($fldname);
+
+ my $func = "parse_" . $recon->{chart_id};
+ if ($self->can($func)){
+ @entries = $self->can($func)->($self,$contents);
@{$self->{recon_entries}} = @entries;
$self->{file_upload} = 1;
}
else {
$self->{file_upload} = 0;
}
+ return $self->{file_upload};
}
sub is_error {
Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/LedgerSMB/Template/HTML.pm 2009-03-22 00:15:15 UTC (rev 2521)
@@ -70,6 +70,8 @@
return escapeHTML($$rawvars);
} elsif ($type eq 'CODE'){
return $rawvars;
+ } elsif ($type eq 'IO::File'){
+ return undef;
} else { # Hashes and objects
for ( keys %{$rawvars} ) {
$vars->{preprocess($_)} = preprocess( $rawvars->{$_} );
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/LedgerSMB.pm 2009-03-22 00:15:15 UTC (rev 2521)
@@ -155,6 +155,7 @@
my $query = ($argstr) ? new CGI::Simple($argstr) : new CGI::Simple;
my $params = $query->Vars;
$self->{VERSION} = $VERSION;
+ $self->{_request} = $query;
$self->merge($params);
$self->{have_latex} = $LedgerSMB::Sysconfig::latex;
Modified: trunk/UI/reconciliation/report.html
===================================================================
--- trunk/UI/reconciliation/report.html 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/UI/reconciliation/report.html 2009-03-22 00:15:15 UTC (rev 2521)
@@ -3,7 +3,7 @@
?>
<?lsmb PROCESS 'elements.html' ?>
-<form action="recon.pl" method="post">
+<form action="recon.pl" method="post" enctype="multipart/form-data">
<div class="listtop" id="title"><?lsmb text('Reconciliation Report') ?></div>
<table class="info">
<tr>
@@ -246,5 +246,5 @@
class = "submit"
} ?>
<?lsmb END ?>
-
+</form>
</body></html>
Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl 2009-03-20 22:31:41 UTC (rev 2520)
+++ trunk/scripts/recon.pl 2009-03-22 00:15:15 UTC (rev 2521)
@@ -67,7 +67,6 @@
sub update_recon_set {
my ($request) = shift;
my $recon = LedgerSMB::DBObject::Reconciliation->new(base => $request);
- $recon->add_entries($recon->import_file()) if !$recon->{submitted};
$recon->{their_total} = $recon->parse_amount(amount => $recon->{their_total}) if defined $recon->{their_total};
$recon->{dbh}->commit;
if ($recon->{line_order}){
@@ -76,7 +75,7 @@
column => $recon->{line_order}}
);
}
- $recon->save();
+ $recon->save() if !$recon->{submitted};
$recon->update();
_display_report($recon);
}
@@ -338,6 +337,7 @@
sub _display_report {
my $recon = shift;
$recon->get();
+ $recon->add_entries($recon->import_file()) if !$recon->{submitted};
$recon->{can_approve} = $recon->is_allowed_role({allowed_roles => ['recon_supervisor']});
$template = LedgerSMB::Template->new(
user=> $user,
@@ -403,7 +403,7 @@
$recon->{zero_string} = $recon->format_amount({amount => 0, money => 1});
$recon->{statement_gl_calc} = $recon->{their_total}
- + $recon->{outstanding_total};
+ + $recon->{outstanding_total} + $recon->{mismatch_our_total};
$recon->{out_of_balance} = $recon->{their_total} - $recon->{our_total};
$recon->{cleared_total} = $recon->format_amount({amount => $recon->{cleared_total}, money => 1});
$recon->{outstanding_total} = $recon->format_amount({amount => $recon->{outstanding_total}, money => 1});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.