X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fdb_helper%2Frecord_links.t;h=5df89a405bfd2a268779d4da6c97a5188c04a9fe;hb=dee8b29f4976d834517d1fced4eacba17dcc315d;hp=e063b33a1d068c2a272e488dcbf8cb0e3a91d4a0;hpb=4f7837d76dff9243196ac8fb3c4099215e32c514;p=kivitendo-erp.git diff --git a/t/db_helper/record_links.t b/t/db_helper/record_links.t index e063b33a1..5df89a405 100644 --- a/t/db_helper/record_links.t +++ b/t/db_helper/record_links.t @@ -20,35 +20,44 @@ use SL::DB::Order; use SL::DB::DeliveryOrder; use SL::DB::Part; use SL::DB::Unit; +use SL::DB::TaxZone; -my ($customer, $currency_id, $buchungsgruppe, $employee, $vendor); +my ($customer, $currency_id, $buchungsgruppe, $employee, $vendor, $taxzone); my ($link, $links, $o1, $o2, $d, $i); -sub reset_state { - my %params = @_; - - $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax); - +sub clear_up { SL::DB::Manager::DeliveryOrder->delete_all(all => 1); SL::DB::Manager::Order->delete_all(all => 1); SL::DB::Manager::Invoice->delete_all(all => 1); + SL::DB::Manager::Part->delete_all(all => 1); SL::DB::Manager::Customer->delete_all(all => 1); SL::DB::Manager::Vendor->delete_all(all => 1); +}; + +sub reset_state { + my %params = @_; + + $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax); + + clear_up(); $buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%', %{ $params{buchungsgruppe} }) || croak "No accounting group"; $employee = SL::DB::Manager::Employee->current || croak "No employee"; + $taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone"; $currency_id = $::instance_conf->get_currency_id; $customer = SL::DB::Customer->new( name => 'Test Customer', currency_id => $currency_id, + taxzone_id => $taxzone->id, %{ $params{customer} } )->save; $vendor = SL::DB::Vendor->new( name => 'Test Vendor', currency_id => $currency_id, + taxzone_id => $taxzone->id, %{ $params{vendor} } )->save; } @@ -61,7 +70,7 @@ sub new_order { currency_id => $currency_id, employee_id => $employee->id, salesman_id => $employee->id, - taxzone_id => 0, + taxzone_id => $taxzone->id, quotation => 0, %params, )->save; @@ -75,7 +84,7 @@ sub new_delivery_order { currency_id => $currency_id, employee_id => $employee->id, salesman_id => $employee->id, - taxzone_id => 0, + taxzone_id => $taxzone->id, %params, )->save; } @@ -89,8 +98,8 @@ sub new_invoice { employee_id => $employee->id, salesman_id => $employee->id, gldate => DateTime->today_local->to_kivitendo, - taxzone_id => 0, invoice => 1, + taxzone_id => $taxzone->id, type => 'invoice', %params, )->save; @@ -100,7 +109,6 @@ Support::TestSetup::login(); reset_state(); - $o1 = new_order(); $i = new_invoice(); @@ -309,4 +317,7 @@ is @$links, 3, 'recursive from i finds 3 (not i)'; $links = $o1->linked_records(direction => 'both', recursive => 1, save_path => 1); is @$links, 4, 'recursive dir=both does not give duplicates'; + +clear_up(); + 1;