From 51504ef44a8f49be8baa983e8a37c301acb9a937 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Tue, 7 Jul 2020 18:18:27 +0200 Subject: [PATCH] =?utf8?q?SL::DB::ShopOrder=20-=20in=20convert=5Fto=5Fsale?= =?utf8?q?s=5Forder=20transdate=20=C3=BCbergeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Um ein bestimmtes Datum zu forcieren, nützlich für Tests. Außerdem Umstellung auf hartkodiertes Testjahr 2019 in 2020. --- SL/DB/ShopOrder.pm | 7 ++++--- t/shop/shop_order.t | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) 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; -- 2.20.1