Revision 96f8e868
Von Sven Schöling vor fast 3 Jahren hinzugefügt
SL/DB/DeliveryOrderItem.pm | ||
---|---|---|
48 | 48 |
. " (" . $self->delivery_order->transdate->to_kivitendo . ")"; |
49 | 49 |
}; |
50 | 50 |
|
51 |
sub effective_project { |
|
52 |
my ($self) = @_; |
|
53 |
|
|
54 |
$self->project // $self->delivery_order->project; |
|
55 |
} |
|
56 |
|
|
51 | 57 |
__END__ |
52 | 58 |
|
53 | 59 |
=pod |
SL/DB/Inventory.pm | ||
---|---|---|
4 | 4 |
package SL::DB::Inventory; |
5 | 5 |
|
6 | 6 |
use strict; |
7 |
use Carp; |
|
8 |
use DateTime; |
|
7 | 9 |
|
10 |
use SL::DBUtils qw(selectrow_query); |
|
8 | 11 |
use SL::DB::MetaSetup::Inventory; |
9 | 12 |
use SL::DB::Manager::Inventory; |
10 | 13 |
|
... | ... | |
19 | 22 |
goto &parts; |
20 | 23 |
} |
21 | 24 |
|
25 |
sub new_from { |
|
26 |
my ($class, $obj) = @_; |
|
27 |
|
|
28 |
if ('SL::DB::DeliveryOrderItemsStock' eq ref $obj) { |
|
29 |
return $class->new_from_delivery_order_stock($obj); |
|
30 |
} |
|
31 |
|
|
32 |
croak "unknown obj type (@{[ ref $obj ]}) for SL::DB::Inventory::new_from"; |
|
33 |
} |
|
34 |
|
|
35 |
sub new_from_delivery_order_stock { |
|
36 |
my ($stock) = @_; |
|
37 |
|
|
38 |
my $project = $stock->delivery_order_item->effective_project; |
|
39 |
|
|
40 |
return __PACKAGE__->new( |
|
41 |
delivery_order_items_stock_id => $stock->id, |
|
42 |
parts_id => $stock->delivery_order_item->parts_id, |
|
43 |
qty => $stock->unit->convert_to($stock->qty => $stock->delivery_order_item->part->unit_obj), |
|
44 |
unit => $stock->delivery_order_item->part->unit_obj, |
|
45 |
warehouse_id => $stock->warehouse_id, |
|
46 |
bin_id => $stock->bin_id, |
|
47 |
chargenumber => $stock->chargenumber, |
|
48 |
bestbefore => $stock->bestbefore, |
|
49 |
project_id => $project ? $project->id : undef, |
|
50 |
# trans_type - not set here, set in controller |
|
51 |
); |
|
52 |
} |
|
53 |
|
|
22 | 54 |
sub _before_save_create_trans_id { |
23 | 55 |
my ($self, %params) = @_; |
24 | 56 |
|
Auch abrufbar als: Unified diff
Inventory::new_from aus DeliveryOrderItemsStock Objekten