1 package SL::Dev::CustomerVendor;
5 our @EXPORT = qw(create_customer);
14 my $taxzone = _check_taxzone(delete $params{taxzone_id});
15 my $currency = _check_currency(delete $params{currency_id});
17 my $customer = SL::DB::Customer->new( name => delete $params{name} || 'Testkunde',
18 currency_id => $currency->id,
19 taxzone_id => $taxzone->id,
21 $customer->assign_attributes( %params );
28 my $taxzone = _check_taxzone(delete $params{taxzone_id});
29 my $currency = _check_currency(delete $params{currency_id});
31 my $vendor = SL::DB::Vendor->new( name => delete $params{name} || 'Testlieferant',
32 currency_id => $currency->id,
33 taxzone_id => $taxzone->id,
35 $vendor->assign_attributes( %params );
40 my ($taxzone_id) = @_;
41 # check that taxzone_id exists or if no taxzone_id passed use 'Inland'
44 $taxzone = SL::DB::Manager::TaxZone->find_by( id => $taxzone_id ) || die "Can't find taxzone_id";
46 $taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || die "No taxzone 'Inland'";
52 my ($currency_id) = @_;
55 $currency = SL::DB::Manager::Currency->find_by( id => $currency_id ) || die "Can't find currency_id";
57 $currency = SL::DB::Manager::Currency->find_by( id => $::instance_conf->get_currency_id );
68 SL::Dev::CustomerVendor - create customer and vendor objects for testing, with minimal defaults
72 =head2 C<create_customer %PARAMS>
74 Creates a new customer.
76 Minimal usage, default values, without saving to database:
78 my $customer = SL::Dev::CustomerVendor::create_customer();
80 Complex usage, overwriting some defaults, and save to database:
82 SL::Dev::CustomerVendor::create_customer(name => 'Test customer',
87 If neither taxzone_id or currency_id (both are NOT NULL) are passed as params
88 then default values are used.
90 =head2 C<create_vendor %PARAMS>
94 Minimal usage, default values, without saving to database:
96 my $vendor = SL::Dev::CustomerVendor::create_vendor();
98 Complex usage, overwriting some defaults, and save to database:
100 SL::Dev::CustomerVendor::create_vendor(name => 'Test vendor',
102 notes => "Order for 100$ for free delivery",
111 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>