summaryrefslogtreecommitdiff
path: root/LedgerSMB/Form.pm
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-26 20:42:18 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-26 20:42:18 +0000
commitfc82031a2d6d90e95b76d32e61ecdef763981d9a (patch)
treeb1d848eec949ea448267eeab485388954bd8aa02 /LedgerSMB/Form.pm
parent8876d69d3d9a0d81b1731f65acf0727676598091 (diff)
Fix typo that stopped non-default currency order->invoice conversion to fail
Add more Pod to Form.pm git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1443 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Form.pm')
-rw-r--r--LedgerSMB/Form.pm63
1 files changed, 62 insertions, 1 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 88773934..e205c0de 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -1071,6 +1071,15 @@ qq|<button class="submit" type="submit" name="action" value="$name" accesskey="$
# Database routines used throughout
+=item $form->db_init($myconfig);
+
+Connect to the database that $myconfig is set to use and initialise the base
+parameters. The connection handle becomes $form->{dbh} and
+$form->{custom_db_fields} is populated. The connection initiated has
+autocommit disabled.
+
+=cut
+
sub db_init {
my ( $self, $myconfig ) = @_;
$self->{dbh} = $self->dbconnect_noauto($myconfig) || $self->dberror();
@@ -1198,6 +1207,12 @@ sub run_custom_queries {
@rc;
}
+=item $form->dbconnect($myconfig);
+
+Returns an autocommit connection to the database specified in $myconfig.
+
+=cut
+
sub dbconnect {
my ( $self, $myconfig ) = @_;
@@ -1217,6 +1232,12 @@ sub dbconnect {
$dbh;
}
+=item $form->dbconnect_noauto($myconfig);
+
+Returns a non-autocommit connection to the database specified in $myconfig.
+
+=cut
+
sub dbconnect_noauto {
my ( $self, $myconfig ) = @_;
@@ -1278,6 +1299,16 @@ sub update_balance {
}
}
+=item $form->update_exchangerate($dbh, $curr, $transdate, $buy, $sell);
+
+Updates the exchange rates $buy and $sell for the given $currency on $transdate.
+If there is not yet an exchange rate for $currency on $transdate, an entry is
+inserted. This returns without doing anything if $curr eq ''.
+
+$dbh is not used, favouring $self->{dbh}.
+
+=cut
+
sub update_exchangerate {
my ( $self, $dbh, $curr, $transdate, $buy, $sell ) = @_;
@@ -1336,6 +1367,16 @@ sub update_exchangerate {
}
+=item $form->save_exchangerate($myconfig, $currency, $transdate, $rate, $fld);
+
+Saves the exchange rate $rate for the given $currency on $transdate for the
+provided purpose in $fld. $fld can be either 'buy' or 'sell'.
+
+$myconfig is not used. $self->update_exchangerate is used for the majority of
+the work.
+
+=cut
+
sub save_exchangerate {
my ( $self, $myconfig, $currency, $transdate, $rate, $fld ) = @_;
@@ -1349,6 +1390,16 @@ sub save_exchangerate {
}
+=item $form->get_exchangerate($dbh, $curr, $transdate, $fld);
+
+Returns the exchange rate in relation to the default currency for $currency on
+$transdate for the purpose indicated by $fld. $fld can be either 'buy' or
+'sell' to get usable results.
+
+$dbh is not used, favouring $self->{dbh}.
+
+=cut
+
sub get_exchangerate {
my ( $self, $dbh, $curr, $transdate, $fld ) = @_;
@@ -1370,6 +1421,16 @@ sub get_exchangerate {
$exchangerate;
}
+=item $form->check_exchangerate($myconfig, $currency, $transdate, $fld);
+
+Returns some true value when an entry for $currency on $transdate is true for
+the purpose indicated by $fld. $fld can be either 'buy' or 'sell' to get
+usable results. Returns false if $transdate is not set.
+
+$myconfig is not used.
+
+=cut
+
sub check_exchangerate {
my ( $self, $myconfig, $currency, $transdate, $fld ) = @_;
@@ -1382,7 +1443,7 @@ sub check_exchangerate {
WHERE curr = ? AND transdate = ?|;
my $sth = $self->{dbh}->prepare($query);
- $sth->execute( $currenct, $transdate );
+ $sth->execute( $currency, $transdate );
my ($exchangerate) = $sth->fetchrow_array;
$sth->finish;