marei: headline/colspec keys for SimpleTabular
[kivitendo-erp.git] / SL / DB / Assembly.pm
1 package SL::DB::Assembly;
2
3 use strict;
4
5 use SL::DB::MetaSetup::Assembly;
6
7 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
8 __PACKAGE__->meta->make_manager_class;
9
10 __PACKAGE__->meta->initialize;
11
12 sub linetotal_sellprice {
13   my ($self) = @_;
14
15   return 0 unless $self->qty > 0 and $self->part->sellprice > 0;
16   return $self->qty * $self->part->sellprice / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 );
17 }
18
19 sub linetotal_lastcost {
20   my ($self) = @_;
21
22   return 0 unless $self->qty > 0 and $self->part->lastcost > 0;
23   return $self->qty * $self->part->lastcost / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 );
24 }
25
26 1;