From: Armaghan S. <sa...@le...> - 2008-01-16 02:43:30
|
Here is a code snippet using SL API to renumber customers (or invoices, vendors, gl trans or anything with minor change). **** WARNING: Use at your own risk. All existing disclaimers apply. **** To use it: (1) Create bin/mozilla/custom_ct.pl with following code. ### Perl code starts here 1; sub renumber { $form->header; my $dbh = $form->dbconnect(\%myconfig); my $query = qq|SELECT id, name FROM customer ORDER BY name|; my $sth = $dbh->prepare($query); $sth->execute or $form->dberror($query); my $updatequery = qq|UPDATE customer SET customernumber = ? WHERE id = ?|; my $updatesth = $dbh->prepare($updatequery); while ($ref = $sth->fetchrow_hashref(NAME_lc)){ $form->{customernumber} = $form->update_defaults($myconfig, "customernumber", $dbh); $updatesth->execute($form->{customernumber}, $ref->{id}); print qq|$form->{customernumber} assigned to $ref->{name}<br>|; } $dbh->disconnect; } ### Perl code ends here (2) Put this in custom_menu.ini [Renumber Customers]] module=ct.pl action=renumber (3) Setup the number to start with minus 1 in system defaults (4) Click "Renumber customers" in menu. All customers will be renumbered and new customer number will start automatically from last one generatd. To clarify anything contact me. Regards -- Purpose-built SQL-Ledger Hosting http://www.ledger123.com/ -- On 1/15/08, Andrew @ ATM Logic <atm...@km...> wrote: > Yes, they are entering them manually... Going from MYOB to SL, I think I > just did not have clear enough instructions on how to export from MYOB and > import to SL. > > If I had this in Black and White I may be able to do it, however... even > with the manual... this seems to be something that is not that straight > forward. > > In any case, they have staff that are doing this in spare time... > > > ---Andrew > ATM Logic > > > > -----Original Message----- > > From: sql...@li... > > [mailto:sql...@li...] On > > Behalf Of Michael Hasse > > Sent: Tuesday, January 15, 2008 1:23 AM > > To: sql...@li... > > Subject: Re: [SL] How to renumber all customers, then "start" > > the numbering? > > > > They're entering them manually...?!? > > > > > > Thanks, > > > > Michael > > > > > > On Jan 14, 2008, at 9:52 PM, Andrew @ ATM Logic wrote: > > > > > We have a client using SQL Ledger (we use it as well) > > however for some > > > reason as they have been entering customers ever single customer is > > > number 1 (They have a little over 1000 of them entered, and > > are only > > > on the letter 'M' so far... > > > > > > I am hoping I am going to be able to find a way to renumber all of > > > them, (was hoping maybe an import / export would have worked) then > > > sort out what was wrong and get it fixed) > > > > > > They started with version 2.8 I think, and I just upgraded them to > > > 2.8.11 > > > > > > Any help would be great, thanks |