Revision fc3b49d6
Von Tamino Steinert vor etwa 2 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
}
|
||
|
||
$form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense);
|
||
$form->{"${_}_accno_id_$index"} = $accounts{"${_}_accno_id"} for qw(inventory expense); # only for purchase_invoice
|
||
|
||
$sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate)) || $::form->dberror($query_tax);
|
||
$ref = $sth_tax->fetchrow_hashref or next;
|
||
my $tax_ref;
|
||
$tax_ref = $sth_tax->fetchrow_hashref or next;
|
||
|
||
$form->{"taxaccounts_$index"} = $ref->{"accno"};
|
||
$form->{"taxaccounts"} .= "$ref->{accno} "if $form->{"taxaccounts"} !~ /$ref->{accno}/;
|
||
$form->{"expense_accno_tax_id_$index"} = $tax_ref->{tax_id}; # only for purchase_invoice
|
||
|
||
$form->{"$ref->{accno}_${_}"} = $ref->{$_} for qw(rate description taxnumber tax_id);
|
||
$form->{"taxaccounts_$index"} = $tax_ref->{"accno"};
|
||
$form->{"taxaccounts"} .= "$tax_ref->{accno} "if $form->{"taxaccounts"} !~ /$ref->{accno}/;
|
||
|
||
$form->{"$tax_ref->{accno}_${_}"} = $tax_ref->{$_} for qw(rate description taxnumber tax_id);
|
||
}
|
||
|
||
$sth_tax->finish;
|
SL/IO.pm | ||
---|---|---|
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub get_active_taxes_for_chart {
|
||
my ($self, $chart_id, $transdate, $tax_id) = @_;
|
||
|
||
my $chart = SL::DB::Chart->new(id => $chart_id)->load;
|
||
my $active_taxkey = $chart->get_active_taxkey($transdate);
|
||
|
||
my $where = [ chart_categories => { like => '%' . $chart->category . '%' } ];
|
||
|
||
if ( defined $tax_id && $tax_id >= 0 ) {
|
||
$where = [ or => [ chart_categories => { like => '%' . $chart->category . '%' },
|
||
id => $tax_id
|
||
]
|
||
];
|
||
}
|
||
|
||
my $taxes = SL::DB::Manager::Tax->get_all(
|
||
where => $where,
|
||
sort_by => 'taxkey, rate',
|
||
);
|
||
|
||
my $default_tax = first { $active_taxkey->tax_id == $_->id } @{ $taxes };
|
||
$default_tax->{is_default} = 1 if $default_tax;
|
||
|
||
return @{ $taxes };
|
||
}
|
||
|
||
1;
|
SL/IR.pm | ||
---|---|---|
return $duedate;
|
||
}
|
||
|
||
|
||
sub get_taxes_dropdown {
|
||
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
|
||
my $deliverydate = $::form->{deliverydate} ? DateTime->from_kivitendo($::form->{deliverydate}) : undef;
|
||
my $item_deliverydate = $::form->{item_deliverydate} ? DateTime->from_kivitendo($::form->{item_deliverydate}) : undef;
|
||
|
||
my @taxes = IO->get_active_taxes_for_chart($::form->{chart_id},
|
||
$item_deliverydate // $deliverydate // $transdate);
|
||
my $html = $::form->parse_html_template("ir/update_taxes", { TAXES => \@taxes });
|
||
|
||
print $::form->ajax_response_header, $html;
|
||
}
|
||
|
||
|
||
1;
|
bin/mozilla/io.pl | ||
---|---|---|
use SL::File;
|
||
use SL::PriceSource;
|
||
use SL::Presenter::Part;
|
||
use SL::Presenter::Chart;
|
||
use SL::Presenter::Tag;
|
||
use SL::Util qw(trim);
|
||
|
||
use SL::DB::AuthUser;
|
||
... | ... | |
bin stock_in_out
|
||
);
|
||
my @row2_sort = qw(
|
||
serialnr projectnr reqdate subtotal recurring_billing_mode marge listprice lastcost onhand
|
||
expense_chart tax inventory_chart serialnr projectnr reqdate subtotal recurring_billing_mode marge listprice lastcost onhand
|
||
);
|
||
# serialnr is important for delivery_orders
|
||
if ($form->{type} eq 'sales_delivery_order') {
|
||
... | ... | |
lastcost => { value => $locale->text('EK'), display => $show_marge, },
|
||
onhand => { value => $locale->text('On Hand'), display => 1, },
|
||
vendor_partnumber => { width => 8, value => $locale->text('Vendor Part Number'), display => $is_delivery_order && $is_purchase, },
|
||
expense_chart => { value => $locale->text('Expense Account'), display => $is_purchase && $is_invoice },
|
||
tax => { value => $locale->text('Tax'), display => $is_purchase && $is_invoice },
|
||
inventory_chart => { value => "", display => $is_purchase && $is_invoice }, # only disply for type='part'
|
||
);
|
||
my @HEADER = map { $column_def{$_} } @header_sort;
|
||
|
||
... | ... | |
$column_data{stock_in_out} = calculate_stock_in_out($i);
|
||
}
|
||
|
||
$column_data{expense_chart} = SL::Presenter::Chart::chart_picker(
|
||
"expense_chart_id_$i", $form->{"expense_chart_id_$i"},
|
||
type => "AP_amount", style => "width: 150px") .
|
||
'<script type="text/javascript">
|
||
<!--
|
||
$(document).ready(function() {
|
||
$("#expense_chart_id_' . $i . q'").on("set_item:ChartPicker", function(e, item) {
|
||
kivi.io.update_tax_ids(this);
|
||
});
|
||
});
|
||
-->
|
||
</script>
|
||
'; # change tax dropdown after change
|
||
|
||
my $tax_value_title_sub = sub {
|
||
my $item = shift;
|
||
return [
|
||
$item->{id},
|
||
$item->{taxkey} . ' - ' . $item->{taxdescription} .' '. ($item->{rate} * 100) .' %',
|
||
];
|
||
};
|
||
|
||
my @taxes = ();
|
||
if ($form->{"expense_chart_id_$i"}) {
|
||
@taxes = IO->get_active_taxes_for_chart($form->{"expense_chart_id_$i"},
|
||
$form->{"reqdate_$i"} // $form->{deliverydate} // $form->{transdate});
|
||
}
|
||
# tax_id_ is used in io.js->update_tax_ids
|
||
$column_data{tax} = SL::Presenter::Tag::select_tag(
|
||
"tax_id_$i", \@taxes, default => $form->{"tax_id_$i"},
|
||
value_title_sub => $tax_value_title_sub,
|
||
style => "width: 100px");
|
||
|
||
if ($record_item && $record_item->part && ($record_item->part->type eq 'part')) {
|
||
$column_data{inventory_chart} =
|
||
'<b>' . $locale->text('Inventory Account') . '<b> ' .
|
||
SL::Presenter::Chart::chart_picker(
|
||
"inventory_chart_id_$i", $form->{"inventory_chart_id_$i"},
|
||
type => "IC", style => "width: 150px");
|
||
}
|
||
|
||
$column_data{serialnr} = qq|<input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|;
|
||
$column_data{projectnr} = NTI($cgi->popup_menu(
|
||
'-name' => "project_id_$i",
|
||
... | ... | |
|
||
$::locale->with_raw_io(\*STDOUT, sub { print $xml_content });
|
||
}
|
||
|
||
sub get_taxes_dropdown {
|
||
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
|
||
my $deliverydate = $::form->{deliverydate} ? DateTime->from_kivitendo($::form->{deliverydate}) : undef;
|
||
my $item_deliverydate = $::form->{item_deliverydate} ? DateTime->from_kivitendo($::form->{item_deliverydate}) : undef;
|
||
|
||
my @taxes = IO->get_active_taxes_for_chart($::form->{chart_id},
|
||
$item_deliverydate // $deliverydate // $transdate);
|
||
my $html = $::form->parse_html_template("ir/update_taxes", { TAXES => \@taxes });
|
||
|
||
print $::form->ajax_response_header, $html;
|
||
}
|
||
|
||
1;
|
bin/mozilla/ir.pl | ||
---|---|---|
use SL::DB::PurchaseInvoice;
|
||
use SL::DB::ValidityToken;
|
||
use SL::DB::Vendor;
|
||
use SL::DB::Tax;
|
||
use SL::DB::Chart;
|
||
use List::MoreUtils qw(uniq);
|
||
use List::Util qw(max sum);
|
||
use List::UtilsBy qw(sort_by);
|
||
... | ... | |
$TMPL_VAR->{payment_terms_obj} = get_payment_terms_for_invoice();
|
||
$form->{duedate} = $TMPL_VAR->{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR->{payment_terms_obj};
|
||
|
||
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_project client_js));
|
||
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_project client_js autocomplete_chart));
|
||
|
||
setup_ir_action_bar($TMPL_VAR);
|
||
|
||
... | ... | |
invoice_links();
|
||
prepare_invoice();
|
||
relink_accounts();
|
||
set_taxaccounts_and_accnos();
|
||
|
||
# Payments must not be recorded for the new storno invoice.
|
||
$form->{paidaccounts} = 0;
|
||
... | ... | |
$form->{storno} ||= 0;
|
||
|
||
relink_accounts();
|
||
set_taxaccounts_and_accnos();
|
||
if (IR->post_invoice(\%myconfig, \%$form)){
|
||
# saving the history
|
||
if(!exists $form->{addition} && $form->{id} ne "") {
|
||
... | ... | |
_assert_access();
|
||
|
||
relink_accounts();
|
||
set_taxaccounts_and_accnos();
|
||
|
||
my $new_rowcount = $::form->{"rowcount"} * 1 + 1;
|
||
$::form->{"project_id_${new_rowcount}"} = $::form->{"globalproject_id"};
|
||
... | ... | |
print $::form->ajax_response_header, $result;
|
||
$::lxdebug->leave_sub;
|
||
}
|
||
|
||
# set values form relink_accounts as default
|
||
# otherwiese override with user selected values
|
||
# recalc taxaccounts string
|
||
sub set_taxaccounts_and_accnos {
|
||
$main::lxdebug->enter_sub;
|
||
|
||
for my $i (1 .. $::form->{rowcount}) {
|
||
|
||
# fill with default, ids can be 0
|
||
if ('' eq $::form->{"expense_chart_id_$i"}) {
|
||
$::form->{"expense_chart_id_$i"} = $::form->{"expense_accno_id_$i"};
|
||
}
|
||
if ('' eq $::form->{"tax_id_$i"}) {
|
||
$::form->{"tax_id_$i"} = $::form->{"expense_accno_tax_id_$i"};
|
||
}
|
||
if ('' eq $::form->{"inventory_chart_id_$i"}) {
|
||
$::form->{"inventory_chart_id_$i"} = $::form->{"inventory_accno_id_$i"};
|
||
}
|
||
|
||
# if changed override with user values
|
||
if ($::form->{"expense_chart_id_$i"} ne $::form->{"expense_accno_id_$i"}) {
|
||
$::form->{"expense_accno_id_$i"} = $::form->{"expense_chart_id_$i"};
|
||
my $chart = SL::DB::Chart->new(id => $::form->{"expense_chart_id_$i"})->load;
|
||
$::form->{"expense_accno_$i"} = $chart->accno;
|
||
}
|
||
if ($::form->{"tax_id_$i"} ne $::form->{"expense_accno_tax_id_$i"}) {
|
||
$::form->{"expense_accno_tax_id_$i"} = $::form->{"tax_id_$i"};
|
||
my $tax = SL::DB::Tax->new(id => $::form->{"tax_id_$i"})->load;
|
||
my $tax_accno;
|
||
if (defined $tax->chart_id) {
|
||
my $chart = SL::DB::Chart->new(id => $tax->chart_id)->load;
|
||
$tax_accno = $chart->accno;
|
||
} else {
|
||
$tax_accno = "NO_ACCNO_" . $tax->id;
|
||
}
|
||
$::form->{"taxaccounts_$i"} = $tax_accno;
|
||
if (!($::form->{taxaccounts} =~ /\Q$tax_accno\E/)) {
|
||
# add tax info if missing
|
||
$::form->{"${tax_accno}_rate"} = $tax->rate;
|
||
$::form->{"${tax_accno}_description"} = $tax->taxdescription;
|
||
$::form->{"${tax_accno}_tax_id"} = $tax->id;
|
||
$::form->{"${tax_accno}_taxnumber"} = $::form->{"expense_accno_$i"};
|
||
}
|
||
}
|
||
if ($::form->{"inventory_chart_id_$i"} ne $::form->{"inventory_accno_id_$i"}) {
|
||
$::form->{"inventory_accno_id_$i"} = $::form->{"inventory_chart_id_$i"};
|
||
my $chart = SL::DB::Chart->new(id => $::form->{"inventory_chart_id_$i"})->load;
|
||
$::form->{"inventory_accno_$i"} = $chart->accno;
|
||
}
|
||
|
||
}
|
||
|
||
# recalc taxaccounts string
|
||
$::form->{taxaccounts} = "";
|
||
for my $i (1 .. $::form->{rowcount}) {
|
||
my $taxaccounts_i = $::form->{"taxaccounts_$i"};
|
||
if (!($::form->{taxaccounts} =~ /\Q$taxaccounts_i\E/)) {
|
||
$::form->{taxaccounts} .= "$taxaccounts_i ";
|
||
}
|
||
}
|
||
|
||
$::lxdebug->leave_sub;
|
||
}
|
js/kivi.io.js | ||
---|---|---|
if (discount_str) $('#discount_' + row).val(discount_str);
|
||
$('#update_button').click();
|
||
}
|
||
|
||
ns.update_tax_ids = function(obj) {
|
||
var row = $(obj).attr('name').replace(/.*_/, '');
|
||
|
||
$.ajax({
|
||
url: 'io.pl?action=get_taxes_dropdown',
|
||
data: { chart_id: $(obj).val(),
|
||
transdate: $('#transdate').val(),
|
||
deliverydate: $('#deliverydate').val() },
|
||
item_deliverydate: $("[name='reqdate_" + row + "']").val(), // has no id
|
||
dataType: 'html',
|
||
success: function (new_html) {
|
||
$("#tax_id_" + row).html(new_html);
|
||
}
|
||
});
|
||
};
|
||
});
|
templates/design40_webpages/ir/update_taxes.html | ||
---|---|---|
[% USE L %][%- USE LxERP -%]
|
||
[% FOR row = TAXES %]
|
||
<option value='[% row.id %]'[% IF row.is_default %] selected[% END %]>[% row.taxkey _ " - " _ row.taxdescription %] [% LxERP.round_amount(row.rate * 100) %] %</option>
|
||
[% END %]
|
templates/webpages/ir/update_taxes.html | ||
---|---|---|
[% USE L %][%- USE LxERP -%]
|
||
[% FOR row = TAXES %]
|
||
<option value='[% row.id %]'[% IF row.is_default %] selected[% END %]>[% row.taxkey _ " - " _ row.taxdescription %] [% LxERP.round_amount(row.rate * 100) %] %</option>
|
||
[% END %]
|
Auch abrufbar als: Unified diff
InvoiceItem: Hinzufügen der Felder für Konten und Steuer
Es werden die Wert von relink_accounts als Default genommen und der
Nutzer kann dies ändern. Es werden alle nötigen Steuerdaten in die Form
geschrieben.