add customer fields option with agent, display_custnum, status and name, RT#73721
[freeside.git] / FS / FS / currency_exchange.pm
1 package FS::currency_exchange;
2 use base qw( FS::Record );
3
4 use strict;
5 #use FS::Record qw( qsearch qsearchs );
6
7 =head1 NAME
8
9 FS::currency_exchange - Object methods for currency_exchange records
10
11 =head1 SYNOPSIS
12
13   use FS::currency_exchange;
14
15   $record = new FS::currency_exchange \%hash;
16   $record = new FS::currency_exchange { '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::currency_exchange object represents an exchange rate between currencies.
29 FS::currency_exchange inherits from FS::Record.  The following fields are
30 currently supported:
31
32 =over 4
33
34 =item currencyratenum
35
36 primary key
37
38 =item from_currency
39
40 from_currency
41
42 =item to_currency
43
44 to_currency
45
46 =item rate
47
48 rate
49
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new exchange rate.  To add the exchange rate to the database, see
60 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 { 'currency_exchange'; }
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 =item delete
75
76 Delete this record from the database.
77
78 =item replace OLD_RECORD
79
80 Replaces the OLD_RECORD with this one in the database.  If there is an error,
81 returns the error, otherwise returns false.
82
83 =item check
84
85 Checks all fields to make sure this is a valid exchange rate.  If there is
86 an error, returns the error, otherwise returns false.  Called by the insert
87 and replace methods.
88
89 =cut
90
91 sub check {
92   my $self = shift;
93
94   my $error = 
95     $self->ut_numbern('currencyratenum')
96     || $self->ut_currency('from_currency')
97     || $self->ut_currency('to_currency')
98     || $self->ut_float('rate') #good enough for untainting
99   ;
100   return $error if $error;
101
102   $self->SUPER::check;
103 }
104
105 =back
106
107 =head1 BUGS
108
109 =head1 SEE ALSO
110
111 L<FS::Record>, schema.html from the base documentation.
112
113 =cut
114
115 1;
116