bulk provisioning via ftp and SOAP #5202
[freeside.git] / FS / FS / part_pkg_taxproduct.pm
1 package FS::part_pkg_taxproduct;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch );
6
7 @ISA = qw(FS::Record);
8
9 =head1 NAME
10
11 FS::part_pkg_taxproduct - Object methods for part_pkg_taxproduct records
12
13 =head1 SYNOPSIS
14
15   use FS::part_pkg_taxproduct;
16
17   $record = new FS::part_pkg_taxproduct \%hash;
18   $record = new FS::part_pkg_taxproduct { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::part_pkg_taxproduct object represents a tax product. 
31 FS::part_pkg_taxproduct inherits from FS::Record.  The following fields are
32 currently supported:
33
34 =over 4
35
36 =item taxproductnum
37
38 Primary key
39
40 =item data_vendor
41
42 Tax data vendor
43
44 =item taxproduct
45
46 Tax product id from the vendor
47
48 =item description
49
50 A human readable description of the id in taxproduct
51
52 =back
53
54 =head1 METHODS
55
56 =over 4
57
58 =item new HASHREF
59
60 Creates a new tax product.  To add the tax product to the database, see L<"insert">.
61
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to.  You can ask the object for a copy with the I<hash> method.
64
65 =cut
66
67 sub table { 'part_pkg_taxproduct'; }
68
69 =item insert
70
71 Adds this record to the database.  If there is an error, returns the error,
72 otherwise returns false.
73
74 =cut
75
76 =item delete
77
78 Delete this record from the database.
79
80 =cut
81
82 sub delete {
83   my $self = shift;
84
85   return "Can't delete a tax product which has attached package tax rates!"
86     if qsearch( 'part_pkg_taxrate', { 'taxproductnum' => $self->taxproductnum } );
87
88   return "Can't delete a tax product which has attached packages!"
89     if qsearch( 'part_pkg', { 'taxproductnum' => $self->taxproductnum } );
90
91   $self->SUPER::delete(@_);
92 }
93
94 =item replace OLD_RECORD
95
96 Replaces the OLD_RECORD with this one in the database.  If there is an error,
97 returns the error, otherwise returns false.
98
99 =cut
100
101 =item check
102
103 Checks all fields to make sure this is a valid tax product.  If there is
104 an error, returns the error, otherwise returns false.  Called by the insert
105 and replace methods.
106
107 =cut
108
109 sub check {
110   my $self = shift;
111
112   my $error = 
113     $self->ut_numbern('taxproductnum')
114     || $self->ut_textn('data_vendor')
115     || $self->ut_text('taxproduct')
116     || $self->ut_textn('description')
117   ;
118   return $error if $error;
119
120   $self->SUPER::check;
121 }
122
123 =back
124
125 =cut
126
127 =head1 BUGS
128
129 =head1 SEE ALSO
130
131 L<FS::Record>, schema.html from the base documentation.
132
133 =cut
134
135 1;
136