Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c621a918

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID c621a9187eb258019fa540490de21b248c709516
  • Vorgänger 80f6efd0
  • Nachfolger ed944ca3

strictness für Menu und Ca

Unterschiede anzeigen:

SL/CA.pm
38 38
use Data::Dumper;
39 39
use SL::DBUtils;
40 40

  
41
use strict;
42

  
41 43
sub all_accounts {
42 44
  $main::lxdebug->enter_sub();
43 45

  
44 46
  my ($self, $myconfig, $form, $chart_id) = @_;
45 47

  
46
  my %amount;
48
  my (%amount, $acc_cash_where);
47 49

  
48 50
  # connect to database
49 51
  my $dbh = $form->dbconnect($myconfig);
......
104 106

  
105 107
  $form->{CA} = [];
106 108

  
107
  while (my $ca = $sth->fetchrow_hashref(NAME_lc)) {
109
  while (my $ca = $sth->fetchrow_hashref("NAME_lc")) {
108 110
    $ca->{amount} = $amount{ $ca->{accno} };
109 111
    if ($ca->{amount} < 0) {
110 112
      $ca->{debit} = $ca->{amount} * -1;
......
145 147
  #    $where .= " AND ac.transdate <= '$form->{todate}'";
146 148
  #  }
147 149

  
148
  my (@values, @where_values, @subwhere_values);
150
  my (@values, @where_values, @subwhere_values, $subwhere);
149 151
  if ($form->{fromdate}) {
150 152
    $where .= qq| AND ac.transdate >= ?|;
151 153
    $subwhere .= qq| AND transdate >= ?|;
......
163 165

  
164 166
  my $sortorder = join ', ',
165 167
    $form->sort_columns(qw(transdate reference description));
166
  my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|;
168
  my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|;
167 169

  
168 170
  # Oracle workaround, use ordinal positions
169 171
  my %ordinal = (transdate   => 4,
......
236 238
      ($form->{old_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{fromdate}, $form->{accno});
237 239

  
238 240
      # get current saldo
239
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
241
      $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
240 242
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id) WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
241 243
      ($form->{saldo_new}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
242 244

  
243 245
      #get current balance
244
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
246
      $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
245 247
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id) WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount < 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
246 248
      ($form->{current_balance_debit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
247 249

  
248
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
250
      $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
249 251
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount > 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
250 252
      ($form->{current_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
251 253
    }
......
301 303
      qq|WHERE | . $where . $dpt_where . $project .
302 304
      qq| AND ac.chart_id = ? | .
303 305
      qq| AND ac.trans_id = a.id | .
304
      qq| AND a.vendor_id = v.id |;
306
      qq| AND a.vendor_id = v.id | .
305 307
      qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)| .
306 308
    push(@values,
307 309
         @where_values, @department_values, @project_values, $id,
......
315 317
      $fromdate_where =~ s/ac\./a\./;
316 318
      $todate_where   =~ s/ac\./a\./;
317 319

  
320
# strict check 20.10.2009 sschoeling
321
# the previous version contained the var $ar_ap_cash_where, which was ONLY set by
322
# RP->trial_balance() I tried to figure out which bizarre flow through the
323
# program would happen to set that var, so that it would be used here later on,
324
# (which would be nonsense, since you would normally load chart before
325
# claculating balance of said charts) and then decided that any mechanic that
326
# complex should fail anyway.
327

  
328
# if anyone is missing a time check on charts, that broke arounf the time
329
# trial_balance was rewritten, this would be it
330

  
318 331
      $query .=
319 332
        qq|UNION ALL | .
320 333

  
......
331 344
        $todate_where .
332 345
        $dpt_where .
333 346
        $project .
334
        $ar_ap_cash_where .
335 347
        qq|UNION ALL | .
336 348

  
337 349
        qq|SELECT a.id, a.invnumber, v.name, a.transdate, | .
......
346 358
        $fromdate_where .
347 359
        $todate_where .
348 360
        $dpt_where .
349
        $project .
350
        $ar_ap_cash_where;
361
        $project;
351 362
      push(@values,
352 363
           $id, @department_values, @project_values,
353 364
           $id, @department_values, @project_values);
......
363 374
  my $sort = grep({ $form->{sort} eq $_ } qw(transdate reference description)) ? $form->{sort} : 'transdate';
364 375

  
365 376
  $query .= qq|ORDER BY $sort|;
366
  $sth = prepare_execute_query($form, $dbh, $query, @values);
377
  my $sth = prepare_execute_query($form, $dbh, $query, @values);
367 378

  
368 379
  #get detail information for each transaction
369
  $trans_query =
380
  my $trans_query =
370 381
        qq|SELECT accno, | .
371 382
        qq|amount, transdate FROM acc_trans LEFT JOIN chart ON (chart_id=chart.id) WHERE | .
372 383
        qq|trans_id = ? AND sign(amount) <> sign(?) AND chart_id <> ? AND transdate = ?|;
373 384
  my $trans_sth = $dbh->prepare($trans_query);
374 385

  
375 386
  $form->{CA} = [];
376
  while (my $ca = $sth->fetchrow_hashref(NAME_lc)) {
387
  while (my $ca = $sth->fetchrow_hashref("NAME_lc")) {
377 388
    # ap
378 389
    if ($ca->{module} eq "ap") {
379 390
      $ca->{module} = ($ca->{invoice}) ? 'ir' : 'ap';
......
397 408
    #get detail information for this transaction
398 409
    $trans_sth->execute($ca->{id}, $ca->{amount}, $ca->{chart_id}, $ca->{transdate}) ||
399 410
    $form->dberror($trans_query . " (" . join(", ", $ca->{id}) . ")");
400
    while (my $trans = $trans_sth->fetchrow_hashref(NAME_lc)) {
411
    while (my $trans = $trans_sth->fetchrow_hashref("NAME_lc")) {
401 412
      if (($ca->{transdate} eq $trans->{transdate}) && ($ca->{amount} * $trans->{amount} < 0)) {
402 413
        if ($trans->{amount} < 0) {
403 414
          $trans->{debit}  = $trans->{amount} * -1;
SL/Menu.pm
37 37
use SL::Auth;
38 38
use SL::Inifile;
39 39

  
40
use strict;
41

  
40 42
sub new {
41 43
  $main::lxdebug->enter_sub();
42 44

  
......
91 93
  # add other params
92 94
  foreach my $key (keys %{ $self->{$item} }) {
93 95
    $str .= "&" . $form->escape($key, 1) . "=";
94
    ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
96
    my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
95 97
    $value = $myconfig->{$value} . "/$conf" if ($conf);
96 98
    $str .= $form->escape($value, 1);
97 99
  }
......
135 137
  # add other params
136 138
  foreach my $key (keys %{ $self->{$item} }) {
137 139
    $str .= "&" . $form->escape($key, 1) . "=";
138
    ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
140
    my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
139 141
    $value = $myconfig->{$value} . "/$conf" if ($conf);
140 142
    $str .= $form->escape($value, 1);
141 143
  }
......
149 151

  
150 152
  my ($self, $name, $item) = @_;
151 153

  
152
  my $form        = $main::form;
154
  my $form        =  $main::form;
155
  my $myconfig    = \%main::myconfig;
153 156

  
154 157
  my $module      = $self->{$name}->{module} || $form->{script};
155 158
  my $action      = $self->{$name}->{action};
......
207 210
  # add other params
208 211
  foreach my $key (keys %{ $self->{$item} }) {
209 212
    $str .= "&" . $form->escape($key, 1) . "=";
210
    ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
213
    my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
211 214
    $value = $myconfig->{$value} . "/$conf" if ($conf);
212 215
    $str .= $form->escape($value, 1);
213 216
  }
......
267 270
  # add other params
268 271
  foreach my $key (keys %{ $self->{$item} }) {
269 272
    $str .= "&amp;" . $form->escape($key, 1) . "=";
270
    ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
273
    my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
271 274
    $value = $myconfig->{$value} . "/$conf" if ($conf);
272 275
    $str .= $form->escape($value, 1);
273 276
  }
......
311 314
  my $key    = shift;
312 315
  my $access = shift;
313 316

  
317
  my $form        =  $main::form;
318
  my $auth        =  $main::auth;
319
  my $myconfig    = \%main::myconfig;
320

  
314 321
  my @stack;
315 322
  my $cur_ary = [];
316 323

  
......
331 338
    } elsif ($token eq ")") {
332 339
      pop @stack;
333 340
      if (!@stack) {
334
        $main::form->error("Error in menu.ini for entry ${key}: missing '('");
341
        $form->error("Error in menu.ini for entry ${key}: missing '('");
335 342
      }
336 343
      $cur_ary = $stack[-1];
337 344

  
......
339 346
      push @{$cur_ary}, $token;
340 347

  
341 348
    } else {
342
      push @{$cur_ary}, $main::auth->check_right($main::form->{login}, $token, 1);
349
      push @{$cur_ary}, $auth->check_right($form->{login}, $token, 1);
343 350
    }
344 351
  }
345 352

  
346 353
  if ($access) {
347
    $main::form->error("Error in menu.ini for entry ${name}: unrecognized token at the start of '$access'\n");
354
    $form->error("Error in menu.ini for entry ${key}: unrecognized token at the start of '$access'\n");
348 355
  }
349 356

  
350 357
  if (1 < scalar @stack) {
351
    $main::form->error("Error in menu.ini for entry ${name}: Missing ')'\n");
358
    $main::form->error("Error in menu.ini for entry ${key}: Missing ')'\n");
352 359
  }
353 360

  
354 361
  return SL::Auth::evaluate_rights_ary($stack[0]);

Auch abrufbar als: Unified diff