communigate provisioning phase 2: Domain:Account Defaults:Settings: RulesAllowed...
[freeside.git] / FS / FS / banned_pay.pm
1 package FS::banned_pay;
2
3 use strict;
4 use base qw( FS::otaker_Mixin FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::UID qw( getotaker );
7
8 =head1 NAME
9
10 FS::banned_pay - Object methods for banned_pay records
11
12 =head1 SYNOPSIS
13
14   use FS::banned_pay;
15
16   $record = new FS::banned_pay \%hash;
17   $record = new FS::banned_pay { '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::banned_pay object represents an banned credit card or ACH account.
30 FS::banned_pay inherits from FS::Record.  The following fields are currently
31 supported:
32
33 =over 4
34
35 =item bannum - primary key
36
37 =item payby - I<CARD> or I<CHEK>
38
39 =item payinfo - fingerprint of banned card (base64-encoded MD5 digest)
40
41 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">.  Also see
42 L<Time::Local> and L<Date::Parse> for conversion functions.
43
44 =item otaker - order taker (assigned automatically, see L<FS::UID>)
45
46 =item reason - reason (text)
47
48 =back
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new ban.  To add the ban to the database, see L<"insert">.
57
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to.  You can ask the object for a copy with the I<hash> method.
60
61 =cut
62
63 # the new method can be inherited from FS::Record, if a table method is defined
64
65 sub table { 'banned_pay'; }
66
67 =item insert
68
69 Adds this record to the database.  If there is an error, returns the error,
70 otherwise returns false.
71
72 =cut
73
74 # the insert method can be inherited from FS::Record
75
76 =item delete
77
78 Delete this record from the database.
79
80 =cut
81
82 # the delete method can be inherited from FS::Record
83
84 =item replace OLD_RECORD
85
86 Replaces the OLD_RECORD with this one in the database.  If there is an error,
87 returns the error, otherwise returns false.
88
89 =cut
90
91 # the replace method can be inherited from FS::Record
92
93 =item check
94
95 Checks all fields to make sure this is a valid ban.  If there is
96 an error, returns the error, otherwise returns false.  Called by the insert
97 and replace methods.
98
99 =cut
100
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
103
104 sub check {
105   my $self = shift;
106
107   my $error = 
108     $self->ut_numbern('bannum')
109     || $self->ut_enum('payby', [ 'CARD', 'CHEK' ] )
110     || $self->ut_text('payinfo')
111     || $self->ut_numbern('_date')
112     || $self->ut_textn('reason')
113   ;
114   return $error if $error;
115
116   $self->_date(time) unless $self->_date;
117
118   $self->otaker(getotaker) unless $self->otaker;
119
120   $self->SUPER::check;
121 }
122
123 # Used by FS::Upgrade to migrate to a new database.
124 sub _upgrade_data {  # class method
125   my ($class, %opts) = @_;
126   $class->_upgrade_otaker(%opts);
127 }
128
129 =back
130
131 =head1 BUGS
132
133 =head1 SEE ALSO
134
135 L<FS::Record>, schema.html from the base documentation.
136
137 =cut
138
139 1;
140