}
$cust_pkg->locationnum($opt->{'cust_location'}->locationnum);
- } else {
+ } elsif ( ! $cust_pkg->locationnum ) {
$cust_pkg->locationnum($self->ship_locationnum);
=cut
+#recurring_pkgs? different from cust_pkg idea of "active" which has
+# a setup vs not_yet_billed which doesn't
sub active_pkgs {
my $self = shift;
grep { my $part_pkg = $_->part_pkg;
=cut
+#ncancelled_recurring_pkgs? different from cust_pkg idea of "active" which has
+# a setup vs not_yet_billed which doesn't
sub ncancelled_active_pkgs {
my $self = shift;
grep { my $part_pkg = $_->part_pkg;
$self->num_pkgs($opt);
}
+=item num_ncancelled_pkgs
+
+Returns the number of packages that have not been cancelled (see L<FS::cust_pkg>) for this
+customer.
+
+=cut
+
sub num_ncancelled_pkgs {
my $self = shift;
my $opt = shift || {};
$self->num_pkgs($opt);
}
+=item num_billing_pkgs
+
+Returns the number of packages that have not been cancelled
+and have a non-zero billing frequency (see L<FS::cust_pkg>)
+for this customer.
+
+=cut
+
+sub num_billing_pkgs {
+ my $self = shift;
+ my $opt = shift || {};
+ $opt->{addl_from} .= ' LEFT JOIN part_pkg USING (pkgpart)';
+ $opt->{extra_sql} .= ' AND ' if $opt->{extra_sql};
+ $opt->{extra_sql} .= "freq IS NOT NULL AND freq != '0'";
+ $self->num_ncancelled_pkgs($opt);
+}
+
sub num_suspended_pkgs {
my $self = shift;
my $opt = shift || {};
my $discount = $cust_pkg_discount->discount;
#and only one of these for each
$pkg_amount -= $discount->amount;
- $pkg_amount -= $amount * $discount->percent/100;
+ $pkg_amount -= $pkg_amount * $discount->percent/100;
}
$pkg_amount *= ( $cust_pkg->quantity || 1 );