Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8181ef34

Von Stephan Köhler vor fast 19 Jahren hinzugefügt

  • ID 8181ef34837e9856c9168db79847c6fe584c15b4
  • Vorgänger 1ecbe728
  • Nachfolger 96fb5f4e

Merge von 813 aus unstable: Bugfix
Berichte -> Kontenuebersicht -> Konto auswaehlen -> Abteilung auswaehlen -> Buchungsliste
ergab einen SQL Fehler. Dieser Fix sollte das beheben

Unterschiede anzeigen:

SL/CA.pm
164 164
    $where .= $fromto;
165 165
    $AR_PAID = "";
166 166
    $AP_PAID = "";
167
    $glwhere = "";
167
    $glwhere = ""; # note! gl will be aliased as "a" later...
168 168
  }
169 169
  my $sortorder = join ', ',
170 170
    $form->sort_columns(qw(transdate reference description));
......
181 181
  my $dpt_join;
182 182
  if ($department_id) {
183 183
    $dpt_join = qq|
184
                   JOIN department t ON (t.trans_id = ac.trans_id)
184
                   JOIN department t ON (t.id = a.department_id)
185 185
		  |;
186
    $dpt_where == qq|
187
		   AND t.department_id = $department_id
186
    $dpt_where = qq|
187
		   AND t.id = $department_id
188 188
		  |;
189 189
  }
190 190

  
......
323 323

  
324 324
  foreach my $id (@id) {
325 325

  
326
      # NOTE: 
327
      #  Postgres is really picky about the order of implicit CROSS JOINs with ','
328
      #  if you alias the  tables and want to use the alias later in another JOIN.
329
      #  the alias you want to use has to be the most recent in the list, otherwise
330
      #  Postgres will overwrite the alias internally and complain.
331
      #  For this reason, in the next 3 SELECTs, the 'a' alias is last in the list.
332
      #  Don't change this, and if you do, substitute the ',' with CROSS JOIN
333
      #  ... that also works.
334

  
326 335
    # get all transactions
327 336
    $query .= qq|$union
328
      SELECT g.id, g.reference, g.description, ac.transdate,
337
      SELECT a.id, a.reference, a.description, ac.transdate,
329 338
	     $false AS invoice, ac.amount, 'gl' as module
330
		FROM gl g, acc_trans ac $dpt_from
339
		FROM acc_trans ac, gl a $dpt_join
331 340
		WHERE $where
332 341
		$glwhere
333
		$dpt_join
342
		$dpt_where
334 343
		$project
335 344
		AND ac.chart_id = $id
336
		AND ac.trans_id = g.id
345
		AND ac.trans_id = a.id
337 346
      UNION
338 347
      SELECT a.id, a.invnumber, c.name, ac.transdate,
339 348
	     a.invoice, ac.amount, 'ar' as module
340
		FROM ar a, acc_trans ac, customer c $dpt_from
349
		FROM acc_trans ac, customer c, ar a $dpt_join
341 350
		WHERE $where
342
		$dpt_join
351
		$dpt_where
343 352
		$project
344 353
		AND ac.chart_id = $id
345 354
		AND ac.trans_id = a.id
......
348 357
      UNION
349 358
      SELECT a.id, a.invnumber, v.name, ac.transdate,
350 359
	     a.invoice, ac.amount, 'ap' as module
351
		FROM ap a, acc_trans ac, vendor v $dpt_from
360
		FROM acc_trans ac, vendor v, ap a $dpt_join
352 361
		WHERE $where
353
		$dpt_join
362
		$dpt_where
354 363
		$project
355 364
		AND ac.chart_id = $id
356 365
		AND ac.trans_id = a.id

Auch abrufbar als: Unified diff