enable CardFortress in test database, #71513
[freeside.git] / FS / FS / type_pkgs.pm
1 package FS::type_pkgs;
2 use base qw( FS::Record );
3
4 use strict;
5
6 =head1 NAME
7
8 FS::type_pkgs - Object methods for type_pkgs records
9
10 =head1 SYNOPSIS
11
12   use FS::type_pkgs;
13
14   $record = new FS::type_pkgs \%hash;
15   $record = new FS::type_pkgs { '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::type_pkgs record links an agent type (see L<FS::agent_type>) to a
28 billing item definition (see L<FS::part_pkg>).  FS::type_pkgs inherits from
29 FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item typepkgnum - primary key
34
35 =item typenum - Agent type, see L<FS::agent_type>
36
37 =item pkgpart - Billing item definition, see L<FS::part_pkg>
38
39 =back
40
41 =head1 METHODS
42
43 =over 4
44
45 =item new HASHREF
46
47 Create a new record.  To add the record to the database, see L<"insert">.
48
49 =cut
50
51 sub table { 'type_pkgs'; }
52
53 =item insert
54
55 Adds this record to the database.  If there is an error, returns the error,
56 otherwise returns false.
57
58 =item delete
59
60 Deletes this record from the database.  If there is an error, returns the
61 error, otherwise returns false.
62
63 =item replace OLD_RECORD
64
65 Replaces OLD_RECORD with this one in the database.  If there is an error,
66 returns the error, otherwise returns false.
67
68 =item check
69
70 Checks all fields to make sure this is a valid record.  If there is an error,
71 returns the error, otherwise returns false.  Called by the insert and replace
72 methods.
73
74 =cut
75
76 sub check {
77   my $self = shift;
78
79   my $error = 
80        $self->ut_numbern('typepkgnum')
81     || $self->ut_foreign_key('typenum', 'agent_type', 'typenum' )
82     || $self->ut_foreign_key('pkgpart', 'part_pkg',   'pkgpart' )
83   ;
84   return $error if $error;
85
86   $self->SUPER::check;
87 }
88
89 =item part_pkg
90
91 Returns the FS::part_pkg object associated with this record.
92
93 =item agent_type
94
95 Returns the FS::agent_type object associated with this record.
96
97 =cut
98
99 =back
100
101 =head1 BUGS
102
103 =head1 SEE ALSO
104
105 L<FS::Record>, L<FS::agent_type>, L<FS::part_pkgs>, schema.html from the base
106 documentation.
107
108 =cut
109
110 1;
111