backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / export_cust_svc.pm
1 package FS::export_cust_svc;
2 use base qw(FS::Record);
3
4 use strict;
5 use FS::Record qw( qsearchs );
6
7 =head1 NAME
8
9 FS::export_cust_svc - Object methods for export_cust_svc records
10
11 =head1 SYNOPSIS
12
13   use FS::export_cust_svc;
14
15   $record = new FS::export_cust_svc \%hash;
16   $record = new FS::export_cust_svc { '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::export_cust_svc object represents information unique
29 to a given part_export and cust_svc pair.
30 FS::export_cust_svc inherits from FS::Record.  
31 The following fields are currently supported:
32
33 =over 4
34
35 =item exportcustsvcnum - primary key
36
37 =item exportnum - export (see L<FS::part_export>)
38
39 =item svcnum - service (see L<FS::cust_svc>)
40
41 =item remoteid - id for accessing service on export remote system
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Creates a new export_cust_svc object.  To add the object to the database, see
52 L<"insert">.
53
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to.  You can ask the object for a copy with the I<hash> method.
56
57 =cut
58
59 # the new method can be inherited from FS::Record, if a table method is defined
60
61 sub table { 'export_cust_svc'; }
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 sub insert {
71   my $self = shift;
72   return "export_cust_svc for exportnum ".$self->exportnum.
73          " svcnum ".$self->svcnum." already exists"
74     if qsearchs('export_cust_svc',{ 'exportnum' => $self->exportnum,
75                                     'svcnum'    => $self->svcnum });
76   $self->SUPER::insert;
77 }
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 export option.  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('exportcustsvcnum')
112     || $self->ut_foreign_key('exportnum', 'part_export', 'exportnum')
113     || $self->ut_foreign_key('svcnum', 'cust_svc', 'svcnum')
114     || $self->ut_text('remoteid')
115   ;
116   return $error if $error;
117
118   $self->SUPER::check;
119 }
120
121 =back
122
123 =head1 BUGS
124
125 Possibly.
126
127 =head1 SEE ALSO
128
129 L<FS::part_export>, L<FS::cust_svc>, L<FS::Record>
130
131 =cut
132
133 1;
134