Revision de651621
Von Stephan Köhler vor etwa 19 Jahren hinzugefügt
SL/AR.pm | ||
---|---|---|
34 | 34 |
|
35 | 35 |
package AR; |
36 | 36 |
|
37 |
use Data::Dumper; |
|
38 |
|
|
37 | 39 |
sub post_transaction { |
38 | 40 |
$main::lxdebug->enter_sub(); |
39 | 41 |
|
... | ... | |
52 | 54 |
$form->check_exchangerate($myconfig, $form->{currency}, |
53 | 55 |
$form->{transdate}, 'buy'); |
54 | 56 |
} |
57 |
for $i (1 .. $form->{rowcount}) { |
|
58 |
$form->{AR_amounts}{"amount_$i"} = (split(/--/, $form->{"AR_amount_$i"}))[0]; |
|
59 |
} |
|
60 |
($form->{AR_amounts}{receivables}) = split(/--/, $form->{ARselected}); |
|
61 |
($form->{AR}{receivables}) = split(/--/, $form->{ARselected}); |
|
55 | 62 |
|
56 | 63 |
$form->{exchangerate} = |
57 | 64 |
($exchangerate) |
58 | 65 |
? $exchangerate |
59 | 66 |
: $form->parse_amount($myconfig, $form->{exchangerate}); |
60 | 67 |
|
61 |
for $i (1 .. 1) {
|
|
68 |
for $i (1 .. $form->{rowcount}) {
|
|
62 | 69 |
|
63 | 70 |
$form->{"amount_$i"} = |
64 | 71 |
$form->round_amount($form->parse_amount($myconfig, $form->{"amount_$i"}) |
... | ... | |
77 | 84 |
# taxincluded doesn't make sense if there is no amount |
78 | 85 |
|
79 | 86 |
$form->{taxincluded} = 0 if ($form->{amount} == 0); |
87 |
for $i (1 .. $form->{rowcount}) { |
|
88 |
($form->{"taxkey_$i"}, $NULL) = split /--/, $form->{"taxchart_$i"}; |
|
80 | 89 |
|
81 |
$query = |
|
82 |
qq| SELECT c.accno, t.rate FROM chart c, tax t where c.id=t.chart_id AND t.taxkey=$form->{taxkey}|; |
|
83 |
$sth = $dbh->prepare($query); |
|
84 |
$sth->execute || $form->dberror($query); |
|
85 |
($form->{AR}{tax}, $form->{taxrate}) = $sth->fetchrow_array; |
|
86 |
$sth->finish; |
|
90 |
$query = |
|
91 |
qq| SELECT c.accno, t.rate FROM chart c, tax t where c.id=t.chart_id AND t.taxkey=$form->{"taxkey_$i"}|; |
|
92 |
$sth = $dbh->prepare($query); |
|
93 |
$sth->execute || $form->dberror($query); |
|
94 |
($form->{AR_amounts}{"tax_$i"}, $form->{"taxrate_$i"}) = $sth->fetchrow_array; |
|
95 |
$form->{AR_amounts}{"tax_$i"}{taxkey} = $form->{"taxkey_$i"}; |
|
96 |
$form->{AR_amounts}{"amount_$i"}{taxkey} = $form->{"taxkey_$i"}; |
|
87 | 97 |
|
88 |
$form->{tax} = $form->{amount_1} * $form->{taxrate}; |
|
89 |
$form->{tax} = $form->round_amount($form->{tax} * $form->{exchangerate}, 2); |
|
90 |
$form->{total_tax} += $form->{tax}; |
|
98 |
$sth->finish; |
|
99 |
if (!$form->{"korrektur_$i"}) { |
|
100 |
if ($form->{taxincluded} *= 1) { |
|
101 |
$tax = $form->{"amount_$i"} - ($form->{"amount_$i"} / ($form->{"taxrate_$i"} + 1)); |
|
102 |
$amount = $form->{"amount_$i"} - $tax; |
|
103 |
$form->{"amount_$i"} = $form->round_amount($amount, 2); |
|
104 |
$diff += $amount - $form->{"amount_$i"}; |
|
105 |
$form->{"tax_$i"} = $form->round_amount($tax, 2); |
|
106 |
$form->{netamount} += $form->{"amount_$i"}; |
|
107 |
} |
|
108 |
$form->{"tax_$i"} = $form->{"amount_$i"} * $form->{"taxrate_$i"}; |
|
109 |
$form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"} * $form->{exchangerate}, 2); |
|
110 |
} |
|
111 |
$form->{total_tax} += $form->{"tax_$i"}; |
|
112 |
} |
|
91 | 113 |
|
92 | 114 |
# adjust paidaccounts if there is no date in the last row |
93 | 115 |
$form->{paidaccounts}-- unless ($form->{"datepaid_$form->{paidaccounts}"}); |
... | ... | |
104 | 126 |
|
105 | 127 |
} |
106 | 128 |
|
107 |
if ($form->{taxincluded} *= 1) { |
|
108 |
for $i (1 .. 1) { |
|
109 |
$tax = |
|
110 |
$form->{"amount_$i"} - ($form->{"amount_$i"} / ($form->{taxrate} + 1)); |
|
111 |
$amount = $form->{"amount_$i"} - $tax; |
|
112 |
$form->{"amount_$i"} = $form->round_amount($amount, 2); |
|
113 |
$diff += $amount - $form->{"amount_$i"}; |
|
114 |
$form->{tax} = $form->round_amount($tax, 2); |
|
115 |
$form->{total_tax} = $form->{tax}; |
|
116 |
} |
|
117 |
|
|
118 |
# deduct difference from amount_1 |
|
119 |
# $form->{amount_1} += $form->round_amount($diff, 2); |
|
120 |
$form->{netamount} = $form->{amount_1}; |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 | 129 |
$form->{amount} = $form->{netamount} + $form->{total_tax}; |
125 | 130 |
$form->{paid} = |
126 | 131 |
$form->round_amount($form->{paid} * $form->{exchangerate}, 2); |
... | ... | |
199 | 204 |
} |
200 | 205 |
|
201 | 206 |
# add individual transactions for AR, amount and taxes |
202 |
foreach my $item (keys %{ $form->{AR} }) {
|
|
203 |
if ($form->{$item} != 0) {
|
|
207 |
for $i (1 .. $form->{rowcount}) {
|
|
208 |
if ($form->{"amount_$i"} != 0) {
|
|
204 | 209 |
$project_id = 'NULL'; |
205 |
if ($item =~ /amount_/) {
|
|
206 |
if ($form->{"project_id_$'"} && $form->{"projectnumber_$'"}) {
|
|
207 |
$project_id = $form->{"project_id_$'"};
|
|
210 |
if ("amount_$i" =~ /amount_/) {
|
|
211 |
if ($form->{"project_id_$i"} && $form->{"projectnumber_$i"}) {
|
|
212 |
$project_id = $form->{"project_id_$i"};
|
|
208 | 213 |
} |
209 | 214 |
} |
215 |
if ("amount_$i" =~ /amount/) { |
|
216 |
$taxkey = $form->{AR_amounts}{"amount_$i"}{taxkey}; |
|
217 |
} |
|
210 | 218 |
|
211 | 219 |
# insert detail records in acc_trans |
212 | 220 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, |
213 | 221 |
project_id, taxkey) |
214 | 222 |
VALUES ($form->{id}, (SELECT c.id FROM chart c |
215 |
WHERE c.accno = '$form->{AR}{$item}'),
|
|
216 |
$form->{$item}, '$form->{transdate}', $project_id, '$form->{taxkey}')|;
|
|
223 |
WHERE c.accno = '$form->{AR_amounts}{"amount_$i"}'),
|
|
224 |
$form->{"amount_$i"}, '$form->{transdate}', $project_id, '$taxkey')|;
|
|
217 | 225 |
$dbh->do($query) || $form->dberror($query); |
226 |
if ($form->{"tax_$i"} !=0) { |
|
227 |
# insert detail records in acc_trans |
|
228 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, |
|
229 |
project_id, taxkey) |
|
230 |
VALUES ($form->{id}, (SELECT c.id FROM chart c |
|
231 |
WHERE c.accno = '$form->{AR_amounts}{"tax_$i"}'), |
|
232 |
$form->{"tax_$i"}, '$form->{transdate}', $project_id, '$taxkey')|; |
|
233 |
$dbh->do($query) || $form->dberror($query); |
|
234 |
} |
|
218 | 235 |
} |
219 | 236 |
} |
237 |
# add recievables |
|
238 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, |
|
239 |
project_id) |
|
240 |
VALUES ($form->{id}, (SELECT c.id FROM chart c |
|
241 |
WHERE c.accno = '$form->{AR_amounts}{receivables}'), |
|
242 |
$form->{receivables}, '$form->{transdate}', $project_id)|; |
|
243 |
$dbh->do($query) || $form->dberror($query); |
|
244 |
|
|
220 | 245 |
|
221 | 246 |
# add paid transactions |
222 | 247 |
for my $i (1 .. $form->{paidaccounts}) { |
SL/Form.pm | ||
---|---|---|
1703 | 1703 |
LEFT Join tax t ON (a.taxkey = t.taxkey) |
1704 | 1704 |
WHERE a.trans_id = $self->{id} |
1705 | 1705 |
AND a.fx_transaction = '0' |
1706 |
ORDER BY a.transdate|; |
|
1706 |
ORDER BY a.oid,a.transdate|;
|
|
1707 | 1707 |
$sth = $dbh->prepare($query); |
1708 | 1708 |
$sth->execute || $self->dberror($query); |
1709 | 1709 |
|
... | ... | |
1713 | 1713 |
$self->{exchangerate} = |
1714 | 1714 |
$self->get_exchangerate($dbh, $self->{currency}, $self->{transdate}, |
1715 | 1715 |
$fld); |
1716 |
my $index=0; |
|
1716 | 1717 |
|
1717 | 1718 |
# store amounts in {acc_trans}{$key} for multiple accounts |
1718 | 1719 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
1719 | 1720 |
$ref->{exchangerate} = |
1720 | 1721 |
$self->get_exchangerate($dbh, $self->{currency}, $ref->{transdate}, |
1721 | 1722 |
$fld); |
1723 |
if ( !($xkeyref{ $ref->{accno} } =~ /tax/)) { |
|
1724 |
$index++; |
|
1725 |
} |
|
1726 |
$ref->{index} = $index; |
|
1722 | 1727 |
|
1723 | 1728 |
push @{ $self->{acc_trans}{ $xkeyref{ $ref->{accno} } } }, $ref; |
1724 | 1729 |
} |
bin/mozilla/ar.pl | ||
---|---|---|
34 | 34 |
use SL::AR; |
35 | 35 |
use SL::IS; |
36 | 36 |
use SL::PE; |
37 |
use Data::Dumper; |
|
37 | 38 |
|
38 | 39 |
require "$form->{path}/arap.pl"; |
39 | 40 |
|
... | ... | |
115 | 116 |
|
116 | 117 |
$form->{duedate} = $duedate if $duedate; |
117 | 118 |
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; |
118 |
|
|
119 |
$form->{rowcount} = 1; |
|
119 | 120 |
# currencies |
120 | 121 |
@curr = split /:/, $form->{currencies}; |
121 | 122 |
chomp $curr[0]; |
... | ... | |
179 | 180 |
$form->{$key} = $form->{"select$key"}; |
180 | 181 |
|
181 | 182 |
# if there is a value we have an old entry |
182 |
$j = 0; |
|
183 |
my $j = 0; |
|
184 |
my $k = 0; |
|
185 |
print(STDERR Dumper($form->{acc_trans})); |
|
183 | 186 |
for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) { |
184 | 187 |
if ($key eq "AR_paid") { |
185 | 188 |
$j++; |
... | ... | |
220 | 223 |
$form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"}; |
221 | 224 |
$withholdingrate += |
222 | 225 |
$form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"}; |
223 |
} |
|
226 |
} |
|
227 |
print(STDERR $form->{acc_trans}{$key}->[$i - 1]->{amount}, " ACC_TRANS\n"); |
|
228 |
print(STDERR "$key KEY, $k Zeile\n"); |
|
229 |
$index = $form->{acc_trans}{$key}->[$i - 1]->{index}; |
|
230 |
$form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount}; |
|
224 | 231 |
|
225 | 232 |
} else { |
226 |
$form->{"${akey}_$i"} = |
|
233 |
$k++; |
|
234 |
$form->{"${akey}_$k"} = |
|
227 | 235 |
$form->round_amount( |
228 | 236 |
$form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate, |
229 | 237 |
2); |
... | ... | |
231 | 239 |
$form->{rowcount}++; |
232 | 240 |
$totalamount += $form->{"${akey}_$i"}; |
233 | 241 |
|
234 |
$form->{"oldprojectnumber_$i"} = $form->{"projectnumber_$i"} =
|
|
242 |
$form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
|
|
235 | 243 |
"$form->{acc_trans}{$key}->[$i-1]->{projectnumber}"; |
236 | 244 |
$form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate}; |
237 |
$form->{"project_id_$i"} =
|
|
245 |
$form->{"project_id_$k"} =
|
|
238 | 246 |
"$form->{acc_trans}{$key}->[$i-1]->{project_id}"; |
239 | 247 |
} |
240 |
$form->{"${key}_$i"} =
|
|
248 |
$form->{"${key}_$k"} =
|
|
241 | 249 |
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
242 | 250 |
$form->{"${key}_$i"} = |
243 | 251 |
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}"; |
244 | 252 |
$form->{"select${key}"} =~ |
245 |
/(<option value=\"$form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*\">$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}<\/option>\n)/;
|
|
253 |
/<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}<\/option>\n/;
|
|
246 | 254 |
$test = $1; |
247 |
$form->{"select${key}"} = $1;
|
|
255 |
$form->{"${key}_$k"} = $1;
|
|
248 | 256 |
if ($akey eq 'amount') { |
249 |
$form->{selecttaxchart} =~ |
|
250 |
/(<option value=\"$form->{acc_trans}{$key}->[$i-1]->{taxkey}--[^<]*)/; |
|
251 |
$form->{selecttaxchart} = $1; |
|
257 |
$form->{"taxchart_$k"} = $form->{taxchart}; |
|
258 |
$form->{"taxchart_$k"} =~ |
|
259 |
/<option value=\"($form->{acc_trans}{$key}->[$i-1]->{taxkey}--[^\"]*)/; |
|
260 |
$form->{"taxchart_$k"} = $1; |
|
252 | 261 |
} |
253 | 262 |
} |
254 | 263 |
} |
... | ... | |
261 | 270 |
if ($form->{taxincluded} && $form->{taxrate} && $totalamount) { |
262 | 271 |
|
263 | 272 |
# add tax to amounts and invtotal |
264 |
for $i (1 .. 1) {
|
|
273 |
for $i (1 .. $form->{rowcount}) {
|
|
265 | 274 |
$taxamount = |
266 | 275 |
($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount; |
267 | 276 |
$tax = $form->round_amount($taxamount, 2); |
... | ... | |
311 | 320 |
|
312 | 321 |
# $locale->text('Add Accounts Receivables Transaction') |
313 | 322 |
# $locale->text('Edit Accounts Receivables Transaction') |
323 |
$form->{javascript} = qq|<script type="text/javascript"> |
|
324 |
<!-- |
|
325 |
function setTaxkey(accno, row) { |
|
326 |
var taxkey = accno.options[accno.selectedIndex].value; |
|
327 |
var reg = /--([0-9])*/; |
|
328 |
var found = reg.exec(taxkey); |
|
329 |
var index = found[1]; |
|
330 |
index = parseInt(index); |
|
331 |
var tax = 'taxchart_' + row; |
|
332 |
for (var i = 0; i < document.getElementById(tax).options.length; ++i) { |
|
333 |
var reg2 = new RegExp("^"+ index, ""); |
|
334 |
if (reg2.exec(document.getElementById(tax).options[i].value)) { |
|
335 |
document.getElementById(tax).options[i].selected = true; |
|
336 |
break; |
|
337 |
} |
|
338 |
} |
|
339 |
}; |
|
340 |
//--> |
|
341 |
</script>|; |
|
314 | 342 |
|
315 | 343 |
$readonly = ($form->{id}) ? "readonly" : ""; |
316 | 344 |
|
... | ... | |
324 | 352 |
$form->{"select$item"} =~ |
325 | 353 |
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; |
326 | 354 |
} |
327 |
|
|
328 |
map { $form->{$_} =~ s/\"/"/g } qw(AR_amount AR taxchart); |
|
355 |
$selectAR_amount_unquoted = $form->{selectAR_amount}; |
|
356 |
$taxchart = $form->{taxchart}; |
|
357 |
map { $form->{$_} =~ s/\"/"/g } qw(AR_amount selectAR_amount AR taxchart); |
|
329 | 358 |
|
330 | 359 |
# format amounts |
331 | 360 |
$form->{exchangerate} = |
... | ... | |
517 | 546 |
</table> |
518 | 547 |
</td> |
519 | 548 |
</tr> |
520 |
<tr> |
|
521 |
<td> |
|
522 |
<table width=100%> |
|
523 | 549 |
|
524 | 550 |
$jsscript |
525 |
|
|
551 |
<input type=hidden name=selectAR_amount value="$form->{selectAR_amount}"> |
|
526 | 552 |
<input type=hidden name=AR_amount value="$form->{AR_amount}"> |
527 | 553 |
<input type=hidden name=taxchart value="$form->{taxchart}"> |
528 | 554 |
<input type=hidden name=rowcount value=$form->{rowcount}> |
555 |
<tr> |
|
556 |
<td> |
|
557 |
<table width=100%> |
|
558 |
<tr class=listheading> |
|
559 |
<th class=listheading style="width:15%">| |
|
560 |
. $locale->text('Account') . qq|</th> |
|
561 |
<th class=listheading style="width:10%">| |
|
562 |
. $locale->text('Amount') . qq|</th> |
|
563 |
<th class=listheading style="width:10%">| |
|
564 |
. $locale->text('Tax') . qq|</th> |
|
565 |
<th class=listheading style="width:5%">| |
|
566 |
. $locale->text('Korrektur') . qq|</th> |
|
567 |
<th class=listheading style="width:10%">| |
|
568 |
. $locale->text('Taxkey') . qq|</th> |
|
569 |
<th class=listheading style="width:10%">| |
|
570 |
. $locale->text('Project') . qq|</th> |
|
571 |
</tr> |
|
529 | 572 |
|; |
530 | 573 |
|
531 |
$form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2); |
|
574 |
|
|
532 | 575 |
|
533 | 576 |
$amount = $locale->text('Amount'); |
534 | 577 |
$project = $locale->text('Project'); |
535 | 578 |
|
536 |
for $i (1 .. 1) {
|
|
579 |
for $i (1 .. $form->{rowcount}) {
|
|
537 | 580 |
|
538 | 581 |
# format amounts |
539 |
$form->{"amount_$i"} = |
|
540 |
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2); |
|
582 |
$form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2); |
|
583 |
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2); |
|
584 |
$selectAR_amount = $selectAR_amount_unquoted; |
|
585 |
$selectAR_amount =~ s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/; |
|
586 |
$tax = $taxchart; |
|
587 |
$tax_selected = $form->{"taxchart_$i"}; |
|
588 |
$tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/; |
|
589 |
$tax = |
|
590 |
qq|<td><select id="taxchart_$i" name="taxchart_$i">$tax</select></td>|; |
|
541 | 591 |
|
542 | 592 |
print qq| |
543 | 593 |
<tr> |
544 |
<th align=right>$amount</th> |
|
545 |
<td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td> |
|
546 |
<th>$project</th> |
|
594 |
<td width=50%><select name="AR_amount_$i">$selectAR_amount</select></td> |
|
595 |
<td><input name="amount_$i" onChange="setTaxkey(this, $i)" size=10 value=$form->{"amount_$i"}></td> |
|
596 |
<td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td> |
|
597 |
<td><input type="checkbox" name="korrektur_$i" value="1"></td> |
|
598 |
$tax |
|
547 | 599 |
<td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}"> |
548 | 600 |
<input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}> |
549 | 601 |
<input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td> |
550 |
<td width=50%><select name="AR_amountselected">$form->{"selectAR_amount"}</select></td> |
|
551 | 602 |
</tr> |
552 | 603 |
|; |
553 | 604 |
$amount = ""; |
554 | 605 |
$project = ""; |
555 | 606 |
} |
556 | 607 |
|
557 |
$taxlabel = |
|
558 |
($form->{taxincluded}) |
|
559 |
? $locale->text('Tax Included') |
|
560 |
: $locale->text('Tax'); |
|
561 | 608 |
|
562 |
print qq| |
|
563 |
<tr> |
|
564 |
<th align=right nowrap>$taxlabel</th> |
|
565 |
<td><input name="tax" size=10 value=$form->{"tax"}></td> |
|
566 |
<td align=right></td> |
|
567 |
<td></td> |
|
568 |
<td><select name="taxchartselected">$form->{"selecttaxchart"}</select></td> |
|
569 |
</tr> |
|
570 |
|; |
|
609 |
|
|
571 | 610 |
|
572 | 611 |
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2); |
573 | 612 |
|
574 | 613 |
print qq| |
575 | 614 |
<tr> |
576 |
|
|
577 |
<th align=right>| . $locale->text('Total') . qq|</th> |
|
615 |
<td colspan=6> |
|
616 |
<hr noshade> |
|
617 |
</td> |
|
618 |
</tr> |
|
619 |
<tr> |
|
620 |
<td><select name=ARselected>$form->{selectAR}</select></td> |
|
621 |
<input type=hidden name=AR value="$form->{AR}"> |
|
578 | 622 |
<th align=left>$form->{invtotal}</th> |
579 | 623 |
|
580 | 624 |
<input type=hidden name=oldinvtotal value=$form->{oldinvtotal}> |
... | ... | |
582 | 626 |
|
583 | 627 |
<input type=hidden name=taxaccounts value="$form->{taxaccounts}"> |
584 | 628 |
|
585 |
<td colspan=2></td> |
|
586 |
<td><select name=ARselected>$form->{selectAR}</select></td> |
|
587 |
<input type=hidden name=AR value="$form->{AR}"> |
|
629 |
<td colspan=4></td> |
|
630 |
|
|
588 | 631 |
|
589 | 632 |
</tr> |
633 |
</table> |
|
634 |
</td> |
|
635 |
</tr> |
|
636 |
<tr> |
|
637 |
<td> |
|
638 |
<table width=100%> |
|
590 | 639 |
<tr> |
591 |
<th align=right>| . $locale->text('Notes') . qq|</th>
|
|
592 |
<td colspan=4>$notes</td>
|
|
640 |
<th align=left width=1%>| . $locale->text('Notes') . qq|</th>
|
|
641 |
<td align=left>$notes</td>
|
|
593 | 642 |
</tr> |
594 | 643 |
</table> |
595 | 644 |
</td> |
... | ... | |
767 | 816 |
|
768 | 817 |
$form->{invtotal} = 0; |
769 | 818 |
|
770 |
$form->{selectAR_amount} = $form->{AR_amount}; |
|
771 |
$form->{selectAR_amount} =~ |
|
772 |
s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/; |
|
819 |
# $form->{selectAR_amount} = $form->{AR_amount};
|
|
820 |
# $form->{selectAR_amount} =~
|
|
821 |
# s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
|
|
773 | 822 |
|
774 | 823 |
$form->{selectAR} = $form->{AR}; |
775 | 824 |
|
... | ... | |
790 | 839 |
@flds = qw(amount AR_amount projectnumber oldprojectnumber project_id); |
791 | 840 |
$count = 0; |
792 | 841 |
@a = (); |
793 |
for $i (1 .. 1) { |
|
842 |
|
|
843 |
for $i (1 .. $form->{rowcount}) { |
|
794 | 844 |
$form->{"amount_$i"} = |
795 | 845 |
$form->parse_amount(\%myconfig, $form->{"amount_$i"}); |
846 |
$form->{"tax_$i"} = |
|
847 |
$form->parse_amount(\%myconfig, $form->{"tax_$i"}); |
|
796 | 848 |
if ($form->{"amount_$i"}) { |
797 | 849 |
push @a, {}; |
798 | 850 |
$j = $#a; |
851 |
if (!$form->{"korrektur_$i"}) { |
|
852 |
($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
|
853 |
if ($taxkey > 1) { |
|
854 |
if ($form->{taxincluded}) { |
|
855 |
$form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate; |
|
856 |
} else { |
|
857 |
$form->{"tax_$i"} = $form->{"amount_$i"} * $rate; |
|
858 |
} |
|
859 |
} else { |
|
860 |
$form->{"tax_$i"} = 0; |
|
861 |
} |
|
862 |
} |
|
863 |
$form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2); |
|
799 | 864 |
|
865 |
$totaltax += $form->{"tax_$i"}; |
|
800 | 866 |
map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; |
801 | 867 |
$count++; |
802 | 868 |
} |
803 | 869 |
} |
804 | 870 |
|
805 | 871 |
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); |
806 |
|
|
807 |
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. 1);
|
|
872 |
$form->{rowcount} = $count + 1; |
|
873 |
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
|
|
808 | 874 |
|
809 | 875 |
$form->{exchangerate} = $exchangerate |
810 | 876 |
if ( |
... | ... | |
821 | 887 |
|
822 | 888 |
&check_project; |
823 | 889 |
|
824 |
TAXCALC: |
|
825 |
|
|
826 |
# recalculate taxes |
|
827 |
|
|
828 |
@taxaccounts = split / /, $form->{taxaccounts}; |
|
829 |
|
|
830 |
$form->{"tax"} = $form->parse_amount(\%myconfig, $form->{"tax"}); |
|
831 |
|
|
832 |
if ($form->{taxincluded} && $form->{"rate"}) { |
|
833 |
$taxrate = $form->{"rate"}; |
|
834 |
$withholdingrate = 0; |
|
835 |
|
|
836 |
$amount = |
|
837 |
$form->round_amount( |
|
838 |
($form->{invtotal} - ($form->{invtotal} / ($taxrate + 1))), |
|
839 |
2); |
|
840 |
$form->{"tax"} = $form->round_amount($amount, 2); |
|
841 |
$taxdiff += ($amount - $form->{"tax"}); |
|
842 |
|
|
843 |
if (abs $taxdiff >= 0.005) { |
|
844 |
$form->{"tax"} += $form->round_amount($taxdiff, 2); |
|
845 |
$taxdiff = 0; |
|
846 |
} |
|
847 |
$totaltax += $form->{"tax"}; |
|
848 |
|
|
849 |
} else { |
|
850 |
$form->{"tax"} = |
|
851 |
$form->round_amount($form->{invtotal} * $form->{"rate"}, 2); |
|
852 |
$totaltax += $form->{"tax"}; |
|
853 |
|
|
854 |
} |
|
855 | 890 |
|
856 | 891 |
$form->{invtotal} = |
857 | 892 |
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax; |
Auch abrufbar als: Unified diff
Merge von 716 aus unstable: Splitbuchungen
Splittbuchungen fuer Debitorenbuchungen