From 6473dcb171ba4e401d001372075ada92cc90e875 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 5 Jun 2014 08:33:53 +0200 Subject: [PATCH] =?utf8?q?RDBO=20{Invoice,DeliveryOrder}->new=5Ffrom=20Att?= =?utf8?q?ribute=20nachtr=C3=A4glich=20zuweisen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Macht man die Vermischung ->new(%args, %attributes), so ist die Reihenfolge, wann welche aus %args und welche aus %attributes genommen werden, aufgrund von Perls beliebiger Hash-Reihenfolge nicht garantiert. Also zuerst nur die berechneten aus %args zuweisen und danach die vom Caller bereitgestellten in %attributes. --- SL/DB/DeliveryOrder.pm | 3 ++- SL/DB/Invoice.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SL/DB/DeliveryOrder.pm b/SL/DB/DeliveryOrder.pm index 75eab64b0..06024855f 100644 --- a/SL/DB/DeliveryOrder.pm +++ b/SL/DB/DeliveryOrder.pm @@ -139,7 +139,8 @@ sub new_from { $args{shipto_id} = $source->shipto_id; } - my $delivery_order = $class->new(%args, %{ $params{attributes} || {} }); + my $delivery_order = $class->new(%args); + $delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes}; my $items = delete($params{items}) || $source->items_sorted; my %item_parents; diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 9cf52a24c..3f94795ee 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -166,7 +166,8 @@ sub new_from { $args{quodate} = $source->transdate; } - my $invoice = $class->new(%args, %{ $params{attributes} || {} }); + my $invoice = $class->new(%args); + $invoice->assign_attributes(%{ $params{attributes} }) if $params{attributes}; my $items = delete($params{items}) || $source->items_sorted; my %item_parents; -- 2.20.1