1 package FS::cust_pay_void;
4 use Business::CreditCard;
5 use FS::UID qw(getotaker);
6 use FS::Record qw(qsearchs); # dbh qsearch );
8 #use FS::cust_bill_pay;
9 #use FS::cust_pay_refund;
12 @ISA = qw( FS::Record );
16 FS::cust_pay_void - Object methods for cust_pay_void objects
20 use FS::cust_pay_void;
22 $record = new FS::cust_pay_void \%hash;
23 $record = new FS::cust_pay_void { 'column' => 'value' };
25 $error = $record->insert;
27 $error = $new_record->replace($old_record);
29 $error = $record->delete;
31 $error = $record->check;
35 An FS::cust_pay_void object represents a voided payment. The following fields
36 are currently supported:
40 =item paynum - primary key (assigned automatically for new payments)
42 =item custnum - customer (see L<FS::cust_main>)
44 =item paid - Amount of this payment
46 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
47 L<Time::Local> and L<Date::Parse> for conversion functions.
49 =item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH),
50 `LECB' (phone bill billing), `BILL' (billing), or `COMP' (free)
52 =item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
54 =item paybatch - text field for tracking card processing
56 =item closed - books closed flag, empty or `Y'
70 Creates a new payment. To add the payment to the databse, see L<"insert">.
74 sub table { 'cust_pay_void'; }
78 Adds this voided payment to the database.
82 Currently unimplemented.
87 return "Can't delete voided payments!";
90 =item replace OLD_RECORD
92 Currently unimplemented.
97 return "Can't modify voided payments!";
102 Checks all fields to make sure this is a valid voided payment. If there is an
103 error, returns the error, otherwise returns false. Called by the insert
112 $self->ut_numbern('paynum')
113 || $self->ut_numbern('custnum')
114 || $self->ut_money('paid')
115 || $self->ut_number('_date')
116 || $self->ut_textn('paybatch')
117 || $self->ut_enum('closed', [ '', 'Y' ])
118 || $self->ut_numbern('void_date')
119 || $self->ut_textn('reason')
121 return $error if $error;
123 return "paid must be > 0 " if $self->paid <= 0;
125 return "unknown cust_main.custnum: ". $self->custnum
127 || qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
129 $self->void_date(time) unless $self->void_date;
131 $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby";
134 #false laziness with cust_refund::check
135 if ( $self->payby eq 'CARD' ) {
136 my $payinfo = $self->payinfo;
138 $self->payinfo($payinfo);
139 if ( $self->payinfo ) {
140 $self->payinfo =~ /^(\d{13,16})$/
141 or return "Illegal (mistyped?) credit card number (payinfo)";
143 validate($self->payinfo) or return "Illegal credit card number";
144 return "Unknown card type" if cardtype($self->payinfo) eq "Unknown";
146 $self->payinfo('N/A');
150 $error = $self->ut_textn('payinfo');
151 return $error if $error;
154 $self->otaker(getotaker);
161 Returns the parent customer object (see L<FS::cust_main>).
167 qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
172 Returns a "masked" payinfo field with all but the last four characters replaced
173 by 'x'es. Useful for displaying credit cards.
179 my $payinfo = $self->payinfo;
180 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4));
187 Delete and replace methods.
191 L<FS::cust_pay>, L<FS::Record>, schema.html from the base documentation.