[ic] I've been writing an Interface to SQL-Ledger Accounting...

Daniel interchange-users@interchange.redhat.com
Mon May 6 14:08:01 2002


Hello List.

First of all thanks to Mike H., Red Hat, and all the Interchange
contributors for putting together a great product.

I'm new to perl and Interchange but not to systems integration projects. -
So please bear with me.

First a little Background: "SQL-Ledger Accounting "www.sql-ledger.org" is a
multi-user, double entry, accounting system written in Perl and is licensed
under the GNU General Public License."

The SQL-Ledger API: "SQL-Ledger functions can be accessed from the command
line by passing all the variables in one long string to the perl script. The
variable=value pairs must be separated by an ampersand. See
"www.sql-ledger.org/misc/api.html" for more details on the command line
interface." (You can also do the same thing via HTTP as apposed to the
command line.)

What I have done on this project so far, sans some of the dirty details...

In order for me to interface interchange with sql-ledger I needed to have
sql-ledger assign a unique customer id to each interchange user. Also I need
a mechanism to save/update sql-ledger's customer information whenever an
interchange user creates or update his account.

My solution to handle this was to create a perl module called
Vend::SLInterface. It contains several routines that encapsulate the
interface to sql-ledger. The current version uses back ticks to call the
local install of sql-ledger. However, future versions will allow calling
sql-ledger using http also.

Here is where I need some guidance...

You see in my first attack at this problem I hacked the UserDB.pm
"assign_username" and "set_values" routines directly. Basically adding a
call to my Vend::SLInterface module just before each routine returns
(successfully) a value.

Works so far so good...

Now I'm trying to use a custom order route that calls my Vend::SLInterface
module to save my orders into sql-ledger but ran right into Safe. -Ouch.
That hurt!

But, I also know that Safe is my friend and I don't want to open up any
holes as I put this thing together.

As I've researched issues regarding [realperl], User tags, Global Subs,
etc...

I'm now asking myself should I be doing this differently?...

Should I be hacking UserDB.pm directly or overriding the routines with a
Global Sub?...

Can a Global Sub that is overriding "set_values" in UserDB.pm call the
"real" "set_values" routine prior to running its own code?...

I'm basically messing in someone else's sandbox and I don't want to violate
the "house rules". Also I want to release this to the community when I'm
done so its got to get along well with others.

Any help or guidance from the group would be really appreciated. The
UserDB.pm patch is included below for your review.

-Daniel

Daniel Thompson

danht@callthenet.com



________________________________________________________________



--- /usr/lib/interchange/lib/Vend/UserDB.pm.old Fri Aug 17 18:30:09 2001

+++ /usr/lib/interchange/lib/Vend/UserDB.pm Sat Apr 27 19:59:32 2002

@@ -29,6 +29,7 @@

use Vend::Util;

use Safe;

use strict;

+use Vend::SLInterface;


my $ready = new Safe;


@@ -754,6 +755,10 @@

return undef;

}


+# Changes made to support SQL-Ledger Accounting Interface.

+ my $obj = Vend::SLInterface->new();

+ my $returnval = $obj->save_customer_data(\@bfields, \@bvals, "$user");

+

return 1;

}


@@ -1259,7 +1264,14 @@

my $start = $self->{OPTIONS}{username} || 'U00000';

$file = './etc/username.counter' if ! $file;

my $ctr = File::CounterFile->new($file, $start);

- return $ctr->inc();

+ # return $ctr->inc();

+

+# Changes made to support SQL-Ledger Accounting Interface.

+ my $nextinc = $ctr->inc();

+ my $emailaddr = $CGI::values{email};

+ my $obj = Vend::SLInterface->new();

+ my $custno = $obj->assign_new_customer_number($nextinc, $emailaddr);

+ return $custno;

}


sub new_account {

________________________________________________________________




-Daniel

____________________________________
 Daniel Thompson
 President
 Callthenet Commerce

 Snail Mail:
 PO Box 2591
 Goldenrod FL 32733

 Phone 407.213.9408