From: G. Richardson Date: Tue, 7 Jul 2020 16:18:27 +0000 (+0200) Subject: SL::DB::ShopOrder - in convert_to_sales_order transdate übergeben X-Git-Tag: release-3.5.6.1~150 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=51504ef44a8f49be8baa983e8a37c301acb9a937;p=kivitendo-erp.git SL::DB::ShopOrder - in convert_to_sales_order transdate übergeben Um ein bestimmtes Datum zu forcieren, nützlich für Tests. Außerdem Umstellung auf hartkodiertes Testjahr 2019 in 2020. --- diff --git a/SL/DB/ShopOrder.pm b/SL/DB/ShopOrder.pm index ee02f3e93..4e125fbc9 100644 --- a/SL/DB/ShopOrder.pm +++ b/SL/DB/ShopOrder.pm @@ -26,8 +26,9 @@ __PACKAGE__->meta->initialize; sub convert_to_sales_order { my ($self, %params) = @_; - my $customer = delete $params{customer}; - my $employee = delete $params{employee}; + my $customer = delete $params{customer}; + my $employee = delete $params{employee}; + my $transdate = delete $params{transdate} // DateTime->today_local; croak "param customer is missing" unless ref($customer) eq 'SL::DB::Customer'; croak "param employee is missing" unless ref($employee) eq 'SL::DB::Employee'; @@ -98,7 +99,7 @@ sub convert_to_sales_order { taxzone_id => $customer->taxzone_id, currency_id => $customer->currency_id, transaction_description => $shop->transaction_description, - transdate => DateTime->today_local + transdate => $transdate, ); return $order; }else{ diff --git a/t/shop/shop_order.t b/t/shop/shop_order.t index 762c63917..aef41501b 100644 --- a/t/shop/shop_order.t +++ b/t/shop/shop_order.t @@ -16,12 +16,16 @@ use SL::Controller::ShopOrder; use Data::Dumper; my ($shop, $shop_order, $shop_part, $part, $customer, $employee); +my ($transdate); sub reset_state { my %params = @_; clear_up(); + $transdate = DateTime->today_local; + $transdate->set_year(2019) if $transdate->year == 2020; # use year 2019 in 2020, because of tax rate change in Germany + $shop = new_shop->save; $part = new_part->save; $shop_part = new_shop_part(part => $part, shop => $shop)->save; @@ -73,7 +77,9 @@ my $shop_trans_id = 1; $shop_order = new_shop_order( shop => $shop, + transfer_date => $transdate, shop_trans_id => $shop_trans_id, + order_date => $transdate->datetime, amount => 59.5, billing_lastname => 'Schmidt', billing_firstname => 'Sven', @@ -141,7 +147,7 @@ is($shop->description , 'testshop' , 'shop description ok'); is($shop_order->shop_id , $shop->id , "shop_id ok"); note('testing convert_to_sales_order'); -my $order = $shop_order->convert_to_sales_order(employee => $employee, customer => $customer); +my $order = $shop_order->convert_to_sales_order(employee => $employee, customer => $customer, transdate => $shop_order->order_date); $order->calculate_prices_and_taxes; $order->save;