summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Cron/bill.pm2
-rw-r--r--FS/FS/Mason.pm1
-rw-r--r--FS/FS/cust_statement.pm37
-rw-r--r--FS/FS/part_event/Action/cust_statement.pm5
-rw-r--r--FS/FS/part_event/Action/cust_statement_send.pm2
-rw-r--r--FS/FS/part_event/Condition/has_pkg_class.pm40
-rw-r--r--FS/FS/part_event/Condition/has_pkgpart.pm41
-rw-r--r--FS/FS/part_event/Condition/hasnt_pkgpart.pm40
8 files changed, 156 insertions, 12 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 2bdb12025..d727d923d 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -194,7 +194,7 @@ END
my $where = FS::part_event_condition->where_conditions_sql( $eventtable,
'time'=>$time,
);
- my $where = "AND $where" if $where;
+ $where = $where ? "AND $where" : '';
my $are_part_event =
"EXISTS ( SELECT 1 FROM part_event $join
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index d73d3810a..f71db208e 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -197,6 +197,7 @@ Initializes the Mason environment, loads all Freeside and RT libraries, etc.
use FS::h_svc_phone;
#use FS::h_phone_device;
use FS::h_svc_www;
+ use FS::cust_statement;
# Sammath Naur
if ( %%%RT_ENABLED%%% ) {
diff --git a/FS/FS/cust_statement.pm b/FS/FS/cust_statement.pm
index cd3e7cec8..83dd5c1be 100644
--- a/FS/FS/cust_statement.pm
+++ b/FS/FS/cust_statement.pm
@@ -180,6 +180,18 @@ sub _aggregate {
@agg;
}
+sub _total {
+ my( $self, $method ) = ( shift, shift );
+
+ my $total = 0;
+
+ foreach my $cust_bill ( $self->cust_bill ) {
+ $total += $cust_bill->$method( @_ );
+ }
+
+ $total;
+}
+
=item cust_bill_pkg
Returns the line items (see L<FS::cust_bill_pkg>) for all associated invoices.
@@ -221,20 +233,29 @@ sub cust_bill_pkg_pkgnum { shift->_aggregate('cust_bill_pkg_pkgnum', @_); }
=item tax
-Returns the tax amount (see L<FS::cust_bill_pkg>) for this invoice.
+Returns the total tax amount for all assoicated invoices.0
=cut
-sub tax {
- my $self = shift;
+=item charged
- my $total = 0;
+Returns the total amount charged for all associated invoices.
- foreach my $cust_bill ( $self->cust_bill ) {
- $total += $cust_bill->tax;
- }
+=cut
- $total;
+=item owed
+
+Returns the total amount owed for all associated invoices.
+
+=cut
+
+sub tax { shift->_total('tax', @_); }
+sub charged { shift->_total('charged', @_); }
+sub owed { shift->_total('owed', @_); }
+
+#don't show previous info
+sub previous {
+ ( 0 ); # 0, empty list
}
=back
diff --git a/FS/FS/part_event/Action/cust_statement.pm b/FS/FS/part_event/Action/cust_statement.pm
index 8d8f12770..2d9e8773c 100644
--- a/FS/FS/part_event/Action/cust_statement.pm
+++ b/FS/FS/part_event/Action/cust_statement.pm
@@ -11,8 +11,9 @@ sub description {
}
sub eventtable_hashref {
- { 'cust_main' => 1, };
- { 'cust_pkg' => 1, };
+ { 'cust_main' => 1,
+ 'cust_pkg' => 1,
+ };
}
sub default_weight {
diff --git a/FS/FS/part_event/Action/cust_statement_send.pm b/FS/FS/part_event/Action/cust_statement_send.pm
index 34f023e0c..74cc48ca8 100644
--- a/FS/FS/part_event/Action/cust_statement_send.pm
+++ b/FS/FS/part_event/Action/cust_statement_send.pm
@@ -19,7 +19,7 @@ sub default_weight {
sub do_action {
my( $self, $cust_statement ) = @_;
- $cust_statement->send;
+ $cust_statement->send( 'statement' ); #XXX configure
}
diff --git a/FS/FS/part_event/Condition/has_pkg_class.pm b/FS/FS/part_event/Condition/has_pkg_class.pm
new file mode 100644
index 000000000..59a3675c3
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_pkg_class.pm
@@ -0,0 +1,40 @@
+package FS::part_event::Condition::has_pkg_class;
+
+use strict;
+
+use base qw( FS::part_event::Condition );
+use FS::Record qw( qsearch );
+use FS::pkg_class;
+
+sub description {
+ 'Customer has uncancelled package with class';
+}
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+#something like this
+sub option_fields {
+ (
+ 'pkgclass' => { 'label' => 'Package Class',
+ 'type' => 'select-pkg_class',
+ 'multiple' => 1,
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ #XXX test
+ my $hashref = $self->option('pkgclass') || {};
+ grep $hashref->{ $_->part_pkg->classnum }, $cust_main->ncancelled_pkgs;
+}
+
+1;
diff --git a/FS/FS/part_event/Condition/has_pkgpart.pm b/FS/FS/part_event/Condition/has_pkgpart.pm
new file mode 100644
index 000000000..c54b7e256
--- /dev/null
+++ b/FS/FS/part_event/Condition/has_pkgpart.pm
@@ -0,0 +1,41 @@
+package FS::part_event::Condition::has_pkgpart;
+
+use strict;
+
+use base qw( FS::part_event::Condition );
+
+sub description { 'Customer has uncancelled package of specified definitions'; }
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+sub option_fields {
+ (
+ 'if_pkgpart' => { 'label' => 'Only packages: ',
+ 'type' => 'select-part_pkg',
+ 'multiple' => 1,
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ #XXX test
+ my $if_pkgpart = $self->option('if_pkgpart') || {};
+ grep $if_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
+
+}
+
+#XXX
+#sub condition_sql {
+#
+#}
+
+1;
diff --git a/FS/FS/part_event/Condition/hasnt_pkgpart.pm b/FS/FS/part_event/Condition/hasnt_pkgpart.pm
new file mode 100644
index 000000000..421d0232c
--- /dev/null
+++ b/FS/FS/part_event/Condition/hasnt_pkgpart.pm
@@ -0,0 +1,40 @@
+package FS::part_event::Condition::hasnt_pkgpart;
+
+use strict;
+
+use base qw( FS::part_event::Condition );
+
+sub description { 'Customer does not have uncancelled package of specified definitions'; }
+
+sub eventtable_hashref {
+ { 'cust_main' => 1,
+ 'cust_bill' => 1,
+ 'cust_pkg' => 1,
+ };
+}
+
+sub option_fields {
+ (
+ 'unless_pkgpart' => { 'label' => 'Packages: ',
+ 'type' => 'select-part_pkg',
+ 'multiple' => 1,
+ },
+ );
+}
+
+sub condition {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ #XXX test
+ my $unless_pkgpart = $self->option('unless_pkgpart') || {};
+ ! grep $unless_pkgpart->{ $_->pkgpart }, $cust_main->ncancelled_pkgs;
+}
+
+#XXX
+#sub condition_sql {
+#
+#}
+
+1;