Part Controller - falschen Code aus kivi.Order.js wieder entfernt
[kivitendo-erp.git] / SL / DB / DeliveryOrderItem.pm
1 package SL::DB::DeliveryOrderItem;
2
3 use strict;
4
5 use SL::DB::MetaSetup::DeliveryOrderItem;
6 use SL::DB::Helper::ActsAsList;
7 use SL::DB::Helper::LinkedRecords;
8 use SL::DB::Helper::RecordItem;
9 use SL::DB::Helper::CustomVariables (
10   sub_module  => 'delivery_order_items',
11   cvars_alias => 1,
12   overloads   => {
13     parts_id => {
14       class => 'SL::DB::Part',
15       module => 'IC',
16     }
17   },
18 );
19
20 __PACKAGE__->meta->make_manager_class;
21
22 __PACKAGE__->meta->add_relationship(
23   delivery_order_stock_entries => {
24     type         => 'one to many',
25     class        => 'SL::DB::DeliveryOrderItemsStock',
26     column_map   => { id => 'delivery_order_item_id' },
27     manager_args => {
28       with_objects => [ 'inventory' ]
29     },
30   },
31 );
32
33 __PACKAGE__->meta->initialize;
34
35 __PACKAGE__->configure_acts_as_list(group_by => [qw(delivery_order_id)]);
36
37 # methods
38
39 sub record { goto &delivery_order }
40
41 sub displayable_delivery_order_info {
42   my ($self, $dec) = @_;
43
44   $dec //= 2;
45
46   return SL::Presenter->get->sales_delivery_order($self->delivery_order, display => 'inline')
47          . " " . $::form->format_amount(\%::myconfig, $self->qty, $dec) . " " . $self->unit
48          . " (" . $self->delivery_order->transdate->to_kivitendo . ")";
49 };
50
51 __END__
52
53 =pod
54
55 =encoding utf-8
56
57 =head1 NAME
58
59 SL::DB::DeliveryOrderItem Model for the 'delivery_order_items' table
60
61 =head1 SYNOPSIS
62
63 This is a standard Rose::DB::Object based model and can be used as one.
64
65 =head1 METHODS
66
67 =over 4
68
69 =item C<displayable_delivery_order_info DEC>
70
71 Returns a string with information about the delivery order item in relation to
72 its delivery order, specifically
73
74 * the (HTML-linked) delivery order number
75
76 * the qty and unit of the part in the delivery order
77
78 * the date of the delivery order
79
80 Doesn't include any part information, it is assumed that is already shown elsewhere.
81
82 The method takes an optional argument "dec" which determines how many decimals to
83 round to, as used by format_amount.
84
85   SL::DB::Manager::DeliveryOrderItem->get_first->displayable_delivery_order_info(0);
86   # 201601234 5 Stck (12.12.2016)
87
88 =back
89
90 =head1 AUTHORS
91
92 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
93
94 =cut
95
96 1;