summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2007-12-12 05:42:49 +0000
committerjeff <jeff>2007-12-12 05:42:49 +0000
commit4adbb7b8375ded193d6049a92e89096c15ae5bcd (patch)
treed2c11e05e3ca51959b17de8edf1a0b8333584ddd /FS
parent58f17f80a92ffcc13bbd21479f1ddd61399ca6a8 (diff)
cust_credit reason improvement, bugfix, and tool
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_credit.pm4
-rw-r--r--FS/FS/h_cust_credit.pm33
-rwxr-xr-xFS/bin/freeside-disable-reasons64
-rwxr-xr-xFS/bin/freeside-upgrade5
4 files changed, 105 insertions, 1 deletions
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 3ead008e6..fda7d95a3 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -280,7 +280,7 @@ sub check {
$self->_date(time) unless $self->_date;
- $self->otaker(getotaker);
+ $self->otaker(getotaker) unless ($self->otaker);
$self->SUPER::check;
}
@@ -388,6 +388,7 @@ sub reason {
if (!$reason && $typenum) {
$reason = new FS::reason( { 'reason_type' => $typenum,
'reason' => $value,
+ 'disabled' => 'Y',
} );
$reason->insert and $reason = undef;
}
@@ -439,6 +440,7 @@ sub _upgrade_data { # class method
};
my $noreason = qsearchs( 'reason', $hashref );
unless ($noreason) {
+ $hashref->{'disabled'} = 'Y';
$noreason = new FS::reason( $hashref );
my $error = $noreason->insert();
die "can't insert legacy reason '(none)' into database: $error\n"
diff --git a/FS/FS/h_cust_credit.pm b/FS/FS/h_cust_credit.pm
new file mode 100644
index 000000000..1425a26a6
--- /dev/null
+++ b/FS/FS/h_cust_credit.pm
@@ -0,0 +1,33 @@
+package FS::h_cust_credit;
+
+use strict;
+use vars qw( @ISA );
+use FS::h_Common;
+use FS::cust_credit;
+
+@ISA = qw( FS::h_Common FS::cust_credit );
+
+sub table { 'h_cust_credit' };
+
+=head1 NAME
+
+FS::h_cust_credit - Historical record of customer credit changes
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+An FS::h_cust_credit object represents historical changes to credits.
+FS::h_cust_credit inherits from FS::h_Common and FS::cust_credit.
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::cust_credit>, L<FS::h_Common>, L<FS::Record>, schema.html from the base
+documentation.
+
+=cut
+
+1;
+
diff --git a/FS/bin/freeside-disable-reasons b/FS/bin/freeside-disable-reasons
new file mode 100755
index 000000000..0af460919
--- /dev/null
+++ b/FS/bin/freeside-disable-reasons
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+
+use strict;
+use vars qw($opt_t $opt_e);
+use Getopt::Std;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch qsearchs);
+use FS::reason_type;
+use FS::reason;
+
+getopts('t:e');
+
+my $user = shift or die &usage;
+adminsuidsetup $user;
+
+die &usage
+ unless ($opt_t);
+
+$FS::Record::nowarn_identical = 1;
+
+my @reason = ();
+if ( $opt_t ) {
+ $opt_t =~ /^(\d+)$/ or die "invalid reason_type";
+ @reason = qsearch('reason', { reason_type => $1 } );
+ die "no reasons found\n" unless @reason;
+} else {
+ die "no reason_type specified\n";
+}
+
+foreach my $reason ( @reason ) {
+ if ( $opt_e ) {
+ $reason->disabled('');
+ }else{
+ $reason->disabled('Y');
+ }
+ my $error = $reason->replace
+ if $reason->modified;
+ die $error if $error;
+}
+
+
+sub usage {
+ die "Usage:\n\n freeside-disable-reasons -t reason_type [ -e ] user\n";
+}
+
+=head1 NAME
+
+freeside-disable-reasons - Command line tool to set the disabled column for reasons
+
+=head1 SYNOPSIS
+
+ freeside-disable-reasons -t reason_type [ -e ] user
+
+=head1 DESCRIPTION
+
+ Disables the reasons of the specified reason type.
+ Enables instead if -e is specified.
+
+=head1 SEE ALSO
+
+L<FS::reason>, L<FS::reason_type>
+
+=cut
+
diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade
index 020d5fec6..f676e1b38 100755
--- a/FS/bin/freeside-upgrade
+++ b/FS/bin/freeside-upgrade
@@ -84,6 +84,11 @@ if ( $dbh->{Driver}->{Name} =~ /^mysql/i ) {
}
}
+$dbh->commit or die $dbh->errstr; # we *MUST* commit before upgrading data
+dbdef_create($dbh, $dbdef_file);
+delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
+reload_dbdef($dbdef_file);
+
upgrade()
unless $DRY_RUN;