X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=7aee8d02781bdcbe447e13f583ec77292fdd33e2;hb=fcf83b9d956af1049af0d13812cc6756c78308b5;hp=147a760d9c634876b06a2d5123e49aebfda57fe3;hpb=1e4aa8069f25e1b4101da20bb9e0d3f60357ea52;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 147a760d9..7aee8d027 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -77,6 +77,9 @@ inherits from FS::Record. The following fields are currently supported: =item otaker - order taker (assigned automatically if null, see L) +=item manual_flag - If this field is set to 1, disables the automatic +unsuspensiond of this package when using the B config file. + =back Note: setup, bill, susp, expire and cancel are specified as UNIX timestamps; @@ -100,17 +103,19 @@ sub table { 'cust_pkg'; } Adds this billing item to the database ("Orders" the item). If there is an error, returns the error, otherwise returns false. +=cut + sub insert { my $self = shift; # custnum might not have have been defined in sub check (for one-shot new # customers), so check it here instead + # (is this still necessary with transactions?) my $error = $self->ut_number('custnum'); - return $error if $error + return $error if $error; - return "Unknown customer" - unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); + return "Unknown customer ". $self->custnum unless $self->cust_main; $self->SUPER::insert; @@ -118,15 +123,16 @@ sub insert { =item delete -Currently unimplemented. You don't want to delete billing items, because there -would then be no record the customer ever purchased the item. Instead, see -the cancel method. +This method now works but you probably shouldn't use it. + +You don't want to delete billing items, because there would then be no record +the customer ever purchased the item. Instead, see the cancel method. =cut -sub delete { - return "Can't delete cust_pkg records!"; -} +#sub delete { +# return "Can't delete cust_pkg records!"; +#} =item replace OLD_RECORD @@ -152,9 +158,12 @@ sub replace { #return "Can't (yet?) change pkgpart!" if $old->pkgpart != $new->pkgpart; return "Can't change otaker!" if $old->otaker ne $new->otaker; - return "Can't change setup once it exists!" - if $old->getfield('setup') && - $old->getfield('setup') != $new->getfield('setup'); + + #allow this *sigh* + #return "Can't change setup once it exists!" + # if $old->getfield('setup') && + # $old->getfield('setup') != $new->getfield('setup'); + #some logic for bill, susp, cancel? $new->SUPER::replace($old); @@ -183,8 +192,7 @@ sub check { return $error if $error; if ( $self->custnum ) { - return "Unknown customer" - unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); + return "Unknown customer ". $self->custnum unless $self->cust_main; } return "Unknown pkgpart" @@ -194,6 +202,11 @@ sub check { $self->otaker =~ /^(\w{0,16})$/ or return "Illegal otaker"; $self->otaker($1); + if ( $self->dbdef_table->column('manual_flag') ) { + $self->manual_flag =~ /^([01]?)$/ or return "Illegal manual_flag"; + $self->manual_flag($1); + } + ''; #no error } @@ -422,6 +435,17 @@ sub labels { map { [ $_->label ] } qsearch ( 'cust_svc', { 'pkgnum' => $self->pkgnum } ); } +=item cust_main + +Returns the parent customer object (see L). + +=cut + +sub cust_main { + my $self = shift; + qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); +} + =back =head1 SUBROUTINES @@ -565,7 +589,7 @@ sub order { =head1 VERSION -$Id: cust_pkg.pm,v 1.6 2001-09-04 14:44:06 ivan Exp $ +$Id: cust_pkg.pm,v 1.12 2001-10-22 08:29:42 ivan Exp $ =head1 BUGS @@ -582,10 +606,13 @@ cancel } because they use %FS::UID::callback to load configuration values. Probably need a subroutine which decides what to do based on whether or not we've fetched the user yet, rather than a hash. See FS::UID and the TODO. +Now that things are transactional should the check in the insert method be +moved to check ? + =head1 SEE ALSO -L, L, L, L -, L, schema.html from the base documentation +L, L, L, L, +L, schema.html from the base documentation =cut