X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg_discount.pm;h=9fc618cab059288502a8cde52bff79b6f9131c1c;hb=1bfbab83c338f6a11ae26c4d197ad775c568ebde;hp=76118ad9211e5fc5e09ae171cffa4a9d9935c096;hpb=0fcdc36642e1430f02ebf5326740e231883bd41f;p=freeside.git diff --git a/FS/FS/cust_pkg_discount.pm b/FS/FS/cust_pkg_discount.pm index 76118ad92..9fc618cab 100644 --- a/FS/FS/cust_pkg_discount.pm +++ b/FS/FS/cust_pkg_discount.pm @@ -2,7 +2,7 @@ package FS::cust_pkg_discount; use strict; use base qw( FS::Record ); -use FS::Record; # qw( qsearch qsearchs ); +use FS::Record qw( qsearchs ); # qsearch ); use FS::cust_pkg; use FS::discount; @@ -131,6 +131,42 @@ sub check { $self->SUPER::check; } +=item cust_pkg + +Returns the customer package (see L). + +=cut + +sub cust_pkg { + my $self = shift; + qsearchs('cust_pkg', { 'pkgnum' => $self->pkgnum } ); +} + +=item discount + +Returns the discount (see L). + +=cut + +sub discount { + my $self = shift; + qsearchs('discount', { 'discountnum' => $self->discountnum } ); +} + +=item increment_months_used + +Increments months_used by the given parameter + +=cut + +sub increment_months_used { + my( $self, $used ) = @_; + #UPDATE cust_pkg_discount SET months_used = months_used + ? + #leaves no history, and billing is mutexed per-customer, so the dum way is ok + $self->months_used( $self->months_used + $used ); + $self->replace(); +} + =back =head1 BUGS