From 85ab58eb1bbdb3fc723bb3ab30e15e150e62556d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 9 Jan 2014 12:03:24 +0100 Subject: [PATCH] Pflichtenhefte -> Angebote: Eintrag in record_links anlegen --- SL/Controller/RequirementSpecOrder.pm | 27 ++++++++++++++++++++------- SL/DB/RequirementSpec.pm | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index 0e9785272..07d3e0603 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -63,13 +63,20 @@ sub action_create { # 2. Create actual quotation/order. my $order = $self->create_order(sections => $sections); - $order->save; + $order->db->with_transaction(sub { + $order->save; + + $self->requirement_spec->orders( + @{ $self->requirement_spec->orders }, + SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version) + ); + $self->requirement_spec->save; + + $self->requirement_spec->link_to_record($order); + }) or do { + $::lxdebug->message(LXDebug::WARN(), "Error creating the order object: $@"); + }; - $self->requirement_spec->orders( - @{ $self->requirement_spec->orders }, - SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version) - ); - $self->requirement_spec->save; $self->init_requirement_spec; # 3. Notify the user and return to list. @@ -135,7 +142,13 @@ sub action_do_update { $order->orderitems([ @{ $order->orderitems }, @new_orderitems ]) if @new_orderitems; $order->calculate_prices_and_taxes; - $order->save; + + $order->db->with_transaction(sub { + $order->save; + $self->requirement_spec->link_to_record($order); + }) or do { + $::lxdebug->message(LXDebug::WARN(), "Error updating the order object: $@"); + }; $self->init_requirement_spec; diff --git a/SL/DB/RequirementSpec.pm b/SL/DB/RequirementSpec.pm index 9ec553ce9..e1298ec29 100644 --- a/SL/DB/RequirementSpec.pm +++ b/SL/DB/RequirementSpec.pm @@ -8,6 +8,7 @@ use Rose::DB::Object::Helpers; use SL::DB::MetaSetup::RequirementSpec; use SL::DB::Manager::RequirementSpec; +use SL::DB::Helper::LinkedRecords; use SL::Locale::String; use SL::Util qw(_hashify); -- 2.20.1