Revision 870e380d
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
bin/mozilla/gl.pl | ||
---|---|---|
44 | 44 |
require "bin/mozilla/drafts.pl"; |
45 | 45 |
require "bin/mozilla/reportgenerator.pl"; |
46 | 46 |
|
47 |
use strict; |
|
48 |
|
|
47 | 49 |
1; |
48 | 50 |
|
49 | 51 |
# end of main |
... | ... | |
76 | 78 |
# $locale->text('Nov') |
77 | 79 |
# $locale->text('Dec') |
78 | 80 |
|
81 |
my $tax; |
|
82 |
my $debitlock = 0; |
|
83 |
my $creditlock = 0; |
|
84 |
|
|
79 | 85 |
sub add { |
80 |
$lxdebug->enter_sub(); |
|
86 |
$main::lxdebug->enter_sub(); |
|
87 |
|
|
88 |
$main::auth->assert('general_ledger'); |
|
81 | 89 |
|
82 |
$auth->assert('general_ledger'); |
|
90 |
my $form = $main::form; |
|
91 |
my %myconfig = %main::myconfig; |
|
83 | 92 |
|
84 |
return $lxdebug->leave_sub() if (load_draft_maybe()); |
|
93 |
return $main::lxdebug->leave_sub() if (load_draft_maybe());
|
|
85 | 94 |
|
86 | 95 |
$form->{title} = "Add"; |
87 | 96 |
|
... | ... | |
117 | 126 |
$form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details}; |
118 | 127 |
|
119 | 128 |
&display_form(1); |
120 |
$lxdebug->leave_sub(); |
|
129 |
$main::lxdebug->leave_sub();
|
|
121 | 130 |
|
122 | 131 |
} |
123 | 132 |
|
124 | 133 |
sub prepare_transaction { |
125 |
$lxdebug->enter_sub(); |
|
134 |
$main::lxdebug->enter_sub();
|
|
126 | 135 |
|
127 |
$auth->assert('general_ledger'); |
|
136 |
$main::auth->assert('general_ledger'); |
|
137 |
|
|
138 |
my $form = $main::form; |
|
139 |
my %myconfig = %main::myconfig; |
|
128 | 140 |
|
129 | 141 |
GL->transaction(\%myconfig, \%$form); |
130 | 142 |
|
... | ... | |
150 | 162 |
my $i = 1; |
151 | 163 |
my $tax = 0; |
152 | 164 |
my $taxaccno = ""; |
153 |
foreach $ref (@{ $form->{GL} }) { |
|
154 |
$j = $i - 1; |
|
165 |
foreach my $ref (@{ $form->{GL} }) {
|
|
166 |
my $j = $i - 1;
|
|
155 | 167 |
if ($tax && ($ref->{accno} eq $taxaccno)) { |
156 | 168 |
$form->{"tax_$j"} = abs($ref->{amount}); |
157 | 169 |
$form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate}; |
... | ... | |
192 | 204 |
($form->datetonum($form->{transdate}, \%myconfig) <= |
193 | 205 |
$form->datetonum($form->{closedto}, \%myconfig)); |
194 | 206 |
|
195 |
$lxdebug->leave_sub(); |
|
207 |
$main::lxdebug->leave_sub();
|
|
196 | 208 |
} |
197 | 209 |
|
198 | 210 |
sub edit { |
199 |
$lxdebug->enter_sub(); |
|
211 |
$main::lxdebug->enter_sub(); |
|
212 |
|
|
213 |
$main::auth->assert('general_ledger'); |
|
200 | 214 |
|
201 |
$auth->assert('general_ledger'); |
|
215 |
my $form = $main::form; |
|
216 |
my %myconfig = %main::myconfig; |
|
202 | 217 |
|
203 | 218 |
prepare_transaction(); |
204 | 219 |
|
... | ... | |
210 | 225 |
display_rows(); |
211 | 226 |
form_footer(); |
212 | 227 |
|
213 |
$lxdebug->leave_sub(); |
|
228 |
$main::lxdebug->leave_sub();
|
|
214 | 229 |
} |
215 | 230 |
|
216 | 231 |
|
217 | 232 |
sub search { |
218 |
$lxdebug->enter_sub(); |
|
233 |
$main::lxdebug->enter_sub(); |
|
234 |
|
|
235 |
$main::auth->assert('general_ledger'); |
|
219 | 236 |
|
220 |
$auth->assert('general_ledger'); |
|
237 |
my $form = $main::form; |
|
238 |
my %myconfig = %main::myconfig; |
|
239 |
my $locale = $main::locale; |
|
240 |
my $cgi = $main::cgi; |
|
221 | 241 |
|
222 | 242 |
$form->{title} = $locale->text('Journal'); |
223 | 243 |
|
... | ... | |
233 | 253 |
} (@{ $form->{all_departments} }); |
234 | 254 |
} |
235 | 255 |
|
236 |
$department = qq| |
|
256 |
my $department = qq|
|
|
237 | 257 |
<tr> |
238 | 258 |
<th align=right nowrap>| . $locale->text('Department') . qq|</th> |
239 | 259 |
<td colspan=3><select name=department>$form->{selectdepartment}</select></td> |
... | ... | |
257 | 277 |
|
258 | 278 |
# use JavaScript Calendar or not |
259 | 279 |
$form->{jsscript} = 1; |
260 |
$jsscript = ""; |
|
280 |
my $jsscript = ""; |
|
281 |
my ($button1, $button2, $onload); |
|
261 | 282 |
if ($form->{jsscript}) { |
262 | 283 |
|
263 | 284 |
# with JavaScript Calendar |
... | ... | |
401 | 422 |
</body> |
402 | 423 |
</html> |
403 | 424 |
|; |
404 |
$lxdebug->leave_sub(); |
|
425 |
$main::lxdebug->leave_sub();
|
|
405 | 426 |
} |
406 | 427 |
|
407 | 428 |
sub create_subtotal_row { |
408 |
$lxdebug->enter_sub(); |
|
429 |
$main::lxdebug->enter_sub();
|
|
409 | 430 |
|
410 | 431 |
my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_; |
411 | 432 |
|
433 |
my $form = $main::form; |
|
434 |
my %myconfig = %main::myconfig; |
|
435 |
|
|
412 | 436 |
my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; |
413 | 437 |
|
414 | 438 |
map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns }; |
415 | 439 |
|
416 | 440 |
map { $totals->{$_} = 0 } @{ $subtotal_columns }; |
417 | 441 |
|
418 |
$lxdebug->leave_sub(); |
|
442 |
$main::lxdebug->leave_sub();
|
|
419 | 443 |
|
420 | 444 |
return $row; |
421 | 445 |
} |
422 | 446 |
|
423 | 447 |
sub generate_report { |
424 |
$lxdebug->enter_sub(); |
|
448 |
$main::lxdebug->enter_sub(); |
|
449 |
|
|
450 |
$main::auth->assert('general_ledger'); |
|
425 | 451 |
|
426 |
$auth->assert('general_ledger'); |
|
452 |
my $form = $main::form; |
|
453 |
my %myconfig = %main::myconfig; |
|
454 |
my $locale = $main::locale; |
|
427 | 455 |
|
428 | 456 |
report_generator_set_default_sort('transdate', 1); |
429 | 457 |
|
... | ... | |
541 | 569 |
my %totals = map { $_ => 0 } @totals_columns; |
542 | 570 |
my $idx = 0; |
543 | 571 |
|
544 |
foreach $ref (@{ $form->{GL} }) { |
|
572 |
foreach my $ref (@{ $form->{GL} }) {
|
|
545 | 573 |
|
546 | 574 |
my %rows; |
547 | 575 |
|
... | ... | |
647 | 675 |
|
648 | 676 |
$report->generate_with_headers(); |
649 | 677 |
|
650 |
$lxdebug->leave_sub(); |
|
678 |
$main::lxdebug->leave_sub();
|
|
651 | 679 |
} |
652 | 680 |
|
653 | 681 |
sub update { |
654 |
$lxdebug->enter_sub(); |
|
682 |
$main::lxdebug->enter_sub();
|
|
655 | 683 |
|
656 |
$auth->assert('general_ledger'); |
|
684 |
$main::auth->assert('general_ledger'); |
|
685 |
|
|
686 |
my $form = $main::form; |
|
687 |
my %myconfig = %main::myconfig; |
|
657 | 688 |
|
658 | 689 |
$form->{oldtransdate} = $form->{transdate}; |
659 | 690 |
|
... | ... | |
663 | 694 |
my $credittax = 0; |
664 | 695 |
my $debitcount = 0; |
665 | 696 |
my $creditcount = 0; |
666 |
$debitlock = 0; |
|
667 |
$creditlock = 0; |
|
697 |
my ($debitcredit, $amount); |
|
668 | 698 |
|
669 | 699 |
my @flds = |
670 | 700 |
qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); |
... | ... | |
713 | 743 |
($form->{"debit_$i"} == 0) |
714 | 744 |
? $form->{"credit_$i"} |
715 | 745 |
: $form->{"debit_$i"}; |
716 |
$j = $#a; |
|
746 |
my $j = $#a;
|
|
717 | 747 |
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { |
718 | 748 |
$form->{"taxchart_$i"} = "0--0.00"; |
719 | 749 |
$form->{"tax_$i"} = 0; |
720 | 750 |
} |
721 |
($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
|
751 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
|
|
722 | 752 |
if ($taxkey > 1) { |
723 | 753 |
if ($debitcredit) { |
724 | 754 |
$debittax = 1; |
... | ... | |
739 | 769 |
} |
740 | 770 |
} |
741 | 771 |
|
742 |
for $i (1 .. $count) { |
|
743 |
$j = $i - 1; |
|
772 |
for my $i (1 .. $count) {
|
|
773 |
my $j = $i - 1;
|
|
744 | 774 |
for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} } |
745 | 775 |
} |
746 | 776 |
|
747 |
for $i ($count + 1 .. $form->{rowcount}) { |
|
777 |
for my $i ($count + 1 .. $form->{rowcount}) {
|
|
748 | 778 |
for (@flds) { delete $form->{"${_}_$i"} } |
749 | 779 |
} |
750 | 780 |
|
751 | 781 |
$form->{rowcount} = $count + 1; |
752 | 782 |
|
753 | 783 |
&display_form; |
754 |
$lxdebug->leave_sub(); |
|
784 |
$main::lxdebug->leave_sub();
|
|
755 | 785 |
|
756 | 786 |
} |
757 | 787 |
|
758 | 788 |
sub display_form { |
759 | 789 |
my ($init) = @_; |
760 |
$lxdebug->enter_sub(); |
|
790 |
$main::lxdebug->enter_sub(); |
|
791 |
|
|
792 |
$main::auth->assert('general_ledger'); |
|
761 | 793 |
|
762 |
$auth->assert('general_ledger'); |
|
794 |
my $form = $main::form; |
|
795 |
my %myconfig = %main::myconfig; |
|
763 | 796 |
|
764 | 797 |
&form_header($init); |
765 | 798 |
|
... | ... | |
771 | 804 |
# } |
772 | 805 |
&display_rows($init); |
773 | 806 |
&form_footer; |
774 |
$lxdebug->leave_sub(); |
|
807 |
$main::lxdebug->leave_sub();
|
|
775 | 808 |
|
776 | 809 |
} |
777 | 810 |
|
778 | 811 |
sub display_rows { |
779 | 812 |
my ($init) = @_; |
780 |
$lxdebug->enter_sub(); |
|
813 |
$main::lxdebug->enter_sub(); |
|
814 |
|
|
815 |
$main::auth->assert('general_ledger'); |
|
781 | 816 |
|
782 |
$auth->assert('general_ledger'); |
|
817 |
my $form = $main::form; |
|
818 |
my %myconfig = %main::myconfig; |
|
819 |
my $cgi = $main::cgi; |
|
783 | 820 |
|
784 | 821 |
$form->{debit_1} = 0 if !$form->{"debit_1"}; |
785 | 822 |
$form->{totaldebit} = 0; |
... | ... | |
797 | 834 |
my %charts = (); |
798 | 835 |
my $taxchart_init; |
799 | 836 |
foreach my $item (@{ $form->{ALL_CHARTS} }) { |
800 |
if ($item->{charttype} eq 'H'){ #falls ?berschrift
|
|
837 |
if ($item->{charttype} eq 'H'){ #falls ?berschrift |
|
801 | 838 |
next; #?berspringen (Bug 1150) |
802 | 839 |
} |
803 | 840 |
my $key = $item->{accno} . "--" . $item->{tax_id}; |
... | ... | |
818 | 855 |
$taxcharts{$item->{id}} = $item; |
819 | 856 |
} |
820 | 857 |
|
821 |
for $i (1 .. $form->{rowcount}) { |
|
858 |
my ($source, $memo, $source_hidden, $memo_hidden); |
|
859 |
for my $i (1 .. $form->{rowcount}) { |
|
822 | 860 |
if ($form->{show_details}) { |
823 | 861 |
$source = qq| |
824 | 862 |
<td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|; |
... | ... | |
850 | 888 |
$selected_accno = '' if ($init); |
851 | 889 |
$selected_taxchart ||= $taxchart_init; |
852 | 890 |
|
853 |
$accno = qq|<td>| . |
|
891 |
my $accno = qq|<td>| .
|
|
854 | 892 |
NTI($cgi->popup_menu('-name' => "accno_$i", |
855 | 893 |
'-id' => "accno_$i", |
856 | 894 |
'-onChange' => "setTaxkey($i)", |
... | ... | |
870 | 908 |
'-default' => $selected_taxchart)) |
871 | 909 |
. qq|</td>|; |
872 | 910 |
|
911 |
my ($fx_transaction, $checked); |
|
873 | 912 |
if ($init) { |
874 | 913 |
if ($form->{transfer}) { |
875 | 914 |
$fx_transaction = qq| |
... | ... | |
900 | 939 |
if ($i < $form->{rowcount}) { |
901 | 940 |
if ($form->{transfer}) { |
902 | 941 |
$checked = ($form->{"fx_transaction_$i"}) ? "1" : ""; |
903 |
$x = ($checked) ? "x" : ""; |
|
942 |
my $x = ($checked) ? "x" : "";
|
|
904 | 943 |
$fx_transaction = qq| |
905 | 944 |
<td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td> |
906 | 945 |
|; |
... | ... | |
958 | 997 |
|
959 | 998 |
$form->hide_form(qw(rowcount selectaccno)); |
960 | 999 |
|
961 |
$lxdebug->leave_sub(); |
|
1000 |
$main::lxdebug->leave_sub();
|
|
962 | 1001 |
|
963 | 1002 |
} |
964 | 1003 |
|
965 | 1004 |
sub form_header { |
966 | 1005 |
my ($init) = @_; |
967 |
$lxdebug->enter_sub(); |
|
1006 |
$main::lxdebug->enter_sub(); |
|
1007 |
|
|
1008 |
$main::auth->assert('general_ledger'); |
|
968 | 1009 |
|
969 |
$auth->assert('general_ledger'); |
|
1010 |
my $form = $main::form; |
|
1011 |
my %myconfig = %main::myconfig; |
|
1012 |
my $locale = $main::locale; |
|
970 | 1013 |
|
971 | 1014 |
my @old_project_ids = (); |
972 | 1015 |
map({ push(@old_project_ids, $form->{"project_id_$_"}) |
... | ... | |
981 | 1024 |
|
982 | 1025 |
GL->get_chart_balances('charts' => $form->{ALL_CHARTS}); |
983 | 1026 |
|
984 |
$title = $form->{title};
|
|
1027 |
my $title = $form->{title};
|
|
985 | 1028 |
$form->{title} = $locale->text("$title General Ledger Transaction"); |
986 |
$readonly = ($form->{id}) ? "readonly" : "";
|
|
1029 |
my $readonly = ($form->{id}) ? "readonly" : "";
|
|
987 | 1030 |
|
988 |
$show_details_checked = "checked" if $form->{show_details}; |
|
1031 |
my $show_details_checked = "checked" if $form->{show_details};
|
|
989 | 1032 |
|
990 |
$ob_transaction_checked = "checked" if $form->{ob_transaction}; |
|
991 |
$cb_transaction_checked = "checked" if $form->{cb_transaction}; |
|
1033 |
my $ob_transaction_checked = "checked" if $form->{ob_transaction};
|
|
1034 |
my $cb_transaction_checked = "checked" if $form->{cb_transaction};
|
|
992 | 1035 |
|
993 | 1036 |
# $locale->text('Add General Ledger Transaction') |
994 | 1037 |
# $locale->text('Edit General Ledger Transaction') |
... | ... | |
1029 | 1072 |
$form->{selectdepartment} =~ |
1030 | 1073 |
s/option>\Q$form->{department}\E/option selected>$form->{department}/; |
1031 | 1074 |
|
1032 |
if (($rows = $form->numtextrows($form->{description}, 50)) > 1) { |
|
1075 |
my $description; |
|
1076 |
if ((my $rows = $form->numtextrows($form->{description}, 50)) > 1) { |
|
1033 | 1077 |
$description = |
1034 | 1078 |
qq|<textarea name=description rows=$rows cols=50 wrap=soft $readonly >$form->{description}</textarea>|; |
1035 | 1079 |
} else { |
... | ... | |
1037 | 1081 |
qq|<input name=description size=50 value="$form->{description}" $readonly>|; |
1038 | 1082 |
} |
1039 | 1083 |
|
1040 |
$taxincluded = ($form->{taxincluded}) ? "checked" : ""; |
|
1084 |
my $taxincluded = ($form->{taxincluded}) ? "checked" : "";
|
|
1041 | 1085 |
|
1042 | 1086 |
if ($init) { |
1043 | 1087 |
$taxincluded = "checked"; |
1044 | 1088 |
} |
1045 | 1089 |
|
1090 |
my $department; |
|
1046 | 1091 |
$department = qq| |
1047 | 1092 |
<tr> |
1048 | 1093 |
<th align=right nowrap>| . $locale->text('Department') . qq|</th> |
... | ... | |
1058 | 1103 |
|
1059 | 1104 |
# use JavaScript Calendar or not |
1060 | 1105 |
$form->{jsscript} = 1; |
1061 |
$jsscript = ""; |
|
1106 |
my $jsscript = ""; |
|
1107 |
my ($button1, $button2); |
|
1062 | 1108 |
if ($form->{jsscript}) { |
1063 | 1109 |
|
1064 | 1110 |
# with JavaScript Calendar |
... | ... | |
1231 | 1277 |
|
1232 | 1278 |
$jsscript |
1233 | 1279 |
|; |
1234 |
$lxdebug->leave_sub(); |
|
1280 |
$main::lxdebug->leave_sub();
|
|
1235 | 1281 |
|
1236 | 1282 |
} |
1237 | 1283 |
|
1238 | 1284 |
sub form_footer { |
1239 |
$lxdebug->enter_sub(); |
|
1285 |
$main::lxdebug->enter_sub(); |
|
1286 |
|
|
1287 |
$main::auth->assert('general_ledger'); |
|
1240 | 1288 |
|
1241 |
$auth->assert('general_ledger'); |
|
1289 |
my $form = $main::form; |
|
1290 |
my %myconfig = %main::myconfig; |
|
1291 |
my $locale = $main::locale; |
|
1292 |
my $cgi = $main::cgi; |
|
1242 | 1293 |
|
1243 | 1294 |
my $follow_ups_block; |
1244 | 1295 |
if ($form->{id}) { |
... | ... | |
1250 | 1301 |
} |
1251 | 1302 |
} |
1252 | 1303 |
|
1253 |
($dec) = ($form->{totaldebit} =~ /\.(\d+)/); |
|
1304 |
my ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
|
|
1254 | 1305 |
$dec = length $dec; |
1255 |
$decimalplaces = ($dec > 2) ? $dec : 2; |
|
1256 |
$radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; |
|
1306 |
my $decimalplaces = ($dec > 2) ? $dec : 2;
|
|
1307 |
my $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
|
|
1257 | 1308 |
|
1258 | 1309 |
map { |
1259 | 1310 |
$form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ") |
... | ... | |
1277 | 1328 |
<br> |
1278 | 1329 |
|; |
1279 | 1330 |
|
1280 |
$transdate = $form->datetonum($form->{transdate}, \%myconfig); |
|
1281 |
$closedto = $form->datetonum($form->{closedto}, \%myconfig); |
|
1331 |
my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
|
|
1332 |
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
|
|
1282 | 1333 |
|
1283 | 1334 |
if ($form->{id}) { |
1284 | 1335 |
|
... | ... | |
1322 | 1373 |
</body> |
1323 | 1374 |
</html> |
1324 | 1375 |
"; |
1325 |
$lxdebug->leave_sub(); |
|
1376 |
$main::lxdebug->leave_sub();
|
|
1326 | 1377 |
|
1327 | 1378 |
} |
1328 | 1379 |
|
1329 | 1380 |
sub delete { |
1330 |
$lxdebug->enter_sub(); |
|
1381 |
$main::lxdebug->enter_sub(); |
|
1382 |
|
|
1383 |
my $form = $main::form; |
|
1384 |
my $locale = $main::locale; |
|
1331 | 1385 |
|
1332 | 1386 |
$form->header; |
1333 | 1387 |
|
... | ... | |
1341 | 1395 |
|
1342 | 1396 |
delete $form->{header}; |
1343 | 1397 |
|
1344 |
foreach $key (keys %$form) { |
|
1398 |
foreach my $key (keys %$form) {
|
|
1345 | 1399 |
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); |
1346 | 1400 |
print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|; |
1347 | 1401 |
} |
... | ... | |
1357 | 1411 |
. $locale->text('Yes') . qq|"> |
1358 | 1412 |
</form> |
1359 | 1413 |
|; |
1360 |
$lxdebug->leave_sub(); |
|
1414 |
$main::lxdebug->leave_sub();
|
|
1361 | 1415 |
|
1362 | 1416 |
} |
1363 | 1417 |
|
1364 | 1418 |
sub yes { |
1365 |
$lxdebug->enter_sub(); |
|
1419 |
$main::lxdebug->enter_sub(); |
|
1420 |
|
|
1421 |
my $form = $main::form; |
|
1422 |
my %myconfig = %main::myconfig; |
|
1423 |
my $locale = $main::locale; |
|
1424 |
|
|
1366 | 1425 |
if (GL->delete_transaction(\%myconfig, \%$form)){ |
1367 | 1426 |
# saving the history |
1368 | 1427 |
if(!exists $form->{addition} && $form->{id} ne "") { |
... | ... | |
1374 | 1433 |
$form->redirect($locale->text('Transaction deleted!')) |
1375 | 1434 |
} |
1376 | 1435 |
$form->error($locale->text('Cannot delete transaction!')); |
1377 |
$lxdebug->leave_sub(); |
|
1436 |
$main::lxdebug->leave_sub();
|
|
1378 | 1437 |
|
1379 | 1438 |
} |
1380 | 1439 |
|
1381 | 1440 |
sub post_transaction { |
1382 |
$lxdebug->enter_sub(); |
|
1441 |
$main::lxdebug->enter_sub(); |
|
1442 |
|
|
1443 |
my $form = $main::form; |
|
1444 |
my %myconfig = %main::myconfig; |
|
1445 |
my $locale = $main::locale; |
|
1383 | 1446 |
|
1384 | 1447 |
# check if there is something in reference and date |
1385 | 1448 |
$form->isblank("reference", $locale->text('Reference missing!')); |
1386 | 1449 |
$form->isblank("transdate", $locale->text('Transaction Date missing!')); |
1387 | 1450 |
$form->isblank("description", $locale->text('Description missing!')); |
1388 | 1451 |
|
1389 |
$transdate = $form->datetonum($form->{transdate}, \%myconfig); |
|
1390 |
$closedto = $form->datetonum($form->{closedto}, \%myconfig); |
|
1452 |
my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
|
|
1453 |
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
|
|
1391 | 1454 |
|
1392 | 1455 |
my @a = (); |
1393 | 1456 |
my $count = 0; |
... | ... | |
1395 | 1458 |
my $credittax = 0; |
1396 | 1459 |
my $debitcount = 0; |
1397 | 1460 |
my $creditcount = 0; |
1398 |
$creditlock = 0; |
|
1399 |
$debitlock = 0; |
|
1461 |
my $debitcredit; |
|
1400 | 1462 |
|
1401 | 1463 |
my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); |
1402 | 1464 |
|
... | ... | |
1440 | 1502 |
if (!$debitcredit && $debittax) { |
1441 | 1503 |
$form->{"taxchart_$i"} = "0--0.00"; |
1442 | 1504 |
} |
1443 |
$amount = ($form->{"debit_$i"} == 0) |
|
1505 |
my $amount = ($form->{"debit_$i"} == 0)
|
|
1444 | 1506 |
? $form->{"credit_$i"} |
1445 | 1507 |
: $form->{"debit_$i"}; |
1446 |
$j = $#a; |
|
1508 |
my $j = $#a;
|
|
1447 | 1509 |
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { |
1448 | 1510 |
$form->{"taxchart_$i"} = "0--0.00"; |
1449 | 1511 |
$form->{"tax_$i"} = 0; |
1450 | 1512 |
} |
1451 |
($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); |
|
1513 |
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
|
|
1452 | 1514 |
if ($taxkey > 1) { |
1453 | 1515 |
if ($debitcredit) { |
1454 | 1516 |
$debittax = 1; |
... | ... | |
1473 | 1535 |
$count++; |
1474 | 1536 |
} |
1475 | 1537 |
|
1476 |
for $i (1 .. $count) { |
|
1477 |
$j = $i - 1; |
|
1538 |
for my $i (1 .. $count) {
|
|
1539 |
my $j = $i - 1;
|
|
1478 | 1540 |
for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} } |
1479 | 1541 |
} |
1480 | 1542 |
|
1481 |
for $i ($count + 1 .. $form->{rowcount}) { |
|
1543 |
for my $i ($count + 1 .. $form->{rowcount}) {
|
|
1482 | 1544 |
for (@flds) { delete $form->{"${_}_$i"} } |
1483 | 1545 |
} |
1484 | 1546 |
|
1485 |
for $i (1 .. $form->{rowcount}) { |
|
1486 |
$dr = $form->{"debit_$i"}; |
|
1487 |
$cr = $form->{"credit_$i"}; |
|
1547 |
my ($debit, $credit, $taxtotal); |
|
1548 |
for my $i (1 .. $form->{rowcount}) { |
|
1549 |
my $dr = $form->{"debit_$i"}; |
|
1550 |
my $cr = $form->{"credit_$i"}; |
|
1488 | 1551 |
$tax = $form->{"tax_$i"}; |
1489 | 1552 |
if ($dr && $cr) { |
1490 | 1553 |
$form->error($locale->text('Cannot post transaction with a debit and credit entry for the same account!')); |
... | ... | |
1507 | 1570 |
$form->error($locale->text('Empty transaction!')); |
1508 | 1571 |
} |
1509 | 1572 |
|
1510 |
if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) { |
|
1573 |
if ((my $errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) {
|
|
1511 | 1574 |
$errno *= -1; |
1575 |
my @err; |
|
1512 | 1576 |
$err[1] = $locale->text('Cannot have a value in both Debit and Credit!'); |
1513 | 1577 |
$err[2] = $locale->text('Debit and credit out of balance!'); |
1514 | 1578 |
$err[3] = $locale->text('Cannot post a transaction without a value!'); |
... | ... | |
1525 | 1589 |
} |
1526 | 1590 |
# /saving the history |
1527 | 1591 |
|
1528 |
$lxdebug->leave_sub(); |
|
1592 |
$main::lxdebug->leave_sub();
|
|
1529 | 1593 |
} |
1530 | 1594 |
|
1531 | 1595 |
sub post { |
1532 |
$lxdebug->enter_sub(); |
|
1596 |
$main::lxdebug->enter_sub(); |
|
1597 |
|
|
1598 |
$main::auth->assert('general_ledger'); |
|
1533 | 1599 |
|
1534 |
$auth->assert('general_ledger'); |
|
1600 |
my $form = $main::form; |
|
1601 |
my $locale = $main::locale; |
|
1535 | 1602 |
|
1536 | 1603 |
$form->{title} = $locale->text("$form->{title} General Ledger Transaction"); |
1537 | 1604 |
$form->{storno} = 0; |
... | ... | |
1543 | 1610 |
$form->{callback} = build_std_url("action=add", "show_details"); |
1544 | 1611 |
$form->redirect($form->{callback}); |
1545 | 1612 |
|
1546 |
$lxdebug->leave_sub(); |
|
1613 |
$main::lxdebug->leave_sub();
|
|
1547 | 1614 |
} |
1548 | 1615 |
|
1549 | 1616 |
sub post_as_new { |
1550 |
$lxdebug->enter_sub(); |
|
1617 |
$main::lxdebug->enter_sub();
|
|
1551 | 1618 |
|
1552 |
$auth->assert('general_ledger'); |
|
1619 |
$main::auth->assert('general_ledger'); |
|
1620 |
|
|
1621 |
my $form = $main::form; |
|
1553 | 1622 |
|
1554 | 1623 |
$form->{id} = 0; |
1555 | 1624 |
&add; |
1556 |
$lxdebug->leave_sub(); |
|
1625 |
$main::lxdebug->leave_sub();
|
|
1557 | 1626 |
|
1558 | 1627 |
} |
1559 | 1628 |
|
1560 | 1629 |
sub storno { |
1561 |
$lxdebug->enter_sub(); |
|
1630 |
$main::lxdebug->enter_sub(); |
|
1631 |
|
|
1632 |
$main::auth->assert('general_ledger'); |
|
1562 | 1633 |
|
1563 |
$auth->assert('general_ledger'); |
|
1634 |
my $form = $main::form; |
|
1635 |
my %myconfig = %main::myconfig; |
|
1636 |
my $locale = $main::locale; |
|
1564 | 1637 |
|
1565 | 1638 |
# don't cancel cancelled transactions |
1566 | 1639 |
if (IS->has_storno(\%myconfig, $form, 'gl')) { |
... | ... | |
1580 | 1653 |
|
1581 | 1654 |
$form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); |
1582 | 1655 |
|
1583 |
$lxdebug->leave_sub(); |
|
1656 |
$main::lxdebug->leave_sub();
|
|
1584 | 1657 |
} |
1585 | 1658 |
|
1586 | 1659 |
sub continue { |
1587 |
call_sub($form->{nextsub}); |
|
1660 |
call_sub($main::form->{nextsub});
|
|
1588 | 1661 |
} |
Auch abrufbar als: Unified diff
gl strict