From a8cba95a2844190deb3efd99ba37294981981234 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 5 Jan 2017 13:22:49 +0100 Subject: [PATCH] =?utf8?q?Verkaufs-/Einkaufsbelege:=20beim=20Laden=20der?= =?utf8?q?=20Lieferadresse=20$form->{shipto=5Fid}=20nicht=20=C3=BCberschre?= =?utf8?q?iben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- SL/DO.pm | 7 +++---- SL/IS.pm | 3 +-- SL/OE.pm | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) 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 }; } -- 2.20.1