Re: [Openledger-developer] Random jottings
Brought to you by:
klavs
From: Tony F. <to...@sy...> - 2005-03-21 20:50:15
|
On Mon, 2005-03-21 at 00:30, Klavs Klavsen wrote: > | > | # Open a GL Transaction > | my $gl_trans = > $acct->start_transaction('Business::Ledger::Transaction::GL'); > | > hmm dividing them into GL etc. transactions.. I guess this is ok from > the users point of view. Connecting/binding the transaction to the $acct > object (which you do here - otherwise $gl_trans->post would not have > known where to post) is IMHO bad. Bad? I would argue that it is good. In a web-gui environment it wouldn't matter one way or the other. HTTP is stateless and can't maintain things like DB connections between requests. Think of a Perl-Gtk app though, it would make sense to maintain a DB connection for each transaction, actually it would be mandatory in order to maintain transaction isolation. > What if I have a transaction, I'd like to post in two different > accounting systems? Or perhaps I have some code that uses the > transaction object for "something else" (like generating a receipt or > whatever)? Copying transactions from system to system would have to be allowed for. Using them for "something else" is fine What does the API care what you do with an object. > I'd prefer having GL etc. as seperate objects (as we have now) - which > the user who creates the objects, can decide to use for whatever they > see fit - and then accept these as parameters for f.ex. post_transaction > - - which could be made to accept both AR,AP and GL transactions. So you plan on putting the whole 20,000 lines of code that makes up the backend of SL (SL/*.pm) into one package? That sounds like an even worse maintenance problem than SL has now to me. BTW, I was looking at your code in CVS, Why don't you use Class::Accessor? You could write TransactionLine.pm as: -SNIP- package TransactionLine; use strict; use vars qw($VERSION); $VERSION = "0.1"; sub Version { $VERSION } use Class::Accessor; use base qw/Class::Accessor/; sub new { bless { }, shift; } TransactionLine->mk_accessors(qw/debit credit accNo/); 1; __END__ -SNIP- You get the idea (Copyright info removed for brevity). > | $gl_trans->reference('test'); > | $gl_trans->date('1-1-2005'); > | $gl_trans->description('This is a test GL entry'); > | > | # Add some amounts > | $gl_trans->post_debit($chart->find_account( number => '1820' ), '55.00'); > | $gl_trans->post_debit($chart->find_account( number => '5700' ), '40.00'); > | $gl_trans->post_credit($chart->find_account( number => '1060' ), '95.00'); > > Why not just use the accountnumber as referencenr.? Instead of having to > find the account based on the accountnr.? The accountnr. is afterall > always unique. > If it wasn't unique, you couldn't trust find_account to find only one, > and thus couldn't use it in the context you do here - as you wouldn't be > sure which one you'd get. The reason is because post_debit would take a reference to a account object and how that object reference is found is up to the user of the API. I could just have easily said: ( $chart->find_account( type => ASSET, name => "%Office Equipment%") )[0] to use the first account that is an asset account with "Office Equipment" in its name. -- Tony Fraser to...@sy... Sybaspace Internet Solutions System Administrator phone: (250) 246-5368 fax: (250) 246-5398 |