1 package FS::cust_credit_bill;
5 use FS::UID qw( getotaker );
6 use FS::Record qw( qsearch qsearchs );
12 @ISA = qw( FS::Record );
16 FS::cust_credit_bill - Object methods for cust_credit_bill records
20 use FS::cust_credit_bill;
22 $record = new FS::cust_credit_bill \%hash;
23 $record = new FS::cust_credit_bill { '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_credit_bill object represents application of a credit (see
36 L<FS::cust_credit>) to a customer bill (see L<FS::cust_bill>). FS::cust_credit
37 inherits from FS::Record. The following fields are currently supported:
41 =item crednum - primary key; credit being applied
43 =item invnum - invoice to which credit is applied (see L<FS::cust_bill>)
45 =item amount - amount of the credit applied
47 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
48 L<Time::Local> and L<Date::Parse> for conversion functions.
58 Creates a new cust_credit_bill. To add the cust_credit_bill to the database,
63 sub table { 'cust_credit_bill'; }
67 Adds this cust_credit_bill to the database ("Posts" all or part of a credit).
68 If there is an error, returns the error, otherwise returns false.
72 Currently unimplemented.
77 return "Can't unapply credit!"
80 =item replace OLD_RECORD
82 Application of credits may not be modified.
87 return "Can't modify application of credit!"
92 Checks all fields to make sure this is a valid credit application. If there
93 is an error, returns the error, otherwise returns false. Called by the insert
102 $self->ut_numbern('creditbillnum')
103 || $self->ut_number('crednum')
104 || $self->ut_number('invnum')
105 || $self->ut_numbern('_date')
106 || $self->ut_money('amount')
108 return $error if $error;
110 return "Unknown credit"
111 unless my $cust_credit =
112 qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
114 return "Unknown invoice"
115 unless my $cust_bill =
116 qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
118 $self->_date(time) unless $self->_date;
120 return "Cannot apply more than remaining value of credit memo"
121 unless $self->amount <= $cust_credit->credited;
123 return "Cannot apply more than remaining value of invoice"
124 unless $self->amount <= $cust_bill->owed;
133 $Id: cust_credit_bill.pm,v 1.2 2001-09-01 22:18:38 ivan Exp $
141 L<FS::Record>, L<FS::cust_refund>, L<FS::cust_bill>, L<cust_credit>,
142 schema.html from the base documentation.