taxdescription,
round(rate * 100, 2) AS rate,
chart_id,
+ chart_categories,
(id IN (SELECT tax_id
FROM acc_trans)) AS tax_already_used
FROM tax
$form->{rate} = $form->{rate} / 100;
- my @values = ($form->{taxkey}, $form->{taxdescription}, $form->{rate}, $form->{chart_id}, $form->{chart_id} );
+ my $chart_categories = '';
+ $chart_categories .= 'A' if $form->{asset};
+ $chart_categories .= 'L' if $form->{liability};
+ $chart_categories .= 'Q' if $form->{equity};
+ $chart_categories .= 'I' if $form->{revenue};
+ $chart_categories .= 'E' if $form->{expense};
+ $chart_categories .= 'C' if $form->{costs};
+
+ my @values = ($form->{taxkey}, $form->{taxdescription}, $form->{rate}, $form->{chart_id}, $form->{chart_id}, $chart_categories);
if ($form->{id} ne "") {
$query = qq|UPDATE tax SET
taxkey = ?,
taxdescription = ?,
rate = ?,
chart_id = ?,
- taxnumber = (SELECT accno FROM chart WHERE id= ? )
+ taxnumber = (SELECT accno FROM chart WHERE id= ? ),
+ chart_categories = ?
WHERE id = ?|;
push(@values, $form->{id});
taxdescription,
rate,
chart_id,
- taxnumber
+ taxnumber,
+ chart_categories
)
- VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?) )|;
+ VALUES (?, ?, ?, ?, (SELECT accno FROM chart WHERE id = ?), ? )|;
}
do_query($form, $dbh, $query, @values);
$main::lxdebug->leave_sub();
}
+sub get_tax_dropdown {
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $form->get_standard_dbh($myconfig);
+
+ my $query = qq|SELECT category FROM chart WHERE accno = ?|;
+ my ($category) = selectrow_query($form, $dbh, $query, $form->{accno});
+
+ $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|;
+
+ my $sth = prepare_execute_query($form, $dbh, $query);
+
+ $form->{TAX_ACCOUNTS} = [];
+ while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+ push(@{ $form->{TAX_ACCOUNTS} }, $ref);
+ }
+
+}
1;
_get_taxaccount_selection();
+ $form->{asset} = 1;
+ $form->{liability} = 1;
+ $form->{equity} = 1;
+ $form->{revenue} = 1;
+ $form->{expense} = 1;
+ $form->{costs} = 1;
+
$form->header();
my $parameters_ref = {
$form->{title} = $locale->text('Edit');
AM->get_tax(\%myconfig, \%$form);
+
_get_taxaccount_selection();
+ $form->{asset} = $form->{chart_categories} =~ 'A' ? 1 : 0;
+ $form->{liability} = $form->{chart_categories} =~ 'L' ? 1 : 0;
+ $form->{equity} = $form->{chart_categories} =~ 'Q' ? 1 : 0;
+ $form->{revenue} = $form->{chart_categories} =~ 'I' ? 1 : 0;
+ $form->{expense} = $form->{chart_categories} =~ 'E' ? 1 : 0;
+ $form->{costs} = $form->{chart_categories} =~ 'C' ? 1 : 0;
+
$form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
$form->header();
my %taxchart_labels = ();
my @taxchart_values = ();
my %taxcharts = ();
- foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
+ foreach my $item (@{ $form->{TAX_ACCOUNTS} }) {
my $key = $item->{id} . "--" . $item->{rate};
$taxchart_init = $key if ($taxchart_init == $item->{id});
push(@taxchart_values, $key);
my $accno = qq|<td>| .
NTI($cgi->popup_menu('-name' => "accno_$i",
'-id' => "accno_$i",
- '-onChange' => "setTaxkey($i)",
+ '-onChange' => "updateTaxes($i);",
'-style' => 'width:200px',
'-values' => \@chart_values,
'-labels' => \%chart_labels,
"all" => 0,
"old_id" => \@old_project_ids },
"charts" => { "key" => "ALL_CHARTS",
- "transdate" => $::form->{transdate} },
- "taxcharts" => "ALL_TAXCHARTS");
+ "transdate" => $::form->{transdate} });
+
+ $::form->{accno} = $::form->{ALL_CHARTS}[0]->{accno};
+ GL->get_tax_dropdown();
GL->get_chart_balances('charts' => $::form->{ALL_CHARTS});
call_sub($main::form->{nextsub});
}
+sub get_tax_dropdown {
+
+ my $form = $main::form;
+ $main::lxdebug->enter_sub();
+ GL->get_tax_dropdown();
+
+ foreach my $item (@{ $form->{TAX_ACCOUNTS} }) {
+ $item->{taxdescription} = $::locale->{iconv_utf8}->convert($item->{taxdescription});
+ $item->{taxdescription} .= ' ' . $form->round_amount($item->{rate} * 100);
+ }
+
+ print $form->ajax_response_header, $form->parse_html_template("gl/update_tax_accounts");
+
+ $main::lxdebug->leave_sub();
+
+}
+
1;
'Account Nummer' => 'Kontonummer',
'Account Type' => 'Kontoart',
'Account Type missing!' => 'Kontoart fehlt!',
+ 'Account categories' => 'Kontoarten',
'Account deleted!' => 'Konto gelöscht!',
'Account for fees' => 'Konto für Gebühren',
'Account for interest' => 'Konto für Zinsen',
[%- USE T8 %]
[%- USE HTML %]
+[%- USE L %]
<form method="post" action="am.pl">
<input type="hidden" name="id" value="[% HTML.escape(id) %]">
<input type="hidden" name="type" value="tax">
<td><select name="chart_id"><option value="0">[% 'None' | $T8 %]</option>[% FOREACH row = ACCOUNTS %]<option value="[% HTML.escape(row.id) %]" [% IF row.selected %]selected[% END %]>[% HTML.escape(row.taxaccount) %]</option>[% END %]</select></td>
</tr>
+ <td>[% 'Account categories' | $T8 %]</td>
+ <td><table>
+ <colgroup>
+ <col width="10">
+ <col width="130">
+ <col width="10">
+ <col width="130">
+ <col width="10">
+ <col width="130">
+ <col width="10">
+ <col width="130">
+ <col width="10">
+ <col width="130">
+ <col width="10">
+ <col width="130">
+ </colgroup>
+ <tr>
+ <td align="right">[% IF asset %]
+ [% L.checkbox_tag('asset', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('asset', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Asset' | $T8 %] (A)</td>
+ <td align="right">[% IF liability %]
+ [% L.checkbox_tag('liability', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('liability', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Liability' | $T8 %] (L)</td>
+ <td align="right">[% IF equity %]
+ [% L.checkbox_tag('equity', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('equity', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Equity' | $T8 %] (Q)</td>
+ <td align="right">[% IF revenue %]
+ [% L.checkbox_tag('revenue', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('revenue', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Revenue' | $T8 %] (I)</td>
+ <td align="right">[% IF expense %]
+ [% L.checkbox_tag('expense', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('expense', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Expense' | $T8 %] (E)</td>
+ <td align="right">[% IF costs %]
+ [% L.checkbox_tag('costs', value => 1, checked => 1, class => 'checkbox') %]
+ [% ELSE %]
+ [% L.checkbox_tag('costs', value => 1, checked => 0, class => 'checkbox') %]
+ [% END %]
+ </td>
+ <td align="left">[% 'Costs' | $T8 %] (C)</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ </table>
</table>
[% UNLESS orphaned %]
[%- USE L %]
<script type="text/javascript">
<!--
- function setTaxkey(row) {
- var accno = document.getElementById('accno_' + row);
- var taxkey = accno.options[accno.selectedIndex].value;
- var reg = /--([0-9]*)/;
- var found = reg.exec(taxkey);
- var index = found[1];
- index = parseInt(index);
- var tax = 'taxchart_' + row;
- for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
- var reg2 = new RegExp("^"+ index, "");
- if (reg2.exec(document.getElementById(tax).options[i].value)) {
- document.getElementById(tax).options[i].selected = true;
- break;
- }
+function updateTaxes(row)
+{
+ var accno = document.getElementById('accno_' + row);
+ var taxkey = accno.options[accno.selectedIndex].value;
+ var reg = /--([0-9]*)/;
+ var found = reg.exec(taxkey);
+ var index = found[1];
+ index = parseInt(index);
+ var tax = 'taxchart_' + row;
+ var taxkeyposition = taxkey.lastIndexOf(found[0]);
+ var account = taxkey.substr(0, taxkeyposition);
+
+ var xmlhttp;
+ if (window.XMLHttpRequest)
+ {// code for IE7+, Firefox, Chrome, Opera, Safari
+ xmlhttp=new XMLHttpRequest();
+ }
+ else
+ {// code for IE6, IE5
+ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ xmlhttp.onreadystatechange=function()
+ {
+ if (xmlhttp.readyState==4 && xmlhttp.status==200)
+ {
+ var element = document.getElementById("taxchart_" + row);
+ element.innerHTML = xmlhttp.responseText;
}
- };
+ }
+ xmlhttp.open("GET","gl.pl?action=get_tax_dropdown&accno=" + account + "&select_index=" + index,true);
+ xmlhttp.send();
+};
function copy_debit_to_credit() {
var txt = document.getElementsByName('debit_1')[0].value;
--- /dev/null
+[% FOR row = TAX_ACCOUNTS %]
+<option value='[% row.id %]--[% row.rate %]' [% IF row.id == select_index %]selected[% END %]>[% row.taxdescription %] %</option>
+[% END %]