X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FDB%2FAssembly.pm;fp=SL%2FDB%2FAssembly.pm;h=fd645c2c98eaaa94b3961d2745095ebeae74c129;hp=22312144c8cba79f15d57cc2a89612455abcf0d8;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44 diff --git a/SL/DB/Assembly.pm b/SL/DB/Assembly.pm index 22312144c..fd645c2c9 100644 --- a/SL/DB/Assembly.pm +++ b/SL/DB/Assembly.pm @@ -1,23 +1,33 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Assembly; use strict; use SL::DB::MetaSetup::Assembly; -__PACKAGE__->meta->add_relationships( - part => { - type => 'many to one', - class => 'SL::DB::Part', - column_map => { parts_id => 'id' }, - }, -); - # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->initialize; +sub linetotal_sellprice { + my ($self) = @_; + + return 0 unless $self->qty > 0 and $self->part->sellprice > 0; + return $self->qty * $self->part->sellprice / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 ); +} + +sub linetotal_lastcost { + my ($self) = @_; + + return 0 unless $self->qty > 0 and $self->part->lastcost > 0; + return $self->qty * $self->part->lastcost / ( $self->part->price_factor_id ? $self->part->price_factor->factor : 1 ); +} + +sub linetotal_weight { + my ($self) = @_; + + return 0 unless $self->qty > 0 and ($self->part->weight||0) > 0; + return $self->qty * $self->part->weight; +} + 1;