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