session monitor updates
[freeside.git] / FS / FS / prepay_credit.pm
1 package FS::prepay_credit;
2
3 use strict;
4 use vars qw( @ISA );
5 #use FS::Record qw( qsearch qsearchs );
6 use FS::Record qw();
7
8 @ISA = qw(FS::Record);
9
10 =head1 NAME
11
12 FS::prepay_credit - Object methods for prepay_credit records
13
14 =head1 SYNOPSIS
15
16   use FS::prepay_credit;
17
18   $record = new FS::prepay_credit \%hash;
19   $record = new FS::prepay_credit {
20     'identifier' => '4198123455512121'
21     'amount'     => '19.95',
22   };
23
24   $error = $record->insert;
25
26   $error = $new_record->replace($old_record);
27
28   $error = $record->delete;
29
30   $error = $record->check;
31
32 =head1 DESCRIPTION
33
34 An FS::table_name object represents an pre--paid credit, such as a pre-paid
35 "calling card".  FS::prepay_credit inherits from FS::Record.  The following
36 fields are currently supported:
37
38 =over 4
39
40 =item field - description
41
42 =item identifier - identifier entered by the user to receive the credit
43
44 =item amount - amount of the credit
45
46 =back
47
48 =head1 METHODS
49
50 =over 4
51
52 =item new HASHREF
53
54 Creates a new pre-paid credit.  To add the example to the database, see
55 L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 sub table { 'prepay_credit'; }
63
64 =item insert
65
66 Adds this record to the database.  If there is an error, returns the error,
67 otherwise returns false.
68
69 =cut
70
71 =item delete
72
73 Delete this record from the database.
74
75 =cut
76
77 =item replace OLD_RECORD
78
79 Replaces the OLD_RECORD with this one in the database.  If there is an error,
80 returns the error, otherwise returns false.
81
82 =cut
83
84 =item check
85
86 Checks all fields to make sure this is a valid pre-paid credit.  If there is
87 an error, returns the error, otherwise returns false.  Called by the insert
88 and replace methods.
89
90 =cut
91
92 sub check {
93   my $self = shift;
94
95   my $identifier = $self->identifier;
96   $identifier =~ s/\W//g; #anything else would just confuse things
97   $self->identifier($identifier);
98
99   $self->ut_numbern('prepaynum')
100   || $self->ut_alpha('identifier')
101   || $self->ut_money('amount')
102   ;
103
104 }
105
106 =back
107
108 =head1 VERSION
109
110 $Id: prepay_credit.pm,v 1.2 2000-02-02 20:22:18 ivan Exp $
111
112 =head1 BUGS
113
114 =head1 SEE ALSO
115
116 L<FS::Record>, schema.html from the base documentation.
117
118 =head1 HISTORY
119
120 $Log: prepay_credit.pm,v $
121 Revision 1.2  2000-02-02 20:22:18  ivan
122 bugfix prepayment in signup server
123
124 Revision 1.1  2000/01/31 05:22:23  ivan
125 prepaid "internet cards"
126
127
128 =cut
129
130 1;
131