summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB/AM.pm7
-rwxr-xr-xLedgerSMB/GL.pm22
-rwxr-xr-xLedgerSMB/RC.pm6
3 files changed, 24 insertions, 11 deletions
diff --git a/LedgerSMB/AM.pm b/LedgerSMB/AM.pm
index cf4b5df8..a8fd1e63 100755
--- a/LedgerSMB/AM.pm
+++ b/LedgerSMB/AM.pm
@@ -251,8 +251,10 @@ sub delete_account {
# set inventory_accno_id, income_accno_id, expense_accno_id to defaults
$query = qq|
UPDATE parts
- SET inventory_accno_id = (SELECT inventory_accno_id
- FROM defaults)
+ SET inventory_accno_id = (SELECT value
+ FROM defaults
+ WHERE setting_key =
+ 'inventory_accno_id')
WHERE inventory_accno_id = ?|;
$sth = $dbh->prepare($query);
@@ -1592,7 +1594,6 @@ sub backup {
my $boundary = time;
my $tmpfile = "${LedgerSMB::Sysconfig::userspath}/$boundary.$myconfig->{dbname}-$form->{dbversion}-$t[5]$t[4]$t[3].sql";
$tmpfile .= ".gz" if ${LedgerSMB::Sysconfig::gzip};
- my $out = $form->{OUT};
$form->{OUT} = ">$tmpfile";
open(OUT, "$form->{OUT}") or $form->error("$form->{OUT} : $!");
diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm
index c6fe1037..8d31c453 100755
--- a/LedgerSMB/GL.pm
+++ b/LedgerSMB/GL.pm
@@ -500,13 +500,17 @@ sub transaction {
if ($form->{id}) {
- $query = "SELECT closedto, revtrans
- FROM defaults";
+ $query = "SELECT setting_key, value
+ FROM defaults
+ WHERE setting_key IN
+ ('closedto', 'revtrans')";
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
- ($form->{closedto}, $form->{revtrans}) = $sth->fetchrow_array;
+ my $results = $sth->fetchall_hashref('setting_key');
+ $form->{closedto} = $results->{'closedto'}->{'value'};
+ $form->{revtrans} = $results->{'revtrans'}->{'value'};
$sth->finish;
$query = qq|SELECT g.*, d.description AS department
@@ -544,13 +548,19 @@ sub transaction {
$form->get_recurring($dbh);
} else {
- $query = "SELECT current_date AS transdate, closedto, revtrans
- FROM defaults";
+ $query = "SELECT current_date AS transdate, setting_key, value
+ FROM defaults
+ WHERE setting_key IN
+ ('closedto', 'revtrans')";
+
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
- ($form->{transdate}, $form->{closedto}, $form->{revtrans}) = $sth->fetchrow_array;
+ my $results = $sth->fetchall_hashref('setting_key');
+ $form->{closedto} = $results->{'closedto'}->{'value'};
+ $form->{revtrans} = $results->{'revtrans'}->{'value'};
+ $form->{transdate} = $results->{'revtrans'}->{'transdate'};
}
$sth->finish;
diff --git a/LedgerSMB/RC.pm b/LedgerSMB/RC.pm
index 5828f441..36488e37 100755
--- a/LedgerSMB/RC.pm
+++ b/LedgerSMB/RC.pm
@@ -232,9 +232,11 @@ sub payment_transactions {
if ($form->{fx_transaction}) {
$fx_transaction = qq|
AND NOT (ac.chart_id IN
- (SELECT fxgain_accno_id FROM defaults
+ (SELECT value AS fxgain_accno_id FROM defaults
+ WHERE setting_key = 'fxgain_accno_id'
UNION
- SELECT fxloss_accno_id FROM defaults))|;
+ SELECT value AS fxloss_accno_id FROM defaults
+ WHERE setting_key = 'fxloss_accno_id))|;
} else {
$fx_transaction = qq|
AND ac.fx_transaction = '0'|;