Revision ef7e9ebd
Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt
t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t | ||
---|---|---|
22 | 22 |
|
23 | 23 |
use Carp; |
24 | 24 |
use Support::TestSetup; |
25 |
use SL::Dev::ALL; |
|
25 | 26 |
|
26 | 27 |
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices'; |
27 | 28 |
use_ok 'SL::Controller::FinancialControllingReport'; |
... | ... | |
35 | 36 |
|
36 | 37 |
Support::TestSetup::login(); |
37 | 38 |
|
38 |
our ($ar_chart, $buchungsgruppe, $ctrl, $currency_id, $customer, $employee, $order, $part, $tax_zone, $unit, @invoices);
|
|
39 |
our ($ar_chart, $ctrl, $customer, $order, $part, $unit, @invoices);
|
|
39 | 40 |
|
40 | 41 |
sub cleanup { |
41 | 42 |
"SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part); |
42 | 43 |
} |
43 | 44 |
|
44 | 45 |
sub init_common_state { |
45 |
$ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart"; |
|
46 |
$buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group"; |
|
47 |
$currency_id = SL::DB::Default->get->currency_id; |
|
48 |
$employee = SL::DB::Manager::Employee->current || croak "No employee"; |
|
49 |
$tax_zone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone"; |
|
50 |
$unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit"; |
|
46 |
$ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart"; |
|
47 |
$unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit"; |
|
51 | 48 |
} |
52 | 49 |
|
53 | 50 |
sub create_sales_order { |
... | ... | |
55 | 52 |
|
56 | 53 |
cleanup(); |
57 | 54 |
|
58 |
$params{$_} ||= {} for qw(customer part tax order orderitem);
|
|
55 |
$params{$_} ||= {} for qw(customer part order orderitem); |
|
59 | 56 |
|
60 |
$customer = SL::DB::Customer->new(
|
|
57 |
$customer = SL::Dev::CustomerVendor::create_customer(
|
|
61 | 58 |
name => 'Test Customer', |
62 |
currency_id => $currency_id, |
|
63 |
taxzone_id => $tax_zone->id, |
|
64 | 59 |
%{ $params{customer} } |
65 | 60 |
)->save; |
66 | 61 |
|
67 |
$part = SL::DB::Part->new(
|
|
62 |
$part = SL::Dev::Part::create_part(
|
|
68 | 63 |
partnumber => 'T4254', |
69 | 64 |
description => 'Fourty-two fifty-four', |
70 | 65 |
lastcost => 222.22, |
71 | 66 |
sellprice => 333.33, |
72 |
part_type => 'part', |
|
73 |
buchungsgruppen_id => $buchungsgruppe->id, |
|
74 | 67 |
unit => $unit->name, |
75 | 68 |
%{ $params{part} } |
76 | 69 |
)->save; |
77 | 70 |
$part->load; |
78 | 71 |
|
79 |
$order = SL::DB::Order->new( |
|
80 |
customer_id => $customer->id, |
|
81 |
currency_id => $currency_id, |
|
82 |
taxzone_id => $tax_zone->id, |
|
72 |
$order = SL::Dev::Record::create_sales_order( |
|
73 |
save => 1, |
|
74 |
customer => $customer, |
|
83 | 75 |
transaction_description => '<%period_start_date%>', |
84 | 76 |
transdate => DateTime->from_kivitendo('01.03.2014'), |
85 | 77 |
orderitems => [ |
86 |
{ parts_id => $part->id, |
|
87 |
description => $part->description, |
|
88 |
lastcost => $part->lastcost, |
|
89 |
sellprice => $part->sellprice, |
|
90 |
qty => 1, |
|
91 |
unit => $unit->name, |
|
92 |
%{ $params{orderitem} }, |
|
93 |
}, |
|
94 |
], |
|
78 |
SL::Dev::Record::create_order_item( |
|
79 |
part => $part, |
|
80 |
qty => 1, |
|
81 |
%{ $params{orderitem} }, |
|
82 |
), |
|
83 |
], |
|
95 | 84 |
periodic_invoices_config => $params{periodic_invoices_config} ? { |
96 | 85 |
active => 1, |
97 | 86 |
ar_chart_id => $ar_chart->id, |
... | ... | |
100 | 89 |
%{ $params{order} }, |
101 | 90 |
); |
102 | 91 |
|
103 |
$order->calculate_prices_and_taxes; |
|
104 |
|
|
105 |
ok($order->save(cascade => 1)); |
|
106 |
|
|
107 | 92 |
$::form = Support::TestSetup->create_new_form; |
108 | 93 |
$ctrl = SL::Controller::FinancialControllingReport->new; |
109 | 94 |
|
Auch abrufbar als: Unified diff
sales_order_with_periodic_invoices_config.t mit SL::Dev refactored