Revision c2075a3c
Von Sven Schöling vor etwa 3 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
911 | 911 |
do_unit => $unit, |
912 | 912 |
delivered => $self->order->delivered, |
913 | 913 |
row => $row, |
914 |
itme_id => $item_id,
|
|
914 |
item_id => $item_id,
|
|
915 | 915 |
); |
916 | 916 |
} |
917 | 917 |
|
... | ... | |
1272 | 1272 |
# You need a custom shipto object to call cvars_by_config to get the cvars. |
1273 | 1273 |
$self->order->custom_shipto(SL::DB::Shipto->new(module => 'OE', custom_variables => [])) if !$self->order->custom_shipto; |
1274 | 1274 |
|
1275 |
$self->prepare_stock_info($_) for $self->order->items; |
|
1276 |
|
|
1275 | 1277 |
return $self->order; |
1276 | 1278 |
} |
1277 | 1279 |
|
... | ... | |
1321 | 1323 |
push @items, $item; |
1322 | 1324 |
$pos++; |
1323 | 1325 |
} |
1326 |
|
|
1327 |
$self->prepare_stock_info($_) for $order->items, @items; |
|
1328 |
|
|
1324 | 1329 |
$order->add_items(grep {!$_->id} @items); |
1325 | 1330 |
|
1326 | 1331 |
return $order; |
... | ... | |
1343 | 1348 |
# saved. Adding empty custom_variables to new orderitem here solves this problem. |
1344 | 1349 |
$item ||= SL::DB::DeliveryOrderItem->new(custom_variables => []); |
1345 | 1350 |
|
1351 |
# handle stock info |
|
1352 |
if (my $stock_info = delete $attr->{stock_info}) { |
|
1353 |
my %existing = map { $_->id => $_ } $item->delivery_order_stock_entries; |
|
1354 |
my @save; |
|
1355 |
|
|
1356 |
for my $line (@{ DO->unpack_stock_information(packed => $stock_info) }) { |
|
1357 |
# lookup existing or make new |
|
1358 |
my $obj = delete $existing{$line->{delivery_order_items_stock_id}} |
|
1359 |
// SL::DB::DeliveryOrderItemsStock->new; |
|
1360 |
|
|
1361 |
# assign attributes |
|
1362 |
$obj->$_($line->{$_}) for qw(bin_id warehouse_id chargenumber qty unit); |
|
1363 |
$obj->bestbefore_as_date($line->{bestfbefore}) |
|
1364 |
if $line->{bestbefore} && $::instance_conf->get_show_bestbefore; |
|
1365 |
push @save, $obj; |
|
1366 |
} |
|
1367 |
|
|
1368 |
$item->delivery_order_stock_entries(@save); |
|
1369 |
} |
|
1370 |
|
|
1346 | 1371 |
$item->assign_attributes(%$attr); |
1347 | 1372 |
|
1348 | 1373 |
if ($is_new) { |
... | ... | |
1428 | 1453 |
return $item; |
1429 | 1454 |
} |
1430 | 1455 |
|
1456 |
sub prepare_stock_info { |
|
1457 |
my ($self, $item) = @_; |
|
1458 |
|
|
1459 |
$item->{stock_info} = SL::YAML::Dump([ |
|
1460 |
map +{ |
|
1461 |
delivery_order_items_stock_id => $_->id, |
|
1462 |
qty => $_->qty, |
|
1463 |
warehouse_id => $_->warehouse_id, |
|
1464 |
bin_id => $_->bin_id, |
|
1465 |
chargenumber => $_->chargenumber, |
|
1466 |
unit => $_->unit, |
|
1467 |
}, $item->delivery_order_stock_entries |
|
1468 |
]); |
|
1469 |
} |
|
1470 |
|
|
1431 | 1471 |
sub setup_order_from_cv { |
1432 | 1472 |
my ($order) = @_; |
1433 | 1473 |
|
SL/DB/DeliveryOrderItemsStock.pm | ||
---|---|---|
13 | 13 |
class => 'SL::DB::Inventory', |
14 | 14 |
column_map => { id => 'delivery_order_items_stock_id' }, |
15 | 15 |
}, |
16 |
unit_obj => { |
|
17 |
type => 'many to one', |
|
18 |
class => 'SL::DB::Unit', |
|
19 |
column_map => { unit => 'name' }, |
|
20 |
}, |
|
16 | 21 |
); |
17 | 22 |
|
18 | 23 |
__PACKAGE__->meta->initialize; |
js/kivi.DeliveryOrder.js | ||
---|---|---|
91 | 91 |
type: $("#type").val(), |
92 | 92 |
parts_id: $row.find("[name$=parts_id]").val(), |
93 | 93 |
unit: $row.find("[name$=unit]").val(), |
94 |
qty_as_number: $("qty_" + id).val(),
|
|
95 |
stock: $("stock_" + id).val(),
|
|
94 |
qty_as_number: $row.find("[name$=qty_as_number]").val(),
|
|
95 |
stock: $row.find("[name$=stock_info]").val(),
|
|
96 | 96 |
item_id: id, |
97 | 97 |
row: $row.attr("id"), |
98 | 98 |
}, |
templates/webpages/delivery_order/tabs/_row.html | ||
---|---|---|
16 | 16 |
[%- END %] |
17 | 17 |
[% L.hidden_tag("orderitem_ids[+]", ID) %] |
18 | 18 |
[% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %] |
19 |
[% L.hidden_tag("stock_info[+]", ITEM.stock_info, class="data-stock-info") %] |
|
20 | 19 |
[% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %] |
20 |
[% L.hidden_tag("order.orderitems[].stock_info", ITEM.stock_info, class="data-stock-info") %] |
|
21 | 21 |
[% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %] |
22 | 22 |
</td> |
23 | 23 |
<td> |
Auch abrufbar als: Unified diff
DeliveryOrder: stock roundtrip