CVars als Object Mixin.
[kivitendo-erp.git] / SL / DB / OrderItem.pm
1 package SL::DB::OrderItem;
2
3 use strict;
4
5 use SL::DB::MetaSetup::OrderItem;
6 use SL::DB::Helper::CustomVariables (
7   sub_module  => 'orderitems',
8   cvars_alias => 1,
9   overloads   => {
10     parts_id => 'SL::DB::Part',
11   },
12 );
13
14 __PACKAGE__->meta->add_relationship(
15   part => {
16     type         => 'one to one',
17     class        => 'SL::DB::Part',
18     column_map   => { parts_id => 'id' },
19   },
20   price_factor_obj => {
21     type           => 'one to one',
22     class          => 'SL::DB::PriceFactor',
23     column_map     => { price_factor_id => 'id' },
24   },
25   unit_obj       => {
26     type         => 'one to one',
27     class        => 'SL::DB::Unit',
28     column_map   => { unit => 'name' },
29   },
30 );
31
32 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
33 __PACKAGE__->meta->make_manager_class;
34
35 __PACKAGE__->meta->initialize;
36
37 sub is_price_update_available {
38   my $self = shift;
39   return $self->origprice > $self->part->sellprice;
40 }
41
42 1;