From: Moritz Bunkus Date: Thu, 5 Jan 2017 12:22:49 +0000 (+0100) Subject: Verkaufs-/Einkaufsbelege: beim Laden der Lieferadresse $form->{shipto_id} nicht übers... X-Git-Tag: release-3.5.4~1770 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a8cba95a2844190deb3efd99ba37294981981234;p=kivitendo-erp.git Verkaufs-/Einkaufsbelege: beim Laden der Lieferadresse $form->{shipto_id} nicht überschreiben Die Semantik in der Datenbank sieht so aus, dass z.B. oe.shipto_id nur dann gesetzt ist, wenn eine der Lieferadressen aus den Stammdaten ausgewählt ist. Genauer: • Stammdatenlieferadresse: oe.shipto_id == shipto.shipto_id, shipto.module = 'CT', shipto.trans_id = customer.id (oder vendor.id) • Individuelle Lieferadresse: oe.shipto_id == NULL, shipto.module = 'OE', shipto.trans_id == oe.id Der Inhalt von $form muss das genau so reflektieren, denn anhand dieses Feldes $form->{shipto_id} wird dann in den Masken entschieden, was wie angezeigt wird. --- diff --git a/SL/DO.pm b/SL/DO.pm index 2cfd43d6e..ed4d2f516 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -746,15 +746,14 @@ sub retrieve { $sth = prepare_execute_query($form, $dbh, $query, $form->{id}); $ref = $sth->fetchrow_hashref("NAME_lc"); - delete $ref->{id}; - map { $form->{$_} = $ref->{$_} } keys %$ref; + $form->{$_} = $ref->{$_} for grep { m{^shipto(?!_id$)} } keys %$ref; $sth->finish(); - if ($form->{shipto_id}) { + if ($ref->{shipto_id}) { my $cvars = CVar->get_custom_variables( dbh => $dbh, module => 'ShipTo', - trans_id => $form->{shipto_id}, + trans_id => $ref->{shipto_id}, ); $form->{"shiptocvar_$_->{name}"} = $_->{value} for @{ $cvars }; } diff --git a/SL/IS.pm b/SL/IS.pm index 8700c4831..2f0896ecb 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1969,8 +1969,7 @@ sub _retrieve_invoice { # get shipto $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AR')|; $ref = selectfirst_hashref_query($form, $dbh, $query, $id); - delete($ref->{id}); - map { $form->{$_} = $ref->{$_} } keys %$ref; + $form->{$_} = $ref->{$_} for grep { m{^shipto(?!_id$)} } keys %$ref; # get printed, emailed $query = qq|SELECT printed, emailed, spoolfile, formname FROM status WHERE trans_id = ?|; diff --git a/SL/OE.pm b/SL/OE.pm index f8b1b00e5..d1eaa568d 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -1051,15 +1051,14 @@ sub _retrieve { $sth = prepare_execute_query($form, $dbh, $query, $form->{id}); $ref = $sth->fetchrow_hashref("NAME_lc"); - delete($ref->{id}); - map { $form->{$_} = $ref->{$_} } keys %$ref; + $form->{$_} = $ref->{$_} for grep { m{^shipto(?!_id$)} } keys %$ref; $sth->finish; - if ($form->{shipto_id}) { + if ($ref->{shipto_id}) { my $cvars = CVar->get_custom_variables( dbh => $dbh, module => 'ShipTo', - trans_id => $form->{shipto_id}, + trans_id => $ref->{shipto_id}, ); $form->{"shiptocvar_$_->{name}"} = $_->{value} for @{ $cvars }; }