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';
taxzone_id => $customer->taxzone_id,
currency_id => $customer->currency_id,
transaction_description => $shop->transaction_description,
- transdate => DateTime->today_local
+ transdate => $transdate,
);
return $order;
}else{
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;
$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',
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;