Revision 598383b3
Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
934 | 934 |
my $data = { |
935 | 935 |
is_standard => $self->order->currency_id == $::instance_conf->get_currency_id, |
936 | 936 |
currency_name => $self->order->currency->name, |
937 |
exchangerate => $self->order->exchangerate_as_null_number, |
|
937 |
exchangerate => $self->order->daily_exchangerate_as_null_number,
|
|
938 | 938 |
}; |
939 | 939 |
|
940 | 940 |
$self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 }); |
... | ... | |
1375 | 1375 |
|
1376 | 1376 |
my $form_orderitems = delete $::form->{order}->{orderitems}; |
1377 | 1377 |
my $form_periodic_invoices_config = delete $::form->{order}->{periodic_invoices_config}; |
1378 |
my $form_exchangerate_as_null_number = delete $::form->{order}->{exchangerate_as_null_number}; |
|
1379 | 1378 |
|
1380 | 1379 |
$order->assign_attributes(%{$::form->{order}}); |
1381 | 1380 |
|
... | ... | |
1384 | 1383 |
$periodic_invoices_config->assign_attributes(%$periodic_invoices_config_attrs); |
1385 | 1384 |
} |
1386 | 1385 |
|
1387 |
# set exchangerate after transdate and currency_id |
|
1388 |
$order->assign_attributes(exchangerate_as_null_number => $form_exchangerate_as_null_number) if $order->currency_id; |
|
1389 |
|
|
1390 | 1386 |
# remove deleted items |
1391 | 1387 |
$self->item_ids_to_delete([]); |
1392 | 1388 |
foreach my $idx (reverse 0..$#{$order->orderitems}) { |
SL/DB/Helper/FlattenToForm.pm | ||
---|---|---|
42 | 42 |
($vc eq 'customer')? 'c_vendor_id': 'v_customer_id'); |
43 | 43 |
my @vc_prefixed_fields = qw(email fax notes number phone); |
44 | 44 |
|
45 |
_copy($self, $form, '', '', 1, qw(amount netamount marge_total marge_percent container_remaining_weight container_remaining_volume paid)); |
|
45 |
_copy($self, $form, '', '', 1, qw(amount netamount marge_total marge_percent container_remaining_weight container_remaining_volume paid exchangerate));
|
|
46 | 46 |
_copy($self->$vc, $form, '', '', 0, @vc_fields); |
47 | 47 |
_copy($self->$vc, $form, $vc, '', 0, @vc_prefixed_fields); |
48 | 48 |
_copy($self->contact, $form, '', '', 0, grep { /^cp_/ } map { $_->name } SL::DB::Contact->meta->columns) if _has($self, 'cp_id'); |
SL/DB/Order.pm | ||
---|---|---|
277 | 277 |
} |
278 | 278 |
|
279 | 279 |
my %args = ( map({ ( $_ => $source->$_ ) } qw(amount cp_id currency_id cusordnumber customer_id delivery_customer_id delivery_term_id delivery_vendor_id |
280 |
department_id employee_id globalproject_id intnotes marge_percent marge_total language_id netamount notes |
|
280 |
department_id employee_id exchangerate globalproject_id intnotes marge_percent marge_total language_id netamount notes
|
|
281 | 281 |
ordnumber payment_id quonumber reqdate salesman_id shippingpoint shipvia taxincluded taxzone_id |
282 | 282 |
transaction_description vendor_id |
283 | 283 |
)), |
... | ... | |
392 | 392 |
} |
393 | 393 |
foreach my $attr (qw(cp_id currency_id employee_id salesman_id department_id |
394 | 394 |
delivery_customer_id delivery_vendor_id shipto_id |
395 |
globalproject_id)) { |
|
395 |
globalproject_id exchangerate)) {
|
|
396 | 396 |
$attributes{$attr} = undef if any { ($sources->[0]->$attr||0) != ($_->$attr||0) } @$sources; |
397 | 397 |
} |
398 | 398 |
|
bin/mozilla/io.pl | ||
---|---|---|
56 | 56 |
use SL::Presenter::Part; |
57 | 57 |
|
58 | 58 |
use SL::DB::Contact; |
59 |
use SL::DB::Currency; |
|
59 | 60 |
use SL::DB::Customer; |
60 | 61 |
use SL::DB::Default; |
61 | 62 |
use SL::DB::Language; |
... | ... | |
910 | 911 |
_order(); |
911 | 912 |
|
912 | 913 |
if ($::instance_conf->get_feature_experimental_order) { |
914 |
|
|
915 |
# At this point, the record is saved and the exchangerate contains |
|
916 |
# an unformatted value. _make_record uses RDBO attributes (i.e. _as_number) |
|
917 |
# to assign values and thus expects an formatted value. |
|
918 |
$::form->{exchangerate} = $::form->format_amount(\%::myconfig, $::form->{exchangerate}); |
|
919 |
|
|
913 | 920 |
my $order = _make_record(); |
914 |
$order->globalproject_id(undef) if !$order->globalproject_id; |
|
915 |
$order->payment_id(undef) if !$order->payment_id; |
|
921 |
|
|
922 |
$order->currency(SL::DB::Currency->new(name => $::form->{currency})->load) if $::form->{currency}; |
|
923 |
$order->globalproject_id(undef) if !$order->globalproject_id; |
|
924 |
$order->payment_id(undef) if !$order->payment_id; |
|
925 |
|
|
916 | 926 |
my $row = 1; |
917 | 927 |
foreach my $item (@{$order->items_sorted}) { |
918 | 928 |
$item->custom_variables([]); |
js/kivi.Order.js | ||
---|---|---|
174 | 174 |
$(event.target).val(kivi.format_amount(kivi.parse_amount($(event.target).val()), -2)); |
175 | 175 |
}; |
176 | 176 |
|
177 |
ns.reformat_number_as_null_number = function(event) { |
|
178 |
if ($(event.target).val() === '') { |
|
179 |
return; |
|
180 |
} |
|
181 |
ns.reformat_number(event); |
|
182 |
}; |
|
183 |
|
|
177 | 184 |
ns.update_exchangerate = function(event) { |
178 | 185 |
if (!ns.check_cv()) { |
179 | 186 |
$('#order_currency_id').val($('#old_currency_id').val()); |
... | ... | |
181 | 188 |
} |
182 | 189 |
|
183 | 190 |
var rate_input = $('#order_exchangerate_as_null_number'); |
184 |
rate_input.prop('disabled', true); |
|
191 |
// unset exchangerate if currency changed |
|
192 |
if ($('#order_currency_id').val() !== $('#old_currency_id').val()) { |
|
193 |
rate_input.val(''); |
|
194 |
} |
|
195 |
|
|
196 |
// only set exchangerate if unset |
|
197 |
if (rate_input.val() !== '') { |
|
198 |
return; |
|
199 |
} |
|
185 | 200 |
|
186 | 201 |
var data = $('#order_form').serializeArray(); |
187 | 202 |
data.push({ name: 'action', value: 'Order/update_exchangerate' }); |
... | ... | |
194 | 209 |
success: function(data){ |
195 | 210 |
if (!data.is_standard) { |
196 | 211 |
$('#currency_name').text(data.currency_name); |
197 |
var rate_text = $('#exchangerate_text'); |
|
198 | 212 |
if (data.exchangerate) { |
199 |
rate_text.text(data.exchangerate); |
|
200 |
rate_input.hide(); |
|
213 |
rate_input.val(data.exchangerate); |
|
201 | 214 |
} else { |
202 |
rate_text.text(''); |
|
203 |
rate_input.prop('disabled', false); |
|
204 |
rate_input.show().val(''); |
|
215 |
rate_input.val(''); |
|
205 | 216 |
} |
206 | 217 |
$('#exchangerate_settings').show(); |
207 | 218 |
} else { |
219 |
rate_input.val(''); |
|
208 | 220 |
$('#exchangerate_settings').hide(); |
209 | 221 |
} |
210 | 222 |
if ($('#order_currency_id').val() != $('#old_currency_id').val() || |
... | ... | |
892 | 904 |
return false; |
893 | 905 |
}); |
894 | 906 |
|
907 |
$('.reformat_number_as_null_number').change(kivi.Order.reformat_number_as_null_number); |
|
908 |
|
|
895 | 909 |
}); |
templates/webpages/order/tabs/basic_data.html | ||
---|---|---|
50 | 50 |
</tr> |
51 | 51 |
|
52 | 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 %] |
|
56 | 53 |
<tr id="currency_settings"> |
57 | 54 |
<th align="right">[% 'Currency' | $T8 %]</th> |
58 | 55 |
<td>[% L.select_tag('order.currency_id', SELF.all_currencies, default=currency_id, value_key='id', title_key='name') %]</td> |
59 | 56 |
</tr> |
60 |
<tr id="exchangerate_settings" [%- IF currency_id==INSTANCE_CONF.get_currency_id %]style='display:none'[%- END %]> |
|
57 |
<tr id="exchangerate_settings" [%- IF SELF.order.currency_id==INSTANCE_CONF.get_currency_id %]style='display:none'[%- END %]>
|
|
61 | 58 |
<th align="right">[% 'Exchangerate' | $T8 %]</th> |
62 | 59 |
<td> 1 <span id="currency_name">[% SELF.order.currency.name %]</span> = |
63 |
<span id="exchangerate_text"> |
|
64 |
[% IF exchangerate %] |
|
65 |
[% HTML.escape(exchangerate) %] |
|
66 |
[% END %] |
|
67 |
</span> |
|
68 |
[% IF currency_id==INSTANCE_CONF.get_currency_id || SELF.order.exchangerate %] |
|
69 |
[% L.input_tag('order.exchangerate_as_null_number', '', size="15", class="reformat_number numeric", style='display:none', disabled=1) %] |
|
70 |
[% ELSE %] |
|
71 |
[% L.input_tag('order.exchangerate_as_null_number', '', size="15", class="reformat_number numeric") %] |
|
72 |
[% END %] |
|
60 |
[% L.input_tag('order.exchangerate_as_null_number', SELF.order.exchangerate_as_null_number, size="15", class="reformat_number_as_null_number numeric") %] |
|
73 | 61 |
[% INSTANCE_CONF.default_currency %] |
74 | 62 |
[% L.hidden_tag('old_currency_id', currency_id) %] |
75 |
[% L.hidden_tag('old_exchangerate', exchangerate) %]
|
|
63 |
[% L.hidden_tag('old_exchangerate', SELF.order.exchangerate_as_null_number) %]
|
|
76 | 64 |
</td> |
77 | 65 |
</tr> |
78 | 66 |
|
Auch abrufbar als: Unified diff
Auftrags-Controller: Wechselkurs pro Beleg …
- Wechselkurs wird pro Beleg gespeichert
- Wechselkurs ist immer änderbar
- vorausgefüllt aus "alter" Tages-Wechselkurstabelle
Bezieht sich auch auf #135
Refs #135