diff options
Diffstat (limited to 'LedgerSMB/Form.pm')
-rw-r--r-- | LedgerSMB/Form.pm | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 4be02825..823ece35 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2322,52 +2322,41 @@ sub create_links { $sth->finish; - for (qw(curr closedto revtrans)) { - $query = qq| - SELECT value FROM defaults - WHERE setting_key = '$_'|; - - $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); - - ($val) = $sth->fetchrow_array(); - if ( $_ eq 'curr' ) { - $self->{currencies} = $val; - } - else { - $self->{$_} = $val; - } - $sth->finish; - } - $self->{transdate} = $self->current_date; } else { - for (qw(current_date curr closedto revtrans)) { + if ( !$self->{"$self->{vc}_id"} ) { + $self->lastname_used( $myconfig, $dbh, $vc, $module ); + } + } + for (qw(current_date curr closedto revtrans)) { + if ($_ eq 'closedto'){ + $query = qq| + SELECT value::date FROM defaults + WHERE setting_key = '$_'|; + } elsif ($_ eq 'current_date') { + $query = qq| select $_|; + } else { $query = qq| SELECT value FROM defaults WHERE setting_key = '$_'|; + } - $sth = $dbh->prepare($query); - $sth->execute || $self->dberror($query); + $sth = $dbh->prepare($query); + $sth->execute || $self->dberror($query); - ($val) = $sth->fetchrow_array(); - if ( $_ eq 'curr' ) { - $self->{currencies} = $val; - } - elsif ( $_ eq 'current_date' ) { - $self->{transdate} = $val; - } - else { - $self->{$_} = $val; - } - $sth->finish; + ($val) = $sth->fetchrow_array(); + if ( $_ eq 'curr' ) { + $self->{currencies} = $val; } - - if ( !$self->{"$self->{vc}_id"} ) { - $self->lastname_used( $myconfig, $dbh, $vc, $module ); + else { + $self->{$_} = $val; } + $sth->finish; + } + if (!$self->{id}){ + $self->{transdate} = $self->{current_date}; } $self->all_vc( $myconfig, $vc, $module, $dbh, $self->{transdate}, $job ); |