1 package FS::cust_pkg_reason_fee;
4 use base qw( FS::Record FS::FeeOrigin_Mixin );
5 use FS::Record qw( qsearch qsearchs );
9 FS::cust_pkg_reason_fee - Object methods for cust_pkg_reason_fee records
13 use FS::cust_pkg_reason_fee;
15 $record = new FS::cust_pkg_reason_fee \%hash;
16 $record = new FS::cust_pkg_reason_fee { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::cust_pkg_reason_fee object links a package status change that charged
29 a fee (an L<FS::cust_pkg_reason> object) to the resulting invoice line item.
30 FS::cust_pkg_reason_fee inherits from FS::Record and FS::FeeOrigin_Mixin.
31 The following fields are currently supported:
35 =item pkgreasonfeenum - primary key
37 =item pkgreasonnum - key of the cust_pkg_reason object that triggered the fee.
39 =item billpkgnum - key of the cust_bill_pkg record representing the fee on an
40 invoice. This can be NULL if the fee is scheduled but hasn't been billed yet.
42 =item feepart - key of the fee definition (L<FS::part_fee>).
44 =item nextbill - 'Y' if the fee should be charged on the customer's next bill,
45 rather than causing a bill to be produced immediately.
55 Creates a new record. To add the record to the database, see L<"insert">.
59 sub table { 'cust_pkg_reason_fee'; }
63 Adds this record to the database. If there is an error, returns the error,
64 otherwise returns false.
68 Delete this record from the database.
70 =item replace OLD_RECORD
72 Replaces the OLD_RECORD with this one in the database. If there is an error,
73 returns the error, otherwise returns false.
77 Checks all fields to make sure this is a valid example. If there is
78 an error, returns the error, otherwise returns false. Called by the insert
87 $self->ut_numbern('pkgreasonfeenum')
88 || $self->ut_foreign_key('pkgreasonnum', 'cust_pkg_reason', 'num')
89 || $self->ut_foreign_keyn('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
90 || $self->ut_foreign_key('feepart', 'part_fee', 'feepart')
91 || $self->ut_flag('nextbill')
93 return $error if $error;
104 =item _by_cust CUSTNUM[, PARAMS]
106 See L<FS::FeeOrigin_Mixin/by_cust>.
112 my $custnum = shift or return;
114 $custnum =~ /^\d+$/ or die "bad custnum $custnum";
116 my $where = ($params{hashref} && keys (%{ $params{hashref} }))
120 table => 'cust_pkg_reason_fee',
121 addl_from => 'JOIN cust_pkg_reason ON (cust_pkg_reason_fee.pkgreasonnum = cust_pkg_reason.num) ' .
122 'JOIN cust_pkg USING (pkgnum) ',
123 extra_sql => "$where cust_pkg.custnum = $custnum",
136 Returns the package that triggered the fee.
142 $self->cust_pkg_reason->cust_pkg;
147 L<FS::FeeOrigin_Mixin>, L<FS::cust_pkg_reason>, L<part_fee>