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