Revision 41cceb1e
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/AR.pm | ||
---|---|---|
75 | 75 |
$form->parse_amount($myconfig, $form->{exchangerate}) ); |
76 | 76 |
|
77 | 77 |
# get the charts selected |
78 |
map { ($form->{AR_amounts}{"amount_$_"}) = split /--/, $form->{"AR_amount_$_"} } 1 .. $form->{rowcount}; |
|
79 |
|
|
80 |
$form->{AR_amounts}{receivables} = $form->{ARselected}; |
|
81 |
$form->{AR}{receivables} = $form->{ARselected}; |
|
78 |
$form->{AR_amounts}{"amount_$_"} = $form->{"AR_amount_chart_id_$_"} for (1 .. $form->{rowcount}); |
|
82 | 79 |
|
83 | 80 |
$form->{tax} = 0; # is this still needed? |
84 | 81 |
|
... | ... | |
157 | 154 |
|
158 | 155 |
# insert detail records in acc_trans |
159 | 156 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link) |
160 |
VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.accno = ?))|;
|
|
157 |
VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.id = ?))|;
|
|
161 | 158 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{"amount_$i"}, conv_i($form->{"amount_$i"}), conv_date($form->{transdate}), $project_id, |
162 | 159 |
conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}), $form->{AR_amounts}{"amount_$i"}); |
163 | 160 |
do_query($form, $dbh, $query, @values); |
... | ... | |
175 | 172 |
|
176 | 173 |
# add recievables |
177 | 174 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link) |
178 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
|
|
175 |
VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?),
|
|
179 | 176 |
(SELECT tax_id |
180 | 177 |
FROM taxkeys |
181 |
WHERE chart_id= (SELECT id |
|
182 |
FROM chart |
|
183 |
WHERE accno = ?) |
|
178 |
WHERE chart_id = ? |
|
184 | 179 |
AND startdate <= ? |
185 | 180 |
ORDER BY startdate DESC LIMIT 1), |
186 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|;
|
|
187 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, conv_i($form->{receivables}), conv_date($form->{transdate}),
|
|
188 |
$form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate}), $form->{AR_amounts}{receivables});
|
|
181 |
(SELECT c.link FROM chart c WHERE c.id = ?))|;
|
|
182 |
@values = (conv_i($form->{id}), $form->{AR_chart_id}, conv_i($form->{receivables}), conv_date($form->{transdate}),
|
|
183 |
$form->{AR_chart_id}, $form->{AR_chart_id}, conv_date($form->{transdate}), $form->{AR_chart_id});
|
|
189 | 184 |
do_query($form, $dbh, $query, @values); |
190 | 185 |
|
191 | 186 |
} else { |
... | ... | |
225 | 220 |
if ($amount != 0) { |
226 | 221 |
# add receivable |
227 | 222 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link) |
228 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?),
|
|
223 |
VALUES (?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?),
|
|
229 | 224 |
(SELECT tax_id |
230 | 225 |
FROM taxkeys |
231 |
WHERE chart_id= (SELECT id |
|
232 |
FROM chart |
|
233 |
WHERE accno = ?) |
|
226 |
WHERE chart_id = ? |
|
234 | 227 |
AND startdate <= ? |
235 | 228 |
ORDER BY startdate DESC LIMIT 1), |
236 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
237 |
@values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"}), |
|
238 |
$form->{AR}{receivables}); |
|
229 |
(SELECT c.link FROM chart c WHERE c.id = ?))|; |
|
230 |
@values = (conv_i($form->{id}), $form->{AR_chart_id}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR_chart_id}, $form->{AR_chart_id}, conv_date($form->{"datepaid_$i"}), $form->{AR_chart_id}); |
|
239 | 231 |
|
240 | 232 |
do_query($form, $dbh, $query, @values); |
241 | 233 |
} |
... | ... | |
421 | 413 |
$form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); |
422 | 414 |
$form->{defaultcurrency} = $form->get_default_currency($myconfig); |
423 | 415 |
|
424 |
# Get the AR accno (which is normally done by Form::create_links()).
|
|
416 |
# Get the AR chart ID (which is normally done by Form::create_links()).
|
|
425 | 417 |
$query = |
426 |
qq|SELECT c.accno
|
|
418 |
qq|SELECT c.id
|
|
427 | 419 |
FROM acc_trans at |
428 | 420 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
429 | 421 |
WHERE (trans_id = ?) |
... | ... | |
431 | 423 |
ORDER BY at.acc_trans_id |
432 | 424 |
LIMIT 1|; |
433 | 425 |
|
434 |
($form->{ARselected}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
426 |
($form->{AR_chart_id}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
|
|
435 | 427 |
|
436 | 428 |
# Post the new payments. |
437 | 429 |
$self->post_transaction($myconfig, $form, $dbh, 1); |
... | ... | |
739 | 731 |
$form->{"projectnumber_$k"} = $form->{acc_trans}{$key}->[$i-1]->{projectnumber}; |
740 | 732 |
$form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate}; |
741 | 733 |
$form->{"project_id_$k"} = $form->{acc_trans}{$key}->[$i-1]->{project_id}; |
742 |
} |
|
743 |
|
|
744 |
$form->{"${key}_$i"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
|
745 |
|
|
746 |
if ($akey eq "AR") { |
|
747 |
$form->{ARselected} = $form->{acc_trans}{$key}->[$i-1]->{accno}; |
|
748 | 734 |
|
749 |
} elsif ($akey eq "amount") { |
|
750 |
$form->{"${key}_$k"} = $form->{acc_trans}{$key}->[$i-1]->{accno} . "--" . $form->{acc_trans}{$key}->[$i-1]->{id}; |
|
735 |
$form->{"${key}_chart_id_$k"} = $form->{acc_trans}{$key}->[$i-1]->{chart_id}; |
|
751 | 736 |
$form->{"taxchart_$k"} = $form->{acc_trans}{$key}->[$i-1]->{id} . "--" . $form->{acc_trans}{$key}->[$i-1]->{rate}; |
752 | 737 |
} |
753 | 738 |
} |
SL/DB/Customer.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use Rose::DB::Object::Helpers qw(as_tree); |
6 | 6 |
|
7 |
use SL::DBUtils (); |
|
7 | 8 |
use SL::DB::MetaSetup::Customer; |
8 | 9 |
use SL::DB::Manager::Customer; |
9 | 10 |
use SL::DB::Helper::IBANValidation; |
... | ... | |
64 | 65 |
return join ' ', grep $_, $self->customernumber, $self->name; |
65 | 66 |
} |
66 | 67 |
|
68 |
sub last_used_ar_chart { |
|
69 |
my ($self) = @_; |
|
70 |
|
|
71 |
my $query = <<EOSQL; |
|
72 |
SELECT c.id |
|
73 |
FROM chart c |
|
74 |
JOIN acc_trans ac ON (ac.chart_id = c.id) |
|
75 |
JOIN ar a ON (a.id = ac.trans_id) |
|
76 |
WHERE (a.customer_id = ?) |
|
77 |
AND (c.category = 'I') |
|
78 |
AND (c.link !~ '_(paid|tax)') |
|
79 |
AND (a.id IN (SELECT max(a2.id) FROM ar a2 WHERE a2.customer_id = ?)) |
|
80 |
ORDER BY ac.acc_trans_id ASC |
|
81 |
LIMIT 1 |
|
82 |
EOSQL |
|
83 |
|
|
84 |
my ($chart_id) = SL::DBUtils::selectfirst_array_query($::form, $self->db->dbh, $query, ($self->id) x 2); |
|
85 |
|
|
86 |
return if !$chart_id; |
|
87 |
return SL::DB::Chart->load_cached($chart_id); |
|
88 |
} |
|
89 |
|
|
67 | 90 |
sub is_customer { 1 }; |
68 | 91 |
sub is_vendor { 0 }; |
69 | 92 |
sub payment_terms { goto &payment } |
SL/Form.pm | ||
---|---|---|
2664 | 2664 |
|
2665 | 2665 |
# now get the account numbers |
2666 | 2666 |
$query = qq| |
2667 |
SELECT c.accno, c.description, c.link, c.taxkey_id, tk2.tax_id |
|
2667 |
SELECT c.accno, c.description, c.link, c.taxkey_id, c.id AS chart_id, tk2.tax_id
|
|
2668 | 2668 |
FROM chart c |
2669 | 2669 |
-- find newest entries in taxkeys |
2670 | 2670 |
INNER JOIN ( |
... | ... | |
2694 | 2694 |
|
2695 | 2695 |
push @{ $self->{"${module}_links"}{$key} }, |
2696 | 2696 |
{ accno => $ref->{accno}, |
2697 |
chart_id => $ref->{chart_id}, |
|
2697 | 2698 |
description => $ref->{description}, |
2698 | 2699 |
taxkey => $ref->{taxkey_id}, |
2699 | 2700 |
tax_id => $ref->{tax_id} }; |
... | ... | |
2747 | 2748 |
} |
2748 | 2749 |
|
2749 | 2750 |
# now get the account numbers |
2750 |
$query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id |
|
2751 |
$query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, c.id AS chart_id, tk.tax_id
|
|
2751 | 2752 |
FROM chart c |
2752 | 2753 |
LEFT JOIN taxkeys tk ON (tk.chart_id = c.id) |
2753 | 2754 |
WHERE c.link LIKE ? |
... | ... | |
2769 | 2770 |
|
2770 | 2771 |
push @{ $self->{"${module}_links"}{$key} }, |
2771 | 2772 |
{ accno => $ref->{accno}, |
2773 |
chart_id => $ref->{chart_id}, |
|
2772 | 2774 |
description => $ref->{description}, |
2773 | 2775 |
taxkey => $ref->{taxkey_id}, |
2774 | 2776 |
tax_id => $ref->{tax_id} }; |
... | ... | |
2783 | 2785 |
$query = |
2784 | 2786 |
qq|SELECT |
2785 | 2787 |
c.accno, c.description, |
2786 |
a.acc_trans_id, a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey, |
|
2788 |
a.acc_trans_id, a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey, a.chart_id,
|
|
2787 | 2789 |
p.projectnumber, |
2788 | 2790 |
t.rate, t.id |
2789 | 2791 |
FROM acc_trans a |
SL/IS.pm | ||
---|---|---|
2203 | 2203 |
} |
2204 | 2204 |
$sth->finish; |
2205 | 2205 |
|
2206 |
# setup last accounts used for this customer |
|
2207 |
if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) { |
|
2208 |
$query = |
|
2209 |
qq|SELECT c.id, c.accno, c.description, c.link, c.category |
|
2210 |
FROM chart c |
|
2211 |
JOIN acc_trans ac ON (ac.chart_id = c.id) |
|
2212 |
JOIN ar a ON (a.id = ac.trans_id) |
|
2213 |
WHERE a.customer_id = ? |
|
2214 |
AND NOT (c.link LIKE '%_tax%' OR c.link LIKE '%_paid%') |
|
2215 |
AND a.id IN (SELECT max(a2.id) FROM ar a2 WHERE a2.customer_id = ?)|; |
|
2216 |
$sth = prepare_execute_query($form, $dbh, $query, $cid, $cid); |
|
2217 |
|
|
2218 |
my $i = 0; |
|
2219 |
while ($ref = $sth->fetchrow_hashref('NAME_lc')) { |
|
2220 |
if ($ref->{category} eq 'I') { |
|
2221 |
$i++; |
|
2222 |
$form->{"AR_amount_$i"} = "$ref->{accno}--$ref->{description}"; |
|
2223 |
|
|
2224 |
if ($form->{initial_transdate}) { |
|
2225 |
my $tax_query = |
|
2226 |
qq|SELECT tk.tax_id, t.rate |
|
2227 |
FROM taxkeys tk |
|
2228 |
LEFT JOIN tax t ON tk.tax_id = t.id |
|
2229 |
WHERE (tk.chart_id = ?) AND (startdate <= date(?)) |
|
2230 |
ORDER BY tk.startdate DESC |
|
2231 |
LIMIT 1|; |
|
2232 |
my ($tax_id, $rate) = |
|
2233 |
selectrow_query($form, $dbh, $tax_query, $ref->{id}, |
|
2234 |
$form->{initial_transdate}); |
|
2235 |
$form->{"taxchart_$i"} = "${tax_id}--${rate}"; |
|
2236 |
} |
|
2237 |
} |
|
2238 |
if ($ref->{category} eq 'A') { |
|
2239 |
$form->{ARselected} = $form->{AR_1} = $ref->{accno}; |
|
2240 |
} |
|
2241 |
} |
|
2242 |
$sth->finish; |
|
2243 |
$form->{rowcount} = $i if ($i && !$form->{type}); |
|
2244 |
} |
|
2245 |
|
|
2246 | 2206 |
$main::lxdebug->leave_sub(); |
2247 | 2207 |
} |
2248 | 2208 |
|
bin/mozilla/ar.pl | ||
---|---|---|
38 | 38 |
|
39 | 39 |
use SL::AR; |
40 | 40 |
use SL::FU; |
41 |
use SL::GL; |
|
41 | 42 |
use SL::IS; |
42 | 43 |
use SL::DB::Default; |
43 | 44 |
use SL::DB::Invoice; |
... | ... | |
101 | 102 |
$form->{initial_transdate} = $form->{transdate}; |
102 | 103 |
create_links(dont_save => 1); |
103 | 104 |
$form->{transdate} = $form->{initial_transdate}; |
105 |
|
|
106 |
if ($form->{customer_id}) { |
|
107 |
my $last_used_ar_chart = SL::DB::Customer->load_cached($form->{customer_id})->last_used_ar_chart; |
|
108 |
$form->{"AR_amount_chart_id_1"} = $last_used_ar_chart->id if $last_used_ar_chart; |
|
109 |
} |
|
110 |
|
|
104 | 111 |
&display_form; |
105 | 112 |
$main::lxdebug->leave_sub(); |
106 | 113 |
} |
... | ... | |
167 | 174 |
$form->{$_} = $saved{$_} for keys %saved; |
168 | 175 |
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; |
169 | 176 |
$form->{rowcount} = 1; |
177 |
$form->{AR_chart_id} = $form->{acc_trans} && $form->{acc_trans}->{AR} ? $form->{acc_trans}->{AR}->[0]->{chart_id} : $form->{AR_links}->{AR}->[0]->{chart_id}; |
|
170 | 178 |
|
171 | 179 |
# currencies |
172 | 180 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
... | ... | |
218 | 226 |
|
219 | 227 |
my ($title, $readonly, $exchangerate, $rows); |
220 | 228 |
my ($notes, $customer, $employee, $amount, $project); |
221 |
my ($ARselected); |
|
222 | 229 |
|
230 |
$form->{initial_focus} = !($form->{amount_1} * 1) ? 'customer' : 'row_' . $form->{rowcount}; |
|
223 | 231 |
|
224 | 232 |
$title = $form->{title}; |
225 | 233 |
# $locale->text('Add Accounts Receivables Transaction') |
226 | 234 |
# $locale->text('Edit Accounts Receivables Transaction') |
227 | 235 |
$form->{title} = $locale->text("$title Accounts Receivables Transaction"); |
228 | 236 |
|
229 |
$form->{javascript} = qq|<script type="text/javascript"> |
|
230 |
<!-- |
|
231 |
function setTaxkey(accno, row) { |
|
232 |
var taxkey = accno.options[accno.selectedIndex].value; |
|
233 |
var reg = /--([0-9]*)/; |
|
234 |
var found = reg.exec(taxkey); |
|
235 |
var index = found[1]; |
|
236 |
index = parseInt(index); |
|
237 |
var tax = 'taxchart_' + row; |
|
238 |
for (var i = 0; i < document.getElementById(tax).options.length; ++i) { |
|
239 |
var reg2 = new RegExp("^"+ index, ""); |
|
240 |
if (reg2.exec(document.getElementById(tax).options[i].value)) { |
|
241 |
document.getElementById(tax).options[i].selected = true; |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
}; |
|
246 |
//--> |
|
247 |
</script>|; |
|
248 |
# show history button js |
|
249 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|; |
|
250 |
#/show history button js |
|
251 | 237 |
$readonly = ($form->{id}) ? "readonly" : ""; |
252 | 238 |
|
253 | 239 |
$form->{radier} = ($::instance_conf->get_ar_changeable == 2) |
... | ... | |
285 | 271 |
|
286 | 272 |
my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} }; |
287 | 273 |
|
288 |
my (@AR_amount_values); |
|
289 |
my (@AR_values); |
|
290 |
my (@AR_paid_values); |
|
291 |
my %chart_labels; |
|
292 |
my %charts; |
|
293 |
my $taxchart_init; |
|
274 |
my (@AR_paid_values, %AR_paid_labels); |
|
275 |
my $default_ar_amount_chart_id; |
|
294 | 276 |
|
295 | 277 |
foreach my $item (@{ $form->{ALL_CHARTS} }) { |
296 | 278 |
if ($item->{link_split}{AR_amount}) { |
297 |
$taxchart_init = $item->{tax_id} if ($taxchart_init eq ""); |
|
298 |
my $key = "$item->{accno}--$item->{tax_id}"; |
|
299 |
push(@AR_amount_values, $key); |
|
300 |
} elsif ($item->{link_split}{AR}) { |
|
301 |
push(@AR_values, $item->{accno}); |
|
279 |
$default_ar_amount_chart_id //= $item->{id}; |
|
280 |
|
|
302 | 281 |
} elsif ($item->{link_split}{AR_paid}) { |
303 | 282 |
push(@AR_paid_values, $item->{accno}); |
283 |
$AR_paid_labels{$item->{accno}} = "$item->{accno}--$item->{description}"; |
|
304 | 284 |
} |
305 |
|
|
306 |
# weirdness for AR_amount |
|
307 |
$chart_labels{$item->{accno}} = "$item->{accno}--$item->{description}"; |
|
308 |
$chart_labels{"$item->{accno}--$item->{tax_id}"} = "$item->{accno}--$item->{description}"; |
|
309 |
|
|
310 |
$charts{$item->{accno}} = $item; |
|
311 |
} |
|
312 |
|
|
313 |
my %taxchart_labels = (); |
|
314 |
my @taxchart_values = (); |
|
315 |
my %taxcharts = (); |
|
316 |
foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { |
|
317 |
my $key = "$item->{id}--$item->{rate}"; |
|
318 |
$taxchart_init = $key if ($taxchart_init eq $item->{id}); |
|
319 |
push(@taxchart_values, $key); |
|
320 |
$taxchart_labels{$key} = "$item->{taxdescription} " . ($item->{rate} * 100) . ' %'; |
|
321 |
$taxcharts{$item->{id}} = $item; |
|
322 | 285 |
} |
323 | 286 |
|
324 | 287 |
my $follow_up_vc = $form->{customer}; |
325 | 288 |
$follow_up_vc =~ s/--.*?//; |
326 | 289 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; |
327 | 290 |
|
328 |
$form->{javascript} .= |
|
329 |
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>| . |
|
330 |
qq|<script type="text/javascript" src="js/follow_up.js"></script>| . |
|
331 |
qq|<script type="text/javascript" src="js/kivi.Draft.js"></script>|; |
|
291 |
$::request->layout->add_javascripts("autocomplete_chart.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js"); |
|
332 | 292 |
|
333 |
# $amount = $locale->text('Amount');
|
|
334 |
# $project = $locale->text('Project');
|
|
293 |
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local;
|
|
294 |
my $first_taxchart;
|
|
335 | 295 |
|
336 | 296 |
my @transactions; |
337 | 297 |
for my $i (1 .. $form->{rowcount}) { |
... | ... | |
341 | 301 |
project_id => ($i==$form->{rowcount}) ? $form->{globalproject_id} : $form->{"project_id_$i"}, |
342 | 302 |
}; |
343 | 303 |
|
344 |
my $selected_accno_full; |
|
345 |
my ($accno_row) = split(/--/, $form->{"AR_amount_$i"}); |
|
346 |
my $item = $charts{$accno_row}; |
|
347 |
$selected_accno_full = "$item->{accno}--$item->{tax_id}"; |
|
304 |
my (%taxchart_labels, @taxchart_values, $default_taxchart, $taxchart_to_use); |
|
305 |
my $amount_chart_id = $form->{"AR_amount_chart_id_$i"} // $default_ar_amount_chart_id; |
|
306 |
my $chart_has_changed = $::form->{"previous_AR_amount_chart_id_$i"} && ($amount_chart_id != $::form->{"previous_AR_amount_chart_id_$i"}); |
|
348 | 307 |
|
349 |
my $selected_taxchart = $form->{"taxchart_$i"}; |
|
350 |
my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full); |
|
351 |
my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"}); |
|
308 |
foreach my $item ( GL->get_active_taxes_for_chart($amount_chart_id, $transdate) ) { |
|
309 |
my $key = $item->id . "--" . $item->rate; |
|
310 |
$first_taxchart //= $item; |
|
311 |
$default_taxchart = $item if $item->{is_default}; |
|
312 |
$taxchart_to_use = $item if $key eq $form->{"taxchart_$i"}; |
|
352 | 313 |
|
353 |
if ($previous_accno && |
|
354 |
($previous_accno eq $selected_accno) && |
|
355 |
($previous_tax_id ne $selected_tax_id)) { |
|
356 |
my $item = $taxcharts{$selected_tax_id}; |
|
357 |
$selected_taxchart = "$item->{id}--$item->{rate}"; |
|
314 |
push(@taxchart_values, $key); |
|
315 |
$taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %'; |
|
358 | 316 |
} |
359 | 317 |
|
360 |
if (!$form->{"taxchart_$i"}) { |
|
361 |
if ($form->{"AR_amount_$i"} =~ m/.--./) { |
|
362 |
$selected_taxchart = join '--', map { ($_->{id}, $_->{rate}) } first { $_->{id} == $item->{tax_id} } @{ $form->{ALL_TAXCHARTS} }; |
|
363 |
} else { |
|
364 |
$selected_taxchart = $taxchart_init; |
|
365 |
} |
|
366 |
} |
|
318 |
$taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use; |
|
319 |
my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate; |
|
367 | 320 |
|
368 | 321 |
$transaction->{selectAR_amount} = |
369 |
NTI($cgi->popup_menu('-name' => "AR_amount_$i", |
|
370 |
'-id' => "AR_amount_$i", |
|
371 |
'-style' => 'width:400px', |
|
372 |
'-onChange' => "setTaxkey(this, $i)", |
|
373 |
'-values' => \@AR_amount_values, |
|
374 |
'-labels' => \%chart_labels, |
|
375 |
'-default' => $selected_accno_full)) |
|
376 |
. $cgi->hidden('-name' => "previous_AR_amount_$i", |
|
377 |
'-default' => $selected_accno_full); |
|
322 |
$::request->presenter->chart_picker("AR_amount_chart_id_$i", $amount_chart_id, style => "width: 400px", type => "AR_amount", class => ($form->{initial_focus} eq "row_$i" ? "initial_focus" : "")) |
|
323 |
. $::request->presenter->hidden_tag("previous_AR_amount_chart_id_$i", $amount_chart_id); |
|
378 | 324 |
|
379 | 325 |
$transaction->{taxchart} = |
380 | 326 |
NTI($cgi->popup_menu('-name' => "taxchart_$i", |
... | ... | |
389 | 335 |
|
390 | 336 |
$form->{invtotal_unformatted} = $form->{invtotal}; |
391 | 337 |
|
392 |
$ARselected = |
|
393 |
NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected", |
|
394 |
'-style' => 'width:400px', |
|
395 |
'-values' => \@AR_values, '-labels' => \%chart_labels, |
|
396 |
'-default' => $form->{ARselected})); |
|
397 |
|
|
398 |
|
|
399 | 338 |
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); |
400 | 339 |
|
401 | 340 |
my $now = $form->current_date(\%myconfig); |
... | ... | |
423 | 362 |
NTI($cgi->popup_menu('-name' => "AR_paid_$i", |
424 | 363 |
'-id' => "AR_paid_$i", |
425 | 364 |
'-values' => \@AR_paid_values, |
426 |
'-labels' => \%chart_labels,
|
|
365 |
'-labels' => \%AR_paid_labels,
|
|
427 | 366 |
'-default' => $payment->{AR_paid} || $form->{accno_arap})); |
428 | 367 |
|
429 | 368 |
|
... | ... | |
457 | 396 |
transactions => \@transactions, |
458 | 397 |
project_labels => \%project_labels, |
459 | 398 |
rows => $rows, |
460 |
ARselected => $ARselected,
|
|
399 |
AR_chart_id => $form->{AR_chart_id},
|
|
461 | 400 |
title_str => $title, |
462 | 401 |
follow_up_trans_info => $follow_up_trans_info, |
463 | 402 |
today => DateTime->today, |
... | ... | |
570 | 509 |
|
571 | 510 |
$form->{invdate} = $form->{transdate}; |
572 | 511 |
|
573 |
my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 customer_id notes); |
|
574 |
|
|
575 | 512 |
&check_name("customer"); |
576 | 513 |
|
577 |
$form->{AR} = $saved_variables{AR}; |
|
578 |
if ($saved_variables{AR_amount_1} =~ m/.--./) { |
|
579 |
map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1); |
|
580 |
} else { |
|
581 |
delete $form->{taxchart_1}; |
|
582 |
} |
|
583 |
|
|
584 | 514 |
$form->{invtotal} = |
585 | 515 |
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax; |
586 | 516 |
|
templates/webpages/ar/form_footer.html | ||
---|---|---|
44 | 44 |
[% END %] |
45 | 45 |
|
46 | 46 |
</form> |
47 |
|
|
48 |
<script type="text/javascript"> |
|
49 |
<!-- |
|
50 |
$(document).ready(function() { |
|
51 |
[%- SET row=0 %] |
|
52 |
[%- WHILE row < rowcount %] |
|
53 |
[%- SET row=row + 1 %] |
|
54 |
$('#AR_amount_chart_id_[% row %]').on('set_item:ChartPicker', function(e, item) { |
|
55 |
kivi.GL.update_taxes(this); |
|
56 |
}); |
|
57 |
[%- END %] |
|
58 |
}); |
|
59 |
--> |
|
60 |
</script> |
templates/webpages/ar/form_header.html | ||
---|---|---|
1 | 1 |
[%- USE HTML %] |
2 | 2 |
[%- USE L %] |
3 | 3 |
[%- USE T8 %] |
4 |
[%- USE LxERP %] |
|
4 |
[%- USE LxERP %][%- USE P -%]
|
|
5 | 5 |
|
6 | 6 |
<form method=post name="arledger" action="[% script %]"> |
7 | 7 |
|
... | ... | |
43 | 43 |
<th align="right" nowrap>[% 'Customer' | $T8 %]</th> |
44 | 44 |
<td colspan=3> |
45 | 45 |
[%- IF selectcustomer %] |
46 |
<select id='customer' name="customer" onchange="document.getElementById('update_button').click();" class="initial_focus">[% selectcustomer %]</select>
|
|
46 |
<select id='customer' name="customer" onchange="document.getElementById('update_button').click();"[% IF initial_focus == 'customer'%] class="initial_focus"[% END %]>[% selectcustomer %]</select>
|
|
47 | 47 |
[%- ELSE %] |
48 |
<input id='customer' name=customer value="[% customer | html %]" size=35 class="initial_focus">
|
|
48 |
<input id='customer' name=customer value="[% customer | html %]" size=35[% IF initial_focus == 'customer'%] class="initial_focus"[% END %]>
|
|
49 | 49 |
[%- END %] |
50 | 50 |
<input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('customer')"></td> |
51 | 51 |
[% L.hidden_tag('selectcustomer', selectcustomer) %] |
... | ... | |
186 | 186 |
</td> |
187 | 187 |
</tr> |
188 | 188 |
<tr> |
189 |
<td>[% ARselected %]</td>
|
|
189 |
<td>[% P.chart_picker("AR_chart_id", AR_chart_id, style="width: 400px", type="AR") %]</td>
|
|
190 | 190 |
<th align=left>[% LxERP.format_amount(invtotal, 2) | html %]</th> |
191 | 191 |
|
192 | 192 |
<input type=hidden name=oldinvtotal value='[% oldinvtotal %]'> |
Auch abrufbar als: Unified diff
Debitorenbuchungen auf Verwendung des Chart-Pickers umgestellt