summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Action
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/part_event/Action')
-rw-r--r--FS/FS/part_event/Action/Mixin/fee.pm45
-rw-r--r--FS/FS/part_event/Action/cust_bill_fee.pm12
-rw-r--r--FS/FS/part_event/Action/cust_fee.pm16
3 files changed, 73 insertions, 0 deletions
diff --git a/FS/FS/part_event/Action/Mixin/fee.pm b/FS/FS/part_event/Action/Mixin/fee.pm
new file mode 100644
index 000000000..8eb86fa1d
--- /dev/null
+++ b/FS/FS/part_event/Action/Mixin/fee.pm
@@ -0,0 +1,45 @@
+package FS::part_event::Action::Mixin::fee;
+
+use strict;
+use base qw( FS::part_event::Action );
+
+sub event_stage { 'pre-bill'; }
+
+sub option_fields {
+ (
+ 'feepart' => { label => 'Fee definition',
+ type => 'select-table', #select-part_fee XXX
+ table => 'part_fee',
+ hashref => { disabled => '' },
+ name_col => 'itemdesc',
+ value_col => 'feepart',
+ disable_empty => 1,
+ },
+ );
+}
+
+sub default_weight { 10; }
+
+sub do_action {
+ my( $self, $cust_object, $cust_event ) = @_;
+
+ die "no fee definition selected for event '".$self->event."'\n"
+ unless $self->option('feepart');
+
+ # mark the event so that the fee will be charged
+ # the logic for calculating the fee amount is in FS::part_fee
+ # the logic for attaching it to the base invoice/line items is in
+ # FS::cust_bill_pkg
+ my $cust_event_fee = FS::cust_event_fee->new({
+ 'eventnum' => $cust_event->eventnum,
+ 'feepart' => $self->option('feepart'),
+ 'billpkgnum' => '',
+ });
+
+ my $error = $cust_event_fee->insert;
+ die $error if $error;
+
+ '';
+}
+
+1;
diff --git a/FS/FS/part_event/Action/cust_bill_fee.pm b/FS/FS/part_event/Action/cust_bill_fee.pm
new file mode 100644
index 000000000..fc185e439
--- /dev/null
+++ b/FS/FS/part_event/Action/cust_bill_fee.pm
@@ -0,0 +1,12 @@
+package FS::part_event::Action::cust_bill_fee;
+
+use strict;
+use base qw( FS::part_event::Action::Mixin::fee );
+
+sub description { 'Charge a fee based on this invoice'; }
+
+sub eventtable_hashref {
+ { 'cust_bill' => 1 };
+}
+
+1;
diff --git a/FS/FS/part_event/Action/cust_fee.pm b/FS/FS/part_event/Action/cust_fee.pm
new file mode 100644
index 000000000..a6f1078e8
--- /dev/null
+++ b/FS/FS/part_event/Action/cust_fee.pm
@@ -0,0 +1,16 @@
+package FS::part_event::Action::cust_fee;
+
+use strict;
+use base qw( FS::part_event::Action::Mixin::fee );
+
+sub description { 'Charge a fee based on the customer\'s current invoice'; }
+
+sub eventtable_hashref {
+ { 'cust_main' => 1 };
+}
+
+# Otherwise identical to cust_bill_fee. We only have a separate event
+# because it behaves differently as an invoice event than as a customer
+# event, and needs a different description.
+
+1;