summaryrefslogtreecommitdiff
path: root/FS/FS/part_event
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/part_event')
-rw-r--r--FS/FS/part_event/Action.pm240
-rw-r--r--FS/FS/part_event/Action/Mixin/credit_pkg.pm63
-rw-r--r--FS/FS/part_event/Action/addpost.pm20
-rw-r--r--FS/FS/part_event/Action/apply.pm24
-rw-r--r--FS/FS/part_event/Action/bill.pm26
-rw-r--r--FS/FS/part_event/Action/cancel.pm30
-rw-r--r--FS/FS/part_event/Action/collect.pm26
-rw-r--r--FS/FS/part_event/Action/cust_bill_batch.pm25
-rw-r--r--FS/FS/part_event/Action/cust_bill_comp.pm28
-rw-r--r--FS/FS/part_event/Action/cust_bill_email.pm23
-rw-r--r--FS/FS/part_event/Action/cust_bill_fee_percent.pm28
-rw-r--r--FS/FS/part_event/Action/cust_bill_realtime_card.pm28
-rw-r--r--FS/FS/part_event/Action/cust_bill_realtime_check.pm28
-rw-r--r--FS/FS/part_event/Action/cust_bill_realtime_lec.pm28
-rw-r--r--FS/FS/part_event/Action/cust_bill_send.pm20
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_agent.pm42
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_alternate.pm31
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm50
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_if_newest.pm38
-rw-r--r--FS/FS/part_event/Action/cust_bill_send_reminder.pm31
-rw-r--r--FS/FS/part_event/Action/cust_bill_spool_csv.pm59
-rw-r--r--FS/FS/part_event/Action/cust_bill_suspend_if_balance.pm42
-rw-r--r--FS/FS/part_event/Action/cust_statement.pm39
-rw-r--r--FS/FS/part_event/Action/cust_statement_send.pm26
-rw-r--r--FS/FS/part_event/Action/fee.pm58
-rw-r--r--FS/FS/part_event/Action/notice.pm47
-rw-r--r--FS/FS/part_event/Action/notice_to.pm55
-rw-r--r--FS/FS/part_event/Action/pkg_agent_credit.pm39
-rw-r--r--FS/FS/part_event/Action/pkg_agent_credit_pkg.pm9
-rw-r--r--FS/FS/part_event/Action/pkg_cancel.pm32
-rw-r--r--FS/FS/part_event/Action/pkg_employee_credit.pm39
-rw-r--r--FS/FS/part_event/Action/pkg_employee_credit_pkg.pm9
-rw-r--r--FS/FS/part_event/Action/pkg_referral_credit.pm62
-rw-r--r--FS/FS/part_event/Action/pkg_referral_credit_pkg.pm9
-rw-r--r--FS/FS/part_event/Action/suspend.pm32
-rw-r--r--FS/FS/part_event/Action/suspend_if_pkgpart.pm40
-rw-r--r--FS/FS/part_event/Action/suspend_unless_pkgpart.pm40
-rw-r--r--FS/FS/part_event/Action/writeoff.pm33
-rw-r--r--FS/FS/part_event/Condition.pm470
-rw-r--r--FS/FS/part_event/Condition/agent.pm37
-rw-r--r--FS/FS/part_event/Condition/agent_type.pm40
-rw-r--r--FS/FS/part_event/Condition/balance.pm48
-rw-r--r--FS/FS/part_event/Condition/balance_age.pm52
-rw-r--r--FS/FS/part_event/Condition/balance_credit_limit.pm32
-rw-r--r--FS/FS/part_event/Condition/balance_under.pm42
-rw-r--r--FS/FS/part_event/Condition/cust_bill_age.pm46
-rw-r--r--FS/FS/part_event/Condition/cust_bill_has_noauto.pm33
-rw-r--r--FS/FS/part_event/Condition/cust_bill_has_service.pm56
-rw-r--r--FS/FS/part_event/Condition/cust_bill_hasnt_noauto.pm33
-rw-r--r--FS/FS/part_event/Condition/cust_bill_owed.pm54
-rw-r--r--FS/FS/part_event/Condition/cust_bill_owed_under.pm49
-rw-r--r--FS/FS/part_event/Condition/cust_bill_past_due.pm41
-rw-r--r--FS/FS/part_event/Condition/cust_pay_batch_declined.pm51
-rw-r--r--FS/FS/part_event/Condition/cust_payments.pm43
-rw-r--r--FS/FS/part_event/Condition/cust_payments_pkg.pm68
-rw-r--r--FS/FS/part_event/Condition/cust_status.pm40
-rw-r--r--FS/FS/part_event/Condition/dundate.pm26
-rw-r--r--FS/FS/part_event/Condition/every.pm67
-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/has_referral_custnum.pm50
-rw-r--r--FS/FS/part_event/Condition/hasnt_pkgpart.pm40
-rw-r--r--FS/FS/part_event/Condition/once.pm55
-rw-r--r--FS/FS/part_event/Condition/once_every.pm46
-rw-r--r--FS/FS/part_event/Condition/once_percust.pm67
-rw-r--r--FS/FS/part_event/Condition/once_perinv.pm57
-rw-r--r--FS/FS/part_event/Condition/payby.pm44
-rw-r--r--FS/FS/part_event/Condition/pkg_age.pm66
-rw-r--r--FS/FS/part_event/Condition/pkg_class.pm38
-rw-r--r--FS/FS/part_event/Condition/pkg_freq.pm36
-rw-r--r--FS/FS/part_event/Condition/pkg_next_bill_within.pm51
-rw-r--r--FS/FS/part_event/Condition/pkg_notchange.pm31
-rw-r--r--FS/FS/part_event/Condition/pkg_pkgpart.pm39
-rw-r--r--FS/FS/part_event/Condition/pkg_recurring.pm28
-rw-r--r--FS/FS/part_event/Condition/pkg_status.pm44
-rw-r--r--FS/FS/part_event/Condition/pkg_unless_pkgpart.pm39
76 files changed, 0 insertions, 3639 deletions
diff --git a/FS/FS/part_event/Action.pm b/FS/FS/part_event/Action.pm
deleted file mode 100644
index 45219a3..0000000
--- a/FS/FS/part_event/Action.pm
+++ /dev/null
@@ -1,240 +0,0 @@
-package FS::part_event::Action;
-
-use strict;
-use base qw( FS::part_event );
-use Tie::IxHash;
-
-=head1 NAME
-
-FS::part_event::Action - Base class for event actions
-
-=head1 SYNOPSIS
-
-package FS::part_event::Action::myaction;
-
-use base FS::part_event::Action;
-
-=head1 DESCRIPTION
-
-FS::part_event::Action is a base class for event action classes.
-
-=head1 METHODS
-
-These methods are implemented in each action class.
-
-=over 4
-
-=item description
-
-Action classes must define a description method. This method should return a
-scalar description of the action.
-
-=item eventtable_hashref
-
-Action classes must define a eventtable_hashref method if they can only be
-triggered against some kinds of tables. This method should return a hash
-reference of eventtables (values set true indicate the action can be performed):
-
- sub eventtable_hashref {
- { 'cust_main' => 1,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- 'cust_pay_batch' => 0,
- };
- }
-
-=cut
-
-#fallback
-sub eventtable_hashref {
- { 'cust_main' => 1,
- 'cust_bill' => 1,
- 'cust_pkg' => 1,
- 'cust_pay_batch' => 1,
- };
-}
-
-=item event_stage
-
-Action classes may define an event_stage method to indicate a preference
-for being run at a non-standard stage of the billing and collection process.
-
-This method may currently return "collect" (the default) or "pre-bill".
-
-=cut
-
-sub event_stage {
- 'collect';
-}
-
-=item option_fields
-
-Action classes may define an option_fields method to indicate that they
-accept one or more options.
-
-This method should return a list of option names and option descriptions.
-Each option description can be a scalar description, for simple options, or a
-hashref with the following values:
-
-=over 4
-
-=item label - Description
-
-=item type - Currently text, money, checkbox, checkbox-multiple, select, select-agent, select-pkg_class, select-part_referral, select-table, fixed, hidden, (others can be implemented as httemplate/elements/tr-TYPE.html mason components). Defaults to text.
-
-=item size - Size for text fields
-
-=item options - For checkbox-multiple and select, a list reference of available option values.
-
-=item option_labels - For select, a hash reference of availble option values and labels.
-
-=item value - for checkbox, fixed, hidden
-
-=item table - for select-table
-
-=item name_col - for select-table
-
-=item NOTE: See httemplate/elements/select-table.html for a full list of the optinal options for the select-table type
-
-=back
-
-NOTE: A database connection is B<not> yet available when this subroutine is
-executed.
-
-Example:
-
- sub option_fields {
- (
- 'field' => 'description',
-
- 'another_field' => { 'label'=>'Amount', 'type'=>'money', },
-
- 'third_field' => { 'label' => 'Types',
- 'type' => 'select',
- 'options' => [ 'h', 's' ],
- 'option_labels' => { 'h' => 'Happy',
- 's' => 'Sad',
- },
- );
- }
-
-=cut
-
-#fallback
-sub option_fields {
- ();
-}
-
-=item default_weight
-
-Action classes may define a default weighting. Weights control execution order
-relative to other actions (that are triggered at the same time).
-
-=cut
-
-#fallback
-sub default_weight {
- 100;
-}
-
-=item deprecated
-
-Action classes may define a deprecated method that returns true, indicating
-that this action is deprecated.
-
-=cut
-
-#default
-sub deprecated {
- 0;
-}
-
-=item do_action CUSTOMER_EVENT_OBJECT
-
-Action classes must define an action method. This method is triggered if
-all conditions have been met.
-
-The object which triggered the event (an FS::cust_main, FS::cust_bill or
-FS::cust_pkg object) is passed as an argument.
-
-To retreive option values, call the option method on the desired option, i.e.:
-
- my( $self, $cust_object ) = @_;
- $value_of_field = $self->option('field');
-
-To indicate sucessful completion, simply return. Optionally, you can return a
-string of information status information about the sucessful completion, or
-simply return the empty string.
-
-To indicate a failure and that this event should retry, die with the desired
-error message.
-
-=back
-
-=head1 BASE METHODS
-
-These methods are defined in the base class for use in action classes.
-
-=over 4
-
-=item cust_main CUST_OBJECT
-
-Return the customer object (see L<FS::cust_main>) associated with the provided
-object (the object itself if it is already a customer object).
-
-=cut
-
-sub cust_main {
- my( $self, $cust_object ) = @_;
-
- $cust_object->isa('FS::cust_main') ? $cust_object : $cust_object->cust_main;
-
-}
-
-=item option_label OPTIONNAME
-
-Returns the label for the specified option name.
-
-=cut
-
-sub option_label {
- my( $self, $optionname ) = @_;
-
- my %option_fields = $self->option_fields;
-
- ref( $option_fields{$optionname} )
- ? $option_fields{$optionname}->{'label'}
- : $option_fields{$optionname}
- or $optionname;
-}
-
-=item option_fields_hashref
-
-Returns the option fields as an (ordered) hash reference.
-
-=cut
-
-sub option_fields_hashref {
- my $self = shift;
- tie my %hash, 'Tie::IxHash', $self->option_fields;
- \%hash;
-}
-
-=item option_fields_listref
-
-Returns just the option field names as a list reference.
-
-=cut
-
-sub option_fields_listref {
- my $self = shift;
- my $hashref = $self->option_fields_hashref;
- [ keys %$hashref ];
-}
-
-=back
-
-=cut
-
-1;
-
diff --git a/FS/FS/part_event/Action/Mixin/credit_pkg.pm b/FS/FS/part_event/Action/Mixin/credit_pkg.pm
deleted file mode 100644
index aeda92f..0000000
--- a/FS/FS/part_event/Action/Mixin/credit_pkg.pm
+++ /dev/null
@@ -1,63 +0,0 @@
-package FS::part_event::Action::Mixin::credit_pkg;
-
-use strict;
-
-sub eventtable_hashref {
- { 'cust_pkg' => 1 };
-}
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Credit reason',
- 'type' => 'select-reason',
- 'reason_class' => 'R',
- },
- 'percent' => { 'label' => 'Percent',
- 'type' => 'input-percentage',
- 'default' => '100',
- },
- 'what' => { 'label' => 'Of',
- 'type' => 'select',
- #add additional ways to specify in the package def
- 'options' => [ qw( base_recur_permonth unit_setup recur_cost_permonth setup_cost ) ],
- 'labels' => { 'base_recur_permonth' => 'Base monthly fee',
- 'unit_setup' => 'Setup fee',
- 'recur_cost_permonth' => 'Monthly cost',
- 'setup_cost' => 'Setup cost',
- },
- },
- );
-
-}
-
-#my %no_cust_pkg = ( 'setup_cost' => 1 );
-
-sub _calc_credit {
- my( $self, $cust_pkg ) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- my $what = $self->option('what');
-
- #false laziness w/Condition/cust_payments_pkg.pm
- if ( $what =~ /_permonth$/ ) { #huh. yuck.
- if ( $part_pkg->freq !~ /^\d+$/ ) {
- die 'WARNING: Not crediting for package '. $cust_pkg->pkgnum.
- ' ( customer '. $cust_pkg->custnum. ')'.
- ' - credits not (yet) available for '.
- ' packages with '. $part_pkg->freq_pretty. ' frequency';
- }
- }
-
- my $percent = $self->option('percent');
-
- #my @arg = $no_cust_pkg{$what} ? () : ($cust_pkg);
- my @arg = ($what eq 'setup_cost') ? () : ($cust_pkg);
-
- sprintf('%.2f', $part_pkg->$what(@arg) * $percent / 100 );
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/addpost.pm b/FS/FS/part_event/Action/addpost.pm
deleted file mode 100644
index f92e72e..0000000
--- a/FS/FS/part_event/Action/addpost.pm
+++ /dev/null
@@ -1,20 +0,0 @@
-package FS::part_event::Action::addpost;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Add postal invoicing'; }
-
-sub default_weight { 20; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- $cust_main->invoicing_list_addpost();
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/apply.pm b/FS/FS/part_event/Action/apply.pm
deleted file mode 100644
index 823d1e0..0000000
--- a/FS/FS/part_event/Action/apply.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-package FS::part_event::Action::apply;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- 'Apply unapplied payments and credits';
-}
-
-sub deprecated { 1; }
-
-sub default_weight { 70; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- $cust_main->apply_payments_and_credits;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/bill.pm b/FS/FS/part_event/Action/bill.pm
deleted file mode 100644
index b96614d..0000000
--- a/FS/FS/part_event/Action/bill.pm
+++ /dev/null
@@ -1,26 +0,0 @@
-package FS::part_event::Action::bill;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- #'Generate invoices (normally only used with a <i>Late Fee</i> event)';
- 'Generate invoices (normally only used with a Late Fee event)';
-}
-
-sub deprecated { 1; }
-
-sub default_weight { 60; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my $error = $cust_main->bill;
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cancel.pm b/FS/FS/part_event/Action/cancel.pm
deleted file mode 100644
index b93682b..0000000
--- a/FS/FS/part_event/Action/cancel.pm
+++ /dev/null
@@ -1,30 +0,0 @@
-package FS::part_event::Action::cancel;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Cancel all of this customer\'s packages'; }
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'C',
- },
- );
-}
-
-sub default_weight { 20; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my $error = $cust_main->cancel( 'reason' => $self->option('reasonnum') );
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/collect.pm b/FS/FS/part_event/Action/collect.pm
deleted file mode 100644
index 9881440..0000000
--- a/FS/FS/part_event/Action/collect.pm
+++ /dev/null
@@ -1,26 +0,0 @@
-package FS::part_event::Action::collect;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- #'Collect on invoices (normally only used with a <i>Late Fee</i> and <i>Generate Invoice</i> events)';
- 'Collect on invoices (normally only used with a Late Fee and Generate Invoice events)';
-}
-
-sub deprecated { 1; }
-
-sub default_weight { 80; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my $error = $cust_main->collect;
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_batch.pm b/FS/FS/part_event/Action/cust_bill_batch.pm
deleted file mode 100644
index 50c306a..0000000
--- a/FS/FS/part_event/Action/cust_bill_batch.pm
+++ /dev/null
@@ -1,25 +0,0 @@
-package FS::part_event::Action::cust_bill_batch;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Add card or check to a pending batch'; }
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 40; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->batch_card; # ( %options ); #XXX options??
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_comp.pm b/FS/FS/part_event/Action/cust_bill_comp.pm
deleted file mode 100644
index 76fd274..0000000
--- a/FS/FS/part_event/Action/cust_bill_comp.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Action::cust_bill_comp;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Pay invoice with a complimentary "payment"'; }
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 30; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- my $error = $cust_bill->comp;
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_email.pm b/FS/FS/part_event/Action/cust_bill_email.pm
deleted file mode 100644
index a5cd861..0000000
--- a/FS/FS/part_event/Action/cust_bill_email.pm
+++ /dev/null
@@ -1,23 +0,0 @@
-package FS::part_event::Action::cust_bill_email;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Send invoice (email only)'; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 51; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->email;
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_fee_percent.pm b/FS/FS/part_event/Action/cust_bill_fee_percent.pm
deleted file mode 100644
index 48daf15..0000000
--- a/FS/FS/part_event/Action/cust_bill_fee_percent.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Action::cust_bill_fee_percent;
-
-use strict;
-use base qw( FS::part_event::Action::fee );
-use Tie::IxHash;
-
-sub description { 'Late fee (percentage of invoice)'; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- my $class = shift;
-
- my $t = tie my %option_fields, 'Tie::IxHash', $class->SUPER::option_fields();
- $t->Shift; #assumes charge is first
- $t->Unshift( 'percent' => { label=>'Percent', size=>2, } );
-
- %option_fields;
-}
-
-sub _calc_fee {
- my( $self, $cust_bill ) = @_;
- sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 );
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_realtime_card.pm b/FS/FS/part_event/Action/cust_bill_realtime_card.pm
deleted file mode 100644
index c1fdba9..0000000
--- a/FS/FS/part_event/Action/cust_bill_realtime_card.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Action::cust_bill_realtime_card;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- #'Run card with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
- 'Run card with a Business::OnlinePayment realtime gateway';
-}
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 30; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->realtime_card;
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_realtime_check.pm b/FS/FS/part_event/Action/cust_bill_realtime_check.pm
deleted file mode 100644
index 11b13a9..0000000
--- a/FS/FS/part_event/Action/cust_bill_realtime_check.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Action::cust_bill_realtime_check;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- #'Run check with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
- 'Run check with a Business::OnlinePayment realtime gateway';
-}
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 30; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->realtime_ach;
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_realtime_lec.pm b/FS/FS/part_event/Action/cust_bill_realtime_lec.pm
deleted file mode 100644
index cd03ddc..0000000
--- a/FS/FS/part_event/Action/cust_bill_realtime_lec.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Action::cust_bill_realtime_lec;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- #'Run phone bill ("LEC") billing with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
- 'Run phone bill ("LEC") billing with a Business::OnlinePayment realtime gateway';
-}
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 30; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->realtime_lec;
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send.pm b/FS/FS/part_event/Action/cust_bill_send.pm
deleted file mode 100644
index 587a7c6..0000000
--- a/FS/FS/part_event/Action/cust_bill_send.pm
+++ /dev/null
@@ -1,20 +0,0 @@
-package FS::part_event::Action::cust_bill_send;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Send invoice (email/print/fax)'; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- $cust_bill->send;
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send_agent.pm b/FS/FS/part_event/Action/cust_bill_send_agent.pm
deleted file mode 100644
index 670a32c..0000000
--- a/FS/FS/part_event/Action/cust_bill_send_agent.pm
+++ /dev/null
@@ -1,42 +0,0 @@
-package FS::part_event::Action::cust_bill_send_agent;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- 'Send invoice (email/print/fax) with alternate template, for specific agents';
-}
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'agentnum' => { label => 'Only for agent(s)',
- type => 'select-agent',
- multiple => 1
- },
- 'agent_templatename' => { label => 'Template',
- type => 'select-invoice_template',
- },
- 'agent_invoice_from' => 'Invoice email From: address',
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->send(
- $self->option('agent_templatename'),
- [ split(/\s*,\s*/, $self->option('agentnum') ) ],
- $self->option('agent_invoice_from'),
- );
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send_alternate.pm b/FS/FS/part_event/Action/cust_bill_send_alternate.pm
deleted file mode 100644
index cfd9264..0000000
--- a/FS/FS/part_event/Action/cust_bill_send_alternate.pm
+++ /dev/null
@@ -1,31 +0,0 @@
-package FS::part_event::Action::cust_bill_send_alternate;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Send invoice (email/print/fax) with alternate template'; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'templatename' => { label => 'Template',
- type => 'select-invoice_template',
- },
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->send( $self->option('templatename') );
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm b/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm
deleted file mode 100644
index bf47268..0000000
--- a/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm
+++ /dev/null
@@ -1,50 +0,0 @@
-package FS::part_event::Action::cust_bill_send_csv_ftp;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Upload CSV invoice data to an FTP server'; }
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'ftpformat' => { label => 'Format',
- type =>'select',
- options => ['default', 'billco'],
- option_labels => { 'default' => 'Default',
- 'billco' => 'Billco',
- },
- },
- 'ftpserver' => 'FTP server',
- 'ftpusername' => 'FTP username',
- 'ftppassword' => 'FTP password',
- 'ftpdir' => 'FTP directory',
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->send_csv(
- 'protocol' => 'ftp',
- 'server' => $self->option('ftpserver'),
- 'username' => $self->option('ftpusername'),
- 'password' => $self->option('ftppassword'),
- 'dir' => $self->option('ftpdir'),
- 'format' => $self->option('ftpformat'),
- );
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send_if_newest.pm b/FS/FS/part_event/Action/cust_bill_send_if_newest.pm
deleted file mode 100644
index 083da8b..0000000
--- a/FS/FS/part_event/Action/cust_bill_send_if_newest.pm
+++ /dev/null
@@ -1,38 +0,0 @@
-package FS::part_event::Action::cust_bill_send_if_newest;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description {
- 'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)';
-}
-
-# XXX is this handled better by something against customers??
-#sub deprecated {
-# 1;
-#}
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'if_newest_templatename' => { label => 'Template',
- type => 'select-invoice_template',
- },
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->send( $self->option('templatename') );
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_send_reminder.pm b/FS/FS/part_event/Action/cust_bill_send_reminder.pm
deleted file mode 100644
index 2ba8136..0000000
--- a/FS/FS/part_event/Action/cust_bill_send_reminder.pm
+++ /dev/null
@@ -1,31 +0,0 @@
-package FS::part_event::Action::cust_bill_send_reminder;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Send invoice (email/print/fax) reminder'; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'notice_name' => 'Reminder name',
- #'notes' => { 'label' => 'Reminder notes' },
- #include standard notes? no/prepend/append
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- #my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->send({ 'notice_name' => $self->option('notice_name') });
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_spool_csv.pm b/FS/FS/part_event/Action/cust_bill_spool_csv.pm
deleted file mode 100644
index 43d2300..0000000
--- a/FS/FS/part_event/Action/cust_bill_spool_csv.pm
+++ /dev/null
@@ -1,59 +0,0 @@
-package FS::part_event::Action::cust_bill_spool_csv;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Spool CSV invoice data'; }
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'spoolformat' => { label => 'Format',
- type => 'select',
- options => ['default', 'billco'],
- option_labels => { 'default' => 'Default',
- 'billco' => 'Billco',
- },
- },
- 'spooldest' => { label => 'For destination',
- type => 'select',
- options => [ '', qw( POST EMAIL FAX ) ],
- option_labels => { '' => '(all)',
- 'POST' => 'Postal Mail',
- 'EMAIL' => 'Email',
- 'FAX' => 'Fax',
- },
- },
- 'spoolbalanceover' => { label =>
- 'If balance (this invoice and previous) over',
- type => 'money',
- },
- 'spoolagent_spools' => { label => 'Individual per-agent spools',
- type => 'checkbox',
- value => '1',
- },
- );
-}
-
-sub default_weight { 50; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- $cust_bill->spool_csv(
- 'format' => $self->option('spoolformat'),
- 'dest' => $self->option('spooldest'),
- 'balanceover' => $self->option('spoolbalanceover'),
- 'agent_spools' => $self->option('spoolagent_spools'),
- );
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_bill_suspend_if_balance.pm b/FS/FS/part_event/Action/cust_bill_suspend_if_balance.pm
deleted file mode 100644
index 13188ab..0000000
--- a/FS/FS/part_event/Action/cust_bill_suspend_if_balance.pm
+++ /dev/null
@@ -1,42 +0,0 @@
-package FS::part_event::Action::cust_bill_suspend_if_balance;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Suspend if balance (this invoice and previous) over'; }
-
-sub deprecated { 1; }
-
-sub eventtable_hashref {
- { 'cust_bill' => 1 };
-}
-
-sub option_fields {
- (
- 'balanceover' => { label=>'Balance over', type=>'money', }, # size=>7 },
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'S',
- },
- );
-}
-
-sub default_weight { 10; }
-
-sub do_action {
- my( $self, $cust_bill ) = @_;
-
- #my $cust_main = $self->cust_main($cust_bill);
- my $cust_main = $cust_bill->cust_main;
-
- my @err = $cust_bill->cust_suspend_if_balance_over(
- $self->option('balanceover'),
- 'reason' => $self->option('reasonnum'),
- );
-
- die join(' / ', @err) if scalar(@err);
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_statement.pm b/FS/FS/part_event/Action/cust_statement.pm
deleted file mode 100644
index 2d9e877..0000000
--- a/FS/FS/part_event/Action/cust_statement.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package FS::part_event::Action::cust_statement;
-
-use strict;
-
-use base qw( FS::part_event::Action );
-
-use FS::cust_statement;
-
-sub description {
- 'Group invoices into an informational statement.';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 1,
- 'cust_pkg' => 1,
- };
-}
-
-sub default_weight {
- 90;
-}
-
-sub do_action {
- my( $self, $cust_main ) = @_;
-
- #my( $self, $object ) = @_;
- #my $cust_main = $self->cust_main($object);
-
- my $cust_statement = new FS::cust_statement {
- 'custnum' => $cust_main->custnum
- };
- my $error = $cust_statement->insert;
- die $error if $error;
-
- '';
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/cust_statement_send.pm b/FS/FS/part_event/Action/cust_statement_send.pm
deleted file mode 100644
index 74cc48c..0000000
--- a/FS/FS/part_event/Action/cust_statement_send.pm
+++ /dev/null
@@ -1,26 +0,0 @@
-package FS::part_event::Action::cust_statement_send;
-
-use strict;
-
-use base qw( FS::part_event::Action );
-
-sub description {
- 'Send statement (email/print/fax)';
-}
-
-sub eventtable_hashref {
- { 'cust_statement' => 1, };
-}
-
-sub default_weight {
- 95;
-}
-
-sub do_action {
- my( $self, $cust_statement ) = @_;
-
- $cust_statement->send( 'statement' ); #XXX configure
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/fee.pm b/FS/FS/part_event/Action/fee.pm
deleted file mode 100644
index 68288d0..0000000
--- a/FS/FS/part_event/Action/fee.pm
+++ /dev/null
@@ -1,58 +0,0 @@
-package FS::part_event::Action::fee;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Late fee (flat)'; }
-
-sub event_stage { 'pre-bill'; }
-
-sub option_fields {
- (
- 'charge' => { label=>'Amount', type=>'money', }, # size=>7, },
- 'reason' => 'Reason (invoice line item)',
- 'classnum' => { label=>'Package class' => type=>'select-pkg_class', },
- 'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
- 'setuptax' => { label=>'Late fee is tax exempt',
- type=>'checkbox', value=>'Y' },
- 'nextbill' => { label=>'Hold late fee until next invoice',
- type=>'checkbox', value=>'Y' },
- );
-}
-
-sub default_weight { 10; }
-
-sub _calc_fee {
- #my( $self, $cust_object ) = @_;
- my $self = shift;
- $self->option('charge');
-}
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my $conf = new FS::Conf;
-
- my %charge = (
- 'amount' => $self->_calc_fee($cust_object),
- 'pkg' => $self->option('reason'),
- 'taxclass' => $self->option('taxclass'),
- 'classnum' => ( $self->option('classnum')
- || scalar($conf->config('finance_pkgclass')) ),
- 'setuptax' => $self->option('setuptax'),
- );
-
- #unless its more than N months away?
- $charge{'start_date'} = $cust_main->next_bill_date
- if $self->option('nextbill');
-
- my $error = $cust_main->charge( \%charge );
-
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/notice.pm b/FS/FS/part_event/Action/notice.pm
deleted file mode 100644
index 8e22c68..0000000
--- a/FS/FS/part_event/Action/notice.pm
+++ /dev/null
@@ -1,47 +0,0 @@
-package FS::part_event::Action::notice;
-
-use strict;
-use base qw( FS::part_event::Action );
-use FS::Record qw( qsearchs );
-use FS::msg_template;
-
-sub description { 'Email a notice to the customer\'s billing address'; }
-
-#sub eventtable_hashref {
-# { 'cust_main' => 1,
-# 'cust_bill' => 1,
-# 'cust_pkg' => 1,
-# };
-#}
-
-sub option_fields {
- (
- 'msgnum' => { 'label' => 'Template',
- 'type' => 'select-table',
- 'table' => 'msg_template',
- 'name_col' => 'msgname',
- 'disable_empty' => 1,
- },
- );
-}
-
-sub default_weight { 55; } #?
-
-sub do_action {
- my( $self, $object ) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $msgnum = $self->option('msgnum');
-
- my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
- or die "Template $msgnum not found";
-
- $msg_template->send(
- 'cust_main' => $cust_main,
- 'object' => $object,
- );
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/notice_to.pm b/FS/FS/part_event/Action/notice_to.pm
deleted file mode 100644
index 194aeb8..0000000
--- a/FS/FS/part_event/Action/notice_to.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-package FS::part_event::Action::notice_to;
-
-use strict;
-use base qw( FS::part_event::Action );
-use FS::Record qw( qsearchs );
-use FS::msg_template;
-
-sub description { 'Email a notice to a specific address'; }
-
-#sub eventtable_hashref {
-# { 'cust_main' => 1,
-# 'cust_bill' => 1,
-# 'cust_pkg' => 1,
-# };
-#}
-
-sub option_fields {
- (
- 'to' => { 'label' => 'Destination',
- 'type' => 'text',
- 'size' => 30,
- },
- 'msgnum' => { 'label' => 'Template',
- 'type' => 'select-table',
- 'table' => 'msg_template',
- 'name_col' => 'msgname',
- 'disable_empty' => 1,
- },
- );
-}
-
-sub default_weight { 56; } #?
-
-sub do_action {
- my( $self, $object ) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $msgnum = $self->option('msgnum');
-
- my $msg_template = qsearchs('msg_template', { 'msgnum' => $msgnum } )
- or die "Template $msgnum not found";
-
- my $to = $self->option('to')
- or die "Can't send notice without a destination address";
-
- $msg_template->send(
- 'to' => $to,
- 'cust_main' => $cust_main,
- 'object' => $object,
- );
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_agent_credit.pm b/FS/FS/part_event/Action/pkg_agent_credit.pm
deleted file mode 100644
index 4bcee98..0000000
--- a/FS/FS/part_event/Action/pkg_agent_credit.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package FS::part_event::Action::pkg_agent_credit;
-
-use strict;
-use base qw( FS::part_event::Action::pkg_referral_credit );
-
-sub description { 'Credit the agent a specific amount'; }
-
-#a little false laziness w/pkg_referral_credit
-sub do_action {
- my( $self, $cust_pkg, $cust_event ) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
- my $agent = $cust_main->agent;
- return "No customer record for agent ". $agent->agent
- unless $agent->agent_custnum;
-
- my $agent_cust_main = $agent->agent_cust_main;
- #? or return "No customer record for agent ". $agent->agent;
-
- my $amount = $self->_calc_credit($cust_pkg);
- return '' unless $amount > 0;
-
- my $reasonnum = $self->option('reasonnum');
-
- my $error = $agent_cust_main->credit(
- $amount,
- \$reasonnum,
- 'eventnum' => $cust_event->eventnum,
- 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
- ': '.$cust_main->name,
- );
- die "Error crediting customer ". $agent_cust_main->custnum.
- " for agent commission: $error"
- if $error;
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_agent_credit_pkg.pm b/FS/FS/part_event/Action/pkg_agent_credit_pkg.pm
deleted file mode 100644
index b3e1181..0000000
--- a/FS/FS/part_event/Action/pkg_agent_credit_pkg.pm
+++ /dev/null
@@ -1,9 +0,0 @@
-package FS::part_event::Action::pkg_agent_credit_pkg;
-
-use strict;
-use base qw( FS::part_event::Action::Mixin::credit_pkg
- FS::part_event::Action::pkg_agent_credit );
-
-sub description { 'Credit the agent an amount based on the referred package'; }
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_cancel.pm b/FS/FS/part_event/Action/pkg_cancel.pm
deleted file mode 100644
index 2bfd35c..0000000
--- a/FS/FS/part_event/Action/pkg_cancel.pm
+++ /dev/null
@@ -1,32 +0,0 @@
-package FS::part_event::Action::pkg_cancel;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Cancel this package'; }
-
-sub eventtable_hashref {
- { 'cust_pkg' => 1 };
-}
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'C',
- },
- );
-}
-
-sub default_weight { 20; }
-
-sub do_action {
- my( $self, $cust_pkg, $cust_event ) = @_;
-
- my $error = $cust_pkg->cancel( 'reason' => $self->option('reasonnum') );
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_employee_credit.pm b/FS/FS/part_event/Action/pkg_employee_credit.pm
deleted file mode 100644
index 64dd8b2..0000000
--- a/FS/FS/part_event/Action/pkg_employee_credit.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package FS::part_event::Action::pkg_employee_credit;
-
-use strict;
-use base qw( FS::part_event::Action::pkg_referral_credit );
-
-sub description { 'Credit the ordering employee a specific amount'; }
-
-#a little false laziness w/pkg_referral_credit
-sub do_action {
- my( $self, $cust_pkg, $cust_event ) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
- my $employee = $cust_pkg->access_user;
- return "No customer record for employee ". $employee->username
- unless $employee->user_custnum;
-
- my $employee_cust_main = $employee->user_cust_main;
- #? or return "No customer record for employee ". $employee->username;
-
- my $amount = $self->_calc_credit($cust_pkg);
- return '' unless $amount > 0;
-
- my $reasonnum = $self->option('reasonnum');
-
- my $error = $employee_cust_main->credit(
- $amount,
- \$reasonnum,
- 'eventnum' => $cust_event->eventnum,
- 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
- ': '.$cust_main->name,
- );
- die "Error crediting customer ". $employee_cust_main->custnum.
- " for employee commission: $error"
- if $error;
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_employee_credit_pkg.pm b/FS/FS/part_event/Action/pkg_employee_credit_pkg.pm
deleted file mode 100644
index e3b867f..0000000
--- a/FS/FS/part_event/Action/pkg_employee_credit_pkg.pm
+++ /dev/null
@@ -1,9 +0,0 @@
-package FS::part_event::Action::pkg_employee_credit_pkg;
-
-use strict;
-use base qw( FS::part_event::Action::Mixin::credit_pkg
- FS::part_event::Action::pkg_employee_credit );
-
-sub description { 'Credit the ordering employee an amount based on the referred package'; }
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_referral_credit.pm b/FS/FS/part_event/Action/pkg_referral_credit.pm
deleted file mode 100644
index e7c92d6..0000000
--- a/FS/FS/part_event/Action/pkg_referral_credit.pm
+++ /dev/null
@@ -1,62 +0,0 @@
-package FS::part_event::Action::pkg_referral_credit;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Credit the referring customer a specific amount'; }
-
-sub eventtable_hashref {
- { 'cust_pkg' => 1 };
-}
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Credit reason',
- 'type' => 'select-reason',
- 'reason_class' => 'R',
- },
- 'amount' => { 'label' => 'Credit amount',
- 'type' => 'money',
- },
- );
-
-}
-
-sub do_action {
- my( $self, $cust_pkg, $cust_event ) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
-# my $part_pkg = $cust_pkg->part_pkg;
-
- return 'No referring customer' unless $cust_main->referral_custnum;
-
- my $referring_cust_main = $cust_main->referring_cust_main;
- return 'Referring customer is cancelled'
- if $referring_cust_main->status eq 'cancelled';
-
- my $amount = $self->_calc_credit($cust_pkg);
- return '' unless $amount > 0;
-
- my $reasonnum = $self->option('reasonnum');
-
- my $error = $referring_cust_main->credit(
- $amount,
- \$reasonnum,
- 'eventnum' => $cust_event->eventnum,
- 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
- ': '.$cust_main->name,
- );
- die "Error crediting customer ". $cust_main->referral_custnum.
- " for referral: $error"
- if $error;
-
-}
-
-sub _calc_credit {
- my( $self, $cust_pkg ) = @_;
-
- $self->option('amount');
-}
-
-1;
diff --git a/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm b/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm
deleted file mode 100644
index 667c4ce..0000000
--- a/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm
+++ /dev/null
@@ -1,9 +0,0 @@
-package FS::part_event::Action::pkg_referral_credit_pkg;
-
-use strict;
-use base qw( FS::part_event::Action::Mixin::credit_pkg
- FS::part_event::Action::pkg_referral_credit );
-
-sub description { 'Credit the referring customer an amount based on the referred package'; }
-
-1;
diff --git a/FS/FS/part_event/Action/suspend.pm b/FS/FS/part_event/Action/suspend.pm
deleted file mode 100644
index c77728e..0000000
--- a/FS/FS/part_event/Action/suspend.pm
+++ /dev/null
@@ -1,32 +0,0 @@
-package FS::part_event::Action::suspend;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Suspend'; }
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'S',
- },
- );
-}
-
-sub default_weight { 10; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my @err = $cust_main->suspend( 'reason' => $self->option('reasonnum') );
-
- die join(' / ', @err) if scalar(@err);
-
- '';
-
-}
-
-1;
diff --git a/FS/FS/part_event/Action/suspend_if_pkgpart.pm b/FS/FS/part_event/Action/suspend_if_pkgpart.pm
deleted file mode 100644
index 6f2007c..0000000
--- a/FS/FS/part_event/Action/suspend_if_pkgpart.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-package FS::part_event::Action::suspend_if_pkgpart;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Suspend packages'; }
-
-#i should be deprecated in favor of using the if_pkgpart condition
-
-sub option_fields {
- (
- 'if_pkgpart' => { 'label' => 'Suspend packages:',
- 'type' => 'select-part_pkg',
- 'multiple' => 1,
- },
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'S',
- },
- );
-}
-
-sub default_weight { 10; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my @err = $cust_main->suspend_if_pkgpart( {
- 'pkgparts' => [ split(/\s*,\s*/, $self->option('if_pkgpart') ) ],
- 'reason' => $self->option('reasonnum'),
- } );
-
- die join(' / ', @err) if scalar(@err);
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/suspend_unless_pkgpart.pm b/FS/FS/part_event/Action/suspend_unless_pkgpart.pm
deleted file mode 100644
index efc7a2d..0000000
--- a/FS/FS/part_event/Action/suspend_unless_pkgpart.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-package FS::part_event::Action::suspend_unless_pkgpart;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Suspend packages except'; }
-
-#i should be deprecated in favor of using the unless_pkgpart condition
-
-sub option_fields {
- (
- 'unless_pkgpart' => { 'label' => 'Suspend packages except:',
- 'type' => 'select-part_pkg',
- 'multiple' => 1,
- },
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'S',
- },
- );
-}
-
-sub default_weight { 10; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my @err = $cust_main->suspend_unless_pkgpart( {
- 'pkgparts' => [ split(/\s*,\s*/, $self->option('unless_pkgpart') ) ],
- 'reason' => $self->option('reasonnum'),
- } );
-
- die join(' / ', @err) if scalar(@err);
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Action/writeoff.pm b/FS/FS/part_event/Action/writeoff.pm
deleted file mode 100644
index 8529d29..0000000
--- a/FS/FS/part_event/Action/writeoff.pm
+++ /dev/null
@@ -1,33 +0,0 @@
-package FS::part_event::Action::writeoff;
-
-use strict;
-use base qw( FS::part_event::Action );
-
-sub description { 'Write off bad debt with a credit entry.'; }
-
-sub option_fields {
- (
- #'charge' => { label=>'Amount', type=>'money', }, # size=>7, },
- 'reasonnum' => { 'label' => 'Reason',
- 'type' => 'select-reason',
- 'reason_class' => 'R',
- },
- );
-}
-
-sub default_weight { 65; }
-
-sub do_action {
- my( $self, $cust_object ) = @_;
-
- my $cust_main = $self->cust_main($cust_object);
-
- my $reasonnum = $self->option('reasonnum');
-
- my $error = $cust_main->credit( $cust_main->balance, \$reasonnum );
- die $error if $error;
-
- '';
-}
-
-1;
diff --git a/FS/FS/part_event/Condition.pm b/FS/FS/part_event/Condition.pm
deleted file mode 100644
index 90b8385..0000000
--- a/FS/FS/part_event/Condition.pm
+++ /dev/null
@@ -1,470 +0,0 @@
-package FS::part_event::Condition;
-
-use strict;
-use base qw( FS::part_event_condition );
-use Time::Local qw(timelocal_nocheck);
-use FS::UID qw( driver_name );
-
-=head1 NAME
-
-FS::part_event::Condition - Base class for event conditions
-
-=head1 SYNOPSIS
-
-package FS::part_event::Condition::mycondition;
-
-use base FS::part_event::Condition;
-
-=head1 DESCRIPTION
-
-FS::part_event::Condition is a base class for event conditions classes.
-
-=head1 METHODS
-
-These methods are implemented in each condition class.
-
-=over 4
-
-=item description
-
-Condition classes must define a description method. This method should return
-a scalar description of the condition.
-
-=item eventtable_hashref
-
-Condition classes must define an eventtable_hashref method if they can only be
-tested against some kinds of tables. This method should return a hash reference
-of eventtables (values set true indicate the condition can be tested):
-
- sub eventtable_hashref {
- { 'cust_main' => 1,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- 'cust_pay_batch' => 0,
- 'cust_statement' => 0,
- };
- }
-
-=cut
-
-#fallback
-sub eventtable_hashref {
- { 'cust_main' => 1,
- 'cust_bill' => 1,
- 'cust_pkg' => 1,
- 'cust_pay_batch' => 1,
- 'cust_statement' => 1,
- };
-}
-
-=item option_fields
-
-Condition classes may define an option_fields method to indicate that they
-accept one or more options.
-
-This method should return a list of option names and option descriptions.
-Each option description can be a scalar description, for simple options, or a
-hashref with the following values:
-
-=over 4
-
-=item label - Description
-
-=item type - Currently text, money, checkbox, checkbox-multiple, select, select-agent, select-pkg_class, select-part_referral, select-table, fixed, hidden, (others can be implemented as httemplate/elements/tr-TYPE.html mason components). Defaults to text.
-
-=item options - For checkbox-multiple and select, a list reference of available option values.
-
-=item option_labels - For checkbox-multiple (and select?), a hash reference of availble option values and labels.
-
-=item value - for checkbox, fixed, hidden (also a default for text, money, more?)
-
-=item table - for select-table
-
-=item name_col - for select-table
-
-=item NOTE: See httemplate/elements/select-table.html for a full list of the optinal options for the select-table type
-
-=back
-
-NOTE: A database connection is B<not> yet available when this subroutine is
-executed.
-
-Example:
-
- sub option_fields {
- (
- 'field' => 'description',
-
- 'another_field' => { 'label'=>'Amount', 'type'=>'money', },
-
- 'third_field' => { 'label' => 'Types',
- 'type' => 'checkbox-multiple',
- 'options' => [ 'h', 's' ],
- 'option_labels' => { 'h' => 'Happy',
- 's' => 'Sad',
- },
- );
- }
-
-=cut
-
-#fallback
-sub option_fields {
- ();
-}
-
-=item condition CUSTOMER_EVENT_OBJECT
-
-Condition classes must define a condition method. This method is evaluated
-to determine if the condition has been met. The object which triggered the
-event (an FS::cust_main, FS::cust_bill or FS::cust_pkg object) is passed as
-the first argument. Additional arguments are list of key-value pairs.
-
-To retreive option values, call the option method on the desired option, i.e.:
-
- my( $self, $cust_object, %opts ) = @_;
- $value_of_field = $self->option('field');
-
-Available additional arguments:
-
- $time = $opt{'time'}; #use this instead of time or $^T
-
- $cust_event = $opt{'cust_event'}; #to retreive the cust_event object being tested
-
-Return a true value if the condition has been met, and a false value if it has
-not.
-
-=item condition_sql EVENTTABLE
-
-Condition classes may optionally define a condition_sql method. This B<class>
-method should return an SQL fragment that tests for this condition. The
-fragment is evaluated and a true value of this expression indicates that the
-condition has been met. The event table (cust_main, cust_bill or cust_pkg) is
-passed as an argument.
-
-This method is used for optimizing event queries. You may want to add indices
-for any columns referenced. It is acceptable to return an SQL fragment which
-partially tests the condition; doing so will still reduce the number of
-records which much be returned and tested with the B<condition> method.
-
-=cut
-
-# fallback.
-sub condition_sql {
- my( $class, $eventtable ) = @_;
- #...
- 'true';
-}
-
-=item disabled
-
-Condition classes may optionally define a disabled method. Returning a true
-value disbles the condition entirely.
-
-=cut
-
-sub disabled {
- 0;
-}
-
-=item implicit_flag
-
-This is used internally by the I<once> and I<balance> conditions. You probably
-do B<not> want to define this method for new custom conditions, unless you're
-sure you want B<every> new action to start with your condition.
-
-Condition classes may define an implicit_flag method that returns true to
-indicate that all new events should start with this condition. (Currently,
-condition classes which do so should be applicable to all kinds of
-I<eventtable>s.) The numeric value of the flag also defines the ordering of
-implicit conditions.
-
-=cut
-
-#fallback
-sub implicit_flag { 0; }
-
-=item remove_warning
-
-Again, used internally by the I<once> and I<balance> conditions; probably not
-a good idea for new custom conditions.
-
-Condition classes may define a remove_warning method containing a string
-warning message to enable a confirmation dialog triggered when the condition
-is removed from an event.
-
-=cut
-
-#fallback
-sub remove_warning { ''; }
-
-=item order_sql
-
-This is used internally by the I<balance_age> and I<cust_bill_age> conditions
-to declare ordering; probably not of general use for new custom conditions.
-
-=item order_sql_weight
-
-In conjunction with order_sql, this defines which order the ordering fragments
-supplied by different B<order_sql> should be used.
-
-=cut
-
-sub order_sql_weight { ''; }
-
-=back
-
-=head1 BASE METHODS
-
-These methods are defined in the base class for use in condition classes.
-
-=over 4
-
-=item cust_main CUST_OBJECT
-
-Return the customer object (see L<FS::cust_main>) associated with the provided
-object (the object itself if it is already a customer object).
-
-=cut
-
-sub cust_main {
- my( $self, $cust_object ) = @_;
-
- $cust_object->isa('FS::cust_main') ? $cust_object : $cust_object->cust_main;
-
-}
-
-=item option_label OPTIONNAME
-
-Returns the label for the specified option name.
-
-=cut
-
-sub option_label {
- my( $self, $optionname ) = @_;
-
- my %option_fields = $self->option_fields;
-
- ref( $option_fields{$optionname} )
- ? $option_fields{$optionname}->{'label'}
- : $option_fields{$optionname}
- or $optionname;
-}
-
-=back
-
-=item option_age_from OPTION FROM_TIMESTAMP
-
-Retreives a condition option, parses it from a frequency (such as "1d", "1w" or
-"12m"), and subtracts that interval from the supplied timestamp. It is
-primarily intended for use in B<condition>.
-
-=cut
-
-sub option_age_from {
- my( $self, $option, $time ) = @_;
- my $age = $self->option($option);
- $age = '0m' unless length($age);
-
- my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($time) )[0,1,2,3,4,5];
-
- if ( $age =~ /^(\d+)m$/i ) {
- $mon -= $1;
- until ( $mon >= 0 ) { $mon += 12; $year--; }
- } elsif ( $age =~ /^(\d+)y$/i ) {
- $year -= $1;
- } elsif ( $age =~ /^(\d+)w$/i ) {
- $mday -= $1 * 7;
- } elsif ( $age =~ /^(\d+)d$/i ) {
- $mday -= $1;
- } elsif ( $age =~ /^(\d+)h$/i ) {
- $hour -= $hour;
- } else {
- die "unparsable age: $age";
- }
-
- timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year);
-
-}
-
-=item condition_sql_option OPTION
-
-This is a class method that returns an SQL fragment for retreiving a condition
-option. It is primarily intended for use in B<condition_sql>.
-
-=cut
-
-sub condition_sql_option {
- my( $class, $option ) = @_;
-
- ( my $condname = $class ) =~ s/^.*:://;
-
- "( SELECT optionvalue FROM part_event_condition_option
- WHERE part_event_condition_option.eventconditionnum =
- cond_$condname.eventconditionnum
- AND part_event_condition_option.optionname = '$option'
- )";
-}
-
-#c.f. part_event_condition_option.pm / part_event_condition_option_option
-#used for part_event/Condition/payby.pm
-sub condition_sql_option_option {
- my( $class, $option ) = @_;
-
- ( my $condname = $class ) =~ s/^.*:://;
-
- my $optionnum =
- "( SELECT optionnum FROM part_event_condition_option
- WHERE part_event_condition_option.eventconditionnum =
- cond_$condname.eventconditionnum
- AND part_event_condition_option.optionname = '$option'
- AND part_event_condition_option.optionvalue = 'HASH'
- )";
-
- "( SELECT optionname FROM part_event_condition_option_option
- WHERE optionnum = $optionnum
- )";
-
-}
-
-
-=item condition_sql_option_age_from OPTION FROM_TIMESTAMP
-
-This is a class method that returns an SQL fragment that will retreive a
-condition option, parse it from a frequency (such as "1d", "1w" or "12m"),
-and subtract that interval from the supplied timestamp. It is primarily
-intended for use in B<condition_sql>.
-
-=cut
-
-sub condition_sql_option_age_from {
- my( $class, $option, $from ) = @_;
-
- my $value = $class->condition_sql_option($option);
-
-# my $str2time = str2time_sql;
-
- if ( driver_name =~ /^Pg/i ) {
-
- #can we do better with Pg now that we have $from? yes we can, bob
- "( $from - EXTRACT( EPOCH FROM REPLACE( $value, 'm', 'mon')::interval ) )";
-
- } elsif ( driver_name =~ /^mysql/i ) {
-
- #hmm... is there a way we can save $value? we're just an expression, hmm
- #we might be able to do something like "AS ${option}_value" except we get
- #used in more complicated expressions and we need some sort of unique
- #identifer passed down too... yow
-
- "CASE WHEN $value IS NULL OR $value = ''
- THEN $from
- WHEN $value LIKE '%m'
- THEN UNIX_TIMESTAMP(
- FROM_UNIXTIME($from) - INTERVAL REPLACE( $value, 'm', '' ) MONTH
- )
- WHEN $value LIKE '%y'
- THEN UNIX_TIMESTAMP(
- FROM_UNIXTIME($from) - INTERVAL REPLACE( $value, 'y', '' ) YEAR
- )
- WHEN $value LIKE '%w'
- THEN UNIX_TIMESTAMP(
- FROM_UNIXTIME($from) - INTERVAL REPLACE( $value, 'w', '' ) WEEK
- )
- WHEN $value LIKE '%d'
- THEN UNIX_TIMESTAMP(
- FROM_UNIXTIME($from) - INTERVAL REPLACE( $value, 'd', '' ) DAY
- )
- WHEN $value LIKE '%h'
- THEN UNIX_TIMESTAMP(
- FROM_UNIXTIME($from) - INTERVAL REPLACE( $value, 'h', '' ) HOUR
- )
- END
- "
- } else {
-
- die "FATAL: don't know how to subtract frequencies from dates for ".
- driver_name. " databases";
-
- }
-
-}
-
-=item condition_sql_option_age OPTION
-
-This is a class method that returns an SQL fragment for retreiving a condition
-option, and additionaly parsing it from a frequency (such as "1d", "1w" or
-"12m") into an approximate number of seconds.
-
-Note that since months vary in length, the results of this method should B<not>
-be used in computations (use condition_sql_option_age_from for that). They are
-useful for for ordering and comparison to other ages.
-
-This method is primarily intended for use in B<order_sql>.
-
-=cut
-
-sub condition_sql_option_age {
- my( $class, $option ) = @_;
- $class->age2seconds_sql( $class->condition_sql_option($option) );
-}
-
-=item age2seconds_sql
-
-Class method returns an SQL fragment for parsing an arbitrary frequeny (such
-as "1d", "1w", "12m", "2y" or "12h") into an approximate number of seconds.
-
-Approximate meaning: months are considered to be 30 days, years to be
-365.25 days. Otherwise the numbers of seconds returned is exact.
-
-=cut
-
-sub age2seconds_sql {
- my( $class, $value ) = @_;
-
- if ( driver_name =~ /^Pg/i ) {
-
- "EXTRACT( EPOCH FROM REPLACE( $value, 'm', 'mon')::interval )";
-
- } elsif ( driver_name =~ /^mysql/i ) {
-
- #hmm... is there a way we can save $value? we're just an expression, hmm
- #we might be able to do something like "AS ${option}_age" except we get
- #used in more complicated expressions and we need some sort of unique
- #identifer passed down too... yow
- # 2592000 = 30d "1 month"
- # 31557600 = 365.25d "1 year"
-
- "CASE WHEN $value IS NULL OR $value = ''
- THEN 0
- WHEN $value LIKE '%m'
- THEN REPLACE( $value, 'm', '' ) * 2592000
- WHEN $value LIKE '%y'
- THEN REPLACE( $value, 'y', '' ) * 31557600
- WHEN $value LIKE '%w'
- THEN REPLACE( $value, 'w', '' ) * 604800
- WHEN $value LIKE '%d'
- THEN REPLACE( $value, 'd', '' ) * 86400
- WHEN $value LIKE '%h'
- THEN REPLACE( $value, 'h', '' ) * 3600
- END
- "
- } else {
-
- die "FATAL: don't know how to approximate frequencies for ". driver_name.
- " databases";
-
- }
-
-}
-
-=head1 NEW CONDITION CLASSES
-
-A module should be added in FS/FS/part_event/Condition/ which implements the
-methods desribed above in L</METHODS>. An example may be found in the
-eg/part_event-Condition-template.pm file.
-
-=cut
-
-1;
-
-
diff --git a/FS/FS/part_event/Condition/agent.pm b/FS/FS/part_event/Condition/agent.pm
deleted file mode 100644
index da428c1..0000000
--- a/FS/FS/part_event/Condition/agent.pm
+++ /dev/null
@@ -1,37 +0,0 @@
-package FS::part_event::Condition::agent;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-# see the FS::part_event::Condition manpage for full documentation on each
-# of the required and optional methods.
-
-sub description {
- 'Agent';
-}
-
-sub option_fields {
- (
- 'agentnum' => { label=>'Agent', type=>'select-agent', },
- );
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $agentnum = $self->option('agentnum');
-
- $cust_main->agentnum == $agentnum;
-
-}
-
-#sub condition_sql {
-# my( $self, $table ) = @_;
-#
-# 'true';
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/agent_type.pm b/FS/FS/part_event/Condition/agent_type.pm
deleted file mode 100644
index 54c8932..0000000
--- a/FS/FS/part_event/Condition/agent_type.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-package FS::part_event::Condition::agent_type;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-# see the FS::part_event::Condition manpage for full documentation on each
-# of the required and optional methods.
-
-sub description {
- 'Agent Type';
-}
-
-sub option_fields {
- (
- 'typenum' => { label => 'Agent Type',
- type => 'select-agent_type',
- disable_empty => 1,
- },
- );
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $typenum = $self->option('typenum');
-
- $cust_main->agent->typenum == $typenum;
-
-}
-
-#sub condition_sql {
-# my( $self, $table ) = @_;
-#
-# 'true';
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/balance.pm b/FS/FS/part_event/Condition/balance.pm
deleted file mode 100644
index 3b8854a..0000000
--- a/FS/FS/part_event/Condition/balance.pm
+++ /dev/null
@@ -1,48 +0,0 @@
-package FS::part_event::Condition::balance;
-
-use strict;
-use FS::cust_main;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer balance'; }
-
-sub implicit_flag { 20; }
-
-sub remove_warning {
- 'Are you sure you want to remove this condition? Doing so will allow this event to run even if the customer has no outstanding balance. Perhaps you want to reset "Balance over" to 0 instead of removing the condition entirely?'; #better error msg?
-}
-
-sub option_fields {
- (
- 'balance' => { 'label' => 'Balance over',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- );
-}
-
-sub condition {
- my($self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $over = $self->option('balance');
- $over = 0 unless length($over);
-
- $cust_main->balance > $over;
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $over = $class->condition_sql_option('balance');
-
- my $balance_sql = FS::cust_main->balance_sql;
-
- "$balance_sql > CAST( $over AS DECIMAL(10,2) )";
-
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/balance_age.pm b/FS/FS/part_event/Condition/balance_age.pm
deleted file mode 100644
index 8480659..0000000
--- a/FS/FS/part_event/Condition/balance_age.pm
+++ /dev/null
@@ -1,52 +0,0 @@
-package FS::part_event::Condition::balance_age;
-
-use strict;
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer balance age'; }
-
-sub option_fields {
- (
- 'balance' => { 'label' => 'Balance over',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- 'age' => { 'label' => 'Age',
- 'type' => 'freq',
- },
- );
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $over = $self->option('balance');
- $over = 0 unless length($over);
-
- my $age = $self->option_age_from('age', $opt{'time'} );
-
- $cust_main->balance_date($age) > $over;
-}
-
-sub condition_sql {
- my( $class, $table, %opt ) = @_;
-
- my $over = $class->condition_sql_option('balance');
- my $age = $class->condition_sql_option_age_from('age', $opt{'time'});
-
- my $balance_sql = FS::cust_main->balance_date_sql( $age );
-
- "$balance_sql > CAST( $over AS DECIMAL(10,2) )";
-}
-
-sub order_sql {
- shift->condition_sql_option_age('age');
-}
-
-sub order_sql_weight {
- 10;
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/balance_credit_limit.pm b/FS/FS/part_event/Condition/balance_credit_limit.pm
deleted file mode 100644
index 1bc2aa1..0000000
--- a/FS/FS/part_event/Condition/balance_credit_limit.pm
+++ /dev/null
@@ -1,32 +0,0 @@
-package FS::part_event::Condition::balance_credit_limit;
-
-use strict;
-use FS::cust_main;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer is over credit limit'; }
-
-sub condition {
- my($self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $over = $cust_main->credit_limit;
- return 0 if !length($over); # if credit limit is null, no limit
-
- $cust_main->balance > $over;
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $balance_sql = FS::cust_main->balance_sql;
-
- "(cust_main.credit_limit IS NULL OR
- $balance_sql - cust_main.credit_limit > 0 )";
-
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/balance_under.pm b/FS/FS/part_event/Condition/balance_under.pm
deleted file mode 100644
index 2002c70..0000000
--- a/FS/FS/part_event/Condition/balance_under.pm
+++ /dev/null
@@ -1,42 +0,0 @@
-package FS::part_event::Condition::balance_under;
-
-use strict;
-use FS::cust_main;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer balance (under)'; }
-
-sub option_fields {
- (
- 'balance' => { 'label' => 'Balance under (or equal to)',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- );
-}
-
-sub condition {
- my($self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $under = $self->option('balance');
- $under = 0 unless length($under);
-
- $cust_main->balance <= $under;
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $under = $class->condition_sql_option('balance');
-
- my $balance_sql = FS::cust_main->balance_sql;
-
- "$balance_sql <= CAST( $under AS DECIMAL(10,2) )";
-
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/cust_bill_age.pm b/FS/FS/part_event/Condition/cust_bill_age.pm
deleted file mode 100644
index 2295e02..0000000
--- a/FS/FS/part_event/Condition/cust_bill_age.pm
+++ /dev/null
@@ -1,46 +0,0 @@
-package FS::part_event::Condition::cust_bill_age;
-
-use strict;
-use base qw( FS::part_event::Condition );
-
-sub description { 'Invoice age'; }
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub option_fields {
- (
- 'age' => { label=>'Age', type=>'freq', },
- );
-}
-
-sub condition {
- my( $self, $cust_bill, %opt ) = @_;
-
- my $age = $self->option_age_from('age', $opt{'time'} );
-
- ( $cust_bill->_date - 60 ) <= $age;
-
-}
-
-sub condition_sql {
- my( $class, $table, %opt ) = @_;
-
- my $age = $class->condition_sql_option_age_from('age', $opt{'time'} );
-
- "( cust_bill._date - 60 ) <= $age";
-}
-
-sub order_sql {
- shift->condition_sql_option_age('age');
-}
-
-sub order_sql_weight {
- 0;
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_has_noauto.pm b/FS/FS/part_event/Condition/cust_bill_has_noauto.pm
deleted file mode 100644
index 6cb94c0..0000000
--- a/FS/FS/part_event/Condition/cust_bill_has_noauto.pm
+++ /dev/null
@@ -1,33 +0,0 @@
-package FS::part_event::Condition::cust_bill_has_noauto;
-
-use strict;
-use FS::cust_bill;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Invoice ineligible for automatic collection';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub condition {
- #my($self, $cust_bill, %opt) = @_;
- my($self, $cust_bill) = @_;
-
- $cust_bill->no_auto;
-}
-
-#sub condition_sql {
-# my( $class, $table ) = @_;
-#
-# my $sql = qq| |;
-# return $sql;
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_has_service.pm b/FS/FS/part_event/Condition/cust_bill_has_service.pm
deleted file mode 100644
index d85af26..0000000
--- a/FS/FS/part_event/Condition/cust_bill_has_service.pm
+++ /dev/null
@@ -1,56 +0,0 @@
-package FS::part_event::Condition::cust_bill_has_service;
-
-use strict;
-use FS::cust_bill;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Invoice is billing for a certain service type';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-# could not find component for path '/elements/tr-select-part_svc.html'
-# sub disabled { 1; }
-
-sub option_fields {
- (
- 'has_service' => { 'label' => 'Has service',
- 'type' => 'select-part_svc',
- },
- );
-}
-
-sub condition {
- #my($self, $cust_bill, %opt) = @_;
- my($self, $cust_bill) = @_;
-
- my $servicenum = $self->option('has_service');
- grep { $servicenum == $_->svcpart }
- map { $_->cust_pkg->cust_svc }
- $cust_bill->cust_bill_pkg ;
-}
-
-sub condition_sql {
- my( $class, $table, %opt ) = @_;
-
- my $integer = $opt{'driver_name'} =~ /^mysql/ ? 'UNSIGNED INTEGER' : 'INTEGER';
-
- my $servicenum = $class->condition_sql_option('has_service');
- my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart)
- FROM cust_bill_pkg cbp, cust_svc cs
- WHERE cbp.invnum = cust_bill.invnum
- AND cs.pkgnum = cbp.pkgnum
- AND cs.svcpart = CAST( $servicenum AS $integer )
- )
- |;
- return $sql;
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_hasnt_noauto.pm b/FS/FS/part_event/Condition/cust_bill_hasnt_noauto.pm
deleted file mode 100644
index 78a6d51..0000000
--- a/FS/FS/part_event/Condition/cust_bill_hasnt_noauto.pm
+++ /dev/null
@@ -1,33 +0,0 @@
-package FS::part_event::Condition::cust_bill_hasnt_noauto;
-
-use strict;
-use FS::cust_bill;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Invoice eligible for automatic collection';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub condition {
- #my($self, $cust_bill, %opt) = @_;
- my($self, $cust_bill) = @_;
-
- ! $cust_bill->no_auto;
-}
-
-#sub condition_sql {
-# my( $class, $table ) = @_;
-#
-# my $sql = qq| |;
-# return $sql;
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_owed.pm b/FS/FS/part_event/Condition/cust_bill_owed.pm
deleted file mode 100644
index d8c77c7..0000000
--- a/FS/FS/part_event/Condition/cust_bill_owed.pm
+++ /dev/null
@@ -1,54 +0,0 @@
-package FS::part_event::Condition::cust_bill_owed;
-
-use strict;
-use FS::cust_bill;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Amount owed on specific invoice';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub implicit_flag { 30; }
-
-sub remove_warning {
- 'Are you sure you want to remove this condition? Doing so will allow this event to run even for invoices which have no outstanding balance. Perhaps you want to reset "Amount owed over" to 0 instead of removing the condition entirely?'; #better error msg?
-}
-
-sub option_fields {
- (
- 'owed' => { 'label' => 'Amount owed over',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- );
-}
-
-sub condition {
- #my($self, $cust_bill, %opt) = @_;
- my($self, $cust_bill) = @_;
-
- my $over = $self->option('owed');
- $over = 0 unless length($over);
-
- $cust_bill->owed > $over;
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $over = $class->condition_sql_option('owed');
-
- my $owed_sql = FS::cust_bill->owed_sql;
-
- "$owed_sql > CAST( $over AS DECIMAL(10,2) )";
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_owed_under.pm b/FS/FS/part_event/Condition/cust_bill_owed_under.pm
deleted file mode 100644
index 4eb6439..0000000
--- a/FS/FS/part_event/Condition/cust_bill_owed_under.pm
+++ /dev/null
@@ -1,49 +0,0 @@
-package FS::part_event::Condition::cust_bill_owed_under;
-
-use strict;
-use FS::cust_bill;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Amount owed on specific invoice (under)';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub option_fields {
- (
- 'owed' => { 'label' => 'Amount owed under (or equal to)',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- );
-}
-
-sub condition {
- #my($self, $cust_bill, %opt) = @_;
- my($self, $cust_bill) = @_;
-
- my $under = $self->option('owed');
- $under = 0 unless length($under);
-
- $cust_bill->owed <= $under;
-
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $under = $class->condition_sql_option('owed');
-
- my $owed_sql = FS::cust_bill->owed_sql;
-
- "$owed_sql <= CAST( $under AS DECIMAL(10,2) )";
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_bill_past_due.pm b/FS/FS/part_event/Condition/cust_bill_past_due.pm
deleted file mode 100644
index a889a00..0000000
--- a/FS/FS/part_event/Condition/cust_bill_past_due.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-package FS::part_event::Condition::cust_bill_past_due;
-
-use strict;
-use FS::cust_bill;
-use Time::Local 'timelocal';
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Invoice due date has passed';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 0,
- };
-}
-
-sub condition {
- my($self, $cust_bill, %opt) = @_;
-
- # If the invoice date is 1/1 at noon and the terms are Net 15,
- # the due_date will be 1/16 at noon. Past due events will not
- # trigger until after the start of 1/17.
- my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
- my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1;
- ($cust_bill->due_date || $cust_bill->_date) < $start_of_today;
-}
-
-sub condition_sql {
- return 'true' if $FS::UID::driver_name ne 'Pg';
- my( $class, $table, %opt ) = @_;
- my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
- my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1;
-
- FS::cust_bill->due_date_sql . " < $start_of_today";
-
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_pay_batch_declined.pm b/FS/FS/part_event/Condition/cust_pay_batch_declined.pm
deleted file mode 100644
index b3a8d70..0000000
--- a/FS/FS/part_event/Condition/cust_pay_batch_declined.pm
+++ /dev/null
@@ -1,51 +0,0 @@
-package FS::part_event::Condition::cust_pay_batch_declined;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- 'Batch payment declined';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 0,
- 'cust_pay_batch' => 1,
- };
-}
-
-#sub option_fields {
-# (
-# 'field' => 'description',
-#
-# 'another_field' => { 'label'=>'Amount', 'type'=>'money', },
-#
-# 'third_field' => { 'label' => 'Types',
-# 'type' => 'checkbox-multiple',
-# 'options' => [ 'h', 's' ],
-# 'option_labels' => { 'h' => 'Happy',
-# 's' => 'Sad',
-# },
-# );
-#}
-
-sub condition {
- my($self, $cust_pay_batch, %opt) = @_;
-
- #my $cust_main = $self->cust_main($object);
- #my $value_of_field = $self->option('field');
- #my $time = $opt{'time'}; #use this instead of time or $^T
-
- $cust_pay_batch->status =~ /Declined/i;
-
-}
-
-#sub condition_sql {
-# my( $class, $table ) = @_;
-# #...
-# 'true';
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/cust_payments.pm b/FS/FS/part_event/Condition/cust_payments.pm
deleted file mode 100644
index 477ecdb..0000000
--- a/FS/FS/part_event/Condition/cust_payments.pm
+++ /dev/null
@@ -1,43 +0,0 @@
-package FS::part_event::Condition::cust_payments;
-
-use strict;
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer total payments (amount)'; }
-
-sub option_fields {
- (
- 'over' => { 'label' => 'Customer total payments at least',
- 'type' => 'money',
- 'value' => '0.00', #default
- },
- );
-}
-
-sub condition {
- my($self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $over = $self->option('over');
- $over = 0 unless length($over);
-
- $cust_main->total_paid >= $over;
-
-}
-
-#XXX add for efficiency. could use cust_main::total_paid_sql
-#use FS::cust_main;
-#sub condition_sql {
-# my( $class, $table ) = @_;
-#
-# my $over = $class->condition_sql_option('balance');
-#
-# my $balance_sql = FS::cust_main->balance_sql;
-#
-# "$balance_sql > $over";
-#
-#}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/cust_payments_pkg.pm b/FS/FS/part_event/Condition/cust_payments_pkg.pm
deleted file mode 100644
index d6c493b..0000000
--- a/FS/FS/part_event/Condition/cust_payments_pkg.pm
+++ /dev/null
@@ -1,68 +0,0 @@
-package FS::part_event::Condition::cust_payments_pkg;
-
-use strict;
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer total payments (multiplier of package)'; }
-
-sub eventtable_hashref {
- { 'cust_pkg' => 1 };
-}
-
-sub option_fields {
- (
- 'over_times' => { 'label' => 'Customer total payments as least',
- 'type' => 'text',
- 'value' => '1', #default
- },
- 'what' => { 'label' => 'Times',
- 'type' => 'select',
- #also add some way to specify in the package def, no?
- 'options' => [ qw( base_recur_permonth ) ],
- 'labels' => { 'base_recur_permonth' => 'Base monthly fee', },
- },
- );
-}
-
-sub condition {
- my($self, $cust_pkg) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- my $over_times = $self->option('over_times');
- $over_times = 0 unless length($over_times);
-
- my $what = $self->option('what');
-
- #false laziness w/Condition/cust_payments_pkg.pm
- if ( $what eq 'base_recur_permonth' ) { #huh. yuck.
- if ( $part_pkg->freq !~ /^\d+$/ ) {
- die 'WARNING: Not crediting customer '. $cust_main->referral_custnum.
- ' for package '. $cust_pkg->pkgnum.
- ' ( customer '. $cust_pkg->custnum. ')'.
- ' - Referral credits not (yet) available for '.
- ' packages with '. $part_pkg->freq_pretty. ' frequency';
- }
- }
-
- $cust_main->total_paid >= $over_times * $part_pkg->$what($cust_pkg);
-
-}
-
-#XXX add for efficiency. could use cust_main::total_paid_sql
-#use FS::cust_main;
-#sub condition_sql {
-# my( $class, $table ) = @_;
-#
-# my $over = $class->condition_sql_option('balance');
-#
-# my $balance_sql = FS::cust_main->balance_sql;
-#
-# "$balance_sql > $over";
-#
-#}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/cust_status.pm b/FS/FS/part_event/Condition/cust_status.pm
deleted file mode 100644
index 066ee48..0000000
--- a/FS/FS/part_event/Condition/cust_status.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-package FS::part_event::Condition::cust_status;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-
-sub description {
- 'Customer Status';
-}
-
-#something like this
-sub option_fields {
- (
- 'status' => { 'label' => 'Customer Status',
- 'type' => 'select-cust_main-status',
- 'multiple' => 1,
- },
- );
-}
-
-sub condition {
- my( $self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- #XXX test
- my $hashref = $self->option('status') || {};
- $hashref->{ $cust_main->status };
-}
-
-sub condition_sql {
- my( $self, $table ) = @_;
-
- '('.FS::cust_main->cust_status_sql . ') IN '.
- $self->condition_sql_option_option('status');
-}
-
-
-1;
diff --git a/FS/FS/part_event/Condition/dundate.pm b/FS/FS/part_event/Condition/dundate.pm
deleted file mode 100644
index ee2a95f..0000000
--- a/FS/FS/part_event/Condition/dundate.pm
+++ /dev/null
@@ -1,26 +0,0 @@
-package FS::part_event::Condition::dundate;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- "Skip until customer dun date is reached";
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- $cust_main->dundate <= $opt{time};
-
-}
-
-#sub condition_sql {
-# my( $self, $table ) = @_;
-#
-# 'true';
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/every.pm b/FS/FS/part_event/Condition/every.pm
deleted file mode 100644
index 1910674..0000000
--- a/FS/FS/part_event/Condition/every.pm
+++ /dev/null
@@ -1,67 +0,0 @@
-package FS::part_event::Condition::every;
-
-use strict;
-use FS::UID qw( dbh );
-use FS::Record qw( qsearch );
-use FS::cust_event;
-
-use base qw( FS::part_event::Condition );
-
-sub description { "Don't retry failures more often than specified interval"; }
-
-sub option_fields {
- (
- 'retry_delay' => { label=>'Retry after', type=>'freq', value=>'1d', },
- 'max_tries' => { label=>'Maximum # of attempts', type=>'text', size=>3, },
- );
-}
-
-my %after = (
- 'h' => 3600,
- 'd' => 86400,
- 'w' => 604800,
- 'm' => 2592000, #well, 30 days... presumably people would mostly use d or w
- '' => 2592000,
- 'y' => 31536000, #well, 365 days...
-);
-
-my $sql =
- "SELECT COUNT(*) FROM cust_event WHERE eventpart = ? AND tablenum = ?";
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $obj_pkey = $object->primary_key;
- my $tablenum = $object->$obj_pkey();
-
- if ( $self->option('max_tries') =~ /^\s*(\d+)\s*$/ ) {
- my $max_tries = $1;
- my $sth = dbh->prepare($sql)
- or die dbh->errstr. " preparing: $sql";
- $sth->execute($self->eventpart, $tablenum)
- or die $sth->errstr. " executing: $sql";
- my $tries = $sth->fetchrow_arrayref->[0];
- return 0 if $tries >= $max_tries;
- }
-
- my $time = $opt{'time'};
- my $retry_delay = $self->option('retry_delay');
- $retry_delay =~ /^(\d+)([hdwmy]?)$/
- or die "unparsable retry_delay: $retry_delay";
- my $date_after = $time - $1 * $after{$2};
-
- my $sth = dbh->prepare("$sql AND _date > ?") # AND status = 'failed' "
- or die dbh->errstr. " preparing: $sql";
- $sth->execute($self->eventpart, $tablenum, $date_after)
- or die $sth->errstr. " executing: $sql";
- ! $sth->fetchrow_arrayref->[0];
-
-}
-
-#sub condition_sql {
-# my( $self, $table ) = @_;
-#
-# 'true';
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/has_pkg_class.pm b/FS/FS/part_event/Condition/has_pkg_class.pm
deleted file mode 100644
index 59a3675..0000000
--- a/FS/FS/part_event/Condition/has_pkg_class.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-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
deleted file mode 100644
index c54b7e2..0000000
--- a/FS/FS/part_event/Condition/has_pkgpart.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-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/has_referral_custnum.pm b/FS/FS/part_event/Condition/has_referral_custnum.pm
deleted file mode 100644
index 70c9c7f..0000000
--- a/FS/FS/part_event/Condition/has_referral_custnum.pm
+++ /dev/null
@@ -1,50 +0,0 @@
-package FS::part_event::Condition::has_referral_custnum;
-
-use strict;
-use FS::cust_main;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Customer has a referring customer'; }
-
-sub option_fields {
- (
- 'active' => { 'label' => 'Referring customer is active',
- 'type' => 'checkbox',
- 'value' => 'Y',
- },
- );
-}
-
-sub condition {
- my($self, $object) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- if ( $self->option('active') ) {
-
- return 0 unless $cust_main->referral_custnum;
-
- #check for no cust_main for referral_custnum? (deleted?)
-
- $cust_main->referral_custnum_cust_main->status eq 'active';
-
- } else {
-
- $cust_main->referral_custnum; # ? 1 : 0;
-
- }
-
-}
-
-sub condition_sql {
- my( $class, $table ) = @_;
-
- my $sql = FS::cust_main->active_sql;
- $sql =~ s/cust_main.custnum/cust_main.referral_custnum/;
- $sql = 'cust_main.referral_custnum IS NOT NULL AND ('.
- $class->condition_sql_option('active') . ' IS NULL OR '.$sql.')';
- return $sql;
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/hasnt_pkgpart.pm b/FS/FS/part_event/Condition/hasnt_pkgpart.pm
deleted file mode 100644
index 421d023..0000000
--- a/FS/FS/part_event/Condition/hasnt_pkgpart.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-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;
diff --git a/FS/FS/part_event/Condition/once.pm b/FS/FS/part_event/Condition/once.pm
deleted file mode 100644
index d004814..0000000
--- a/FS/FS/part_event/Condition/once.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-package FS::part_event::Condition::once;
-
-use strict;
-use FS::Record qw( qsearch );
-use FS::part_event;
-use FS::cust_event;
-
-use base qw( FS::part_event::Condition );
-
-sub description { "Don't run this event again after it has completed successfully"; }
-
-sub implicit_flag { 10; }
-
-sub remove_warning {
- 'Are you sure you want to remove this condition? Doing so will allow this event to run every time the other conditions are satisfied, even if it has already run sucessfully.'; #better error msg?
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $obj_pkey = $object->primary_key;
- my $tablenum = $object->$obj_pkey();
-
- my @existing = qsearch( {
- 'table' => 'cust_event',
- 'hashref' => {
- 'eventpart' => $self->eventpart,
- 'tablenum' => $tablenum,
- 'status' => { op=>'!=', value=>'failed' },
- },
- 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
- ? " AND eventnum != $1 "
- : ''
- ),
- } );
-
- ! scalar(@existing);
-
-}
-
-sub condition_sql {
- my( $self, $table ) = @_;
-
- my %tablenum = %{ FS::part_event->eventtable_pkey_sql };
-
- "0 = ( SELECT COUNT(*) FROM cust_event
- WHERE cust_event.eventpart = part_event.eventpart
- AND cust_event.tablenum = $tablenum{$table}
- AND status != 'failed'
- )
- ";
-
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/once_every.pm b/FS/FS/part_event/Condition/once_every.pm
deleted file mode 100644
index 2921b3a..0000000
--- a/FS/FS/part_event/Condition/once_every.pm
+++ /dev/null
@@ -1,46 +0,0 @@
-package FS::part_event::Condition::once_every;
-
-use strict;
-use FS::Record qw( qsearch );
-use FS::part_event;
-use FS::cust_event;
-
-use base qw( FS::part_event::Condition );
-
-sub description { "Don't run this event more than once in the specified interval"; }
-
-# Runs the event at most "once every X".
-
-sub option_fields {
- (
- 'run_delay' => { label=>'Interval', type=>'freq', value=>'1m', },
- );
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $obj_pkey = $object->primary_key;
- my $tablenum = $object->$obj_pkey();
-
- my $max_date = $self->option_age_from('run_delay',$opt{'time'});
-
- my @existing = qsearch( {
- 'table' => 'cust_event',
- 'hashref' => {
- 'eventpart' => $self->eventpart,
- 'tablenum' => $tablenum,
- 'status' => { op=>'!=', value=>'failed' },
- '_date' => { op=>'>=', value=>$max_date },
- },
- 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
- ? " AND eventnum != $1 "
- : ''
- ),
- } );
-
- ! scalar(@existing);
-
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/once_percust.pm b/FS/FS/part_event/Condition/once_percust.pm
deleted file mode 100644
index b8a8fbf..0000000
--- a/FS/FS/part_event/Condition/once_percust.pm
+++ /dev/null
@@ -1,67 +0,0 @@
-package FS::part_event::Condition::once_percust;
-
-use strict;
-use FS::Record qw( qsearch );
-use FS::part_event;
-use FS::cust_event;
-
-use base qw( FS::part_event::Condition );
-
-sub description { "Don't run more than once per customer"; }
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 1,
- 'cust_pkg' => 1,
- };
-}
-
-sub condition {
- my($self, $object, %opt) = @_;
-
- my $obj_pkey = $object->primary_key;
- my $obj_table = $object->table;
- my $custnum = $object->custnum;
-
- my @where = (
- "tablenum IN ( SELECT $obj_pkey FROM $obj_table WHERE custnum = $custnum )"
- );
- if ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/ ) {
- push @where, " eventnum != $1 ";
- }
- my $extra_sql = ' AND '. join(' AND ', @where);
-
- my @existing = qsearch( {
- 'table' => 'cust_event',
- 'hashref' => {
- 'eventpart' => $self->eventpart,
- #'tablenum' => $tablenum,
- 'status' => { op=>'!=', value=>'failed' },
- },
- 'extra_sql' => $extra_sql,
- } );
-
- ! scalar(@existing);
-
-}
-
-#XXX test?
-sub condition_sql {
- my( $self, $table ) = @_;
-
- my %pkey = %{ FS::part_event->eventtable_pkey };
-
- my $pkey = $pkey{$table};
-
- "0 = ( SELECT COUNT(*) FROM cust_event
- WHERE cust_event.eventpart = part_event.eventpart
- AND cust_event.tablenum IN (
- SELECT $pkey FROM $table AS once_percust
- WHERE once_percust.custnum = cust_main.custnum )
- AND status != 'failed'
- )
- ";
-
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/once_perinv.pm b/FS/FS/part_event/Condition/once_perinv.pm
deleted file mode 100644
index f85a056..0000000
--- a/FS/FS/part_event/Condition/once_perinv.pm
+++ /dev/null
@@ -1,57 +0,0 @@
-package FS::part_event::Condition::once_perinv;
-
-use strict;
-use FS::Record qw( qsearch );
-use FS::part_event;
-use FS::cust_event;
-
-use base qw( FS::part_event::Condition );
-
-sub description { "Run only once for each time the package has been billed"; }
-
-# Run the event, at most, a number of times equal to the number of
-# distinct invoices that contain line items from this package.
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub condition {
- my($self, $cust_pkg, %opt) = @_;
-
- my %invnum;
- $invnum{$_->invnum} = 1
- foreach ( qsearch('cust_bill_pkg', { 'pkgnum' => $cust_pkg->pkgnum }) );
- my @events = qsearch( {
- 'table' => 'cust_event',
- 'hashref' => { 'eventpart' => $self->eventpart,
- 'status' => { op=>'!=', value=>'failed' },
- 'tablenum' => $cust_pkg->pkgnum,
- },
- 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
- ? " AND eventnum != $1 " : '' ),
- } );
- scalar(@events) < scalar(keys %invnum);
-}
-
-sub condition_sql {
- my( $self, $table ) = @_;
-
- "(
- ( SELECT COUNT(distinct(invnum))
- FROM cust_bill_pkg
- WHERE cust_bill_pkg.pkgnum = cust_pkg.pkgnum )
- >
- ( SELECT COUNT(*)
- FROM cust_event
- WHERE cust_event.eventpart = part_event.eventpart
- AND cust_event.tablenum = cust_pkg.pkgnum
- AND status != 'failed' )
- )"
-
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/payby.pm b/FS/FS/part_event/Condition/payby.pm
deleted file mode 100644
index 16bf480..0000000
--- a/FS/FS/part_event/Condition/payby.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-package FS::part_event::Condition::payby;
-
-use strict;
-use Tie::IxHash;
-use FS::payby;
-
-use base qw( FS::part_event::Condition );
-
-sub description {
- #'customer payment types: ';
- 'Customer payment type';
-}
-
-#something like this
-tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname;
-sub option_fields {
- (
- 'payby' => {
- label => 'Customer payment type',
- #type => 'select-multiple',
- type => 'checkbox-multiple',
- options => [ keys %payby ],
- option_labels => \%payby,
- },
- );
-}
-
-sub condition {
- my( $self, $object ) = @_;
-
- my $cust_main = $self->cust_main($object);
-
- my $hashref = $self->option('payby') || {};
- $hashref->{ $cust_main->payby };
-
-}
-
-sub condition_sql {
- my( $self, $table ) = @_;
-
- 'cust_main.payby IN '. $self->condition_sql_option_option('payby');
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/pkg_age.pm b/FS/FS/part_event/Condition/pkg_age.pm
deleted file mode 100644
index 4a85387..0000000
--- a/FS/FS/part_event/Condition/pkg_age.pm
+++ /dev/null
@@ -1,66 +0,0 @@
-package FS::part_event::Condition::pkg_age;
-
-use strict;
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-
-sub description {
- 'Package Age';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-#something like this
-sub option_fields {
- (
- 'age' => { 'label' => 'Package date age',
- 'type' => 'freq',
- },
- 'field' => { 'label' => 'Compare date',
- 'type' => 'select',
- 'options' =>
- [qw( setup last_bill bill adjourn susp expire cancel )],
- 'labels' => {
- 'setup' => 'Setup date',
- 'last_bill' => 'Last bill date',
- 'bill' => 'Next bill date',
- 'adjourn' => 'Adjournment date',
- 'susp' => 'Suspension date',
- 'expire' => 'Expiration date',
- 'cancel' => 'Cancellation date',
- },
- },
- );
-}
-
-sub condition {
- my( $self, $cust_pkg, %opt ) = @_;
-
- my $age = $self->option_age_from('age', $opt{'time'} );
-
- my $pkg_date = $cust_pkg->get( $self->option('field') );
-
- $pkg_date && $pkg_date <= $age;
-
-}
-
-sub condition_sql {
- my( $class, $table, %opt ) = @_;
- my $age = $class->condition_sql_option_age_from('age', $opt{'time'});
- my $field = $class->condition_sql_option('field');
-#amazingly, this is actually faster
- my $sql = '( CASE';
- foreach( qw(setup last_bill bill adjourn susp expire cancel) ) {
- $sql .= " WHEN $field = '$_' THEN (cust_pkg.$_ IS NOT NULL AND cust_pkg.$_ <= $age)";
- }
- $sql .= ' END )';
- return $sql;
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/pkg_class.pm b/FS/FS/part_event/Condition/pkg_class.pm
deleted file mode 100644
index 8c9031c..0000000
--- a/FS/FS/part_event/Condition/pkg_class.pm
+++ /dev/null
@@ -1,38 +0,0 @@
-package FS::part_event::Condition::pkg_class;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-use FS::pkg_class;
-
-sub description {
- 'Package Class';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-#something like this
-sub option_fields {
- (
- 'pkgclass' => { 'label' => 'Package Class',
- 'type' => 'select-pkg_class',
- 'multiple' => 1,
- },
- );
-}
-
-sub condition {
- my( $self, $cust_pkg ) = @_;
-
- #XXX test
- my $hashref = $self->option('pkgclass') || {};
- $hashref->{ $cust_pkg->part_pkg->classnum };
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/pkg_freq.pm b/FS/FS/part_event/Condition/pkg_freq.pm
deleted file mode 100644
index 1fb8484..0000000
--- a/FS/FS/part_event/Condition/pkg_freq.pm
+++ /dev/null
@@ -1,36 +0,0 @@
-package FS::part_event::Condition::pkg_freq;
-
-use strict;
-use FS::Misc;
-use FS::cust_pkg;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Package billing frequency'; }
-
-sub option_fields {
- my $freqs = FS::Misc::pkg_freqs();
- (
- 'freq' => { 'label' => 'Frequency',
- 'type' => 'select',
- 'labels' => $freqs,
- 'options' => [ keys(%$freqs) ],
- },
- );
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub condition {
- my($self, $cust_pkg) = @_;
-
- $cust_pkg->part_pkg->freq eq $self->option('freq')
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/pkg_next_bill_within.pm b/FS/FS/part_event/Condition/pkg_next_bill_within.pm
deleted file mode 100644
index 90c4c6a..0000000
--- a/FS/FS/part_event/Condition/pkg_next_bill_within.pm
+++ /dev/null
@@ -1,51 +0,0 @@
-package FS::part_event::Condition::pkg_next_bill_within;
-
-use strict;
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-
-sub description {
- 'Next bill date within upcoming interval';
-}
-
-# Run the event when the next bill date is within X days.
-# To clarify, that's within X days _after_ the current date,
-# not before.
-# Combine this with a "once_every" condition so that the event
-# won't repeat every day until the bill date.
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub option_fields {
- (
- 'within' => { 'label' => 'Bill date within',
- 'type' => 'freq',
- },
- # possibly "field" to allow date fields besides 'bill'?
- );
-}
-
-sub condition {
- my( $self, $cust_pkg, %opt ) = @_;
-
- my $pkg_date = $cust_pkg->get('bill') or return 0;
- $pkg_date = $self->option_age_from('within', $pkg_date );
-
- $opt{'time'} >= $pkg_date;
-
-}
-
-#XXX write me for efficiency
-sub condition_sql {
- my ($self, $table, %opt) = @_;
- $opt{'time'}.' >= '.
- $self->condition_sql_option_age_from('within', 'cust_pkg.bill')
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/pkg_notchange.pm b/FS/FS/part_event/Condition/pkg_notchange.pm
deleted file mode 100644
index 4c103c2..0000000
--- a/FS/FS/part_event/Condition/pkg_notchange.pm
+++ /dev/null
@@ -1,31 +0,0 @@
-package FS::part_event::Condition::pkg_notchange;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-
-sub description {
- 'Package is a new order, not a change';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub condition {
- my( $self, $cust_pkg ) = @_;
-
- ! $cust_pkg->change_date;
-
-}
-
-sub condition_sql {
- '( cust_pkg.change_date IS NULL OR cust_pkg.change_date = 0 )';
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/pkg_pkgpart.pm b/FS/FS/part_event/Condition/pkg_pkgpart.pm
deleted file mode 100644
index 6adef8e..0000000
--- a/FS/FS/part_event/Condition/pkg_pkgpart.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package FS::part_event::Condition::pkg_pkgpart;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Package definitions'; }
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub option_fields {
- (
- 'if_pkgpart' => { 'label' => 'Only packages: ',
- 'type' => 'select-part_pkg',
- 'multiple' => 1,
- },
- );
-}
-
-sub condition {
- my( $self, $cust_pkg) = @_;
-
- #XXX test
- my $if_pkgpart = $self->option('if_pkgpart') || {};
- $if_pkgpart->{ $cust_pkg->pkgpart };
-
-}
-
-#XXX
-#sub condition_sql {
-#
-#}
-
-1;
diff --git a/FS/FS/part_event/Condition/pkg_recurring.pm b/FS/FS/part_event/Condition/pkg_recurring.pm
deleted file mode 100644
index 1a08869..0000000
--- a/FS/FS/part_event/Condition/pkg_recurring.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package FS::part_event::Condition::pkg_recurring;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Package is recurring'; }
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub condition {
- my( $self, $cust_pkg ) = @_;
-
- $cust_pkg->part_pkg->freq !~ /^0+\D?$/; #just in case, probably just != '0'
-
-}
-
-sub condition_sql {
- FS::cust_pkg->recurring_sql()
-}
-
-1;
-
diff --git a/FS/FS/part_event/Condition/pkg_status.pm b/FS/FS/part_event/Condition/pkg_status.pm
deleted file mode 100644
index 3fb374e..0000000
--- a/FS/FS/part_event/Condition/pkg_status.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-package FS::part_event::Condition::pkg_status;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
-
-sub description {
- 'Package Status';
-}
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-#something like this
-sub option_fields {
- (
- 'status' => { 'label' => 'Package Status',
- 'type' => 'select-cust_pkg-status',
- 'multiple' => 1,
- },
- );
-}
-
-sub condition {
- my( $self, $cust_pkg ) = @_;
-
- #XXX test
- my $hashref = $self->option('status') || {};
- $hashref->{ $cust_pkg->status };
-}
-
-sub condition_sql {
- my( $self, $table ) = @_;
-
- '('.FS::cust_pkg->status_sql . ') IN '.
- $self->condition_sql_option_option('status');
-}
-
-1;
diff --git a/FS/FS/part_event/Condition/pkg_unless_pkgpart.pm b/FS/FS/part_event/Condition/pkg_unless_pkgpart.pm
deleted file mode 100644
index 47fa8c3..0000000
--- a/FS/FS/part_event/Condition/pkg_unless_pkgpart.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-package FS::part_event::Condition::pkg_unless_pkgpart;
-
-use strict;
-
-use base qw( FS::part_event::Condition );
-
-sub description { 'Except package definitions'; }
-
-sub eventtable_hashref {
- { 'cust_main' => 0,
- 'cust_bill' => 0,
- 'cust_pkg' => 1,
- };
-}
-
-sub option_fields {
- (
- 'unless_pkgpart' => { 'label' => 'Except packages: ',
- 'type' => 'select-part_pkg',
- 'multiple' => 1,
- },
- );
-}
-
-sub condition {
- my( $self, $cust_pkg) = @_;
-
- #XXX test
- my $unless_pkgpart = $self->option('unless_pkgpart') || {};
- ! $unless_pkgpart->{ $cust_pkg->pkgpart };
-
-}
-
-#XXX
-#sub condition_sql {
-#
-#}
-
-1;