From a8c675b5c7481a9f8a26462961e863bffde2cdeb Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sun, 24 Feb 2008 03:15:55 +0000 Subject: Closing bug 1895526-- exchange rate double parse on check payments git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@2078 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/CP.pm | 6 ++++-- LedgerSMB/Form.pm | 10 +++++++++- LedgerSMB/HR.pm | 8 +++++++- LedgerSMB/User.pm | 2 +- bin/hr.pl | 26 ++++++++++++++++++++++++++ bin/ir.pl | 7 ++++--- bin/is.pl | 4 +++- bin/oe.pl | 6 +++--- 8 files changed, 57 insertions(+), 12 deletions(-) diff --git a/LedgerSMB/CP.pm b/LedgerSMB/CP.pm index abcf2fdd..20f5818b 100755 --- a/LedgerSMB/CP.pm +++ b/LedgerSMB/CP.pm @@ -664,7 +664,7 @@ sub post_payments { # get exchangerate for original $query = qq| - SELECT $buysell + SELECT $buysell AS fx FROM exchangerate e JOIN $form->{arap} a ON (a.transdate = e.transdate) @@ -674,7 +674,9 @@ sub post_payments { $sth = $dbh->prepare($query); $sth->execute( $form->{currency}, $form->{"id_$i"} ) || $form->dberror( $query, 'CP.pm', 671 ); - my ($exchangerate) = $sth->fetchrow_array; + my $ref = $sth->fetchrow_arrayref(); + $form->db_parse_numeric(sth => $sth, arrayref => $ref); + my ($exchangerate) = @$ref; $exchangerate ||= 1; diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index abc280e2..6f2b80e1 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1792,7 +1792,9 @@ sub check_exchangerate { my $sth = $self->{dbh}->prepare($query); $sth->execute( $currency, $transdate ); - my ($exchangerate) = $sth->fetchrow_array; + my @array = $sth->fetchrow_array; + $self->db_parse_numeric(sth => $sth, arrayref => \@array); + my ($exchangerate) = @array; $sth->finish; $self->{dbh}->commit; @@ -2152,6 +2154,9 @@ sub all_departments { while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) { push @{ $self->{all_department} }, $ref; + if ($self->{department_id} == $ref->{id}){ + $self->{department} = "$ref->{description}--$ref->{id}"; + } } $sth->finish; @@ -2195,6 +2200,7 @@ sub create_links { my ( $self, $module, $myconfig, $vc, $job ) = @_; + $self->{department_id} = $myconfig->{department_id}; # get last customers or vendors my ( $query, $sth ); @@ -2369,6 +2375,8 @@ sub lastname_used { my ( $self, $myconfig, $dbh2, $vc, $module ) = @_; my $dbh = $self->{dbh}; + $self->{department_id} = $myconfig->{department_id}; + $vc ||= $self->{vc}; # add default to correct for improper passing my $arap = ( $vc eq 'customer' ) ? "ar" : "ap"; my $where = "1 = 1"; diff --git a/LedgerSMB/HR.pm b/LedgerSMB/HR.pm index 4f1f4dab..7324694e 100755 --- a/LedgerSMB/HR.pm +++ b/LedgerSMB/HR.pm @@ -126,6 +126,10 @@ sub save_employee { my ( $null, $managerid ) = split /--/, $form->{manager}; $managerid *= 1; $form->{sales} *= 1; + my ($department, $department_id) = (undef, undef); + if ($form->{department}){ + ($department, $department_id) = split /--/, $form->{department}; + } $query = qq| @@ -150,6 +154,7 @@ sub save_employee { dob = ?, iban = ?, bic = ?, + department_id = ?, managerid = ? WHERE id = ?|; $sth = $dbh->prepare($query); @@ -163,7 +168,8 @@ sub save_employee { $form->{homephone}, $form->{startdate}, $form->{enddate}, $form->{notes}, $form->{role}, $form->{sales}, $form->{email}, $form->{ssn}, $form->{dob}, - $form->{iban}, $form->{bic}, $managerid, + $form->{iban}, $form->{bic}, $department_id, + $managerid, $form->{id} ) || $form->dberror( __FILE__ . ':' . __LINE__ . ':' . $query ); diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm index e935583d..3d025588 100755 --- a/LedgerSMB/User.pm +++ b/LedgerSMB/User.pm @@ -138,7 +138,7 @@ sub fetch_config { email, fax, menuwidth, name, numberformat, password, print, printer, role, sid, signature, stylesheet, tel, templates, - timeout, vclimit, u.username + timeout, vclimit, u.username, department_id FROM users_conf as uc, users as u WHERE u.username = ? AND u.id = uc.id;" diff --git a/bin/hr.pl b/bin/hr.pl index 78b098c0..dee1b0e2 100755 --- a/bin/hr.pl +++ b/bin/hr.pl @@ -528,6 +528,16 @@ sub employee_links { for ( keys %$form ) { $form->{$_} = $form->quote( $form->{$_} ) } + $form->all_departments; + if ( @{ $form->{all_department} } ) { + $form->{selectdepartment} = "