Part Controller - Helper Funktionen für linetotals
[kivitendo-erp.git] / SL / DB / Assembly.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::Assembly;
5
6 use strict;
7
8 use SL::DB::MetaSetup::Assembly;
9
10 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
11 __PACKAGE__->meta->make_manager_class;
12
13 __PACKAGE__->meta->initialize;
14
15 sub linetotal_sellprice {
16   my ($self) = @_;
17
18   return 0 unless $self->qty > 0 and $self->part->sellprice > 0;
19   return $self->qty * $self->part->sellprice / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 );
20 }
21
22 sub linetotal_lastcost {
23   my ($self) = @_;
24
25   return 0 unless $self->qty > 0 and $self->part->lastcost > 0;
26   return $self->qty * $self->part->lastcost / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 );
27 }
28
29 1;