Revision 5737ce39
Von Bernd Bleßmann vor fast 8 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
387 | 387 |
|
388 | 388 |
$self->js |
389 | 389 |
->run('kivi.Order.update_sellprice', $::form->{item_id}, $item->sellprice_as_number); |
390 |
$self->_js_redisplay_linetotals;
|
|
390 |
$self->_js_redisplay_line_values;
|
|
391 | 391 |
$self->_js_redisplay_amounts_and_taxes; |
392 | 392 |
$self->js->render(); |
393 | 393 |
} |
... | ... | |
539 | 539 |
|
540 | 540 |
$self->_recalc(); |
541 | 541 |
|
542 |
$self->_js_redisplay_linetotals;
|
|
542 |
$self->_js_redisplay_line_values;
|
|
543 | 543 |
$self->_js_redisplay_amounts_and_taxes; |
544 | 544 |
$self->js->render(); |
545 | 545 |
} |
... | ... | |
601 | 601 |
sub action_load_second_rows { |
602 | 602 |
my ($self) = @_; |
603 | 603 |
|
604 |
$self->_recalc() if $self->order->is_sales; # for margin calculation |
|
605 |
|
|
604 | 606 |
foreach my $item_id (@{ $::form->{item_ids} }) { |
605 | 607 |
my $idx = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} }; |
606 | 608 |
my $item = $self->order->items_sorted->[$idx]; |
... | ... | |
631 | 633 |
->data('.row_entry:has(#item_' . $item_id . ') [name = "second_row"]', 'loaded', 1); |
632 | 634 |
} |
633 | 635 |
|
634 |
sub _js_redisplay_linetotals {
|
|
636 |
sub _js_redisplay_line_values {
|
|
635 | 637 |
my ($self) = @_; |
636 | 638 |
|
637 |
my @data = map {$::form->format_amount(\%::myconfig, $_->{linetotal}, 2, 0)} @{ $self->order->items_sorted }; |
|
639 |
my $is_sales = $self->order->is_sales; |
|
640 |
|
|
641 |
# sales orders with margins |
|
642 |
my @data; |
|
643 |
if ($is_sales) { |
|
644 |
@data = map { |
|
645 |
[ |
|
646 |
$::form->format_amount(\%::myconfig, $_->{linetotal}, 2, 0), |
|
647 |
$::form->format_amount(\%::myconfig, $_->{marge_total}, 2, 0), |
|
648 |
$::form->format_amount(\%::myconfig, $_->{marge_percent}, 2, 0), |
|
649 |
]} @{ $self->order->items_sorted }; |
|
650 |
} else { |
|
651 |
@data = map { |
|
652 |
[ |
|
653 |
$::form->format_amount(\%::myconfig, $_->{linetotal}, 2, 0), |
|
654 |
]} @{ $self->order->items_sorted }; |
|
655 |
} |
|
656 |
|
|
638 | 657 |
$self->js |
639 |
->run('kivi.Order.redisplay_linetotals', \@data);
|
|
658 |
->run('kivi.Order.redisplay_line_values', $is_sales, \@data);
|
|
640 | 659 |
} |
641 | 660 |
|
642 | 661 |
sub _js_redisplay_amounts_and_taxes { |
js/kivi.Order.js | ||
---|---|---|
296 | 296 |
|
297 | 297 |
}; |
298 | 298 |
|
299 |
ns.redisplay_linetotals = function(data) { |
|
300 |
$('.row_entry [name="linetotal"]').each(function(idx, elt) { |
|
301 |
$(elt).html(data[idx]); |
|
299 |
ns.redisplay_line_values = function(is_sales, data) { |
|
300 |
$('.row_entry').each(function(idx, elt) { |
|
301 |
$(elt).find('[name="linetotal"]').html(data[idx][0]); |
|
302 |
if (is_sales && $(elt).find('[name="second_row"]').data('loaded') == 1) { |
|
303 |
var mt = data[idx][1]; |
|
304 |
var mp = data[idx][2]; |
|
305 |
var h = '<span'; |
|
306 |
if (mt[0] === '-') h += ' class="plus0"'; |
|
307 |
h += '>' + mt + ' ' + mp + '%'; |
|
308 |
h += '</span>'; |
|
309 |
$(elt).find('[name="linemargin"]').html(h); |
|
310 |
} |
|
302 | 311 |
}); |
303 | 312 |
}; |
304 | 313 |
|
templates/webpages/order/tabs/_second_row.html | ||
---|---|---|
14 | 14 |
<th>[%- 'Subtotal' | $T8 %]</th> |
15 | 15 |
<td>[% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]</td> |
16 | 16 |
[%- IF ITEM.order.is_sales %] |
17 |
<th>[%- 'Ertrag' | $T8 %]</th> |
|
18 |
<td> |
|
19 |
<div name="linemargin"> |
|
20 |
<span[%- IF ITEM.marge_total < 0 -%] class="plus0"[%- END -%]> |
|
21 |
[%- LxERP.format_amount(ITEM.marge_total, 2, 0) %] |
|
22 |
[%- LxERP.format_amount(ITEM.marge_percent, 2, 0) %]% |
|
23 |
</span> |
|
24 |
</div> |
|
25 |
</td> |
|
17 | 26 |
<th>[%- 'LP' | $T8 %]</th> |
18 | 27 |
<td>[%- LxERP.format_amount(ITEM.part.listprice, 2, 0) %]</td> |
19 | 28 |
[%- END %] |
Auch abrufbar als: Unified diff
Auftrags-Controller: Marge in zweiter Zeile