Revision 2d29844d
Von Jan Büren vor mehr als 7 Jahren hinzugefügt
SL/Dev/Record.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
use base qw(Exporter); |
5 |
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); |
|
5 |
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);
|
|
6 | 6 |
our %EXPORT_TAGS = (ALL => \@EXPORT_OK); |
7 | 7 |
|
8 | 8 |
use SL::DB::Invoice; |
... | ... | |
278 | 278 |
sub create_project { |
279 | 279 |
my (%params) = @_; |
280 | 280 |
my $project = SL::DB::Project->new( |
281 |
projectnumber => 1, |
|
282 |
description => "Test project", |
|
281 |
projectnumber => delete $params{projectnumber} // 1,
|
|
282 |
description => delete $params{description} // "Test project",
|
|
283 | 283 |
active => 1, |
284 | 284 |
valid => 1, |
285 | 285 |
project_status_id => SL::DB::Manager::ProjectStatus->find_by(name => "running")->id, |
... | ... | |
289 | 289 |
return $project; |
290 | 290 |
} |
291 | 291 |
|
292 |
sub create_department { |
|
293 |
my (%params) = @_; |
|
294 |
|
|
295 |
my $department = SL::DB::Department->new( |
|
296 |
'description' => delete $params{description} // 'Test Department', |
|
297 |
)->save; |
|
298 |
|
|
299 |
$department->assign_attributes(%params) if %params; |
|
300 |
return $department; |
|
301 |
|
|
302 |
} |
|
292 | 303 |
1; |
293 | 304 |
|
294 | 305 |
__END__ |
... | ... | |
402 | 413 |
description => 'Test project', |
403 | 414 |
) |
404 | 415 |
|
416 |
If C<$params{description}> or C<$params{projectnumber}> exists, this will override the |
|
417 |
default value 'Test project'. |
|
418 |
|
|
419 |
C<%params> should only contain alterable keys from the object Project. |
|
420 |
|
|
421 |
=head2 C<create_department %PARAMS> |
|
422 |
|
|
423 |
Creates a default department. |
|
424 |
|
|
425 |
Minimal example: |
|
426 |
my $department = SL::Dev::Record::create_department(); |
|
427 |
|
|
428 |
my $department = SL::Dev::Record::create_department( |
|
429 |
description => 'Hawaii', |
|
430 |
) |
|
431 |
|
|
432 |
If C<$params{description}> exists, this will override the |
|
433 |
default value 'Test Department'. |
|
434 |
|
|
435 |
C<%params> should only contain alterable keys from the object Department. |
|
436 |
|
|
437 |
|
|
405 | 438 |
=head1 TODO |
406 | 439 |
|
407 | 440 |
=head1 BUGS |
Auch abrufbar als: Unified diff
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