default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / FS / FS / cust_credit_source_bill_pkg.pm
1 package FS::cust_credit_source_bill_pkg;
2 use base qw( FS::cust_main_Mixin FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::cust_credit_source_bill_pkg - Object methods for cust_credit_source_bill_pkg records
10
11 =head1 SYNOPSIS
12
13   use FS::cust_credit_source_bill_pkg;
14
15   $record = new FS::cust_credit_source_bill_pkg \%hash;
16   $record = new FS::cust_credit_source_bill_pkg { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::cust_credit_source_bill_pkg object represents the record that a credit
29 was triggered by a specific line item.  FS::cust_credit_source_bill_pkg
30 inherits from FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item creditsourcebillpkgnum
35
36 Primary key
37
38 =item crednum
39
40 Credit (see L<FS::cust_credit>)
41
42 =item billpkgnum
43
44 Line item (see L<FS::cust_bill_pkg>)
45
46 =item amount
47
48 Amount specific to this line item.
49
50 =item currency
51
52 Currency
53
54 =back
55
56 =head1 METHODS
57
58 =over 4
59
60 =item new HASHREF
61
62 Creates a new record.  To add the record to the database, see L<"insert">.
63
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to.  You can ask the object for a copy with the I<hash> method.
66
67 =cut
68
69 sub table { 'cust_credit_source_bill_pkg'; }
70
71 =item insert
72
73 Adds this record to the database.  If there is an error, returns the error,
74 otherwise returns false.
75
76 =item delete
77
78 Delete this record from the database.
79
80 =item replace OLD_RECORD
81
82 Replaces the OLD_RECORD with this one in the database.  If there is an error,
83 returns the error, otherwise returns false.
84
85 =item check
86
87 Checks all fields to make sure this is a valid record.  If there is
88 an error, returns the error, otherwise returns false.  Called by the insert
89 and replace methods.
90
91 =cut
92
93 sub check {
94   my $self = shift;
95
96   my $error = 
97     $self->ut_numbern('creditsourcebillpkgnum')
98     || $self->ut_foreign_key('crednum', 'cust_credit', 'crednum')
99     || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
100     || $self->ut_money('amount')
101     || $self->ut_currencyn('currency')
102   ;
103   return $error if $error;
104
105   $self->SUPER::check;
106 }
107
108 =back
109
110 =head1 BUGS
111
112 Terminology/documentation surrounding credit "sources" vs. credit
113 "applications" is hard to understand.
114
115 =head1 SEE ALSO
116
117 L<FS::cust_credit>, L<FS::cust_bill_pkg>, L<FS::Record>
118
119 =cut
120
121 1;
122