Revision 958b82d6
Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
887 | 887 |
$self->js->render(); |
888 | 888 |
} |
889 | 889 |
|
890 |
# update item input row when a part ist picked |
|
891 |
sub action_update_item_input_row { |
|
892 |
my ($self) = @_; |
|
893 |
|
|
894 |
delete $::form->{add_item}->{$_} for qw(create_part_type sellprice_as_number discount_as_percent); |
|
895 |
|
|
896 |
my $form_attr = $::form->{add_item}; |
|
897 |
|
|
898 |
return unless $form_attr->{parts_id}; |
|
899 |
|
|
900 |
my $record = $self->order; |
|
901 |
my $item = SL::DB::OrderItem->new(%$form_attr); |
|
902 |
my $part = SL::DB::Part->new(id => $::form->{add_item}->{parts_id})->load; |
|
903 |
my $price_source = SL::PriceSource->new(record_item => $item, record => $record); |
|
904 |
|
|
905 |
$item->unit($part->unit); |
|
906 |
|
|
907 |
my $price_src; |
|
908 |
if ( $part->is_assortment ) { |
|
909 |
# add assortment items with price 0, as the components carry the price |
|
910 |
$price_src = $price_source->price_from_source(""); |
|
911 |
$price_src->price(0); |
|
912 |
} elsif (defined $item->sellprice) { |
|
913 |
$price_src = $price_source->price_from_source(""); |
|
914 |
$price_src->price($item->sellprice); |
|
915 |
} else { |
|
916 |
$price_src = $price_source->best_price |
|
917 |
? $price_source->best_price |
|
918 |
: $price_source->price_from_source(""); |
|
919 |
$price_src->price($::form->round_amount($price_src->price / $record->exchangerate, 5)) if $record->exchangerate; |
|
920 |
$price_src->price(0) if !$price_source->best_price; |
|
921 |
} |
|
922 |
|
|
923 |
my $discount_src; |
|
924 |
if (defined $item->discount) { |
|
925 |
$discount_src = $price_source->discount_from_source(""); |
|
926 |
$discount_src->discount($item->discount); |
|
927 |
} else { |
|
928 |
$discount_src = $price_source->best_discount |
|
929 |
? $price_source->best_discount |
|
930 |
: $price_source->discount_from_source(""); |
|
931 |
$discount_src->discount(0) if !$price_source->best_discount; |
|
932 |
} |
|
933 |
|
|
934 |
$self->js |
|
935 |
->val ('#add_item_unit', $item->unit) |
|
936 |
->val ('#add_item_description', $part->description) |
|
937 |
->val ('#add_item_sellprice_as_number', '') |
|
938 |
->attr ('#add_item_sellprice_as_number', 'placeholder', $price_src->price_as_number) |
|
939 |
->attr ('#add_item_sellprice_as_number', 'title', $price_src->source_description) |
|
940 |
->val ('#add_item_discount_as_percent', '') |
|
941 |
->attr ('#add_item_discount_as_percent', 'placeholder', $discount_src->discount_as_percent) |
|
942 |
->attr ('#add_item_discount_as_percent', 'title', $discount_src->source_description) |
|
943 |
->render; |
|
944 |
} |
|
945 |
|
|
890 | 946 |
# add an item row for a new item entered in the input row |
891 | 947 |
sub action_add_item { |
892 | 948 |
my ($self) = @_; |
... | ... | |
954 | 1010 |
|
955 | 1011 |
$self->js |
956 | 1012 |
->val('.add_item_input', '') |
1013 |
->attr('.add_item_input', 'placeholder', '') |
|
1014 |
->attr('.add_item_input', 'title', '') |
|
957 | 1015 |
->run('kivi.Order.init_row_handlers') |
958 | 1016 |
->run('kivi.Order.renumber_positions') |
959 | 1017 |
->focus('#add_item_parts_id_name'); |
... | ... | |
2711 | 2769 |
|
2712 | 2770 |
=item * |
2713 | 2771 |
|
2714 |
Customer discount is not displayed as a valid discount in price source popup |
|
2715 |
(this might be a bug in price sources) |
|
2716 |
|
|
2717 |
(I cannot reproduce this (Bernd)) |
|
2718 |
|
|
2719 |
=item * |
|
2720 |
|
|
2721 | 2772 |
No indication that <shift>-up/down expands/collapses second row. |
2722 | 2773 |
|
2723 | 2774 |
=item * |
2724 | 2775 |
|
2725 |
Inline creation of parts is not currently supported |
|
2726 |
|
|
2727 |
=item * |
|
2728 |
|
|
2729 | 2776 |
Table header is not sticky in the scrolling area. |
2730 | 2777 |
|
2731 | 2778 |
=item * |
... | ... | |
2748 | 2795 |
|
2749 | 2796 |
=item * |
2750 | 2797 |
|
2751 |
Possibility to select PriceSources in input row? |
|
2752 |
|
|
2753 |
=item * |
|
2754 |
|
|
2755 | 2798 |
This controller uses a (changed) copy of the template for the PriceSource |
2756 | 2799 |
dialog. Maybe there could be used one code source. |
2757 | 2800 |
|
js/kivi.Order.js | ||
---|---|---|
474 | 474 |
return insert_before_item_id; |
475 | 475 |
}; |
476 | 476 |
|
477 |
ns.update_item_input_row = function() { |
|
478 |
if (!ns.check_cv()) return; |
|
479 |
|
|
480 |
var data = $('#order_form').serializeArray(); |
|
481 |
data.push({ name: 'action', value: 'Order/update_item_input_row' }); |
|
482 |
|
|
483 |
$.post("controller.pl", data, kivi.eval_json_result); |
|
484 |
}; |
|
485 |
|
|
477 | 486 |
ns.add_item = function() { |
478 | 487 |
if ($('#add_item_parts_id').val() === '') return; |
479 | 488 |
if (!ns.check_cv()) return; |
... | ... | |
902 | 911 |
$('#order_transdate_as_date').change(kivi.Order.update_exchangerate); |
903 | 912 |
$('#order_exchangerate_as_null_number').change(kivi.Order.exchangerate_changed); |
904 | 913 |
|
905 |
if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { |
|
906 |
$('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) }); |
|
907 |
} else { |
|
908 |
$('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) }); |
|
909 |
} |
|
910 |
$('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) }); |
|
911 |
$('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_unit').val(o.unit) }); |
|
914 |
$('#add_item_parts_id').on('set_item:PartPicker', function() { |
|
915 |
kivi.Order.update_item_input_row(); |
|
916 |
}); |
|
912 | 917 |
|
913 | 918 |
$('.add_item_input').keydown(function(event) { |
914 | 919 |
if (event.keyCode == 13) { |
templates/webpages/order/tabs/_item_input.html | ||
---|---|---|
29 | 29 |
[%- SET PARAM_KEY = SELF.cv == "customer" ? 'with_customer_partnumber' : 'with_makemodel' -%] |
30 | 30 |
[%- SET PARAM_VAL = SELF.search_cvpartnumber -%] |
31 | 31 |
[% P.part.picker('add_item.parts_id', SELF.created_part, style='width: 300px', class="add_item_input", |
32 |
fat_set_item=1, |
|
33 | 32 |
multiple_pos_input=1, |
34 | 33 |
action={set_multi_items='kivi.Order.add_multi_items'}, |
35 | 34 |
classification_id=SELF.part_picker_classification_ids.as_list.join(','), |
... | ... | |
39 | 38 |
[% L.input_tag('add_item.qty_as_number', '', size = 5, class="add_item_input numeric") %] |
40 | 39 |
[% L.hidden_tag('add_item.unit', SELF.created_part.unit, class="add_item_input") %] |
41 | 40 |
</td> |
42 |
[%- SET price = LxERP.format_amount(((SELF.type == 'sales_quotation' || SELF.type == 'sales_order') ? SELF.created_part.sellprice : SELF.created_part.lastcost), -2) -%] |
|
43 |
<td>[% L.input_tag('add_item.sellprice_as_number', price, size = 10, class="add_item_input numeric") %]</td> |
|
44 |
<td>[% L.input_tag('add_item.discount_as_percent', '', size = 5, class="add_item_input numeric") %]</td> |
|
41 |
[%- SET price = '' %] |
|
42 |
[%- IF SELF.created_part %] |
|
43 |
[%- SET price = LxERP.format_amount(((SELF.type == 'sales_quotation' || SELF.type == 'sales_order') ? SELF.created_part.sellprice : SELF.created_part.lastcost), -2) -%] |
|
44 |
[%- END %] |
|
45 |
<td>[% L.input_tag('add_item.sellprice_as_number', price, size = 10, class="add_item_input numeric tooltipster-html") %]</td> |
|
46 |
<td>[% L.input_tag('add_item.discount_as_percent', '', size = 5, class="add_item_input numeric tooltipster-html") %]</td> |
|
45 | 47 |
<td>[% L.button_tag('kivi.Order.add_item()', LxERP.t8('Add part')) %]</td> |
46 | 48 |
</tr> |
47 | 49 |
</tbody> |
Auch abrufbar als: Unified diff
Auftrags-Controller: Preisquellen in oberer Eingabezeile besser berücksichtigen
Das alte Verhalten war, Preisquellen bei der Übernahme der Eingabezeile in die
Position zu berücksichtigen, wenn das Preisfeld leer war.
Das war nicht ersichtlich. Zudem wurde bei der Auswahl (Picker) eines Artikels
der Artikelpreis ohne Berücksichtigung der Quellen in das Preisfeld oben
eingetragen, so dass man es leer machen musste, um den Preisquellenpreis in die
Position zu übernehmen.
Nun wird nach der Auswahl (Picker) eines Artikels der Preis der Preisquelle
als placeholder in das Preisfeld eingetragen. Ein tooltip zeigt die Quelle an.
Damit bleibt das Feld leer und der Quellenpreis wird für die Position
verwendet.
Die Bearbeiterin sieht den Preis, der verwendet wird, kann ihn aber
auch leicht überschreiben.
Analog gilt das alles für das Rabattfeld.