diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/restore-ship_company | 32 | ||||
| -rw-r--r-- | bin/test_scrub | 12 |
2 files changed, 44 insertions, 0 deletions
diff --git a/bin/restore-ship_company b/bin/restore-ship_company new file mode 100644 index 000000000..cee700962 --- /dev/null +++ b/bin/restore-ship_company @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use FS::UID 'adminsuidsetup'; +use FS::Record qw(qsearch qsearchs dbh); +use FS::cust_main; +my $user = shift or die "Usage: + restore-ship_company username [ max-age ] +"; +adminsuidsetup($user); + +$FS::UID::AutoCommit = 1; +local $FS::cust_main::import = 1; + +my $days = shift || 30; +my $time = time - (86400*$days); # by default, only restore within the last + # 30 days +foreach my $cust_main (qsearch('cust_main', { ship_company => '' })) { + my $custnum = $cust_main->custnum; + my $last_h = qsearchs({ + table => 'h_cust_main', + extra_sql => " WHERE custnum = $custnum". + " AND ship_company IS NOT NULL". + " AND history_date >= $time", + order_by => " ORDER BY history_date DESC LIMIT 1", + }); + next if !$last_h; + print "$custnum\t".$last_h->ship_company."\n"; + $cust_main->set('ship_company' => $last_h->ship_company); + my $error = $cust_main->replace; + warn "Error setting service company for customer #$custnum:\n $error\n" + if $error; +} diff --git a/bin/test_scrub b/bin/test_scrub index 45a257ab9..e39a28a4e 100644 --- a/bin/test_scrub +++ b/bin/test_scrub @@ -3,6 +3,7 @@ #This drops anything from the database that could cause live things to happen. #You'd want to do this on a test copy of your live database but NEVER on the #live database itself. +die "remove this line to run -- NEVER ON A LIVE DATABASE"; #-all exports (all records in part_export, part_export_option export_svc) #-all non-POST invoice destinations (cust_main_invoice) @@ -42,6 +43,17 @@ my $dsth = dbh->prepare("DELETE FROM cust_main_invoice WHERE dest != 'POST'") or die dbh->errstr; $dsth->execute or die $dsth->errstr; +foreach my $table (qw( cust_main + cust_pay_pending cust_pay cust_pay_void cust_pay_batch + cust_refund +)) { + my $ccsth = dbh->prepare(" + UPDATE $table SET payinfo = '4111111111111111' + WHERE payby = 'CARD' OR payby = 'DCRD' + ") or die dbh->errstr; + $ccsth->execute or die $ccsth->errstr; +} + my $sth = dbh->prepare("UPDATE part_event SET disabled = 'Y'"); $sth->execute or die $sth->errstr; |
