From ef7e9ebd2580220c889a8e94579a5a5e246548a2 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Mon, 7 Aug 2017 18:37:38 +0200 Subject: [PATCH] sales_order_with_periodic_invoices_config.t mit SL::Dev refactored --- ...ales_order_with_periodic_invoices_config.t | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t b/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t index 8541cb7be..8447166ba 100644 --- a/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t +++ b/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t @@ -22,6 +22,7 @@ use utf8; use Carp; use Support::TestSetup; +use SL::Dev::ALL; use_ok 'SL::BackgroundJob::CreatePeriodicInvoices'; use_ok 'SL::Controller::FinancialControllingReport'; @@ -35,19 +36,15 @@ use_ok 'SL::DB::TaxZone'; Support::TestSetup::login(); -our ($ar_chart, $buchungsgruppe, $ctrl, $currency_id, $customer, $employee, $order, $part, $tax_zone, $unit, @invoices); +our ($ar_chart, $ctrl, $customer, $order, $part, $unit, @invoices); sub cleanup { "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part); } sub init_common_state { - $ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart"; - $buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group"; - $currency_id = SL::DB::Default->get->currency_id; - $employee = SL::DB::Manager::Employee->current || croak "No employee"; - $tax_zone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone"; - $unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit"; + $ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart"; + $unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit"; } sub create_sales_order { @@ -55,43 +52,35 @@ sub create_sales_order { cleanup(); - $params{$_} ||= {} for qw(customer part tax order orderitem); + $params{$_} ||= {} for qw(customer part order orderitem); - $customer = SL::DB::Customer->new( + $customer = SL::Dev::CustomerVendor::create_customer( name => 'Test Customer', - currency_id => $currency_id, - taxzone_id => $tax_zone->id, %{ $params{customer} } )->save; - $part = SL::DB::Part->new( + $part = SL::Dev::Part::create_part( partnumber => 'T4254', description => 'Fourty-two fifty-four', lastcost => 222.22, sellprice => 333.33, - part_type => 'part', - buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part} } )->save; $part->load; - $order = SL::DB::Order->new( - customer_id => $customer->id, - currency_id => $currency_id, - taxzone_id => $tax_zone->id, + $order = SL::Dev::Record::create_sales_order( + save => 1, + customer => $customer, transaction_description => '<%period_start_date%>', transdate => DateTime->from_kivitendo('01.03.2014'), orderitems => [ - { parts_id => $part->id, - description => $part->description, - lastcost => $part->lastcost, - sellprice => $part->sellprice, - qty => 1, - unit => $unit->name, - %{ $params{orderitem} }, - }, - ], + SL::Dev::Record::create_order_item( + part => $part, + qty => 1, + %{ $params{orderitem} }, + ), + ], periodic_invoices_config => $params{periodic_invoices_config} ? { active => 1, ar_chart_id => $ar_chart->id, @@ -100,10 +89,6 @@ sub create_sales_order { %{ $params{order} }, ); - $order->calculate_prices_and_taxes; - - ok($order->save(cascade => 1)); - $::form = Support::TestSetup->create_new_form; $ctrl = SL::Controller::FinancialControllingReport->new; -- 2.20.1