stray closing /TABLE in the no-ticket case
[freeside.git] / FS / FS / agent_currency.pm
1 package FS::agent_currency;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6 use FS::agent;
7
8 =head1 NAME
9
10 FS::agent_currency - Object methods for agent_currency records
11
12 =head1 SYNOPSIS
13
14   use FS::agent_currency;
15
16   $record = new FS::agent_currency \%hash;
17   $record = new FS::agent_currency { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::agent_currency object represents an agent's ability to sell
30 in a specific non-default currency.  FS::agent_currency inherits from
31 FS::Record.  The following fields are currently supported:
32
33 =over 4
34
35 =item agentcurrencynum
36
37 primary key
38
39 =item agentnum
40
41 Agent (see L<FS::agent>)
42
43 =item currency
44
45 3 letter currency code
46
47 =back
48
49 =head1 METHODS
50
51 =over 4
52
53 =item new HASHREF
54
55 Creates a new record.  To add the record to the database, see L<"insert">.
56
57 Note that this stores the hash reference, not a distinct copy of the hash it
58 points to.  You can ask the object for a copy with the I<hash> method.
59
60 =cut
61
62 sub table { 'agent_currency'; }
63
64 =item insert
65
66 Adds this record to the database.  If there is an error, returns the error,
67 otherwise returns false.
68
69 =item delete
70
71 Delete this record from the database.
72
73 =item replace OLD_RECORD
74
75 Replaces the OLD_RECORD with this one in the database.  If there is an error,
76 returns the error, otherwise returns false.
77
78 =item check
79
80 Checks all fields to make sure this is a valid record.  If there is
81 an error, returns the error, otherwise returns false.  Called by the insert
82 and replace methods.
83
84 =cut
85
86 sub check {
87   my $self = shift;
88
89   my $error = 
90     $self->ut_numbern('agentcurrencynum')
91     || $self->ut_foreign_key('agentnum', 'agent', 'agentnum')
92     || $self->ut_currency('currency')
93   ;
94   return $error if $error;
95
96   $self->SUPER::check;
97 }
98
99 =back
100
101 =head1 BUGS
102
103 =head1 SEE ALSO
104
105 L<FS::Record>, L<FS::agent>
106
107 =cut
108
109 1;
110