diff options
-rwxr-xr-x | LedgerSMB/AA.pm | 4 | ||||
-rwxr-xr-x | LedgerSMB/CP.pm | 24 | ||||
-rwxr-xr-x | LedgerSMB/User.pm | 38 | ||||
-rwxr-xr-x | bin/admin.pl | 1 |
4 files changed, 26 insertions, 41 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index e9d8c938..fcf5782a 100755 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -346,10 +346,10 @@ sub post_transaction { transdate, fx_transaction) VALUES (?, (SELECT id FROM chart WHERE accno = ?), - ? * ?, ?, ?)|; + ?, ?, ?)|; @queryargs = ($form->{id}, $ref->{accno}, - $ref->{amount}, $ml, $form->{transdate}, + $ref->{amount} * $ml, $form->{transdate}, $ref->{fx_transaction}); $dbh->prepare($query)->execute(@queryargs) || $form->dberror($query); diff --git a/LedgerSMB/CP.pm b/LedgerSMB/CP.pm index 33d47bcf..279aab95 100755 --- a/LedgerSMB/CP.pm +++ b/LedgerSMB/CP.pm @@ -417,12 +417,10 @@ sub post_payment { INSERT INTO acc_trans (trans_id, chart_id, transdate, amount) - VALUES (?, ?, - ?, - ? * ?)|; + VALUES (?, ?, ?, ?)|; $sth = $dbh->prepare($query); $sth->execute($form->{"id_$i"}, $id, - $form->{date_paid}, $amount, $ml) + $form->{date_paid}, $amount * $ml) || $form->dberror($query, 'CP.pm', 427); # add payment @@ -433,11 +431,11 @@ sub post_payment { VALUES (?, (SELECT id FROM chart WHERE accno = ?), - ?, ? * ? * -1, ?, ?)|; + ?, ?, ?, ?)|; $sth = $dbh->prepare($query); $sth->execute( $form->{"id_$i"}, $paymentaccno, - $form->{datepaid}, $form->{"paid_$i"}, $ml, + $form->{datepaid}, $form->{"paid_$i"} * $ml *-1, $form->{source}, $form->{memo}) || $form->dberror( $query, 'CP.pm', 444); @@ -458,12 +456,11 @@ sub post_payment { VALUES (?, (SELECT id FROM chart WHERE accno = ?), - ?, ? * ? * -1, '0', '1', - ?)|; + ?, ?, '0', '1', ?)|; $sth = $dbh->prepare($query); $sth->execute( $form->{"id_$i"}, $paymentaccno, - $form->{datepaid}, $amount, $ml, + $form->{datepaid}, $amount * $ml * -1, $form->{source}) || $form->dberror( $query, 'CP.pm', 470); @@ -693,12 +690,12 @@ sub post_payments { INSERT INTO acc_trans (trans_id, chart_id, transdate, amount) - VALUES (?, ?, ?, ? * ?)|; + VALUES (?, ?, ?, ?)|; $sth = $dbh->prepare($query); $sth->execute( $form->{"id_$i"}, $id, $form->{datepaid}, - $amount, $ml) + $amount * $ml) || $form->dberror($query, 'CP.pm', 701); @@ -715,12 +712,13 @@ sub post_payments { INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, memo) - VALUES (?, ?, ?, ? * ? * -1, ?, ?)|; + VALUES (?, ?, ?, ?, ?, ?)|; $sth = $dbh->prepare($query); $sth->execute( $form->{"id_$i"}, $accno_id, $form->{datepaid}, - $paid, $ml, $form->{source}, $form->{memo}) + $paid * $ml * -1, $form->{source}, + $form->{memo}) || $form->dberror($query, 'CP.pm', 723); diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm index e28af072..8cc551bc 100755 --- a/LedgerSMB/User.pm +++ b/LedgerSMB/User.pm @@ -71,10 +71,6 @@ sub new { chomp($self->{dbname}); chomp($self->{dbhost}); - if(! int($self->{dbport})){#in case there's a space or junk in the dbport - $self->{dbport} = '5432'; - } - $self->{dbconnect} = 'dbi:Pg:dbname='.$self->{dbname}.';host='.$self->{dbhost}.';port='.$self->{dbport}; if($self->{username}){ @@ -142,13 +138,10 @@ sub fetch_config { $myconfig{$key} = $value; } - if(! int($myconfig{'dbport'})){#in case there's a space or junk in the dbport - $myconfig{'dbport'} = '5432'; - } + chomp($myconfig{'dbport'}); + chomp($myconfig{'dbname'}); + chomp($myconfig{'dbhost'}); - if (! $myconfig{'dbhost'}){ # necessary to avoid many issues - $myconfig{'dbhost'} = 'localhost'; - } $myconfig{'login'} = $login; $myconfig{'dbconnect'} = 'dbi:Pg:dbname='.$myconfig{'dbname'}.';host='.$myconfig{'dbhost'}.';port='.$myconfig{'dbport'}; } @@ -277,21 +270,8 @@ sub dbconnect_vars { $form->{dboptions} = $dboptions{$form->{dbdriver}}{$form->{dateformat}}; $form->{dbconnect} = "dbi:$form->{dbdriver}:dbname=$db"; - - - if ($form->{dbhost}) { - $form->{dbconnect} .= ";host=$form->{dbhost}"; - - } else { - $form->{dbconnect} .= ";host=localhost"; - } - - - if ($form->{dbport}) { - $form->{dbconnect} .= ";port=$form->{dbport}"; - } else { - $form->{dbconnect} .= ";port=5432"; - } + $form->{dbconnect} .= ";host=$form->{dbhost}"; + $form->{dbconnect} .= ";port=$form->{dbport}"; } @@ -720,6 +700,14 @@ sub save_member { my $userCheck = $dbh->prepare("SELECT id FROM users WHERE username = ?"); $userCheck->execute($self->{login}); my ($userID) = $userCheck->fetchrow_array; + + if (! $self->{dbhost}) { + $self->{dbhost} = 'localhost'; + } + if (! $self->{dbport}) { + $self->{dbport} = '5432'; + } + my $userConfExists = 0; if($userID){ diff --git a/bin/admin.pl b/bin/admin.pl index 69369504..1a0a765b 100755 --- a/bin/admin.pl +++ b/bin/admin.pl @@ -270,7 +270,6 @@ sub list_users { $href =~ s/ /%20/g; $member{$key}{templates} =~ s/^${LedgerSMB::Sysconfig::templates}\///; - $member{$key}{dbhost} = 'localhost' unless $member{$key}{dbhost}; $column_data{login} = qq|<td><a href="$href">$key</a></td>|; $column_data{name} = qq|<td>$member{$key}{name}</td>|; |