Revision ebdc6e13
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
bin/mozilla/ar.pl | ||
---|---|---|
40 | 40 |
use SL::PE; |
41 | 41 |
use SL::ReportGenerator; |
42 | 42 |
|
43 |
# use strict; |
|
44 |
#use warnings; |
|
45 |
|
|
46 |
# imports |
|
47 |
our ($cgi, $form, $lxdebug, $locale, %myconfig); |
|
48 |
|
|
49 | 43 |
require "bin/mozilla/arap.pl"; |
50 | 44 |
require "bin/mozilla/common.pl"; |
51 | 45 |
require "bin/mozilla/drafts.pl"; |
52 | 46 |
require "bin/mozilla/reportgenerator.pl"; |
53 | 47 |
|
48 |
use strict; |
|
49 |
#use warnings; |
|
50 |
|
|
54 | 51 |
1; |
55 | 52 |
|
56 | 53 |
# end of main |
... | ... | |
83 | 80 |
# $locale->text('Nov') |
84 | 81 |
# $locale->text('Dec') |
85 | 82 |
|
83 |
my $totalpaid; |
|
84 |
|
|
86 | 85 |
sub add { |
87 |
$lxdebug->enter_sub(); |
|
86 |
$main::lxdebug->enter_sub(); |
|
87 |
|
|
88 |
$main::auth->assert('general_ledger'); |
|
88 | 89 |
|
89 |
$auth->assert('general_ledger'); |
|
90 |
my $form = $main::form; |
|
91 |
my %myconfig = %main::myconfig; |
|
90 | 92 |
|
91 |
return $lxdebug->leave_sub() if (load_draft_maybe()); |
|
93 |
return $main::lxdebug->leave_sub() if (load_draft_maybe());
|
|
92 | 94 |
|
93 | 95 |
# saving the history |
94 | 96 |
if(!exists $form->{addition} && ($form->{id} ne "")) { |
... | ... | |
106 | 108 |
&create_links; |
107 | 109 |
$form->{transdate} = $form->{initial_transdate}; |
108 | 110 |
&display_form; |
109 |
$lxdebug->leave_sub(); |
|
111 |
$main::lxdebug->leave_sub();
|
|
110 | 112 |
} |
111 | 113 |
|
112 | 114 |
sub edit { |
113 |
$lxdebug->enter_sub(); |
|
115 |
$main::lxdebug->enter_sub();
|
|
114 | 116 |
|
115 |
$auth->assert('general_ledger'); |
|
117 |
$main::auth->assert('general_ledger'); |
|
118 |
|
|
119 |
my $form = $main::form; |
|
116 | 120 |
|
117 | 121 |
# show history button |
118 | 122 |
$form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|; |
... | ... | |
123 | 127 |
&create_links; |
124 | 128 |
&display_form; |
125 | 129 |
|
126 |
$lxdebug->leave_sub(); |
|
130 |
$main::lxdebug->leave_sub();
|
|
127 | 131 |
} |
128 | 132 |
|
129 | 133 |
sub display_form { |
130 |
$lxdebug->enter_sub(); |
|
134 |
$main::lxdebug->enter_sub(); |
|
135 |
|
|
136 |
$main::auth->assert('general_ledger'); |
|
131 | 137 |
|
132 |
$auth->assert('general_ledger');
|
|
138 |
my $form = $main::form;
|
|
133 | 139 |
|
134 | 140 |
&form_header; |
135 | 141 |
&form_footer; |
136 | 142 |
|
137 |
$lxdebug->leave_sub(); |
|
143 |
$main::lxdebug->leave_sub();
|
|
138 | 144 |
} |
139 | 145 |
|
140 | 146 |
sub create_links { |
141 |
$lxdebug->enter_sub(); |
|
147 |
$main::lxdebug->enter_sub(); |
|
148 |
|
|
149 |
$main::auth->assert('general_ledger'); |
|
142 | 150 |
|
143 |
$auth->assert('general_ledger'); |
|
151 |
my $form = $main::form; |
|
152 |
my %myconfig = %main::myconfig; |
|
144 | 153 |
|
145 | 154 |
my ($duedate, $taxincluded, @curr); |
146 | 155 |
|
... | ... | |
203 | 212 |
($form->datetonum($form->{transdate}, \%myconfig) <= |
204 | 213 |
$form->datetonum($form->{closedto}, \%myconfig)); |
205 | 214 |
|
206 |
$lxdebug->leave_sub(); |
|
215 |
$main::lxdebug->leave_sub();
|
|
207 | 216 |
} |
208 | 217 |
|
209 | 218 |
sub form_header { |
210 |
$lxdebug->enter_sub(); |
|
219 |
$main::lxdebug->enter_sub();
|
|
211 | 220 |
|
212 |
$auth->assert('general_ledger'); |
|
221 |
$main::auth->assert('general_ledger'); |
|
222 |
|
|
223 |
my $form = $main::form; |
|
224 |
my %myconfig = %main::myconfig; |
|
225 |
my $locale = $main::locale; |
|
226 |
my $cgi = $main::cgi; |
|
213 | 227 |
|
214 | 228 |
my ($title, $readonly, $exchangerate, $rows); |
215 | 229 |
my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project); |
... | ... | |
798 | 812 |
</table> |
799 | 813 |
|; |
800 | 814 |
|
801 |
$lxdebug->leave_sub(); |
|
815 |
$main::lxdebug->leave_sub();
|
|
802 | 816 |
} |
803 | 817 |
|
804 | 818 |
sub form_footer { |
805 |
$lxdebug->enter_sub(); |
|
819 |
$main::lxdebug->enter_sub(); |
|
820 |
|
|
821 |
$main::auth->assert('general_ledger'); |
|
806 | 822 |
|
807 |
$auth->assert('general_ledger'); |
|
823 |
my $form = $main::form; |
|
824 |
my %myconfig = %main::myconfig; |
|
825 |
my $locale = $main::locale; |
|
826 |
my $cgi = $main::cgi; |
|
808 | 827 |
|
809 | 828 |
my ($transdate, $closedto); |
810 | 829 |
|
... | ... | |
849 | 868 |
|
850 | 869 |
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it |
851 | 870 |
print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> | |
852 |
if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($total_paid == 0) || ($total_paid eq "")));
|
|
871 |
if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($totalpaid == 0) || ($totalpaid eq "")));
|
|
853 | 872 |
|
854 | 873 |
if ($form->{id}) { |
855 | 874 |
if ($form->{radier}) { |
... | ... | |
897 | 916 |
</html> |
898 | 917 |
"; |
899 | 918 |
|
900 |
$lxdebug->leave_sub(); |
|
919 |
$main::lxdebug->leave_sub();
|
|
901 | 920 |
} |
902 | 921 |
|
903 | 922 |
sub mark_as_paid { |
904 |
$lxdebug->enter_sub(); |
|
923 |
$main::lxdebug->enter_sub(); |
|
924 |
|
|
925 |
$main::auth->assert('general_ledger'); |
|
905 | 926 |
|
906 |
$auth->assert('general_ledger'); |
|
927 |
my $form = $main::form; |
|
928 |
my %myconfig = %main::myconfig; |
|
907 | 929 |
|
908 | 930 |
&mark_as_paid_common(\%myconfig,"ar"); |
909 | 931 |
|
910 |
$lxdebug->leave_sub(); |
|
932 |
$main::lxdebug->leave_sub();
|
|
911 | 933 |
} |
912 | 934 |
|
913 | 935 |
sub update { |
914 |
$lxdebug->enter_sub(); |
|
936 |
$main::lxdebug->enter_sub();
|
|
915 | 937 |
|
916 |
$auth->assert('general_ledger'); |
|
938 |
$main::auth->assert('general_ledger'); |
|
939 |
|
|
940 |
my $form = $main::form; |
|
941 |
my %myconfig = %main::myconfig; |
|
917 | 942 |
|
918 | 943 |
my $display = shift; |
919 | 944 |
|
920 |
my ($totaltax, $exchangerate, $totalpaid);
|
|
945 |
my ($totaltax, $exchangerate); |
|
921 | 946 |
|
922 | 947 |
$form->{invtotal} = 0; |
923 | 948 |
|
... | ... | |
1001 | 1026 |
|
1002 | 1027 |
&display_form; |
1003 | 1028 |
|
1004 |
$lxdebug->leave_sub(); |
|
1029 |
$main::lxdebug->leave_sub();
|
|
1005 | 1030 |
} |
1006 | 1031 |
|
1007 | 1032 |
# |
1008 | 1033 |
# ToDO: fix $closedto and $invdate |
1009 | 1034 |
# |
1010 | 1035 |
sub post_payment { |
1011 |
$lxdebug->enter_sub(); |
|
1036 |
$main::lxdebug->enter_sub(); |
|
1037 |
|
|
1038 |
$main::auth->assert('general_ledger'); |
|
1012 | 1039 |
|
1013 |
$auth->assert('general_ledger'); |
|
1040 |
my $form = $main::form; |
|
1041 |
my %myconfig = %main::myconfig; |
|
1042 |
my $locale = $main::locale; |
|
1014 | 1043 |
|
1015 | 1044 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
1016 | 1045 |
|
... | ... | |
1035 | 1064 |
$form->redirect($locale->text('Payment posted!')) if (AR->post_payment(\%myconfig, \%$form)); |
1036 | 1065 |
$form->error($locale->text('Cannot post payment!')); |
1037 | 1066 |
|
1038 |
$lxdebug->leave_sub(); |
|
1067 |
$main::lxdebug->leave_sub();
|
|
1039 | 1068 |
} |
1040 | 1069 |
|
1041 | 1070 |
sub _post { |
1042 | 1071 |
|
1043 |
$auth->assert('general_ledger'); |
|
1072 |
$main::auth->assert('general_ledger'); |
|
1073 |
|
|
1074 |
my $form = $main::form; |
|
1044 | 1075 |
|
1045 | 1076 |
# inline post |
1046 | 1077 |
post(1); |
1047 | 1078 |
} |
1048 | 1079 |
|
1049 | 1080 |
sub post { |
1050 |
$lxdebug->enter_sub(); |
|
1081 |
$main::lxdebug->enter_sub();
|
|
1051 | 1082 |
|
1052 |
$auth->assert('general_ledger'); |
|
1083 |
$main::auth->assert('general_ledger'); |
|
1084 |
|
|
1085 |
my $form = $main::form; |
|
1086 |
my %myconfig = %main::myconfig; |
|
1087 |
my $locale = $main::locale; |
|
1053 | 1088 |
|
1054 | 1089 |
my ($inline) = @_; |
1055 | 1090 |
|
... | ... | |
1098 | 1133 |
$form->{AR}{receivables} = $form->{ARselected}; |
1099 | 1134 |
$form->{storno} = 0; |
1100 | 1135 |
|
1101 |
$lxdebug->message(0, $form->{amount}); |
|
1136 |
$main::lxdebug->message(0, $form->{amount});
|
|
1102 | 1137 |
$form->{id} = 0 if $form->{postasnew}; |
1103 | 1138 |
$form->error($locale->text('Cannot post transaction!')) unless AR->post_transaction(\%myconfig, \%$form); |
1104 | 1139 |
|
... | ... | |
1113 | 1148 |
|
1114 | 1149 |
$form->redirect($locale->text('Transaction posted!')) unless $inline; |
1115 | 1150 |
|
1116 |
$lxdebug->leave_sub(); |
|
1151 |
$main::lxdebug->leave_sub();
|
|
1117 | 1152 |
} |
1118 | 1153 |
|
1119 | 1154 |
sub post_as_new { |
1120 |
$lxdebug->enter_sub(); |
|
1155 |
$main::lxdebug->enter_sub(); |
|
1156 |
|
|
1157 |
$main::auth->assert('general_ledger'); |
|
1121 | 1158 |
|
1122 |
$auth->assert('general_ledger'); |
|
1159 |
my $form = $main::form; |
|
1160 |
my %myconfig = %main::myconfig; |
|
1123 | 1161 |
|
1124 | 1162 |
$form->{postasnew} = 1; |
1125 | 1163 |
# saving the history |
... | ... | |
1131 | 1169 |
# /saving the history |
1132 | 1170 |
&post; |
1133 | 1171 |
|
1134 |
$lxdebug->leave_sub(); |
|
1172 |
$main::lxdebug->leave_sub();
|
|
1135 | 1173 |
} |
1136 | 1174 |
|
1137 | 1175 |
sub use_as_template { |
1138 |
$lxdebug->enter_sub(); |
|
1176 |
$main::lxdebug->enter_sub(); |
|
1177 |
|
|
1178 |
$main::auth->assert('general_ledger'); |
|
1139 | 1179 |
|
1140 |
$auth->assert('general_ledger'); |
|
1180 |
my $form = $main::form; |
|
1181 |
my %myconfig = %main::myconfig; |
|
1141 | 1182 |
|
1142 | 1183 |
map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); |
1143 | 1184 |
$form->{paidaccounts} = 1; |
... | ... | |
1145 | 1186 |
$form->{invdate} = $form->current_date(\%myconfig); |
1146 | 1187 |
&update; |
1147 | 1188 |
|
1148 |
$lxdebug->leave_sub(); |
|
1189 |
$main::lxdebug->leave_sub();
|
|
1149 | 1190 |
} |
1150 | 1191 |
|
1151 | 1192 |
sub delete { |
1152 |
$lxdebug->enter_sub(); |
|
1193 |
$main::lxdebug->enter_sub();
|
|
1153 | 1194 |
|
1154 |
$auth->assert('general_ledger'); |
|
1195 |
$main::auth->assert('general_ledger'); |
|
1196 |
|
|
1197 |
my $form = $main::form; |
|
1198 |
my $locale = $main::locale; |
|
1155 | 1199 |
|
1156 | 1200 |
$form->{title} = $locale->text('Confirm!'); |
1157 | 1201 |
|
... | ... | |
1186 | 1230 |
</html> |
1187 | 1231 |
|; |
1188 | 1232 |
|
1189 |
$lxdebug->leave_sub(); |
|
1233 |
$main::lxdebug->leave_sub();
|
|
1190 | 1234 |
} |
1191 | 1235 |
|
1192 | 1236 |
sub yes { |
1193 |
$lxdebug->enter_sub(); |
|
1237 |
$main::lxdebug->enter_sub(); |
|
1238 |
|
|
1239 |
$main::auth->assert('general_ledger'); |
|
1194 | 1240 |
|
1195 |
$auth->assert('general_ledger'); |
|
1241 |
my $form = $main::form; |
|
1242 |
my %myconfig = %main::myconfig; |
|
1243 |
my $locale = $main::locale; |
|
1196 | 1244 |
|
1197 | 1245 |
if (AR->delete_transaction(\%myconfig, \%$form)) { |
1198 | 1246 |
# saving the history |
... | ... | |
1206 | 1254 |
} |
1207 | 1255 |
$form->error($locale->text('Cannot delete transaction!')); |
1208 | 1256 |
|
1209 |
$lxdebug->leave_sub(); |
|
1257 |
$main::lxdebug->leave_sub();
|
|
1210 | 1258 |
} |
1211 | 1259 |
|
1212 | 1260 |
sub search { |
1213 |
$lxdebug->enter_sub(); |
|
1261 |
$main::lxdebug->enter_sub(); |
|
1262 |
|
|
1263 |
$main::auth->assert('general_ledger | invoice_edit'); |
|
1214 | 1264 |
|
1215 |
$auth->assert('general_ledger | invoice_edit'); |
|
1265 |
my $form = $main::form; |
|
1266 |
my %myconfig = %main::myconfig; |
|
1267 |
my $locale = $main::locale; |
|
1268 |
my $cgi = $main::cgi; |
|
1216 | 1269 |
|
1217 | 1270 |
my ($customer, $department); |
1218 | 1271 |
my ($jsscript, $button1, $button2, $onload); |
... | ... | |
1458 | 1511 |
</html> |
1459 | 1512 |
|; |
1460 | 1513 |
|
1461 |
$lxdebug->leave_sub(); |
|
1514 |
$main::lxdebug->leave_sub();
|
|
1462 | 1515 |
} |
1463 | 1516 |
|
1464 | 1517 |
sub create_subtotal_row { |
1465 |
$lxdebug->enter_sub(); |
|
1518 |
$main::lxdebug->enter_sub();
|
|
1466 | 1519 |
|
1467 | 1520 |
my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_; |
1468 | 1521 |
|
1522 |
my $form = $main::form; |
|
1523 |
my %myconfig = %main::myconfig; |
|
1524 |
|
|
1469 | 1525 |
my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; |
1470 | 1526 |
|
1471 | 1527 |
map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns }; |
... | ... | |
1474 | 1530 |
|
1475 | 1531 |
map { $totals->{$_} = 0 } @{ $subtotal_columns }; |
1476 | 1532 |
|
1477 |
$lxdebug->leave_sub(); |
|
1533 |
$main::lxdebug->leave_sub();
|
|
1478 | 1534 |
|
1479 | 1535 |
return $row; |
1480 | 1536 |
} |
1481 | 1537 |
|
1482 | 1538 |
sub ar_transactions { |
1483 |
$lxdebug->enter_sub(); |
|
1539 |
$main::lxdebug->enter_sub(); |
|
1540 |
|
|
1541 |
$main::auth->assert('general_ledger | invoice_edit'); |
|
1484 | 1542 |
|
1485 |
$auth->assert('general_ledger | invoice_edit'); |
|
1543 |
my $form = $main::form; |
|
1544 |
my %myconfig = %main::myconfig; |
|
1545 |
my $locale = $main::locale; |
|
1486 | 1546 |
|
1487 | 1547 |
my ($callback, $href, @columns); |
1488 | 1548 |
|
... | ... | |
1661 | 1721 |
|
1662 | 1722 |
$report->generate_with_headers(); |
1663 | 1723 |
|
1664 |
$lxdebug->leave_sub(); |
|
1724 |
$main::lxdebug->leave_sub();
|
|
1665 | 1725 |
} |
1666 | 1726 |
|
1667 | 1727 |
sub storno { |
1668 |
$lxdebug->enter_sub(); |
|
1728 |
$main::lxdebug->enter_sub(); |
|
1729 |
|
|
1730 |
$main::auth->assert('general_ledger'); |
|
1669 | 1731 |
|
1670 |
$auth->assert('general_ledger'); |
|
1732 |
my $form = $main::form; |
|
1733 |
my %myconfig = %main::myconfig; |
|
1734 |
my $locale = $main::locale; |
|
1671 | 1735 |
|
1672 | 1736 |
# don't cancel cancelled transactions |
1673 | 1737 |
if (IS->has_storno(\%myconfig, $form, 'ar')) { |
... | ... | |
1687 | 1751 |
|
1688 | 1752 |
$form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); |
1689 | 1753 |
|
1690 |
$lxdebug->leave_sub(); |
|
1754 |
$main::lxdebug->leave_sub();
|
|
1691 | 1755 |
} |
Auch abrufbar als: Unified diff
ar strict