1 package SL::Dev::CustomerVendor;
5 our @EXPORT_OK = qw(new_customer new_vendor);
6 our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
15 my $taxzone = _check_taxzone(delete $params{taxzone_id});
16 my $currency = _check_currency(delete $params{currency_id});
18 my $customer = SL::DB::Customer->new( name => delete $params{name} || 'Testkunde',
19 currency_id => $currency->id,
20 taxzone_id => $taxzone->id,
22 $customer->assign_attributes( %params );
29 my $taxzone = _check_taxzone(delete $params{taxzone_id});
30 my $currency = _check_currency(delete $params{currency_id});
32 my $vendor = SL::DB::Vendor->new( name => delete $params{name} || 'Testlieferant',
33 currency_id => $currency->id,
34 taxzone_id => $taxzone->id,
36 $vendor->assign_attributes( %params );
41 my ($taxzone_id) = @_;
42 # check that taxzone_id exists or if no taxzone_id passed use 'Inland'
45 $taxzone = SL::DB::Manager::TaxZone->find_by( id => $taxzone_id ) || die "Can't find taxzone_id";
47 $taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || die "No taxzone 'Inland'";
53 my ($currency_id) = @_;
56 $currency = SL::DB::Manager::Currency->find_by( id => $currency_id ) || die "Can't find currency_id";
58 $currency = SL::DB::Manager::Currency->find_by( id => $::instance_conf->get_currency_id );
69 SL::Dev::CustomerVendor - create customer and vendor objects for testing, with minimal defaults
73 =head2 C<new_customer %PARAMS>
75 Creates a new customer.
77 Minimal usage, default values, without saving to database:
79 my $customer = SL::Dev::CustomerVendor::new_customer();
81 Complex usage, overwriting some defaults, and save to database:
83 SL::Dev::CustomerVendor::new_customer(name => 'Test customer',
88 If neither taxzone_id or currency_id (both are NOT NULL) are passed as params
89 then default values are used.
91 =head2 C<new_vendor %PARAMS>
95 Minimal usage, default values, without saving to database:
97 my $vendor = SL::Dev::CustomerVendor::new_vendor();
99 Complex usage, overwriting some defaults, and save to database:
101 SL::Dev::CustomerVendor::new_vendor(name => 'Test vendor',
103 notes => "Order for 100$ for free delivery",
113 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>