]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/DB/Assembly.pm
Assembly - linetotal Helperfunktionen
[kivitendo-erp.git] / SL / DB / Assembly.pm
index 767ba411bdab020ef179914bd292b17e46b54058..a77e34b54e75dee6c0f16b00843e79cf18b2ace6 100644 (file)
@@ -12,4 +12,18 @@ __PACKAGE__->meta->make_manager_class;
 
 __PACKAGE__->meta->initialize;
 
+sub linetotal {
+  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 );
+}
+
 1;