From 1904d8c63b2ab4172b36b117ec476c81c690ca86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 5 Aug 2015 17:35:17 +0200 Subject: [PATCH] RecordItem: unit_muiltiplier Methode --- SL/DB/DeliveryOrderItem.pm | 1 + SL/DB/Helper/RecordItem.pm | 17 +++++++++++++++++ SL/DB/InvoiceItem.pm | 1 + SL/DB/OrderItem.pm | 1 + 4 files changed, 20 insertions(+) create mode 100644 SL/DB/Helper/RecordItem.pm diff --git a/SL/DB/DeliveryOrderItem.pm b/SL/DB/DeliveryOrderItem.pm index de7587cfd..ba2c2e099 100644 --- a/SL/DB/DeliveryOrderItem.pm +++ b/SL/DB/DeliveryOrderItem.pm @@ -5,6 +5,7 @@ use strict; use SL::DB::MetaSetup::DeliveryOrderItem; use SL::DB::Helper::ActsAsList; use SL::DB::Helper::LinkedRecords; +use SL::DB::Helper::RecordItem; use SL::DB::Helper::CustomVariables ( sub_module => 'delivery_order_items', cvars_alias => 1, diff --git a/SL/DB/Helper/RecordItem.pm b/SL/DB/Helper/RecordItem.pm new file mode 100644 index 000000000..020128db1 --- /dev/null +++ b/SL/DB/Helper/RecordItem.pm @@ -0,0 +1,17 @@ +package SL::DB::Helper::RecordItem; + +use strict; +use parent qw(Exporter); + +our @EXPORT = qw(base_sellprice unit_multiplier); + +sub base_sellprice { + $_[0]->sellprice / $_[0]->unit_multiplier; +} + +sub unit_multiplier { + $_[0]->unit_obj->convert_to(1, $_[0]->part->unit_obj) +} + + +1; diff --git a/SL/DB/InvoiceItem.pm b/SL/DB/InvoiceItem.pm index a20f56fc9..80c406b77 100644 --- a/SL/DB/InvoiceItem.pm +++ b/SL/DB/InvoiceItem.pm @@ -5,6 +5,7 @@ use strict; use SL::DB::MetaSetup::InvoiceItem; use SL::DB::Helper::ActsAsList; use SL::DB::Helper::LinkedRecords; +use SL::DB::Helper::RecordItem; use SL::DB::Helper::CustomVariables ( sub_module => 'invoice', cvars_alias => 1, diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index 6ab16ac2a..8ae5e0bdd 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -9,6 +9,7 @@ use SL::DB::Manager::OrderItem; use SL::DB::DeliveryOrderItemsStock; use SL::DB::Helper::ActsAsList; use SL::DB::Helper::LinkedRecords; +use SL::DB::Helper::RecordItem; use SL::DB::Helper::CustomVariables ( sub_module => 'orderitems', cvars_alias => 1, -- 2.20.1