This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_pkg_vendor.pm
1 package FS::part_pkg_vendor;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::part_pkg_vendor - Object methods for part_pkg_vendor records
10
11 =head1 SYNOPSIS
12
13   use FS::part_pkg_vendor;
14
15   $record = new FS::part_pkg_vendor \%hash;
16   $record = new FS::part_pkg_vendor { '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::part_pkg_vendor object represents a mapping of pkgpart numbers to
29 external package numbers.  FS::part_pkg_vendor inherits from FS::Record. 
30 The following fields are currently supported:
31
32 =over 4
33
34 =item num
35
36 primary key
37
38 =item pkgpart
39
40 pkgpart
41
42 =item exportnum
43
44 exportnum
45
46 =item vendor_pkg_id
47
48 vendor_pkg_id
49
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new example.  To add the example 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 { 'part_pkg_vendor'; }
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 =cut
76
77 # the insert method can be inherited from FS::Record
78
79 =item delete
80
81 Delete this record from the database.
82
83 =cut
84
85 # the delete method can be inherited from FS::Record
86
87 =item replace OLD_RECORD
88
89 Replaces the OLD_RECORD with this one in the database.  If there is an error,
90 returns the error, otherwise returns false.
91
92 =cut
93
94 # the replace method can be inherited from FS::Record
95
96 =item check
97
98 Checks all fields to make sure this is a valid example.  If there is
99 an error, returns the error, otherwise returns false.  Called by the insert
100 and replace methods.
101
102 =cut
103
104 # the check method should currently be supplied - FS::Record contains some
105 # data checking routines
106
107 sub check {
108   my $self = shift;
109
110   my $error = 
111     $self->ut_numbern('num')
112     || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart')
113     || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
114     || $self->ut_textn('vendor_pkg_id')
115   ;
116   return $error if $error;
117
118   $self->SUPER::check;
119 }
120
121 =item part_export
122
123 Returns the L<FS::part_export> associated with this vendor/external package id.
124
125 =cut
126 sub part_export {
127     my $self = shift;
128     qsearchs( 'part_export', { 'exportnum' => $self->exportnum } );
129 }
130
131 =back
132
133 =head1 SEE ALSO
134
135 L<FS::part_pkg>, L<FS::Record>, schema.html from the base documentation.
136
137 =cut
138
139 1;
140