From e0b9c11fba186b3b931cfce5887e2f9273b8a22e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 10 Dec 2021 15:09:40 +0100 Subject: [PATCH] =?utf8?q?DeliveryOrder:=20tests=20f=C3=BCr=20new=5Ffrom?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- t/db/delivery_order.t | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 t/db/delivery_order.t diff --git a/t/db/delivery_order.t b/t/db/delivery_order.t new file mode 100644 index 000000000..372cc872f --- /dev/null +++ b/t/db/delivery_order.t @@ -0,0 +1,49 @@ +use Test::More; + +use strict; + +use lib 't'; +use utf8; + +use Carp; +use Data::Dumper; +use Support::TestSetup; +use Test::Exception; + +use SL::DB::Order; +use SL::DB::Customer; +use SL::DB::Department; +use SL::DB::Currency; +use SL::DB::PaymentTerm; +use SL::DB::DeliveryTerm; +use SL::DB::Employee; +use SL::DB::Part; +use SL::DB::Unit; +use SL::DB::DeliveryOrder; +use SL::DB::DeliveryOrder::TypeData qw(:types); + +use SL::Dev::ALL qw(:ALL); + +Support::TestSetup::login(); + + +####### + +my $order1 = SL::Dev::Record::create_purchase_order( + save => 1, + taxincluded => 0, +); + +my $delivery_order = SL::DB::DeliveryOrder->new_from($order1); + +is $delivery_order->type, PURCHASE_DELIVERY_ORDER_TYPE, "new_from purchase order gives purchase delivery order"; +is scalar @{ $delivery_order->items }, 2, "purchase delivery order keeps items"; +is $delivery_order->vendor_id, $order1->vendor_id, "purchase delivery order keeps vendor"; + +my $supplier_delivery_order = SL::DB::DeliveryOrder->new_from($order1, type => SUPPLIER_DELIVERY_ORDER_TYPE); + +is $supplier_delivery_order->type, SUPPLIER_DELIVERY_ORDER_TYPE, "new_from purchase order with given type gives supplier delivery order"; +is scalar @{ $supplier_delivery_order->items }, 0, "supplier delivery order ignores items"; +is $supplier_delivery_order->vendor_id, $order1->vendor_id, "supplier delivery order keeps vendor"; + +done_testing(); -- 2.20.1