Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 94a8c9a8

Von Bernd Bleßmann vor mehr als 1 Jahr hinzugefügt

  • ID 94a8c9a893244ec6766f60c69d7653e254be197a
  • Vorgänger daf9f2d2
  • Nachfolger 1eb4e4a4

Offene Restbeträge optional auch in Lieferanten-Auftragsbericht anzeigen

Die Häkchen waren auf der EK-Seite da, aber diese wurde in der SQL-Abfrage
nicht berücksichtigt.

Unterschiede anzeigen:

SL/OE.pm
my %billed_amount;
my %billed_netamount;
if ($form->{l_remaining_amount} || $form->{l_remaining_netamount}) {
$query = <<'';
SELECT from_id, ar.amount, ar.netamount FROM (
my $arap = $form->{vc} eq "customer" ? "ar" : "ap";
$query = <<"SQL";
SELECT from_id, ${arap}.amount, $arap.netamount FROM (
SELECT from_id, to_id
FROM record_links
WHERE from_table = 'oe' AND to_table = 'ar'
WHERE from_table = 'oe' AND to_table = '$arap'
UNION
SELECT rl1.from_id, rl2.to_id
FROM record_links rl1
LEFT JOIN record_links rl2 ON (rl1.to_table = rl2.from_table AND rl1.to_id = rl2.from_id)
WHERE rl1.from_table = 'oe' AND rl2.to_table = 'ar'
WHERE rl1.from_table = 'oe' AND rl2.to_table = '$arap'
UNION
SELECT rl1.from_id, rl3.to_id
FROM record_links rl1
JOIN record_links rl2 ON (rl1.to_table = rl2.from_table AND rl1.to_id = rl2.from_id)
JOIN record_links rl3 ON (rl2.to_table = rl3.from_table AND rl2.to_id = rl3.from_id)
WHERE rl1.from_table = 'oe' AND rl2.to_table = 'ar' AND rl3.to_table = 'ar'
WHERE rl1.from_table = 'oe' AND rl2.to_table = '$arap' AND rl3.to_table = '$arap'
) rl
LEFT JOIN ar ON ar.id = rl.to_id
LEFT JOIN $arap ON $arap.id = rl.to_id
SQL
for my $ref (@{ selectall_hashref_query($form, $dbh, $query) }) {
$billed_amount{ $ref->{from_id}} += $ref->{amount};

Auch abrufbar als: Unified diff