Revision de651621
Von Stephan Köhler vor etwa 19 Jahren hinzugefügt
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