Revision 0956f2d4
Von Felix Eichler vor mehr als 4 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
929 | 929 |
sub action_update_exchangerate { |
930 | 930 |
my ($self) = @_; |
931 | 931 |
my $data = {}; |
932 |
if ($self->order->currency_id != $::instance_conf->get_currency_id) { |
|
933 |
$data = { |
|
934 |
currency_name => $self->order->currency->name, |
|
935 |
exchangerate => $self->order->exchangerate_as_number, |
|
936 |
}; |
|
937 |
} |
|
932 |
|
|
933 |
$data = { |
|
934 |
is_standard => $self->order->currency_id == $::instance_conf->get_currency_id, |
|
935 |
currency_name => $self->order->currency->name, |
|
936 |
exchangerate => $self->order->exchangerate_as_null_number, |
|
937 |
}; |
|
938 |
|
|
938 | 939 |
$self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); |
939 | 940 |
} |
940 | 941 |
|
... | ... | |
1372 | 1373 |
|
1373 | 1374 |
my $form_orderitems = delete $::form->{order}->{orderitems}; |
1374 | 1375 |
my $form_periodic_invoices_config = delete $::form->{order}->{periodic_invoices_config}; |
1375 |
my $exchangerate = delete $::form->{order}->{exchangerate};
|
|
1376 |
my $exchangerate_as_null_number = delete $::form->{order}->{exchangerate_as_null_number};
|
|
1376 | 1377 |
|
1377 | 1378 |
$order->assign_attributes(%{$::form->{order}}); |
1378 | 1379 |
|
... | ... | |
1382 | 1383 |
} |
1383 | 1384 |
|
1384 | 1385 |
# set exchangerate after transdate and currency_id |
1385 |
$order->assign_attributes(exchangerate => $exchangerate);
|
|
1386 |
$order->assign_attributes(exchangerate_as_null_number => $exchangerate_as_null_number) if $order->currency_id;
|
|
1386 | 1387 |
|
1387 | 1388 |
# remove deleted items |
1388 | 1389 |
$self->item_ids_to_delete([]); |
SL/DB/Order.pm | ||
---|---|---|
18 | 18 |
use SL::DB::Helper::PriceTaxCalculator; |
19 | 19 |
use SL::DB::Helper::PriceUpdater; |
20 | 20 |
use SL::DB::Helper::TransNumberGenerator; |
21 |
use SL::Locale::String qw(t8); |
|
21 | 22 |
use SL::RecordLinks; |
22 | 23 |
use Rose::DB::Object::Helpers qw(as_tree); |
23 | 24 |
|
... | ... | |
124 | 125 |
|
125 | 126 |
return 1 if $self->currency_id == $::instance_conf->get_currency_id; |
126 | 127 |
|
128 |
# unable to determine if sales or purchase |
|
129 |
return undef if !$self->has_customervendor; |
|
130 |
|
|
127 | 131 |
my $rate = $self->is_sales ? 'buy' : 'sell'; |
128 | 132 |
|
129 | 133 |
if (defined $val) { |
130 |
croak 'exchange rate has to be positive' if $val <= 0;
|
|
134 |
croak t8('exchange rate has to be positive') if $val <= 0;
|
|
131 | 135 |
if (!$self->exchangerate_obj) { |
132 | 136 |
$self->exchangerate_obj(SL::DB::Exchangerate->new( |
133 | 137 |
currency_id => $self->currency_id, |
... | ... | |
137 | 141 |
} elsif (!defined $self->exchangerate_obj->$rate) { |
138 | 142 |
$self->exchangerate_obj->$rate($val); |
139 | 143 |
} else { |
140 |
croak 'exchange rate already exists, no update allowed';
|
|
144 |
croak t8('exchange rate already exists, no update allowed');
|
|
141 | 145 |
} |
142 | 146 |
} |
143 | 147 |
return $self->exchangerate_obj->$rate if $self->exchangerate_obj; |
js/kivi.Order.js | ||
---|---|---|
175 | 175 |
}; |
176 | 176 |
|
177 | 177 |
ns.update_exchangerate = function(event) { |
178 |
var rate_input = $('#order_exchangerate_as_number'); |
|
179 |
rate_input.attr('name', '');
|
|
178 |
var rate_input = $('#order_exchangerate_as_null_number');
|
|
179 |
rate_input.prop('disabled', true);
|
|
180 | 180 |
|
181 | 181 |
var data = $('#order_form').serializeArray(); |
182 | 182 |
data.push({ name: 'action', value: 'Order/update_exchangerate' }); |
... | ... | |
187 | 187 |
method: 'POST', |
188 | 188 |
dataType: 'json', |
189 | 189 |
success: function(data){ |
190 |
if (data.currency_name) {
|
|
190 |
if (!data.is_standard) {
|
|
191 | 191 |
$('#currency_name').text(data.currency_name); |
192 | 192 |
var rate_text = $('#exchangerate_text'); |
193 | 193 |
if (data.exchangerate) { |
... | ... | |
195 | 195 |
rate_input.hide(); |
196 | 196 |
} else { |
197 | 197 |
rate_text.text(''); |
198 |
rate_input.show().attr('name', rate_input.data('name')).val(0); |
|
198 |
rate_input.prop('disabled', false); |
|
199 |
rate_input.show().val(0); |
|
199 | 200 |
} |
200 | 201 |
$('#exchangerate_settings').show(); |
201 | 202 |
} else { |
202 | 203 |
$('#exchangerate_settings').hide(); |
203 | 204 |
} |
204 |
if ($('#order_currency_id').val() != $('#old_currency_id').val() || data.exchangerate != $('#old_exchangerate').val()) { |
|
205 |
console.log(data.is_standard); |
|
206 |
console.log(data.exchangerate); |
|
207 |
console.log($('#old_exchangerate').val()); |
|
208 |
if ($('#order_currency_id').val() != $('#old_currency_id').val() || |
|
209 |
!data.is_standard && data.exchangerate != $('#old_exchangerate').val()) { |
|
205 | 210 |
kivi.display_flash('warning', kivi.t8('You have changed the currency or exchange rate. Please update prices.')); |
206 | 211 |
} |
207 | 212 |
$('#old_currency_id').val($('#order_currency_id').val()); |
... | ... | |
211 | 216 |
}; |
212 | 217 |
|
213 | 218 |
ns.exchangerate_changed = function(event) { |
214 |
if (kivi.parse_amount($('#order_exchangerate_as_number').val()) != kivi.parse_amount($('#old_exchangerate').val())) { |
|
219 |
if (kivi.parse_amount($('#order_exchangerate_as_null_number').val()) != kivi.parse_amount($('#old_exchangerate').val())) {
|
|
215 | 220 |
kivi.display_flash('warning', kivi.t8('You have changed the currency or exchange rate. Please update prices.')); |
216 |
$('#old_exchangerate').val($('#order_exchangerate_as_number').val()); |
|
221 |
$('#old_exchangerate').val($('#order_exchangerate_as_null_number').val());
|
|
217 | 222 |
} |
218 | 223 |
}; |
219 | 224 |
|
... | ... | |
837 | 842 |
|
838 | 843 |
$('#order_currency_id').change(kivi.Order.update_exchangerate); |
839 | 844 |
$('#order_transdate_as_date').change(kivi.Order.update_exchangerate); |
840 |
$('#order_exchangerate_as_number').change(kivi.Order.exchangerate_changed); |
|
845 |
$('#order_exchangerate_as_null_number').change(kivi.Order.exchangerate_changed);
|
|
841 | 846 |
|
842 | 847 |
if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { |
843 | 848 |
$('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) }); |
locale/de/all | ||
---|---|---|
4135 | 4135 |
'error while unlinking payment #1 : ' => 'Fehler beim Zurücksetzen von Zahlung #1:', |
4136 | 4136 |
'every third month' => 'vierteljährlich', |
4137 | 4137 |
'every time' => 'immer', |
4138 |
'exchange rate already exists, no update allowed' => 'Wechselkurs existiert bereits und kann nicht geändert werden', |
|
4139 |
'exchange rate has to be positive' => 'Wechselkurs muss positiv sein', |
|
4138 | 4140 |
'executed' => 'ausgeführt', |
4139 | 4141 |
'execution as user \'#1\'' => 'Ausführung als User »#1«', |
4140 | 4142 |
'failed' => 'fehlgeschlagen', |
templates/webpages/order/tabs/basic_data.html | ||
---|---|---|
49 | 49 |
<td>[% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px', class='recalc') %]</td> |
50 | 50 |
</tr> |
51 | 51 |
|
52 |
[% SET currency_id = SELF.order.currency_id || INSTANCE_CONF.get_currency_id # use default currency for new order %] |
|
53 |
[% IF SELF.order.exchangerate %] |
|
54 |
[% SET exchangerate = SELF.order.exchangerate_as_null_number %] |
|
55 |
[% END %] |
|
52 | 56 |
<tr id="currency_settings"> |
53 | 57 |
<th align="right">[% 'Currency' | $T8 %]</th> |
54 |
<td>[% L.select_tag('order.currency_id', SELF.all_currencies, default=SELF.order.currency_id, value_key='id', title_key='name') %]</td>
|
|
58 |
<td>[% L.select_tag('order.currency_id', SELF.all_currencies, default=currency_id, value_key='id', title_key='name') %]</td> |
|
55 | 59 |
</tr> |
56 |
<tr id="exchangerate_settings" [%- IF !SELF.order.currency_id || SELF.order.currency_id==INSTANCE_CONF.get_currency_id %]style='display:none'[%- END %]>
|
|
60 |
<tr id="exchangerate_settings" [%- IF currency_id==INSTANCE_CONF.get_currency_id %]style='display:none'[%- END %]> |
|
57 | 61 |
<th align="right">[% 'Exchangerate' | $T8 %]</th> |
58 | 62 |
<td> 1 <span id="currency_name">[% SELF.order.currency.name %]</span> = |
59 | 63 |
<span id="exchangerate_text"> |
60 |
[% IF SELF.order.exchangerate %]
|
|
61 |
[% HTML.escape(SELF.order.exchangerate_as_number) %]
|
|
64 |
[% IF exchangerate %] |
|
65 |
[% HTML.escape(exchangerate) %]
|
|
62 | 66 |
[% END %] |
63 | 67 |
</span> |
64 |
[% IF !SELF.order.currency_id || SELF.order.currency_id==INSTANCE_CONF.get_currency_id || SELF.order.exchangerate %]
|
|
65 |
[% L.input_tag('', '', size="15", id='order_exchangerate_as_number', 'data-name'='order.exchangerate_as_number', style='display:none') %]
|
|
68 |
[% IF currency_id==INSTANCE_CONF.get_currency_id || SELF.order.exchangerate %] |
|
69 |
[% L.input_tag('order.exchangerate_as_null_number', '', size="15", style='display:none', disabled=1) %]
|
|
66 | 70 |
[% ELSE %] |
67 |
[% L.input_tag('order.exchangerate_as_number', 0, size="15") %] |
|
71 |
[% L.input_tag('order.exchangerate_as_null_number', 0, size="15") %]
|
|
68 | 72 |
[% END %] |
69 | 73 |
[% INSTANCE_CONF.default_currency %] |
70 |
[% L.hidden_tag('old_currency_id', SELF.order.currency_id) %]
|
|
71 |
[% L.hidden_tag('old_exchangerate', SELF.order.exchangerate_as_number) %]
|
|
74 |
[% L.hidden_tag('old_currency_id', currency_id) %] |
|
75 |
[% L.hidden_tag('old_exchangerate', exchangerate) %]
|
|
72 | 76 |
</td> |
73 | 77 |
</tr> |
74 | 78 |
|
Auch abrufbar als: Unified diff
Auftragsschnellerfassung: Korrekturen für Währung/Wechselkurs
- Feld auf disabled setzen wenn nicht gebraucht
- _as_null_number damit undef nicht zu 0 wird
- Übersetzte Fehlermeldungen
ticket #9491
(cherry picked from commit c581e4685a217bdd5b73380b1f808037a473dd9f)
(cherry pick von odyn)