X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_credit.pm;h=70d78749c63b121b1b8ed4e414bb5ede8e772c8e;hb=34f91089a0d54fa39d622ec5e03d9e09a50e9f79;hp=cbdc71db4147d1df815b4bd12a6f5694cb4c29b5;hpb=158a88620fa861dc473bf5501526fb1e9a9517dd;p=freeside.git diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index cbdc71db4..70d78749c 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -262,11 +262,14 @@ methods. sub check { my $self = shift; + $self->otaker(getotaker) unless ($self->otaker); + my $error = $self->ut_numbern('crednum') || $self->ut_number('custnum') || $self->ut_numbern('_date') || $self->ut_money('amount') + || $self->ut_alpha('otaker') || $self->ut_textn('reason') || $self->ut_foreign_key('reasonnum', 'reason', 'reasonnum') || $self->ut_enum('closed', [ '', 'Y' ]) @@ -280,8 +283,6 @@ sub check { $self->_date(time) unless $self->_date; - $self->otaker(getotaker) unless ($self->otaker); - $self->SUPER::check; } @@ -330,15 +331,15 @@ sub cust_credit_bill { ; } -=item credited +=item unapplied -Returns the amount of this credit that is still outstanding; which is +Returns the amount of this credit that is still unapplied/outstanding; amount minus all refund applications (see L) and applications to invoices (see L). =cut -sub credited { +sub unapplied { my $self = shift; my $amount = $self->amount; $amount -= $_->amount foreach ( $self->cust_credit_refund ); @@ -346,6 +347,18 @@ sub credited { sprintf( "%.2f", $amount ); } +=item credited + +Deprecated name for the unapplied method. + +=cut + +sub credited { + my $self = shift; + #carp "cust_credit->credited deprecated; use ->unapplied"; + $self->unapplied(@_); +} + =item cust_main Returns the customer (see L) for this credit. @@ -419,9 +432,9 @@ sub _upgrade_data { # class method warn "$me Checking for unmigrated reasons\n" if $DEBUG; - my @cust_credits = qsearch({ 'table' => $class->table, - 'hashref' => {}, - 'extrasql' => 'WHERE reason IS NOT NULL', + my @cust_credits = qsearch({ 'table' => $class->table, + 'hashref' => {}, + 'extra_sql' => 'WHERE reason IS NOT NULL', }); if (scalar(grep { $_->getfield('reason') =~ /\S/ } @cust_credits)) { @@ -480,8 +493,7 @@ sub _upgrade_data { # class method die "$class had error inserting FS::reason_type into database: $error\n" if $error; } - # or clause for 1.7.x - $conf->set($_, $reason_type->typenum) or die "failed setting config"; + $conf->set($_, $reason_type->typenum); } } @@ -527,13 +539,13 @@ sub _upgrade_data { # class method =over 4 -=item credited_sql +=item unapplied_sql Returns an SQL fragment to retreive the unapplied amount. =cut -sub credited_sql { +sub unapplied_sql { #my $class = shift; "amount @@ -551,14 +563,29 @@ sub credited_sql { } +=item credited_sql + +Deprecated name for the unapplied_sql method. + +=cut + +sub credited_sql { + #my $class = shift; + + #carp "cust_credit->credited_sql deprecated; use ->unapplied_sql"; + + #$class->unapplied_sql(@_); + unapplied_sql(); +} + =back =head1 BUGS The delete method. The replace method. -B and B should probably be called B and -B. +B and B are now called B and +B. The old method names should start to give warnings. =head1 SEE ALSO