commit 6329a5b2d5cc225c41f6202ecd0beb1a19789000
Author: Tamino Steinert <tamino.steinert@tamino.st>
Date:   Wed Feb 15 15:59:17 2023 +0100

    Model::Record: nutze neue Methoden in Workflow-Test

diff --git a/t/workflow/delivery_order_reclamation.t b/t/workflow/delivery_order_reclamation.t
index 176112d09..8b26ceea9 100644
--- a/t/workflow/delivery_order_reclamation.t
+++ b/t/workflow/delivery_order_reclamation.t
@@ -38,7 +38,7 @@ my (
   $unit,
   @parts,
   $department,
-  $relamation_reason,
+  $reclamation_reason,
 );
 
 
@@ -101,7 +101,7 @@ sub reset_state {
     partnumber => 'Serv_2'
   )->save;
 
-  $relamation_reason = SL::DB::ReclamationReason->new(
+  $reclamation_reason = SL::DB::ReclamationReason->new(
     name => "test_reason",
     description => "",
     position => 1,
@@ -125,11 +125,11 @@ my $sales_reclamation = SL::Dev::Record::create_sales_reclamation(
   reclamation_items       => [
     SL::Dev::Record::create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     SL::Dev::Record::create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -145,11 +145,11 @@ my $purchase_reclamation = SL::Dev::Record::create_purchase_reclamation(
   reclamation_items       => [
     SL::Dev::Record::create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     SL::Dev::Record::create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -182,19 +182,18 @@ my $purchase_delivery_order = SL::Dev::Record::create_purchase_delivery_order(
 )->load;
 
 # convert order → reclamation
-my $converted_sales_reclamation = SL::Model::Record->new_from_workflow($sales_delivery_order, "sales_reclamation");
-$converted_sales_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_sales_reclamation->items_sorted->[1]->reason($relamation_reason);
+my $converted_sales_reclamation = SL::Model::Record->new_from_workflow($sales_delivery_order, 'sales_reclamation');
+$converted_sales_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_sales_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_sales_reclamation->save->load;
-my $converted_purchase_reclamation = SL::Model::Record->new_from_workflow($purchase_delivery_order, "purchase_reclamation");
-$converted_purchase_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_purchase_reclamation->items_sorted->[1]->reason($relamation_reason);
+my $converted_purchase_reclamation = SL::Model::Record->new_from_workflow($purchase_delivery_order, 'purchase_reclamation');
+$converted_purchase_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_purchase_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_purchase_reclamation->save->load;
 
-# TODO: use SL::Model::Record for conversion
 # convert reclamation → order
-my $converted_sales_delivery_order = $sales_reclamation->convert_to_delivery_order->save->load;
-my $converted_purchase_delivery_order = $purchase_reclamation->convert_to_delivery_order->save->load;
+my $converted_sales_delivery_order = SL::Model::Record->new_from_workflow($sales_reclamation, 'rma_delivery_order')->save->load;
+my $converted_purchase_delivery_order = SL::Model::Record->new_from_workflow($purchase_reclamation, 'supplier_delivery_order')->save->load;
 
 
 #get items before strip
diff --git a/t/workflow/invoice_to_reclamation.t b/t/workflow/invoice_to_reclamation.t
index e91048ec1..ca9380c19 100644
--- a/t/workflow/invoice_to_reclamation.t
+++ b/t/workflow/invoice_to_reclamation.t
@@ -38,7 +38,7 @@ my (
   $unit,
   @parts,
   $department,
-  $relamation_reason,
+  $reclamation_reason,
 );
 
 
@@ -101,7 +101,7 @@ sub reset_state {
     partnumber => 'Serv_2'
   )->save;
 
-  $relamation_reason = SL::DB::ReclamationReason->new(
+  $reclamation_reason = SL::DB::ReclamationReason->new(
     name => "test_reason",
     description => "",
     position => 1,
@@ -125,11 +125,11 @@ my $sales_reclamation = create_sales_reclamation(
   reclamation_items       => [
     create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -145,11 +145,11 @@ my $purchase_reclamation = create_purchase_reclamation(
   reclamation_items       => [
     create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -183,12 +183,12 @@ my $purchase_invoice = create_minimal_purchase_invoice(
 
 # convert invoice → reclamation
 my $converted_sales_reclamation =SL::Model::Record->new_from_workflow($sales_invoice, "sales_reclamation");
-$converted_sales_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_sales_reclamation->items_sorted->[1]->reason($relamation_reason);
+$converted_sales_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_sales_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_sales_reclamation->save->load;
 my $converted_purchase_reclamation = SL::Model::Record->new_from_workflow($purchase_invoice, "purchase_reclamation");
-$converted_purchase_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_purchase_reclamation->items_sorted->[1]->reason($relamation_reason);
+$converted_purchase_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_purchase_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_purchase_reclamation->save->load;
 
 #get items before strip
diff --git a/t/workflow/order_reclamation.t b/t/workflow/order_reclamation.t
index cb5595fba..aa85c1f91 100644
--- a/t/workflow/order_reclamation.t
+++ b/t/workflow/order_reclamation.t
@@ -38,7 +38,7 @@ my (
   $unit,
   @parts,
   $department,
-  $relamation_reason,
+  $reclamation_reason,
 );
 
 
@@ -101,7 +101,7 @@ sub reset_state {
     partnumber => 'Serv_2'
   )->save;
 
-  $relamation_reason = SL::DB::ReclamationReason->new(
+  $reclamation_reason = SL::DB::ReclamationReason->new(
     name => "test_reason",
     description => "",
     position => 1,
@@ -125,11 +125,11 @@ my $sales_reclamation = SL::Dev::Record::create_sales_reclamation(
   reclamation_items       => [
     SL::Dev::Record::create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     SL::Dev::Record::create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -145,11 +145,11 @@ my $purchase_reclamation = SL::Dev::Record::create_purchase_reclamation(
   reclamation_items       => [
     SL::Dev::Record::create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     SL::Dev::Record::create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -183,18 +183,17 @@ my $purchase_order = SL::Dev::Record::create_purchase_order(
 
 # convert order → reclamation
 my $converted_sales_reclamation = SL::Model::Record->new_from_workflow($sales_order, "sales_reclamation");
-$converted_sales_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_sales_reclamation->items_sorted->[1]->reason($relamation_reason);
+$converted_sales_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_sales_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_sales_reclamation->save->load;
 my $converted_purchase_reclamation = SL::Model::Record->new_from_workflow($purchase_order, "purchase_reclamation");
-$converted_purchase_reclamation->items_sorted->[0]->reason($relamation_reason);
-$converted_purchase_reclamation->items_sorted->[1]->reason($relamation_reason);
+$converted_purchase_reclamation->items_sorted->[0]->reason($reclamation_reason);
+$converted_purchase_reclamation->items_sorted->[1]->reason($reclamation_reason);
 $converted_purchase_reclamation->save->load;
 
-# TODO: use SL::Model::Record for conversion
 # convert reclamation → order
-my $converted_sales_order = $sales_reclamation->convert_to_order->save->load;
-my $converted_purchase_order = $purchase_reclamation->convert_to_order->save->load;
+my $converted_sales_order = SL::Model::Record->new_from_workflow($sales_reclamation, 'sales_order')->save->load;
+my $converted_purchase_order = SL::Model::Record->new_from_workflow($purchase_reclamation, 'purchase_order')->save->load;
 
 
 #get items before strip
diff --git a/t/workflow/reclamation_reclamation.t b/t/workflow/reclamation_reclamation.t
index 81798e338..c5c092909 100644
--- a/t/workflow/reclamation_reclamation.t
+++ b/t/workflow/reclamation_reclamation.t
@@ -36,7 +36,7 @@ my (
   $unit,
   @parts,
   $department,
-  $relamation_reason,
+  $reclamation_reason,
 );
 
 
@@ -98,7 +98,7 @@ sub reset_state {
     partnumber => 'Serv_2'
   )->save;
 
-  $relamation_reason = SL::DB::ReclamationReason->new(
+  $reclamation_reason = SL::DB::ReclamationReason->new(
     name => "test_reason",
     description => "",
     position => 1,
@@ -122,11 +122,11 @@ my $sales_reclamation = create_sales_reclamation(
   reclamation_items       => [
     create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
@@ -142,11 +142,11 @@ my $purchase_reclamation = create_purchase_reclamation(
   reclamation_items       => [
     create_reclamation_item(
       part => $parts[0], qty =>  3, sellprice => 70,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
     create_reclamation_item(
       part => $parts[1], qty => 10, sellprice => 50,
-      reason => $relamation_reason,
+      reason => $reclamation_reason,
     ),
   ],
 )->load;
