Revision 51504ef4
Von G. Richardson vor mehr als 4 Jahren hinzugefügt
SL/DB/ShopOrder.pm | ||
---|---|---|
26 | 26 |
sub convert_to_sales_order { |
27 | 27 |
my ($self, %params) = @_; |
28 | 28 |
|
29 |
my $customer = delete $params{customer}; |
|
30 |
my $employee = delete $params{employee}; |
|
29 |
my $customer = delete $params{customer}; |
|
30 |
my $employee = delete $params{employee}; |
|
31 |
my $transdate = delete $params{transdate} // DateTime->today_local; |
|
31 | 32 |
croak "param customer is missing" unless ref($customer) eq 'SL::DB::Customer'; |
32 | 33 |
croak "param employee is missing" unless ref($employee) eq 'SL::DB::Employee'; |
33 | 34 |
|
... | ... | |
98 | 99 |
taxzone_id => $customer->taxzone_id, |
99 | 100 |
currency_id => $customer->currency_id, |
100 | 101 |
transaction_description => $shop->transaction_description, |
101 |
transdate => DateTime->today_local
|
|
102 |
transdate => $transdate,
|
|
102 | 103 |
); |
103 | 104 |
return $order; |
104 | 105 |
}else{ |
t/shop/shop_order.t | ||
---|---|---|
16 | 16 |
use Data::Dumper; |
17 | 17 |
|
18 | 18 |
my ($shop, $shop_order, $shop_part, $part, $customer, $employee); |
19 |
my ($transdate); |
|
19 | 20 |
|
20 | 21 |
sub reset_state { |
21 | 22 |
my %params = @_; |
22 | 23 |
|
23 | 24 |
clear_up(); |
24 | 25 |
|
26 |
$transdate = DateTime->today_local; |
|
27 |
$transdate->set_year(2019) if $transdate->year == 2020; # use year 2019 in 2020, because of tax rate change in Germany |
|
28 |
|
|
25 | 29 |
$shop = new_shop->save; |
26 | 30 |
$part = new_part->save; |
27 | 31 |
$shop_part = new_shop_part(part => $part, shop => $shop)->save; |
... | ... | |
73 | 77 |
|
74 | 78 |
$shop_order = new_shop_order( |
75 | 79 |
shop => $shop, |
80 |
transfer_date => $transdate, |
|
76 | 81 |
shop_trans_id => $shop_trans_id, |
82 |
order_date => $transdate->datetime, |
|
77 | 83 |
amount => 59.5, |
78 | 84 |
billing_lastname => 'Schmidt', |
79 | 85 |
billing_firstname => 'Sven', |
... | ... | |
141 | 147 |
is($shop_order->shop_id , $shop->id , "shop_id ok"); |
142 | 148 |
|
143 | 149 |
note('testing convert_to_sales_order'); |
144 |
my $order = $shop_order->convert_to_sales_order(employee => $employee, customer => $customer); |
|
150 |
my $order = $shop_order->convert_to_sales_order(employee => $employee, customer => $customer, transdate => $shop_order->order_date);
|
|
145 | 151 |
$order->calculate_prices_and_taxes; |
146 | 152 |
$order->save; |
147 | 153 |
|
Auch abrufbar als: Unified diff
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.