From: Jan Büren Date: Mon, 11 Sep 2017 09:17:10 +0000 (+0200) Subject: Neue sub create_department - create_project erweitert X-Git-Tag: release-3.5.4~821 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2d29844d93acd3f05fa023605c4c1fc16dac33fc;p=kivitendo-erp.git Neue sub create_department - create_project erweitert create_project: description und projectnumber werden beim ersten Anlegen direkt gesetzt => kann jetzt mehrfach aufgerufen werden. create_department: Wie create_project, POD ergänzt --- diff --git a/SL/Dev/Record.pm b/SL/Dev/Record.pm index 5fbbd8738..f98283cea 100644 --- a/SL/Dev/Record.pm +++ b/SL/Dev/Record.pm @@ -2,7 +2,7 @@ package SL::Dev::Record; use strict; use base qw(Exporter); -our @EXPORT_OK = qw(create_invoice_item create_sales_invoice create_credit_note create_order_item create_sales_order create_purchase_order create_delivery_order_item create_sales_delivery_order create_purchase_delivery_order create_project); +our @EXPORT_OK = qw(create_invoice_item create_sales_invoice create_credit_note create_order_item create_sales_order create_purchase_order create_delivery_order_item create_sales_delivery_order create_purchase_delivery_order create_project create_department); our %EXPORT_TAGS = (ALL => \@EXPORT_OK); use SL::DB::Invoice; @@ -278,8 +278,8 @@ sub _create_two_items { sub create_project { my (%params) = @_; my $project = SL::DB::Project->new( - projectnumber => 1, - description => "Test project", + projectnumber => delete $params{projectnumber} // 1, + description => delete $params{description} // "Test project", active => 1, valid => 1, project_status_id => SL::DB::Manager::ProjectStatus->find_by(name => "running")->id, @@ -289,6 +289,17 @@ sub create_project { return $project; } +sub create_department { + my (%params) = @_; + + my $department = SL::DB::Department->new( + 'description' => delete $params{description} // 'Test Department', + )->save; + + $department->assign_attributes(%params) if %params; + return $department; + +} 1; __END__ @@ -402,6 +413,28 @@ Minimal example, creating a project with status "running" and type "Standard": description => 'Test project', ) +If C<$params{description}> or C<$params{projectnumber}> exists, this will override the +default value 'Test project'. + +C<%params> should only contain alterable keys from the object Project. + +=head2 C + +Creates a default department. + +Minimal example: + my $department = SL::Dev::Record::create_department(); + + my $department = SL::Dev::Record::create_department( + description => 'Hawaii', + ) + +If C<$params{description}> exists, this will override the +default value 'Test Department'. + +C<%params> should only contain alterable keys from the object Department. + + =head1 TODO =head1 BUGS