summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-01 20:30:05 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-01 20:30:05 +0000
commitd6f5e7b43d9d0adba0f6161dbdd7f07985b25bd4 (patch)
tree771d303d20f2d2abc53de9f59d8ad191cd9f5d6d /LedgerSMB
parent411e61879b0efad2c5bfdcd209b46e01a33e0f35 (diff)
Bulk updarte for the entirety of Reconciliation code to date. All code, SQL, and templates as provided.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2180 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/AA.pm5
-rw-r--r--LedgerSMB/Reconciliation.pm113
-rw-r--r--LedgerSMB/Reconciliation/CSV.pm69
-rwxr-xr-xLedgerSMB/Template.pm7
4 files changed, 160 insertions, 34 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm
index d5d8a1fe..93e64e61 100644
--- a/LedgerSMB/AA.pm
+++ b/LedgerSMB/AA.pm
@@ -311,9 +311,14 @@ sub post_transaction {
# AR/AP Transaction.
# ~A
$query = qq|
+<<<<<<< .mine
+ INSERT INTO $table (invnumber, person_id)
+ VALUES (?, (select e.id from person p, entity e, users u
+=======
INSERT INTO $table (invnumber, person_id,
entity_credit_account)
VALUES (?, (select e.id from person p, entity e, users u
+>>>>>>> .r2156
where u.username = ?
AND e.id = u.entity_id
AND p.entity_id = e.id ), ?)|;
diff --git a/LedgerSMB/Reconciliation.pm b/LedgerSMB/Reconciliation.pm
index e1096f63..f0f57804 100644
--- a/LedgerSMB/Reconciliation.pm
+++ b/LedgerSMB/Reconciliation.pm
@@ -85,14 +85,55 @@ your software.
=cut
-package LedgerSMB::DBObject::Reconciliation;
+package LedgerSMB::Reconciliation;
-use base qw(LedgerSMB);
+use base qw(LedgerSMB::DBObject);
use LedgerSMB::DBObject;
+use LedgerSMB::Reconciliation::CSV;
# don't need new
-#sub reconcile {
+sub import_file {
+
+ 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();
+
+ return $self->{entries};
+}
+
+sub approve {
+
+ my $self = shift @_;
+ # 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
+
+ if ($code == 0) { # no problem.
+ return $code;
+ }
+ # this is destined to change as we figure out the Error system.
+ elsif ($code == 99) {
+
+ $self->error("User $self->{user}->{name} cannot approve report, must be a different user.");
+ }
+}
+
sub new_report {
my $self = shift @_;
@@ -102,48 +143,37 @@ sub new_report {
# Total is in here somewhere, too
- my $report_id = $self->new_report_id()[0]; # gives us a report ID to insert with.
+ # gives us a report ID to insert with.
+ my $report_id = $self->exec_method(funcname=>'reconciliation__new_report_id');
# 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.
unshift @{$entries}, {
scn => -1,
balance=> $total,
- old_balance=> $self->current_balance,
+ old_balance=> $self->exec_method(funcname=>'reconciliation__current_balance'),
date=>$month
};
- for my $entry (@{$entries}) {
+ for my $entry ( @{$entries} ) {
# Codes:
# 0 is success
# 1 is found, but mismatch
# 2 is not found
+ $code = $self->exec_method(
+ funcname=>'reconciliation__add_entry',
+ args=>[
+ $report_id,
+ ]
+ );
$entry{report_id} = $report_id;
$entry{code} = $self->add_entry( $entry );
}
- $self->pending_transactions($report_id, $date);
+ $self->exec_method(funcname=>'reconciliation__pending_transactions', args=>[$report_id, $date]);
- return $entries; # returns the report ID.
-}
-
-sub approve {
-
- my $self = shift @_;
- # the user should be embedded into the $self object.
- my $report_id = shift @_;
-
- my $code = $self->report_approve($report_id); # user
-
- if ($code == 0) { # no problem.
- return $code;
- }
- # this is destined to change as we figure out the Error system.
- elsif ($code == 99) {
-
- $self->error("User $self->{user}->{name} cannot approve report, must be a different user.");
- }
+ return ($report_id, $entries); # returns the report ID.
}
sub correct_entry {
@@ -154,7 +184,10 @@ sub correct_entry {
my $new_amount = $self->{new_amount}; #shift @_;
# correct should return the new code value - whether or not it actually "matches"
- my $code = $self->correct($report_id, $scn, $new_amount);
+ my $code = $self->exec_method(
+ funcname=>'reconciliation__correct',
+ args=>[$report_id, $scn, $new_amount]
+ );
return $code[0]->{'correct'};
}
@@ -162,21 +195,39 @@ sub get_report {
my $self = shift @_;
- return $self->report($self->{report_id});
+ return $self->exec_method(funcname=>'reconciliation__report', args=>[$self->{report_id}]);
}
sub get_corrections {
my $self = shift @_;
- return $self->corrections($self->{report_id},$self->{entry_id});
+ return $self->exec_method(
+ funcname=>'reconciliation__corrections',
+ args=>[$self->{report_id}, $self->{entry_id}]
+ );
}
sub entry {
my $self = shift @_;
- return $self->single_entry($self->{report_id},$self->{entry_id});
+ return $self->exec_method(
+ funcname=>'reconciliation__single_entry',
+ args=>[$self->{report_id}, $self->{entry_id}]
+ );
+}
+
+sub search {
+
+ my $self = shift @_;
+
+ return $self->exec_method(
+ funcname=>'reconciliation__search',
+ args=>[$self->{date_begin}, $self->{date_end}, $self->{account}, $self->{status}]
+ );
}
-1;
+
+
+1; \ No newline at end of file
diff --git a/LedgerSMB/Reconciliation/CSV.pm b/LedgerSMB/Reconciliation/CSV.pm
new file mode 100644
index 00000000..f95bf194
--- /dev/null
+++ b/LedgerSMB/Reconciliation/CSV.pm
@@ -0,0 +1,69 @@
+# CSV parser is basically a framework to handle any CSV files or fixed-width format files.
+# Parsers are defined in CSV/parser_type.
+
+package LedgerSMB::Reconciliation::CSV;
+
+use base qw/LedgerSMB/;
+use Datetime;
+
+sub load_file {
+
+ my $self = shift @_;
+ my $filename = shift @_;
+ my $contents;
+ do {
+
+ local $/; # I think this is the right way to outrageously cheat
+ open(FH,$filename);
+ $contents = <FH>;
+ }
+ return $contents;
+}
+
+sub process {
+
+ # thoroughly implementation-dependent.
+ my $self = shift @_;
+ my $contents = $self->load_file($self->{csv_filename});
+
+ foreach my $line (split /\n/,$contents) {
+ # Unpack for the format it is inexplicably in
+ ($accno,
+ $checkno,
+ $issuedate
+ $amount
+ $cleared,
+ $last_three) = unpack("A10A10A6A10A6A3",$line);
+
+ push @{ $self->{entries} }, {
+ account_num => $accno,
+ scn => $checkno,
+ issue_date => $issuedate,
+ amount => $amount,
+ cleared_date => $cleared
+ };
+ }
+ # Okay, now how do I test to see if this is actually, y'know, bad data.
+
+ for my $line (@{ $self->{entries} }) {
+
+ # First check the account number.
+ # According to the docs I have, it's all numbers.
+
+
+ }
+
+ return;
+}
+
+sub is_error {
+
+
+}
+
+sub error {
+
+
+}
+
+1; \ No newline at end of file
diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm
index 3a92e1c2..c7386928 100755
--- a/LedgerSMB/Template.pm
+++ b/LedgerSMB/Template.pm
@@ -254,9 +254,10 @@ sub render {
if (UNIVERSAL::isa($self->{locale}, 'LedgerSMB::Locale')){
$cleanvars->{text} = sub { return $self->{locale}->text(@_)};
- } else {
- $cleanvars->{text} = sub { return shift @_ };
- }
+ }
+ else {
+ $cleanvars->{text} = sub { return shift @_ };
+ }
$format->can('process')->($self, $cleanvars);
#return $format->can('postprocess')->($self);