Revision 82eea3be
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
402 | 402 |
$column_data{stock_in_out} = calculate_stock_in_out($i); |
403 | 403 |
} |
404 | 404 |
|
405 |
# tax_chart |
|
406 |
my ($tax_chart_id, $chart_title, $chart_picker); |
|
407 |
if ($record_item && $record_item->part && ($record_item->part->type eq 'part')) { |
|
408 |
my $tax_chart_type = $form->{"tax_chart_type_$i"}; |
|
409 |
$tax_chart_type ||= |
|
410 |
$::instance_conf->get_inventory_system eq 'periodic' ? 'expense' |
|
411 |
: 'inventory'; |
|
412 |
$tax_chart_id = $form->{"${tax_chart_type}_chart_id_$i"}; |
|
413 |
|
|
414 |
$chart_title = SL::Presenter::Tag::select_tag("tax_chart_type_$i", [ |
|
415 |
{value => 'expense', title => $locale->text('Expense Account')}, |
|
416 |
{value => 'inventory', title => $locale->text('Inventory Account')}, |
|
417 |
], |
|
418 |
value_key => 'value', title_key => 'title', |
|
419 |
default => $tax_chart_type, |
|
420 |
onchange => "kivi.io.update_tax_chart_picker(this.value, $i)", |
|
421 |
); |
|
422 |
|
|
423 |
$chart_picker = |
|
424 |
SL::Presenter::Tag::html_tag('span', |
|
425 |
SL::Presenter::Chart::chart_picker( |
|
426 |
"expense_chart_id_$i", $form->{"expense_chart_id_$i"}, |
|
427 |
type => "AP_amount", style => "width: 150px"), |
|
428 |
id => "expense_chart_span_$i", |
|
429 |
style => $tax_chart_type eq 'expense' ? '' : 'display:none', |
|
430 |
) |
|
431 |
. |
|
432 |
SL::Presenter::Tag::html_tag('span', |
|
433 |
SL::Presenter::Chart::chart_picker( |
|
434 |
"inventory_chart_id_$i", $form->{"inventory_chart_id_$i"}, |
|
435 |
type => "IC", style => "width: 150px"), |
|
436 |
id => "inventory_chart_span_$i", |
|
437 |
style => $tax_chart_type eq 'inventory' ? '' : 'display:none', |
|
405 |
# tax_chart and tax |
|
406 |
if ($is_purchase && $is_invoice) { #only calc if used |
|
407 |
my ($tax_chart_id, $chart_title, $chart_picker); |
|
408 |
if ($record_item && $record_item->part && ($record_item->part->type eq 'part')) { |
|
409 |
my $tax_chart_type = $form->{"tax_chart_type_$i"}; |
|
410 |
$tax_chart_type ||= |
|
411 |
$::instance_conf->get_inventory_system eq 'periodic' ? 'expense' |
|
412 |
: 'inventory'; |
|
413 |
$tax_chart_id = $form->{"${tax_chart_type}_chart_id_$i"}; |
|
414 |
|
|
415 |
$chart_title = SL::Presenter::Tag::select_tag("tax_chart_type_$i", [ |
|
416 |
{value => 'expense', title => $locale->text('Expense Account')}, |
|
417 |
{value => 'inventory', title => $locale->text('Inventory Account')}, |
|
418 |
], |
|
419 |
value_key => 'value', title_key => 'title', |
|
420 |
default => $tax_chart_type, |
|
421 |
onchange => "kivi.io.update_tax_chart_picker(this.value, $i)", |
|
438 | 422 |
); |
439 |
} else { |
|
440 |
$tax_chart_id = $form->{"expense_chart_id_$i"}; |
|
441 |
$chart_title = $locale->text('Expense Account'); |
|
442 |
$chart_picker = SL::Presenter::Chart::chart_picker( |
|
443 |
"expense_chart_id_$i", $form->{"expense_chart_id_$i"}, |
|
444 |
type => "AP_amount", style => "width: 150px"); |
|
445 |
} |
|
446 |
# change tax dropdown after change |
|
447 |
my $js_set_on_select_item = '<script type="text/javascript"> |
|
448 |
<!-- |
|
449 |
$(document).ready(function() { |
|
450 |
$("#expense_chart_id_' . $i . '").on("set_item:ChartPicker", function(e, item) { |
|
451 |
kivi.io.update_tax_ids(this); |
|
452 |
}); |
|
453 |
$("#inventory_chart_id_' . $i . '").on("set_item:ChartPicker", function(e, item) { |
|
454 |
kivi.io.update_tax_ids(this); |
|
455 |
}); |
|
456 |
}); |
|
457 |
--> |
|
458 |
</script> |
|
459 |
'; |
|
460 |
$column_data{tax_chart} = SL::Presenter::Tag::html_tag('span', |
|
461 |
$chart_title . $chart_picker . $js_set_on_select_item); |
|
462 |
|
|
463 |
my $tax_value_title_sub = sub { |
|
464 |
my $item = shift; |
|
465 |
return [ |
|
466 |
$item->{id}, |
|
467 |
$item->{taxkey} . ' - ' . $item->{taxdescription} .' '. ($item->{rate} * 100) .' %', |
|
468 |
]; |
|
469 |
}; |
|
470 | 423 |
|
471 |
my @taxes = (); |
|
472 |
if ($form->{"expense_chart_id_$i"}) { |
|
473 |
@taxes = IO->get_active_taxes_for_chart($tax_chart_id, |
|
474 |
$form->{"reqdate_$i"} // $form->{deliverydate} // $form->{transdate}); |
|
424 |
$chart_picker = |
|
425 |
SL::Presenter::Tag::html_tag('span', |
|
426 |
SL::Presenter::Chart::chart_picker( |
|
427 |
"expense_chart_id_$i", $form->{"expense_chart_id_$i"}, |
|
428 |
type => "AP_amount", style => "width: 150px"), |
|
429 |
id => "expense_chart_span_$i", |
|
430 |
style => $tax_chart_type eq 'expense' ? '' : 'display:none', |
|
431 |
) |
|
432 |
. |
|
433 |
SL::Presenter::Tag::html_tag('span', |
|
434 |
SL::Presenter::Chart::chart_picker( |
|
435 |
"inventory_chart_id_$i", $form->{"inventory_chart_id_$i"}, |
|
436 |
type => "IC", style => "width: 150px"), |
|
437 |
id => "inventory_chart_span_$i", |
|
438 |
style => $tax_chart_type eq 'inventory' ? '' : 'display:none', |
|
439 |
); |
|
440 |
} else { |
|
441 |
$tax_chart_id = $form->{"expense_chart_id_$i"}; |
|
442 |
$chart_title = $locale->text('Expense Account'); |
|
443 |
$chart_picker = SL::Presenter::Chart::chart_picker( |
|
444 |
"expense_chart_id_$i", $form->{"expense_chart_id_$i"}, |
|
445 |
type => "AP_amount", style => "width: 150px"); |
|
446 |
} |
|
447 |
# change tax dropdown after change |
|
448 |
my $js_set_on_select_item = '<script type="text/javascript"> |
|
449 |
<!-- |
|
450 |
$(document).ready(function() { |
|
451 |
$("#expense_chart_id_' . $i . '").on("set_item:ChartPicker", function(e, item) { |
|
452 |
kivi.io.update_tax_ids(this); |
|
453 |
}); |
|
454 |
$("#inventory_chart_id_' . $i . '").on("set_item:ChartPicker", function(e, item) { |
|
455 |
kivi.io.update_tax_ids(this); |
|
456 |
}); |
|
457 |
}); |
|
458 |
--> |
|
459 |
</script> |
|
460 |
'; |
|
461 |
$column_data{tax_chart} = SL::Presenter::Tag::html_tag('span', |
|
462 |
$chart_title . $chart_picker . $js_set_on_select_item); |
|
463 |
|
|
464 |
my $tax_value_title_sub = sub { |
|
465 |
my $item = shift; |
|
466 |
return [ |
|
467 |
$item->{id}, |
|
468 |
$item->{taxkey} . ' - ' . $item->{taxdescription} .' '. ($item->{rate} * 100) .' %', |
|
469 |
]; |
|
470 |
}; |
|
471 |
|
|
472 |
my @taxes = (); |
|
473 |
if ($form->{"expense_chart_id_$i"}) { |
|
474 |
@taxes = IO->get_active_taxes_for_chart($tax_chart_id, |
|
475 |
$form->{"reqdate_$i"} // $form->{deliverydate} // $form->{transdate}); |
|
476 |
} |
|
477 |
# tax_id_ is used in io.js->update_tax_ids |
|
478 |
$column_data{tax} = SL::Presenter::Tag::select_tag( |
|
479 |
"tax_id_$i", \@taxes, default => $form->{"tax_id_$i"}, |
|
480 |
value_title_sub => $tax_value_title_sub, |
|
481 |
style => "width: 100px"); |
|
475 | 482 |
} |
476 |
# tax_id_ is used in io.js->update_tax_ids |
|
477 |
$column_data{tax} = SL::Presenter::Tag::select_tag( |
|
478 |
"tax_id_$i", \@taxes, default => $form->{"tax_id_$i"}, |
|
479 |
value_title_sub => $tax_value_title_sub, |
|
480 |
style => "width: 100px"); |
|
481 | 483 |
|
482 | 484 |
$column_data{serialnr} = qq|<input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|; |
483 | 485 |
$column_data{projectnr} = NTI($cgi->popup_menu( |
Auch abrufbar als: Unified diff
PurchaseInvoice: Felder tax_chart und tax nur bei Bedarf berechnen