1 package FS::part_event::Action::Mixin::fee;
4 use base qw( FS::part_event::Action );
5 use FS::Record qw( qsearch );
7 sub event_stage { 'pre-bill'; }
11 'feepart' => { label => 'Fee definition',
12 type => 'select-table', #select-part_fee XXX
14 hashref => { disabled => '' },
15 name_col => 'itemdesc',
16 value_col => 'feepart',
23 sub default_weight { 10; }
25 sub hold_until_bill { 1 }
28 my( $self, $cust_object, $cust_event ) = @_;
30 my $feepart = $self->option('feepart')
31 or die "no fee definition selected for event '".$self->event."'\n";
32 my $tablenum = $cust_object->get($cust_object->primary_key);
34 # see if there's already a pending fee for this customer/invoice
35 my @existing = qsearch({
36 table => 'cust_event_fee',
37 addl_from => 'JOIN cust_event USING (eventnum)',
38 hashref => { feepart => $feepart,
40 extra_sql => " AND tablenum = $tablenum",
42 if (scalar @existing > 0) {
43 warn $self->event." event, object $tablenum: already scheduled\n"
44 if $FS::part_fee::DEBUG;
48 # mark the event so that the fee will be charged
49 # the logic for calculating the fee amount is in FS::part_fee
50 # the logic for attaching it to the base invoice/line items is in
52 my $cust_event_fee = FS::cust_event_fee->new({
53 'eventnum' => $cust_event->eventnum,
54 'feepart' => $feepart,
56 'nextbill' => $self->hold_until_bill ? 'Y' : '',
59 my $error = $cust_event_fee->insert;