delete fees, RT#81713
[freeside.git] / FS / FS / cust_main_credit_limit.pm
1 package FS::cust_main_credit_limit;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6 use FS::cust_main;
7
8 =head1 NAME
9
10 FS::cust_main_credit_limit - Object methods for cust_main_credit_limit records
11
12 =head1 SYNOPSIS
13
14   use FS::cust_main_credit_limit;
15
16   $record = new FS::cust_main_credit_limit \%hash;
17   $record = new FS::cust_main_credit_limit { '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::cust_main_credit_limit object represents a specific incident where a
30 customer exceeds their credit limit.  FS::cust_main_credit_limit inherits from
31 FS::Record.  The following fields are currently supported:
32
33 =over 4
34
35 =item creditlimitnum
36
37 primary key
38
39 =item custnum
40
41 Customer (see L<FS::cust_main>)
42
43 =item _date
44
45 Ppecified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
46 L<Time::Local> and L<Date::Parse> for conversion functions.
47
48 =item amount
49
50 Amount of credit of the incident
51
52 =item credit_limit
53
54 Appliable customer or default credit_limit at the time of the incident
55
56 =back
57
58 =head1 METHODS
59
60 =over 4
61
62 =item new HASHREF
63
64 Creates a new record.  To add the record to the database, see L<"insert">.
65
66 Note that this stores the hash reference, not a distinct copy of the hash it
67 points to.  You can ask the object for a copy with the I<hash> method.
68
69 =cut
70
71 sub table { 'cust_main_credit_limit'; }
72
73 =item insert
74
75 Adds this record to the database.  If there is an error, returns the error,
76 otherwise returns false.
77
78 =item delete
79
80 Delete this record from the database.
81
82 =item replace OLD_RECORD
83
84 Replaces the OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =item check
88
89 Checks all fields to make sure this is a valid record.  If there is
90 an error, returns the error, otherwise returns false.  Called by the insert
91 and replace methods.
92
93 =cut
94
95 sub check {
96   my $self = shift;
97
98   my $error = 
99     $self->ut_numbern('creditlimitnum')
100     || $self->ut_foreign_keyn('custnum', 'cust_main', 'custnum')
101     || $self->ut_number('_date')
102     || $self->ut_money('amount')
103     || $self->ut_money('credit_limit')
104   ;
105   return $error if $error;
106
107   $self->SUPER::check;
108 }
109
110 =back
111
112 =head1 BUGS
113
114 =head1 SEE ALSO
115
116 L<FS::Record>
117
118 =cut
119
120 1;
121