Re: [Openledger-developer] How to handle invoicenumbers?
Brought to you by:
klavs
From: Ang T. C. <tc...@st...> - 2005-02-21 14:47:38
|
hi everyone, i hope my function can help sub last_invoice { my ($self, $myconfig, $form) = @_; # connect to database my $dbh = $form->dbconnect($myconfig); # get the last invnumber my $query = qq|select lastinvnumber from (SELECT id,invnumber as lastinvnumber FROM ar WHERE invoice='t' and transtype='$form->{transtype}' order by id desc limit 2) as foo order by id DESC|; my $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); $ref = $sth->fetchrow_hashref(NAME_lc); map { $form->{$_} = $ref->{$_} } keys %$ref; $sth->finish; $dbh->disconnect; } This code is derived from "Open Business Accounting (OBA)". OBA uses a variable "transtype" to control different type of "Invoices/AR". Ex, use can create Cash Sales , Invoice , Consignment Notes or etc using the same module with its own running number. from Ang Tun Chek Klavs Klavsen wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi guys, > > Currently SL's way of handling invoicenumbers does NOT work for me. It > does not increment as it should and I have no way of defining a specific > pattern I'd like (f.ex. $year-incnr, $year$xdigitincnr or > $year$month$day$hour$min$sec etc. ). > > I was thinking that I'd add a function that gives you the next available > invoicenumber (ie. whatever invoicenumbering scheme you use - +1 :) and > also I'd like to make PostInvoice able to handle this, if the invoicenr. > field is left out, it should automatically assign it the next available > invoicenr. > > My reasoning for doing this, is that I currently handle invoicenumbers > in my own scripts - and IMHO this is (again :) the responsibility of the > accounting system - my scripts should not have to care about that for > posting a mere invoice. > > I think I'll build the "get next invoicenr." function to use a > openledger.conf file in which you can define the pattern - to begin with > I'll build it to support the sceme I use, which is the $year followed by > a 5 digitnr. in my case (ie. any invoicenumber is padded with zero's to > always be 5 digits). I'll let the digit amount be defineable ofcourse - > probably the printf way. > > What do you think? Any ideas to implementing it will be welcome - > otherwise I'll just think of a way to get it rolling when I get to it :) > > I was thinking of a $InvoiceNumber variable to be defined in > openledger.conf which would simply be used in printf - and any variables > given in it, should also (somehow) be chosen from a predefined set in, > and defined in openledger.conf. > > - -- > Regards, > Klavs Klavsen, GSEC - kl...@vs... - http://www.vsen.dk > PGP: 7E063C62/2873 188C 968E 600D D8F8 B8DA 3D3A 0B79 7E06 3C62 > > "Those who do not understand Unix are condemned to reinvent it, poorly." > ~ --Henry Spencer > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.6 (GNU/Linux) > > iD8DBQFCGZcoPToLeX4GPGIRArfTAJ9Ip5/aRglIdo1g/MpFSU+10kFDjgCfXpy1 > KZgsUz6HubzHQ4tvKMuave4= > =EoGG > -----END PGP SIGNATURE----- > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Openledger-developer mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openledger-developer |