X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_void.pm;h=1f8119721d174aa99c3d0f2be8c729c956934313;hb=8b1320ce3eca72830fe8b138f07b22968e349f96;hp=cce77b3aa7376a0fa6e428d28f5705aafbd733a1;hpb=24b3cded842823df810e6bee6ef66237c783f033;p=freeside.git diff --git a/FS/FS/cust_bill_void.pm b/FS/FS/cust_bill_void.pm index cce77b3aa..1f8119721 100644 --- a/FS/FS/cust_bill_void.pm +++ b/FS/FS/cust_bill_void.pm @@ -266,6 +266,71 @@ sub cust_bill_pkg { #actually cust_bill_pkg_void objects =back +=item cust_pkg + +Returns the packages (see L) corresponding to the line items for +this invoice. + +=cut + +sub cust_pkg { + my $self = shift; + my @cust_pkg = map { $_->pkgnum > 0 ? $_->cust_pkg : () } + $self->cust_bill_pkg; + my %saw = (); + grep { ! $saw{$_->pkgnum}++ } @cust_pkg; +} + +=item search_sql_where HASHREF + +Class method which returns an SQL WHERE fragment to search for parameters +specified in HASHREF. Accepts the following parameters for +L: C<_date>, C, C, +C, C, C, C, C. Also +accepts the following: + +=over 4 + +=item void_date + +Arrayref of start and end date to find invoices voided in a date range. + +=item void_usernum + +User identifier (L key) that voided the invoice. + +=back + +=cut + +sub search_sql_where { + my($class, $param) = @_; + + my $cust_bill_param = { + map { $_ => $param->{$_} } + grep { exists($param->{$_}) } + qw( _date invnum_min invnum_max agentnum custnum cust_classnum + refnum payby ) + }; + my $search_sql = FS::cust_bill->search_sql_where($cust_bill_param); + $search_sql =~ s/cust_bill/cust_bill_void/g; + my @search = ($search_sql); + + if ( $param->{void_date} ) { + my($beginning, $ending) = @{$param->{void_date}}; + push @search, "cust_bill_void.void_date >= $beginning", + "cust_bill_void.void_date < $ending"; + } + + if ( $param->{void_usernum} =~ /^(\d+)$/ ) { + my $usernum = $1; + push @search, "cust_bill_void.void_usernum = $1"; + } + + join(" AND ", @search); +} + + =item enable_previous =cut