time/data/etc. unit pricing add-ons, RT#24392
[freeside.git] / FS / FS / cust_pkg_usageprice.pm
1 package FS::cust_pkg_usageprice;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::cust_pkg_usageprice - Object methods for cust_pkg_usageprice records
10
11 =head1 SYNOPSIS
12
13   use FS::cust_pkg_usageprice;
14
15   $record = new FS::cust_pkg_usageprice \%hash;
16   $record = new FS::cust_pkg_usageprice { '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_pkg_usageprice object represents an specific customer package usage
29 pricing add-on.  FS::cust_pkg_usageprice inherits from FS::Record.  The
30 following fields are currently supported:
31
32 =over 4
33
34 =item usagepricenum
35
36 primary key
37
38 =item pkgnum
39
40 pkgnum
41
42 =item usagepricepart
43
44 usagepricepart
45
46 =item quantity
47
48 quantity
49
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new record.  To add the record to the database, see L<"insert">.
60
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to.  You can ask the object for a copy with the I<hash> method.
63
64 =cut
65
66 # the new method can be inherited from FS::Record, if a table method is defined
67
68 sub table { 'cust_pkg_usageprice'; }
69
70 =item insert
71
72 Adds this record to the database.  If there is an error, returns the error,
73 otherwise returns false.
74
75 =item delete
76
77 Delete this record from the database.
78
79 =item replace OLD_RECORD
80
81 Replaces the OLD_RECORD with this one in the database.  If there is an error,
82 returns the error, otherwise returns false.
83
84 =item check
85
86 Checks all fields to make sure this is a valid record.  If there is
87 an error, returns the error, otherwise returns false.  Called by the insert
88 and replace methods.
89
90 =cut
91
92 sub check {
93   my $self = shift;
94
95   my $error = 
96     $self->ut_numbern('usagepricenum')
97     || $self->ut_number('pkgnum')
98     || $self->ut_number('usagepricepart')
99     || $self->ut_number('quantity')
100   ;
101   return $error if $error;
102
103   $self->SUPER::check;
104 }
105
106 =back
107
108 =head1 BUGS
109
110 =head1 SEE ALSO
111
112 L<FS::Record>
113
114 =cut
115
116 1;
117