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