agent-virtualize credit card surcharge percentage, RT#72961
[freeside.git] / FS / FS / rt_field_charge.pm
1 package FS::rt_field_charge;
2 use base qw( FS::Record );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::rt_field_charge - Object methods for rt_field_charge records
10
11 =head1 SYNOPSIS
12
13   use FS::rt_field_charge;
14
15   $record = new FS::rt_field_charge \%hash;
16   $record = new FS::rt_field_charge { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::rt_field_charge object represents an individual charge
29 that has been added to an invoice by a package with the rt_field price plan.
30 FS::rt_field_charge inherits from FS::Record.
31 The following fields are currently supported:
32
33 =over 4
34
35 =item rtfieldchargenum - primary key
36
37 =item pkgnum - cust_pkg that generated the charge
38
39 =item ticketid - RT ticket that generated the charge
40
41 =item rate - the rate per unit for the charge
42
43 =item units - quantity of units being charged
44
45 =item charge - the total amount charged
46
47 =item _date - billing date for the charge
48
49 =back
50
51 =head1 METHODS
52
53 =over 4
54
55 =item new HASHREF
56
57 Creates a new object.  To add the object to the database, see L<"insert">.
58
59 Note that this stores the hash reference, not a distinct copy of the hash it
60 points to.  You can ask the object for a copy with the I<hash> method.
61
62 =cut
63
64 # the new method can be inherited from FS::Record, if a table method is defined
65
66 sub table { 'rt_field_charge'; }
67
68 =item insert
69
70 Adds this record to the database.  If there is an error, returns the error,
71 otherwise returns false.
72
73 =cut
74
75 # the insert method can be inherited from FS::Record
76
77 =item delete
78
79 Delete this record from the database.
80
81 =cut
82
83 # the delete method can be inherited from FS::Record
84
85 =item replace OLD_RECORD
86
87 Replaces the OLD_RECORD with this one in the database.  If there is an error,
88 returns the error, otherwise returns false.
89
90 =cut
91
92 # the replace method can be inherited from FS::Record
93
94 =item check
95
96 Checks all fields to make sure this is a valid object.  If there is
97 an error, returns the error, otherwise returns false.  Called by the insert
98 and replace methods.
99
100 =cut
101
102 sub check {
103   my $self = shift;
104
105   my $error = 
106     $self->ut_numbern('rtfieldchargenum')
107     || $self->ut_foreign_key('pkgnum', 'cust_pkg', 'pkgnum' )
108     || $self->ut_number('ticketid')
109     || $self->ut_money('rate')
110     || $self->ut_float('units')
111     || $self->ut_money('charge')
112     || $self->ut_number('_date')
113   ;
114   return $error if $error;
115
116   $self->SUPER::check;
117 }
118
119 =back
120
121 =head1 BUGS
122
123
124
125 =head1 SEE ALSO
126
127 L<FS::Record>
128
129 =cut
130
131 1;
132