Revision 76c486e3
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/ARAP.pm | ||
---|---|---|
6 | 6 |
use SL::MoreCommon; |
7 | 7 |
use Data::Dumper; |
8 | 8 |
|
9 |
use strict; |
|
10 |
|
|
9 | 11 |
sub close_orders_if_billed { |
10 | 12 |
$main::lxdebug->enter_sub(); |
11 | 13 |
|
SL/Auth.pm | ||
---|---|---|
19 | 19 |
use SL::User; |
20 | 20 |
use SL::DBUtils; |
21 | 21 |
|
22 |
use strict; |
|
23 |
|
|
22 | 24 |
sub new { |
23 | 25 |
$main::lxdebug->enter_sub(); |
24 | 26 |
|
... | ... | |
140 | 142 |
$dsn .= ';port=' . $cfg->{port}; |
141 | 143 |
} |
142 | 144 |
|
143 |
$main::lxdebug->message(LXDebug::DEBUG1, "Auth::dbconnect DSN: $dsn");
|
|
145 |
$main::lxdebug->message(LXDebug->DEBUG1, "Auth::dbconnect DSN: $dsn");
|
|
144 | 146 |
|
145 | 147 |
$self->{dbh} = DBI->connect($dsn, $cfg->{user}, $cfg->{password}, { 'AutoCommit' => 0 }); |
146 | 148 |
|
... | ... | |
215 | 217 |
$dsn .= ';port=' . $cfg->{port}; |
216 | 218 |
} |
217 | 219 |
|
218 |
$main::lxdebug->message(LXDebug::DEBUG1, "Auth::create_database DSN: $dsn");
|
|
220 |
$main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database DSN: $dsn");
|
|
219 | 221 |
|
220 | 222 |
my $dbh = DBI->connect($dsn, $params{superuser}, $params{superuser_password}); |
221 | 223 |
|
... | ... | |
230 | 232 |
|
231 | 233 |
my $query = qq|CREATE DATABASE "$cfg->{db}" OWNER "$cfg->{user}" TEMPLATE "$params{template}" ENCODING '$encoding'|; |
232 | 234 |
|
233 |
$main::lxdebug->message(LXDebug::DEBUG1, "Auth::create_database query: $query");
|
|
235 |
$main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database query: $query");
|
|
234 | 236 |
|
235 | 237 |
$dbh->do($query); |
236 | 238 |
|
SL/BP.pm | ||
---|---|---|
36 | 36 |
|
37 | 37 |
use SL::DBUtils; |
38 | 38 |
|
39 |
use strict; |
|
40 |
|
|
39 | 41 |
sub get_vc { |
40 | 42 |
$main::lxdebug->enter_sub(); |
41 | 43 |
|
... | ... | |
56 | 58 |
my $vc = $form->{vc} eq "customer" ? "customer" : "vendor"; |
57 | 59 |
my $arap_type = defined($arap{$form->{type}}) ? $arap{$form->{type}} : 'ar'; |
58 | 60 |
|
59 |
$query = |
|
61 |
my $query =
|
|
60 | 62 |
qq|SELECT count(*) | . |
61 | 63 |
qq|FROM (SELECT DISTINCT ON (vc.id) vc.id FROM $vc vc, $arap_type a, status s | . |
62 | 64 |
qq| WHERE a.${vc}_id = vc.id AND s.trans_id = a.id AND s.formname = ? | . |
... | ... | |
72 | 74 |
qq|WHERE a.${vc}_id = vc.id AND s.trans_id = a.id AND s.formname = ? | . |
73 | 75 |
qq| AND s.spoolfile IS NOT NULL|; |
74 | 76 |
|
75 |
$sth = $dbh->prepare($query); |
|
77 |
my $sth = $dbh->prepare($query);
|
|
76 | 78 |
$sth->execute($form->{type}) || $form->dberror($query . " ($form->{type})"); |
77 | 79 |
|
78 | 80 |
$form->{"all_${vc}"} = []; |
79 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
81 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
80 | 82 |
push @{ $form->{"all_${vc}"} }, $ref; |
81 | 83 |
} |
82 | 84 |
$sth->finish; |
... | ... | |
103 | 105 |
$sth->execute($form->{type}) || $form->dberror($query . " ($form->{type})"); |
104 | 106 |
|
105 | 107 |
$form->{accounts} = []; |
106 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
108 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
107 | 109 |
push @{ $form->{accounts} }, $ref; |
108 | 110 |
} |
109 | 111 |
|
... | ... | |
192 | 194 |
} |
193 | 195 |
} |
194 | 196 |
|
195 |
my @a = (transdate, $invnumber, name);
|
|
197 |
my @a = ("transdate", $invnumber, "name");
|
|
196 | 198 |
my $sortorder = join ', ', $form->sort_columns(@a); |
197 | 199 |
|
198 | 200 |
if (grep({ $_ eq $form->{sort} } |
... | ... | |
207 | 209 |
$form->dberror($query . " (" . join(", ", @values) . ")"); |
208 | 210 |
|
209 | 211 |
$form->{SPOOL} = []; |
210 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
212 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
211 | 213 |
push @{ $form->{SPOOL} }, $ref; |
212 | 214 |
} |
213 | 215 |
|
... | ... | |
279 | 281 |
open(OUT, $output) or $form->error("$output : $!"); |
280 | 282 |
|
281 | 283 |
$form->{"spoolfile_$i"} =~ s|.*/||; |
282 |
$spoolfile = qq|$spool/$form->{"spoolfile_$i"}|; |
|
284 |
my $spoolfile = qq|$spool/$form->{"spoolfile_$i"}|;
|
|
283 | 285 |
|
284 | 286 |
# send file to printer |
285 | 287 |
open(IN, $spoolfile) or $form->error("$spoolfile : $!"); |
SL/Common.pm | ||
---|---|---|
13 | 13 |
|
14 | 14 |
use SL::DBUtils; |
15 | 15 |
|
16 |
use vars qw(@db_encodings %db_encoding_to_charset); |
|
16 |
use vars qw(@db_encodings %db_encoding_to_charset %charset_to_db_encoding); |
|
17 |
|
|
18 |
use strict; |
|
17 | 19 |
|
18 | 20 |
@db_encodings = ( |
19 | 21 |
{ "label" => "ASCII", "dbencoding" => "SQL_ASCII", "charset" => "ASCII" }, |
SL/DBUpgrade2.pm | ||
---|---|---|
3 | 3 |
use SL::Common; |
4 | 4 |
|
5 | 5 |
require Exporter; |
6 |
@ISA = qw(Exporter); |
|
6 |
our @ISA = qw(Exporter);
|
|
7 | 7 |
|
8 |
@EXPORT = qw(parse_dbupdate_controls sort_dbupdate_controls); |
|
8 |
our @EXPORT = qw(parse_dbupdate_controls sort_dbupdate_controls); |
|
9 |
|
|
10 |
use strict; |
|
9 | 11 |
|
10 | 12 |
sub parse_dbupdate_controls { |
11 | 13 |
$main::lxdebug->enter_sub(); |
SL/GL.pm | ||
---|---|---|
41 | 41 |
use Data::Dumper; |
42 | 42 |
use SL::DBUtils; |
43 | 43 |
|
44 |
use strict; |
|
45 |
|
|
44 | 46 |
sub delete_transaction { |
45 | 47 |
my ($self, $myconfig, $form) = @_; |
46 | 48 |
$main::lxdebug->enter_sub(); |
... | ... | |
86 | 88 |
$form->{taxincluded} = 0; |
87 | 89 |
} |
88 | 90 |
|
89 |
my ($query, $sth); |
|
91 |
my ($query, $sth, @values, $taxkey, $rate, $posted);
|
|
90 | 92 |
|
91 | 93 |
if ($form->{id}) { |
92 | 94 |
|
... | ... | |
196 | 198 |
|
197 | 199 |
# connect to database |
198 | 200 |
my $dbh = $form->dbconnect($myconfig); |
199 |
my ($query, $sth, $source, $null); |
|
201 |
my ($query, $sth, $source, $null, $space);
|
|
200 | 202 |
|
201 | 203 |
my ($glwhere, $arwhere, $apwhere) = ("1 = 1", "1 = 1", "1 = 1"); |
202 | 204 |
my (@glvalues, @arvalues, @apvalues); |
... | ... | |
294 | 296 |
push(@apvalues, $project_id, $project_id); |
295 | 297 |
} |
296 | 298 |
|
297 |
my ($project_columns, %project_join);
|
|
299 |
my ($project_columns, $project_join);
|
|
298 | 300 |
if ($form->{"l_projectnumbers"}) { |
299 | 301 |
$project_columns = qq|, ac.project_id, pr.projectnumber|; |
300 | 302 |
$project_join = qq|LEFT JOIN project pr ON (ac.project_id = pr.id)|; |
... | ... | |
315 | 317 |
} |
316 | 318 |
} |
317 | 319 |
|
318 |
my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|;
|
|
320 |
my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|;
|
|
319 | 321 |
|
320 | 322 |
my %sort_columns = ( |
321 | 323 |
'id' => [ qw(id) ], |
... | ... | |
342 | 344 |
map { $columns_for_sorting{$_} .= sprintf(', lower(%s) AS lower_%s', $lowered_columns{$column}->{$_}, $column) } qw(gl arap); |
343 | 345 |
} |
344 | 346 |
|
345 |
my $query =
|
|
347 |
$query = |
|
346 | 348 |
qq|SELECT |
347 | 349 |
ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link, |
348 | 350 |
g.description, ac.transdate, ac.source, ac.trans_id, |
... | ... | |
388 | 390 |
my @values = (@glvalues, @arvalues, @apvalues); |
389 | 391 |
|
390 | 392 |
# Show all $query in Debuglevel LXDebug::QUERY |
391 |
$callingdetails = (caller (0))[3]; |
|
392 |
dump_query(LXDebug::QUERY, "$callingdetails", $query, @values);
|
|
393 |
my $callingdetails = (caller (0))[3];
|
|
394 |
dump_query(LXDebug->QUERY(), "$callingdetails", $query, @values);
|
|
393 | 395 |
|
394 | 396 |
$sth = prepare_execute_query($form, $dbh, $query, @values); |
395 | 397 |
my $trans_id = ""; |
396 | 398 |
my $trans_id2 = ""; |
399 |
my $balance; |
|
397 | 400 |
|
398 | 401 |
my ($i, $j, $k, $l, $ref, $ref2); |
399 | 402 |
|
400 | 403 |
$form->{GL} = []; |
401 |
while (my $ref0 = $sth->fetchrow_hashref(NAME_lc)) {
|
|
404 |
while (my $ref0 = $sth->fetchrow_hashref("NAME_lc")) {
|
|
402 | 405 |
|
403 | 406 |
$trans_id = $ref0->{id}; |
404 | 407 |
|
... | ... | |
489 | 492 |
} else { # following lines of a booking, line increasing |
490 | 493 |
|
491 | 494 |
$ref2 = $ref0; |
492 |
$trans_old = $trans_id2;
|
|
495 |
# $trans_old = $trans_id2; # doesn't seem to be used anymore
|
|
493 | 496 |
$trans_id2 = $ref2->{id}; |
494 | 497 |
|
495 | 498 |
$balance = |
... | ... | |
596 | 599 |
if ($form->{id}) { |
597 | 600 |
$query = |
598 | 601 |
qq|SELECT g.reference, g.description, g.notes, g.transdate, g.storno, g.storno_id, |
599 |
d.description AS department, e.name AS employee, g.taxincluded, g.gldate,
|
|
602 |
d.description AS department, e.name AS employee, g.taxincluded, g.gldate, |
|
600 | 603 |
g.ob_transaction, g.cb_transaction |
601 | 604 |
FROM gl g |
602 | 605 |
LEFT JOIN department d ON (d.id = g.department_id) |
... | ... | |
701 | 704 |
|
702 | 705 |
# now copy acc_trans entries |
703 | 706 |
$query = qq|SELECT * FROM acc_trans WHERE trans_id = ?|; |
704 |
my $rowref = selectall_hashref_query($form, $dbh, $query, $id);
|
|
707 |
my $rowref = selectall_hashref_query($form, $dbh, $query, $id); |
|
705 | 708 |
|
706 | 709 |
for my $row (@$rowref) { |
707 | 710 |
delete @$row{qw(itime mtime)}; |
SL/IR.pm | ||
---|---|---|
44 | 44 |
use SL::MoreCommon; |
45 | 45 |
use List::Util qw(min); |
46 | 46 |
|
47 |
use strict; |
|
48 |
|
|
47 | 49 |
sub post_invoice { |
48 | 50 |
$main::lxdebug->enter_sub(); |
49 | 51 |
|
... | ... | |
61 | 63 |
my ($amount, $linetotal, $lastinventoryaccno, $lastexpenseaccno); |
62 | 64 |
my ($netamount, $invoicediff, $expensediff) = (0, 0, 0); |
63 | 65 |
my $exchangerate = 0; |
66 |
my ($basefactor, $baseqty, @taxaccounts, $totaltax); |
|
64 | 67 |
|
65 | 68 |
my $all_units = AM->retrieve_units($myconfig, $form); |
66 | 69 |
|
... | ... | |
133 | 136 |
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; |
134 | 137 |
##################################################################### |
135 | 138 |
# das ist aus IS.pm kopiert. schlimm. jb 7.10.2009 |
136 |
# ich würde mir wünschen, dass diese vier stellen zusammengefasst werden
|
|
139 |
# ich würde mir wünschen, dass diese vier stellen zusammengefasst werden |
|
137 | 140 |
# ... vier stellen = (einkauf + verkauf) * (maske + backend) |
138 | 141 |
# ansonsten stolpert man immer wieder viermal statt einmal heftig |
139 | 142 |
# und auch das undo discount formatting ist nicht besonders wartungsfreundlich |
140 |
|
|
143 |
|
|
141 | 144 |
# keep entered selling price |
142 |
my $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
|
|
145 |
$fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
|
143 | 146 |
|
144 | 147 |
# keine ahnung wofür das in IS.pm gemacht wird: |
145 | 148 |
# my ($dec) = ($fxsellprice =~ /\.(\d+)/); |
... | ... | |
150 | 153 |
$form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100; |
151 | 154 |
# deduct discount |
152 | 155 |
$form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"}); |
153 |
|
|
156 |
|
|
154 | 157 |
###################################################################### |
155 | 158 |
if ($form->{"inventory_accno_$i"}) { |
156 | 159 |
|
... | ... | |
218 | 221 |
ORDER BY transdate|; |
219 | 222 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"id_$i"})); |
220 | 223 |
|
221 |
my $totalqty = $base_qty;
|
|
224 |
my $totalqty = $baseqty; |
|
222 | 225 |
|
223 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
226 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
224 | 227 |
my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated}); |
225 | 228 |
$linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2); |
226 | 229 |
|
... | ... | |
631 | 634 |
|
632 | 635 |
my $netamount = 0; |
633 | 636 |
|
634 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
637 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
635 | 638 |
$netamount += $form->round_amount($ref->{sellprice} * $ref->{qty} * -1, 2); |
636 | 639 |
|
637 | 640 |
next unless $ref->{inventory_accno_id}; |
... | ... | |
649 | 652 |
ORDER BY transdate DESC|; |
650 | 653 |
my $sth2 = prepare_execute_query($form, $dbh, $query, $ref->{parts_id}); |
651 | 654 |
|
652 |
while (my $pthref = $sth2->fetchrow_hashref(NAME_lc)) {
|
|
655 |
while (my $pthref = $sth2->fetchrow_hashref("NAME_lc")) {
|
|
653 | 656 |
my $qty = $ref->{allocated}; |
654 | 657 |
if (($ref->{allocated} + $pthref->{allocated}) > 0) { |
655 | 658 |
$qty = $pthref->{allocated} * -1; |
... | ... | |
813 | 816 |
ORDER BY i.id|; |
814 | 817 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
815 | 818 |
|
816 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
819 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
817 | 820 |
# Retrieve custom variables. |
818 | 821 |
my $cvars = CVar->get_custom_variables(dbh => $dbh, |
819 | 822 |
module => 'IC', |
... | ... | |
849 | 852 |
$ref->{taxaccounts} = ""; |
850 | 853 |
|
851 | 854 |
my $i = 0; |
852 |
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
|
|
855 |
while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
|
|
853 | 856 |
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { |
854 | 857 |
$i++; |
855 | 858 |
$ptr->{accno} = $i; |
... | ... | |
923 | 926 |
LEFT JOIN business b ON (b.id = v.business_id) |
924 | 927 |
LEFT JOIN payment_terms pt ON (v.payment_id = pt.id) |
925 | 928 |
WHERE 1=1 $where|; |
926 |
$ref = selectfirst_hashref_query($form, $dbh, $query, @values); |
|
929 |
my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
|
|
927 | 930 |
map { $params->{$_} = $ref->{$_} } keys %$ref; |
928 | 931 |
|
929 | 932 |
$params->{creditremaining} = $params->{creditlimit}; |
... | ... | |
972 | 975 |
for $ref (@$refs) { |
973 | 976 |
if ($ref->{category} eq 'E') { |
974 | 977 |
$i++; |
975 |
|
|
978 |
my ($tax_id, $rate); |
|
976 | 979 |
if ($params->{initial_transdate}) { |
977 | 980 |
my $tax_query = qq|SELECT tk.tax_id, t.rate FROM taxkeys tk |
978 | 981 |
LEFT JOIN tax t ON (tk.tax_id = t.id) |
979 | 982 |
WHERE (tk.chart_id = ?) AND (startdate <= ?) |
980 | 983 |
ORDER BY tk.startdate DESC |
981 | 984 |
LIMIT 1|; |
982 |
my ($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate});
|
|
985 |
($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate}); |
|
983 | 986 |
$params->{"taxchart_$i"} = "${tax_id}--${rate}"; |
984 | 987 |
} |
985 | 988 |
|
... | ... | |
1082 | 1085 |
my $sth = prepare_execute_query($form, $dbh, $query, @values); |
1083 | 1086 |
|
1084 | 1087 |
$form->{item_list} = []; |
1085 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
1088 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
1086 | 1089 |
|
1087 | 1090 |
# In der Buchungsgruppe ist immer ein Bestandskonto verknuepft, auch wenn |
1088 | 1091 |
# es sich um eine Dienstleistung handelt. Bei Dienstleistungen muss das |
... | ... | |
1093 | 1096 |
delete($ref->{inventory_accno_id}); |
1094 | 1097 |
|
1095 | 1098 |
# get tax rates and description |
1096 |
$accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; |
|
1099 |
my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
|
|
1097 | 1100 |
$query = |
1098 | 1101 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber |
1099 | 1102 |
FROM tax t |
... | ... | |
1113 | 1116 |
|
1114 | 1117 |
$ref->{taxaccounts} = ""; |
1115 | 1118 |
my $i = 0; |
1116 |
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
|
|
1119 |
while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
|
|
1117 | 1120 |
|
1118 | 1121 |
# if ($customertax{$ref->{accno}}) { |
1119 | 1122 |
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { |
... | ... | |
1227 | 1230 |
ORDER BY accno|; |
1228 | 1231 |
my $sth = prepare_execute_query($query, $dbh, $query); |
1229 | 1232 |
|
1230 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
1233 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
1231 | 1234 |
foreach my $key (split(/:/, $ref->{link})) { |
1232 | 1235 |
if ($key =~ /IC/) { |
1233 | 1236 |
push @{ $form->{IC_links}{$key} }, |
SL/IS.pm | ||
---|---|---|
34 | 34 |
|
35 | 35 |
package IS; |
36 | 36 |
|
37 |
#use strict; |
|
38 |
|
|
39 | 37 |
use List::Util qw(max); |
40 | 38 |
|
41 | 39 |
use SL::AM; |
... | ... | |
49 | 47 |
use SL::IC; |
50 | 48 |
use Data::Dumper; |
51 | 49 |
|
50 |
use strict; |
|
51 |
|
|
52 | 52 |
sub invoice_details { |
53 | 53 |
$main::lxdebug->enter_sub(); |
54 | 54 |
|
SL/Inifile.pm | ||
---|---|---|
37 | 37 |
|
38 | 38 |
use IO::File; |
39 | 39 |
|
40 |
use strict; |
|
41 |
|
|
40 | 42 |
sub new { |
41 | 43 |
$main::lxdebug->enter_sub(2); |
42 | 44 |
|
SL/LICENSES.pm | ||
---|---|---|
35 | 35 |
|
36 | 36 |
use SL::Form; |
37 | 37 |
|
38 |
use strict; |
|
39 |
|
|
38 | 40 |
sub save_license { |
39 | 41 |
$main::lxdebug->enter_sub(); |
40 | 42 |
|
41 | 43 |
my ($self, $myconfig, $form) = @_; |
42 | 44 |
|
43 |
$dbh = $form->dbconnect($myconfig); |
|
45 |
my $dbh = $form->dbconnect($myconfig);
|
|
44 | 46 |
|
45 |
$query = |
|
47 |
my $query =
|
|
46 | 48 |
qq| INSERT INTO license (licensenumber) VALUES ('$form->{licensenumber}')|; |
47 |
$sth = $dbh->prepare($query); |
|
49 |
my $sth = $dbh->prepare($query);
|
|
48 | 50 |
$sth->execute || $form->dberror($query); |
49 | 51 |
$sth->finish(); |
50 | 52 |
|
... | ... | |
52 | 54 |
qq|SELECT l.id FROM license l WHERE l.licensenumber = '$form->{licensenumber}'|; |
53 | 55 |
$sth = $dbh->prepare($query); |
54 | 56 |
$sth->execute || $form->dberror($query); |
55 |
($license_id) = $sth->fetchrow_array; |
|
57 |
my ($license_id) = $sth->fetchrow_array;
|
|
56 | 58 |
$sth->finish(); |
57 | 59 |
|
58 | 60 |
# save license |
... | ... | |
88 | 90 |
my $sth = $dbh->prepare($query); |
89 | 91 |
$sth->execute || $form->dberror($query); |
90 | 92 |
$form->{"all_customers"} = []; |
91 |
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
93 |
while ($ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
92 | 94 |
push(@{ $form->{"all_customers"} }, $ref); |
93 | 95 |
} |
94 | 96 |
$sth->finish(); |
... | ... | |
174 | 176 |
$sth = $dbh->prepare($query); |
175 | 177 |
$sth->execute() || $form->dberror($query); |
176 | 178 |
$form->{"licenses"} = []; |
177 |
while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
179 |
while ($ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
178 | 180 |
push(@{ $form->{"licenses"} }, $ref); |
179 | 181 |
} |
180 | 182 |
|
... | ... | |
207 | 209 |
. $form->{"id"}; |
208 | 210 |
$sth = $dbh->prepare($query); |
209 | 211 |
$sth->execute() || $form->dberror($query); |
210 |
$form->{"license"} = $sth->fetchrow_hashref(NAME_lc);
|
|
212 |
$form->{"license"} = $sth->fetchrow_hashref("NAME_lc");
|
|
211 | 213 |
$sth->finish(); |
212 | 214 |
$dbh->disconnect(); |
213 | 215 |
$main::lxdebug->leave_sub(); |
SL/Locale.pm | ||
---|---|---|
42 | 42 |
use SL::Common; |
43 | 43 |
use SL::Inifile; |
44 | 44 |
|
45 |
use strict; |
|
46 |
|
|
45 | 47 |
sub new { |
46 | 48 |
$main::lxdebug->enter_sub(); |
47 | 49 |
|
... | ... | |
229 | 231 |
my $longdate = ""; |
230 | 232 |
my $longmonth = ($longformat) ? 'LONG_MONTH' : 'SHORT_MONTH'; |
231 | 233 |
|
234 |
my ($spc, $yy, $mm, $dd); |
|
235 |
|
|
232 | 236 |
if ($date) { |
233 | 237 |
|
234 | 238 |
# get separator |
... | ... | |
302 | 306 |
$main::lxdebug->enter_sub(); |
303 | 307 |
|
304 | 308 |
my ($self, $myconfig, $date, $longformat) = @_; |
309 |
my ($spc, $yy, $mm, $dd); |
|
305 | 310 |
|
306 | 311 |
unless ($date) { |
307 | 312 |
$main::lxdebug->leave_sub(); |
SL/MoreCommon.pm | ||
---|---|---|
1 | 1 |
package SL::MoreCommon; |
2 | 2 |
|
3 | 3 |
require Exporter; |
4 |
@ISA = qw(Exporter); |
|
4 |
our @ISA = qw(Exporter);
|
|
5 | 5 |
|
6 |
@EXPORT = qw(save_form restore_form compare_numbers any cross); |
|
7 |
@EXPORT_OK = qw(ary_union ary_intersect ary_diff listify); |
|
6 |
our @EXPORT = qw(save_form restore_form compare_numbers any cross);
|
|
7 |
our @EXPORT_OK = qw(ary_union ary_intersect ary_diff listify);
|
|
8 | 8 |
|
9 | 9 |
use YAML; |
10 | 10 |
|
11 | 11 |
use SL::AM; |
12 | 12 |
|
13 |
use strict; |
|
14 |
|
|
13 | 15 |
sub save_form { |
14 | 16 |
$main::lxdebug->enter_sub(); |
15 | 17 |
|
SL/Projects.pm | ||
---|---|---|
39 | 39 |
use SL::DBUtils; |
40 | 40 |
use SL::CVar; |
41 | 41 |
|
42 |
use strict; |
|
43 |
|
|
42 | 44 |
my %project_id_column_prefixes = ("ar" => "global", |
43 | 45 |
"ap" => "global", |
44 | 46 |
"oe" => "global", |
... | ... | |
178 | 180 |
$params{active} = 1; |
179 | 181 |
} |
180 | 182 |
|
181 |
$query = qq|UPDATE project SET projectnumber = ?, description = ?, active = ? |
|
183 |
my $query = qq|UPDATE project SET projectnumber = ?, description = ?, active = ?
|
|
182 | 184 |
WHERE id = ?|; |
183 | 185 |
|
184 | 186 |
@values = ($params{projectnumber}, $params{description}, $params{active} ? 't' : 'f', conv_i($params{id})); |
SL/RC.pm | ||
---|---|---|
36 | 36 |
|
37 | 37 |
use SL::DBUtils; |
38 | 38 |
|
39 |
use strict; |
|
40 |
|
|
39 | 41 |
sub paymentaccounts { |
40 | 42 |
$main::lxdebug->enter_sub(); |
41 | 43 |
|
SL/RecordLinks.pm | ||
---|---|---|
5 | 5 |
use Data::Dumper; |
6 | 6 |
use List::Util qw(reduce); |
7 | 7 |
|
8 |
use strict; |
|
9 |
|
|
8 | 10 |
sub create_links { |
9 | 11 |
$main::lxdebug->enter_sub(); |
10 | 12 |
|
SL/ReportGenerator.pm | ||
---|---|---|
12 | 12 |
|
13 | 13 |
use SL::Form; |
14 | 14 |
|
15 |
use strict; |
|
16 |
|
|
15 | 17 |
# Cause locales.pl to parse these files: |
16 | 18 |
# parse_html_template('report_generator/html_report') |
17 | 19 |
|
... | ... | |
789 | 791 |
$report->add_data($row1, $row2, @more_rows); |
790 | 792 |
$report->generate_with_headers(); |
791 | 793 |
|
792 |
This creates a report object, sets a few columns, adds some data and generates a standard report.
|
|
794 |
This creates a report object, sets a few columns, adds some data and generates a standard report. |
|
793 | 795 |
Sorting of columns will be alphabetic, and options will be set to their defaults. |
794 | 796 |
The report will be printed including table headers, html headers and http headers. |
795 | 797 |
|
... | ... | |
802 | 804 |
Then it lacks usability. You want it to be able to sort the data. You add code for that. |
803 | 805 |
Then there are too many results, you need pagination, you want to print or export that data..... and so on. |
804 | 806 |
|
805 |
The ReportGenerator class was designed because this exact scenario happened about half a dozen times in Lx-Office.
|
|
806 |
It's purpose is to manage all those formating, culling, sorting, and templating.
|
|
807 |
The ReportGenerator class was designed because this exact scenario happened about half a dozen times in Lx-Office. |
|
808 |
It's purpose is to manage all those formating, culling, sorting, and templating. |
|
807 | 809 |
Which makes it almost as complicated to use as doing the work for yourself. |
808 | 810 |
|
809 | 811 |
=head1 FUNCTIONS |
... | ... | |
831 | 833 |
|
832 | 834 |
=item add_data \%data |
833 | 835 |
|
834 |
Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines.
|
|
835 |
Every line will be expected to be in a kay => value format. Note that the rows have to be already sorted.
|
|
836 |
Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines. |
|
837 |
Every line will be expected to be in a kay => value format. Note that the rows have to be already sorted. |
|
836 | 838 |
ReportGenerator does only colum sorting on its own, and provides links to sorting and visual cue as to which column was sorted by. |
837 | 839 |
|
838 | 840 |
=item add_separator |
... | ... | |
842 | 844 |
=item add_control \%data |
843 | 845 |
|
844 | 846 |
Adds a control element to the data. Control elements are an experimental feature to add functionality to a report the regular data cannot. |
845 |
Every control element needs to set IS_CONTROL_DATA, in order to be recongnized by the template.
|
|
847 |
Every control element needs to set IS_CONTROL_DATA, in order to be recongnized by the template. |
|
846 | 848 |
Currently the only control element is a colspan element, which can be used as a mini header further down the report. |
847 | 849 |
|
848 | 850 |
=item clear_data |
... | ... | |
867 | 869 |
|
868 | 870 |
=item generate_with_headers |
869 | 871 |
|
870 |
Parses the report, adds headers and prints it out. Headers depend on the option 'output_format',
|
|
872 |
Parses the report, adds headers and prints it out. Headers depend on the option 'output_format', |
|
871 | 873 |
for example 'HTML' will add proper table headers, html headers and http headers. See configuration for this option. |
872 | 874 |
|
873 | 875 |
=item get_visible_columns $format |
... | ... | |
880 | 882 |
|
881 | 883 |
=item prepare_html_content $column,$name,@column_headers |
882 | 884 |
|
883 |
Parses the data, and sets internal data needed for certain output format. Must be called once before the template is invoked.
|
|
885 |
Parses the data, and sets internal data needed for certain output format. Must be called once before the template is invoked. |
|
884 | 886 |
Should not be called extrenally, since all render and generate functions invoke it anyway. |
885 |
|
|
887 |
|
|
886 | 888 |
=item generate_html_content |
887 | 889 |
|
888 | 890 |
The html generation function. Is invoked by generate_with_headers. |
... | ... | |
939 | 941 |
|
940 | 942 |
Landscape or portrait. Default is landscape. |
941 | 943 |
|
942 |
=item font_name
|
|
944 |
=item font_name |
|
943 | 945 |
|
944 | 946 |
Default is Verdana. Supported font names are Courier, Georgia, Helvetica, Times and Verdana. This option only affects the rendering with PDF::API2. |
945 | 947 |
|
SL/TODO.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use SL::DBUtils; |
6 | 6 |
|
7 |
use strict; |
|
8 |
|
|
7 | 9 |
sub get_user_config { |
8 | 10 |
$main::lxdebug->enter_sub(); |
9 | 11 |
|
SL/USTVA.pm | ||
---|---|---|
29 | 29 |
|
30 | 30 |
use SL::DBUtils; |
31 | 31 |
|
32 |
use strict; |
|
33 |
|
|
32 | 34 |
my @tax_office_information = ( |
33 | 35 |
{ 'id' => 8, 'name' => 'Baden W?rttemberg', 'taxbird_nr' => '0', 'elster_format' => 'FF/BBB/UUUUP', }, |
34 | 36 |
{ 'id' => 9, 'name' => 'Bayern', 'taxbird_nr' => '1', 'elster_format' => 'FFF/BBB/UUUUP', }, |
... | ... | |
145 | 147 |
sub create_steuernummer { |
146 | 148 |
$main::lxdebug->enter_sub(); |
147 | 149 |
|
148 |
$part = $form->{part}; |
|
149 |
$patterncount = $form->{patterncount}; |
|
150 |
$delimiter = $form->{delimiter}; |
|
151 |
$elster_pattern = $form->{elster_pattern}; |
|
150 |
my $form = $main::form; |
|
151 |
|
|
152 |
our ($elster_FFFF); |
|
153 |
|
|
154 |
my $part = $form->{part}; |
|
155 |
my $patterncount = $form->{patterncount}; |
|
156 |
my $delimiter = $form->{delimiter}; |
|
157 |
my $elster_pattern = $form->{elster_pattern}; |
|
152 | 158 |
|
153 | 159 |
# rebuild steuernummer and elstersteuernummer |
154 | 160 |
# es gibt eine gespeicherte steuernummer $form->{steuernummer} |
... | ... | |
157 | 163 |
my $h = 0; |
158 | 164 |
my $i = 0; |
159 | 165 |
|
160 |
$steuernummer_new = $part; |
|
161 |
$elstersteuernummer_new = $elster_FFFF; |
|
162 |
$elstersteuernummer_new .= '0'; |
|
166 |
my $steuernummer_new = $part;
|
|
167 |
my $elstersteuernummer_new = $elster_FFFF;
|
|
168 |
$elstersteuernummer_new .= '0';
|
|
163 | 169 |
|
164 | 170 |
for ($h = 1; $h < $patterncount; $h++) { |
165 | 171 |
$steuernummer_new .= qq|$delimiter|; |
... | ... | |
181 | 187 |
$main::lxdebug->enter_sub(); |
182 | 188 |
|
183 | 189 |
my ($self, $elsterland, $elsterFFFF, $steuernummer) = @_; |
190 |
our ($elster_FFFF, $elster_land); |
|
184 | 191 |
|
185 | 192 |
my $steuernummer_input = ''; |
186 | 193 |
|
... | ... | |
286 | 293 |
my $ffff = ''; |
287 | 294 |
my $checked = ''; |
288 | 295 |
$checked = 'checked' if ($elsterFFFF eq '' and $land eq ''); |
296 |
my %elster_land_fa; |
|
289 | 297 |
|
290 | 298 |
my $fa_auswahl = qq| |
291 | 299 |
<script language="Javascript"> |
... | ... | |
297 | 305 |
elsterFAAuswahl.options.length = 0; // dropdown aufr?umen |
298 | 306 |
|; |
299 | 307 |
|
300 |
foreach $elster_land (sort keys %$elster_init) { |
|
308 |
foreach my $elster_land (sort keys %$elster_init) {
|
|
301 | 309 |
$fa_auswahl .= qq| |
302 | 310 |
if (elsterBLAuswahl.options[elsterBLAuswahl.selectedIndex]. |
303 | 311 |
value == "$elster_land") |
304 | 312 |
{ |
305 | 313 |
|; |
306 | 314 |
my $j = 0; |
307 |
my %elster_land_fa = ();
|
|
315 |
%elster_land_fa = (); |
|
308 | 316 |
$FFFF = ''; |
309 | 317 |
for $FFFF (keys %{ $elster_init->{$elster_land} }) { |
310 | 318 |
$elster_land_fa{$FFFF} = $elster_init->{$elster_land}->{$FFFF}->[0]; |
... | ... | |
333 | 341 |
if ($land eq '') { |
334 | 342 |
$fa_auswahl .= qq|<option value="Auswahl" $checked>| . $main::locale->text('Select federal state...') . qq|</option>\n|; |
335 | 343 |
} |
336 |
foreach $elster_land (sort keys %$elster_init) { |
|
344 |
foreach my $elster_land (sort keys %$elster_init) {
|
|
337 | 345 |
$fa_auswahl .= qq| |
338 | 346 |
<option value="$elster_land"|; |
339 | 347 |
if ($elster_land eq $land and $checked eq '') { |
... | ... | |
414 | 422 |
$main::lxdebug->leave_sub(); |
415 | 423 |
} |
416 | 424 |
|
425 |
# 20.10.2009 sschoeling: this sub seems to be orphaned. |
|
417 | 426 |
sub stichtag { |
418 | 427 |
$main::lxdebug->enter_sub(); |
419 | 428 |
|
... | ... | |
428 | 437 |
|
429 | 438 |
#$today =today * 1; |
430 | 439 |
$today =~ /(\d\d\d\d)(\d\d)(\d\d)/; |
431 |
$year = $1; |
|
432 |
$month = $2; |
|
433 |
$day = $3; |
|
434 |
$yy = $year; |
|
435 |
$mm = $month; |
|
436 |
$yymmdd = "$year$month$day" * 1; |
|
437 |
$mmdd = "$month$day" * 1; |
|
438 |
$stichtag = ''; |
|
440 |
my $year = $1;
|
|
441 |
my $month = $2;
|
|
442 |
my $day = $3;
|
|
443 |
my $yy = $year;
|
|
444 |
my $mm = $month;
|
|
445 |
my $yymmdd = "$year$month$day" * 1;
|
|
446 |
my $mmdd = "$month$day" * 1;
|
|
447 |
my $stichtag = '';
|
|
439 | 448 |
|
440 | 449 |
#$tage_bis = '1234'; |
441 | 450 |
#$ical = '...vcal format'; |
442 | 451 |
|
443 | 452 |
#if ($FA_voranmeld eq 'month'){ |
444 | 453 |
|
445 |
%liste = ("0110" => 'December', |
|
446 |
"0210" => 'January', |
|
447 |
"0310" => 'February', |
|
448 |
"0410" => 'March', |
|
449 |
"0510" => 'April', |
|
450 |
"0610" => 'May', |
|
451 |
"0710" => 'June', |
|
452 |
"0810" => 'July', |
|
453 |
"0910" => 'August', |
|
454 |
"1010" => 'September', |
|
455 |
"1110" => 'October', |
|
456 |
"1210" => 'November'); |
|
454 |
my %liste = ( |
|
455 |
"0110" => 'December', |
|
456 |
"0210" => 'January', |
|
457 |
"0310" => 'February', |
|
458 |
"0410" => 'March', |
|
459 |
"0510" => 'April', |
|
460 |
"0610" => 'May', |
|
461 |
"0710" => 'June', |
|
462 |
"0810" => 'July', |
|
463 |
"0910" => 'August', |
|
464 |
"1010" => 'September', |
|
465 |
"1110" => 'October', |
|
466 |
"1210" => 'November', |
|
467 |
); |
|
457 | 468 |
|
458 | 469 |
#$mm += $dauerfrist |
459 | 470 |
#$month *= 1; |
460 | 471 |
$month += 1 if ($day > 10); |
461 | 472 |
$month = sprintf("%02d", $month); |
462 | 473 |
$stichtag = $year . $month . "10"; |
463 |
$ust_va = $month . "10"; |
|
474 |
my $ust_va = $month . "10";
|
|
464 | 475 |
|
465 |
foreach $date (%liste) { |
|
476 |
foreach my $date (%liste) {
|
|
466 | 477 |
$ust_va = $liste{$date} if ($date eq $stichtag); |
467 | 478 |
} |
468 | 479 |
|
... | ... | |
486 | 497 |
#$stichtag =~ /([\d]\d)(\d\d)$/ |
487 | 498 |
#$stichtag = "$1.$2.$yy" |
488 | 499 |
#$stichtag=$1; |
500 |
our $description; # most probably not existant. |
|
501 |
our $tage_bis; # most probably not existant. |
|
502 |
our $ical; # most probably not existant. |
|
503 |
|
|
489 | 504 |
$main::lxdebug->leave_sub(); |
490 | 505 |
return ($stichtag, $description, $tage_bis, $ical); |
491 | 506 |
} |
... | ... | |
557 | 572 |
$sth->execute || $form->dberror($query); |
558 | 573 |
my $array_ref = $sth->fetchall_arrayref(); |
559 | 574 |
my $land = ''; |
575 |
my %finanzamt; |
|
560 | 576 |
foreach my $row (@$array_ref) { |
561 | 577 |
my $FA_finanzamt = $row; |
562 | 578 |
my $tax_office = first { $_->{id} == $FA_finanzamt->[0] } @{ $self->{tax_office_information} }; |
... | ... | |
679 | 695 |
|
680 | 696 |
$form->{decimalplaces} *= 1; |
681 | 697 |
|
682 |
foreach $item (@category_cent) { |
|
698 |
foreach my $item (@category_cent) {
|
|
683 | 699 |
$form->{"$item"} = 0; |
684 | 700 |
} |
685 |
foreach $item (@category_euro) { |
|
701 |
foreach my $item (@category_euro) {
|
|
686 | 702 |
$form->{"$item"} = 0; |
687 | 703 |
} |
688 | 704 |
my $coa_name = coa_get($dbh); |
... | ... | |
691 | 707 |
# Controlvariable for templates |
692 | 708 |
$form->{"$coa_name"} = '1'; |
693 | 709 |
|
694 |
$main::lxdebug->message(LXDebug::DEBUG2, "COA: '$form->{coa}', \$form->{$coa_name} = 1");
|
|
710 |
$main::lxdebug->message(LXDebug->DEBUG2(), "COA: '$form->{coa}', \$form->{$coa_name} = 1");
|
|
695 | 711 |
|
696 | 712 |
&get_accounts_ustva($dbh, $last_period, $form->{fromdate}, $form->{todate}, |
697 | 713 |
$form, $category); |
... | ... | |
762 | 778 |
sub coa_get { |
763 | 779 |
|
764 | 780 |
my ($dbh) = @_; |
781 |
my $form = $main::form; |
|
765 | 782 |
|
766 | 783 |
my $query= qq|SELECT coa FROM defaults|; |
767 | 784 |
|
... | ... | |
769 | 786 |
|
770 | 787 |
$sth->execute || $form->dberror($query); |
771 | 788 |
|
772 |
($ref) = $sth->fetchrow_array; |
|
789 |
my ($ref) = $sth->fetchrow_array;
|
|
773 | 790 |
|
774 | 791 |
return $ref; |
775 | 792 |
|
... | ... | |
779 | 796 |
$main::lxdebug->enter_sub(); |
780 | 797 |
|
781 | 798 |
my ($dbh, $last_period, $fromdate, $todate, $form, $category) = @_; |
799 |
our ($dpt_join); |
|
782 | 800 |
|
783 | 801 |
my $query; |
784 | 802 |
my $where = ""; |
... | ... | |
987 | 1005 |
my $ref; |
988 | 1006 |
|
989 | 1007 |
# Show all $query in Debuglevel LXDebug::QUERY |
990 |
$callingdetails = (caller (0))[3]; |
|
991 |
$main::lxdebug->message(LXDebug::QUERY, "$callingdetails \$query=\n $query");
|
|
1008 |
my $callingdetails = (caller (0))[3];
|
|
1009 |
$main::lxdebug->message(LXDebug->QUERY(), "$callingdetails \$query=\n $query");
|
|
992 | 1010 |
|
993 | 1011 |
my $sth = $dbh->prepare($query); |
994 | 1012 |
|
995 | 1013 |
$sth->execute || $form->dberror($query); |
996 | 1014 |
|
997 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
1015 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
998 | 1016 |
# Bug 365 solved?! |
999 | 1017 |
$ref->{amount} *= -1; |
1000 | 1018 |
$form->{ $ref->{$category} } += $ref->{amount}; |
... | ... | |
1011 | 1029 |
|
1012 | 1030 |
my ($self, $userspath, $filename) = @_; |
1013 | 1031 |
|
1014 |
$form->error("Missing Parameter: @_") if !$userspath || !$filename; |
|
1015 |
|
|
1016 | 1032 |
my $form = $main::form; |
1017 | 1033 |
|
1034 |
$form->error("Missing Parameter: @_") if !$userspath || !$filename; |
|
1035 |
|
|
1018 | 1036 |
$filename = "$form->{login}_$filename"; |
1019 | 1037 |
$filename =~ s|.*/||; |
1020 | 1038 |
$filename = "$userspath/$filename"; |
1021 |
open my $FACONF, "<", $filename or sub {# Annon Sub
|
|
1039 |
open my $FACONF, "<", $filename or do {# Annon Sub
|
|
1022 | 1040 |
# catch open error |
1023 | 1041 |
# create file if file does not exist |
1024 | 1042 |
open my $FANEW, ">", $filename or $form->error("CREATE: $filename : $!"); |
SL/User.pm | ||
---|---|---|
445 | 445 |
|
446 | 446 |
$dbh->begin_work(); |
447 | 447 |
|
448 |
# setup dbup_ export vars |
|
448 | 449 |
my %dbup_myconfig = (); |
449 | 450 |
map({ $dbup_myconfig{$_} = $form->{$_}; } |
450 | 451 |
qw(dbname dbuser dbpasswd dbhost dbport dbconnect)); |
SL/Watchdog.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
require Tie::Hash; |
6 | 6 |
|
7 |
@ISA = (Tie::StdHash); |
|
7 |
our @ISA = qw(Tie::StdHash); |
|
8 |
|
|
9 |
use strict; |
|
8 | 10 |
|
9 | 11 |
my %watched_variables; |
10 | 12 |
|
sql/Pg-upgrade2/USTVA_abstraction.pl | ||
---|---|---|
8 | 8 |
|
9 | 9 |
################### |
10 | 10 |
|
11 |
use strict; |
|
12 |
|
|
11 | 13 |
die("This script cannot be run from the command line.") unless ($main::form); |
12 | 14 |
|
15 |
# import vars from caller |
|
16 |
our ($dbup_locale, $dbup_myconfig, $dbh, $iconv); |
|
17 |
|
|
13 | 18 |
sub mydberror { |
14 | 19 |
my ($msg) = @_; |
15 | 20 |
die($dbup_locale->text("Database update error:") . |
sql/Pg-upgrade2/USTVA_at.pl | ||
---|---|---|
2 | 2 |
# @description: USTVA Report Daten fuer Oesterreich. Vielen Dank an Gerhard Winkler.. |
3 | 3 |
# @depends: USTVA_abstraction |
4 | 4 |
|
5 |
unless ( $main::form ) { |
|
5 |
use strict; |
|
6 |
|
|
7 |
unless ( $main::form ) { |
|
6 | 8 |
die("This script cannot be run from the command line."); |
7 | 9 |
} |
8 | 10 |
|
11 |
# import vars from caller |
|
12 |
our ($dbup_locale, $dbup_myconfig, $dbh, $iconv); |
|
13 |
|
|
9 | 14 |
if ( check_coa('Austria') ){ |
10 | 15 |
|
11 | 16 |
if ( coa_is_empty() ) { |
12 | 17 |
print qq|Eine leere Datenbank mit Kontenrahmen ?sterreich vorgefunden. <br /> |
13 | 18 |
Die Aktualisierungen werden eingespielt...<br /> |
14 | 19 |
<b>Achtung: Dieses Update ist ungetestet und bedarf weiterer Konfiguration</b>|; |
15 |
|
|
20 |
|
|
16 | 21 |
return 1 |
17 |
&& clear_tables(( 'tax.report_variables', 'tax.report_headings',
|
|
18 |
'tax.report_categorys', 'taxkeys',
|
|
22 |
&& clear_tables(( 'tax.report_variables', 'tax.report_headings', |
|
23 |
'tax.report_categorys', 'taxkeys', |
|
19 | 24 |
'tax', 'chart', |
20 | 25 |
'buchungsgruppen', |
21 | 26 |
)) |
... | ... | |
25 | 30 |
&& do_insert_taxkeys() |
26 | 31 |
&& do_insert_buchungsgruppen() |
27 | 32 |
; |
28 |
}
|
|
33 |
} |
|
29 | 34 |
else { |
30 |
print qq|Eine ?sterreichische Datenbank in der bereits Buchungss?tze enthalten sind, kann nicht aktualisiert werden.<br />
|
|
35 |
print qq|Eine ?sterreichische Datenbank in der bereits Buchungss?tze enthalten sind, kann nicht aktualisiert werden.<br /> |
|
31 | 36 |
Bitte eine neue Datenbank mit Kontenrahmen 'Austria' anlegen.|; |
32 | 37 |
return 1; |
33 | 38 |
} |
... | ... | |
76 | 81 |
} |
77 | 82 |
|
78 | 83 |
sub check_coa { |
79 |
|
|
84 |
|
|
80 | 85 |
my ( $want_coa ) = @_; |
81 |
|
|
86 |
|
|
82 | 87 |
my $query = q{ SELECT count(*) FROM defaults WHERE coa = ? }; |
83 |
my ($have_coa) = selectrow_query($form, $dbh, $query, $want_coa); |
|
88 |
my ($have_coa) = selectrow_query($main::form, $dbh, $query, $want_coa);
|
|
84 | 89 |
|
85 | 90 |
return $have_coa; |
86 | 91 |
|
87 | 92 |
} |
88 | 93 |
|
89 | 94 |
sub coa_is_empty { |
90 |
|
|
91 |
my $query = q{ SELECT count(*)
|
|
95 |
|
|
96 |
my $query = q{ SELECT count(*) |
|
92 | 97 |
FROM ar, ap, gl, invoice, acc_trans, customer, vendor, parts |
93 | 98 |
}; |
94 |
my ($empty) = selectrow_query($form, $dbh, $query); |
|
99 |
my ($empty) = selectrow_query($main::form, $dbh, $query);
|
|
95 | 100 |
|
96 | 101 |
$empty = !$empty; |
97 | 102 |
|
... | ... | |
106 | 111 |
"INSERT INTO tax.report_headings (id, category_id, type, description, subdescription) VALUES (0, 0, NULL, NULL, NULL)", |
107 | 112 |
); |
108 | 113 |
|
109 |
map({ do_query($_); } @queries);
|
|
114 |
map({ do_query($_); } @queries); |
|
110 | 115 |
|
111 | 116 |
|
112 | 117 |
my @copy_statements = ( |
113 | 118 |
"INSERT INTO tax.report_variables (id, position, heading_id, description, dec_places, valid_from) VALUES (?, ?, ?, ?, ?, ?)", |
114 | 119 |
); |
115 | 120 |
|
116 |
|
|
121 |
|
|
117 | 122 |
my @copy_data = ( |
118 |
[
|
|
123 |
[ |
|
119 | 124 |
"1;000;0;a) Gesamtbetrag der Bemessungsgrundlage f?r Lieferungen und sonstige Leistungen (ohne den nachstehend angef?hrten Eigenverbrauch) einschlie?lich Anzahlungen (jeweils ohne Umsatzsteuer);2;1970-01-01", |
120 | 125 |
"2;001;0;zuz?glich Eigenverbrauch (?1 Abs. 1 Z 2, ? 3 Abs. 2 und ? 3a Abs. 1a);2;1970-01-01", |
121 | 126 |
"3;021;0;abz?glich Ums?tze f?r die die Steuerschuld gem?? ? 19 Abs. 1 zweiter Satz sowie gem?? ? 19 Abs. 1a, Abs. 1b, Abs. 1c auf den Leistungsempf?nger ?bergegangen ist.;2;1970-01-01", |
... | ... | |
355 | 360 |
return 1; |
356 | 361 |
} |
357 | 362 |
sub do_insert_tax { |
358 |
|
|
363 |
|
|
359 | 364 |
my @copy_statements = ( |
360 | 365 |
"INSERT INTO tax (chart_id, taxnumber, taxkey, taxdescription, itime, mtime, rate, id) VALUES (65, '2510', 7, 'Vorsteuer 10%', '2006-01-30 11:08:23.332857', '2006-02-08 20:28:09.63567', 0.10000, 173);", |
361 | 366 |
"INSERT INTO tax (chart_id, taxnumber, taxkey, taxdescription, itime, mtime, rate, id) VALUES (64, '2512', 8, 'Vorsteuer 12%', '2006-02-02 17:39:18.535036', '2006-02-08 20:28:21.463869', 0.12000, 174);", |
... | ... | |
366 | 371 |
"INSERT INTO tax (chart_id, taxnumber, taxkey, taxdescription, itime, mtime, rate, id) VALUES (NULL, NULL, 10, 'Im anderen EG-Staat steuerpfl. Lieferung', '2006-01-30 11:08:23.332857', '2006-02-08 12:45:36.44088', NULL, 171);", |
367 | 372 |
"INSERT INTO tax (chart_id, taxnumber, taxkey, taxdescription, itime, mtime, rate, id) VALUES (NULL, NULL, 11, 'Steuerfreie EG-Lief. an Abn. mit UStIdNr', '2006-01-30 11:08:23.332857', '2006-02-08 12:45:36.44088', NULL, 172);", |
368 | 373 |
"INSERT INTO tax (chart_id, taxnumber, taxkey, taxdescription, itime, mtime, rate, id) VALUES (NULL, NULL, 0, 'Keine Steuer', '2006-01-30 11:08:23.332857', '2006-02-08 12:45:36.44088', 0.00000, 0);", |
369 |
|
|
374 |
|
|
370 | 375 |
); |
371 | 376 |
|
372 | 377 |
for my $statement ( 0 .. $#copy_statements ) { |
... | ... | |
378 | 383 |
} |
379 | 384 |
|
380 | 385 |
sub do_insert_taxkeys { |
381 |
|
|
386 |
|
|
382 | 387 |
my @copy_statements = ( |
383 | 388 |
"INSERT INTO taxkeys VALUES (230, 69, 177, 2, NULL, '1970-01-01');", |
384 | 389 |
"INSERT INTO taxkeys VALUES (231, 72, 178, 3, NULL, '1970-01-01');", |
... | ... | |
476 | 481 |
"UPDATE taxkeys SET pos_ustva='017' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('4015', '4025', '4035', '4045', '4315', '4325', '4335', '4345'));", |
477 | 482 |
"UPDATE taxkeys SET pos_ustva='022' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('4040', '4045'));", |
478 | 483 |
"UPDATE taxkeys SET pos_ustva='122' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('3520'));", |
479 |
"UPDATE taxkeys SET pos_ustva='029' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('4010', '4015'));",
|
|
484 |
"UPDATE taxkeys SET pos_ustva='029' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('4010', '4015'));", |
|
480 | 485 |
"UPDATE taxkeys SET pos_ustva='129' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('3510'));", |
481 | 486 |
"UPDATE taxkeys SET pos_ustva='025' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('4012'));", |
482 | 487 |
"UPDATE taxkeys SET pos_ustva='125' WHERE chart_id IN (SELECT id FROM chart WHERE accno IN ('3512'));", |
sql/Pg-upgrade2/cp_greeting_migration.pl | ||
---|---|---|
2 | 2 |
# @description: Migration of cp_greeting to cp_gender |
3 | 3 |
# @depends: generic_translations |
4 | 4 |
|
5 |
use strict; |
|
6 |
|
|
5 | 7 |
die("This script cannot be run from the command line.") unless ($main::form); |
6 | 8 |
|
9 |
# import vars from caller |
|
10 |
our ($dbup_locale, $dbup_myconfig, $dbh, $iconv); |
|
7 | 11 |
|
8 | 12 |
sub mydberror { |
9 | 13 |
my ($msg) = @_; |
... | ... | |
26 | 30 |
|
27 | 31 |
# list of all entries where cp_greeting is empty, meaning can't determine gender from parsing Herr/Frau/... |
28 | 32 |
# this assumes cp_greeting still exists, i.e. gender.sql was not run yet |
29 |
my $gender_table;
|
|
33 |
my ($gender_table, $mchecked, $fchecked);
|
|
30 | 34 |
|
31 | 35 |
my $sql2 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%') "; |
32 | 36 |
my $sth2 = $dbh->prepare($sql2) or die $dbh->errstr(); |
33 |
$sth2->execute() or die $dbh->errstr();
|
|
37 |
$sth2->execute() or die $dbh->errstr(); |
|
34 | 38 |
|
35 |
my $i = 1;
|
|
39 |
my $i = 1; |
|
36 | 40 |
$gender_table .= '<table border="1"><tr><th>cp_givenname</th><th>cp_name</th><th>cp_title</th><th>cp_greeting</th><th><translate>male/female</th></tr>'; |
37 | 41 |
$gender_table .= "\n"; |
38 | 42 |
|
39 | 43 |
while (my $row = $sth2->fetchrow_hashref()) { |
40 |
if ( main::form->{"gender_$i"} eq "f" ) {
|
|
44 |
if ($main::form->{"gender_$i"} eq "f" ) {
|
|
41 | 45 |
$mchecked = ""; |
42 | 46 |
$fchecked = "checked"; |
43 | 47 |
} else { |
44 | 48 |
$mchecked = "checked"; |
45 | 49 |
$fchecked = ""; |
46 | 50 |
}; |
47 |
|
|
51 |
|
|
48 | 52 |
$gender_table .= "<tr><input type=hidden name=\"cp_id_$i\" value=\"$row->{cp_id}\"> <td>$row->{cp_givenname}</td> <td>$row->{cp_name}</td> <td>$row->{cp_title} </td> <td>$row->{cp_greeting} </td><td> <input type=\"radio\" name=\"gender_$i\" value=\"m\" $mchecked> <input type=\"radio\" name=\"gender_$i\" value=\"f\" $fchecked></td></tr>\n"; |
49 | 53 |
$i++; |
50 | 54 |
}; |
51 | 55 |
|
52 |
$gender_table .= "<input type=hidden name=\"number_of_gender_entries\" value=\"$i\">";
|
|
56 |
$gender_table .= "<input type=hidden name=\"number_of_gender_entries\" value=\"$i\">"; |
|
53 | 57 |
$gender_table .= "</table>"; |
54 | 58 |
|
55 | 59 |
$main::form->{gender_table} = $gender_table; |
56 | 60 |
|
57 | 61 |
my $title_table; |
58 |
|
|
62 |
|
|
59 | 63 |
my $sql3 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not ( (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%')) and not (cp_greeting like ''); "; |
60 | 64 |
|
61 | 65 |
my $sth3 = $dbh->prepare($sql3) or die $dbh->errstr(); |
62 |
$sth3->execute() or die $dbh->errstr();
|
|
66 |
$sth3->execute() or die $dbh->errstr(); |
|
63 | 67 |
|
64 | 68 |
$title_table = '<table border="1"><tr><th>cp_givenname</th><th>cp_name</th><th>cp_title</th><th>cp_greeting</th><th>cp_title new</th></tr>'; |
65 | 69 |
|
... | ... | |
74 | 78 |
$j++; |
75 | 79 |
}; |
76 | 80 |
|
77 |
$title_table .= "<input type=hidden name=\"number_of_title_entries\" value=\"$j\">";
|
|
81 |
$title_table .= "<input type=hidden name=\"number_of_title_entries\" value=\"$j\">"; |
|
78 | 82 |
$title_table .= "</table>"; |
79 | 83 |
$main::form->{title_table} = $title_table; |
80 | 84 |
|
sql/Pg-upgrade2/globalprojectnumber_ap_ar_oe.pl | ||
---|---|---|
2 | 2 |
# @description: Neue Spalte für eine globale Projektnummer in Einkaufs- und Verkaufsbelegen |
3 | 3 |
# @depends: release_2_4_1 |
4 | 4 |
|
5 |
use strict; |
|
6 |
|
|
7 |
# import vars from caller |
|
8 |
our ($dbup_locale, $dbup_myconfig, $dbh); |
|
9 |
|
|
5 | 10 |
die("This script cannot be run from the command line.") unless ($main::form); |
6 | 11 |
|
7 | 12 |
sub mydberror { |
sql/Pg-upgrade2/warehouse.pl | ||
---|---|---|
2 | 2 |
# @description: Diverse neue Tabellen und Spalten zur Mehrlagerfähigkeit inkl. Migration |
3 | 3 |
# @depends: release_2_4_3 |
4 | 4 |
|
5 |
use strict; |
|
5 | 6 |
|
6 | 7 |
die("This script cannot be run from the command line.") unless ($main::form); |
7 | 8 |
|
9 |
# import vars from caller |
|
10 |
our ($dbup_locale, $dbup_myconfig, $dbh, $iconv); |
|
11 |
my $do_sql_migration = 0; |
|
12 |
my ($check_sql, $sqlcode); |
|
13 |
|
|
8 | 14 |
sub mydberror { |
9 | 15 |
my ($msg) = @_; |
10 | 16 |
die($dbup_locale->text("Database update error:") . |
... | ... | |
21 | 27 |
} |
22 | 28 |
} |
23 | 29 |
|
24 |
$do_sql_migration = 0; |
|
25 | 30 |
|
26 | 31 |
sub print_question { |
27 | 32 |
print $main::form->parse_html_template("dbupgrade/warehouse_form"); |
... | ... | |
57 | 62 |
UPDATE tmp_parts SET bin = NULL WHERE bin = ''; |
58 | 63 |
|
59 | 64 |
-- Restore old onhand |
60 |
INSERT INTO bin
|
|
61 |
(warehouse_id, description)
|
|
62 |
(SELECT DISTINCT warehouse.id, COALESCE(bin, $bin)
|
|
63 |
FROM warehouse, tmp_parts
|
|
65 |
INSERT INTO bin |
|
66 |
(warehouse_id, description) |
|
67 |
(SELECT DISTINCT warehouse.id, COALESCE(bin, $bin) |
|
68 |
FROM warehouse, tmp_parts |
|
64 | 69 |
WHERE warehouse.description=$warehouse); |
65 |
INSERT INTO inventory
|
|
70 |
INSERT INTO inventory |
|
66 | 71 |
(warehouse_id, parts_id, bin_id, qty, employee_id, trans_id, trans_type_id, chargenumber) |
67 | 72 |
(SELECT warehouse.id, tmp_parts.id, bin.id, onhand, (SELECT id FROM employee LIMIT 1), nextval('id'), transfer_type.id, '' |
68 | 73 |
FROM transfer_type, warehouse, tmp_parts, bin |
69 | 74 |
WHERE warehouse.description = $warehouse |
70 |
AND COALESCE(bin, $bin) = bin.description
|
|
75 |
AND COALESCE(bin, $bin) = bin.description |
|
71 | 76 |
AND transfer_type.description = 'stock'); |
72 | 77 |
EOF |
73 | 78 |
; |
Auch abrufbar als: Unified diff
Und wieder ein Schwung strict.