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