]> wagnertech.de Git - kivitendo-erp.git/blobdiff - t/db_helper/record_links.t
Consolidation and extended test runs
[kivitendo-erp.git] / t / db_helper / record_links.t
index edfcf72fdbad46ccfeaeb778d15395a9e5c9305f..f3ee0e9b8b03ae0a06d406312127ec7419fbf70a 100644 (file)
@@ -25,20 +25,31 @@ use SL::DB::TaxZone;
 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";
+  if ($::lx_office_conf{system}->{default_manager} eq "swiss") {
+    $buchungsgruppe  = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 8%', %{ $params{buchungsgruppe} })  || croak "No accounting group";
+    $employee        = SL::DB::Manager::Employee->current                                                                    || croak "No employee";
+    $taxzone         = SL::DB::Manager::TaxZone->find_by( description => 'Schweiz')                                          || croak "No taxzone";
+  } else {
+    $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;
 
@@ -104,7 +115,6 @@ Support::TestSetup::login();
 
 reset_state();
 
-
 $o1 = new_order();
 $i  = new_invoice();
 
@@ -313,4 +323,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;