From 50133d13d307d4172a0a3c1bd5a283e29609756a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 4 Mar 2014 16:11:50 +0100 Subject: [PATCH] =?utf8?q?Offene=20Restbetr=C3=A4ge=20optional=20in=20Auft?= =?utf8?q?ragsbericht=20anzeigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/OE.pm | 26 ++++++++++++++++++++++++++ bin/mozilla/oe.pl | 9 ++++++--- locale/de/all | 5 +++++ templates/webpages/oe/search.html | 10 ++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/SL/OE.pm b/SL/OE.pm index a6b9a9c52..13e735a38 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -80,6 +80,28 @@ sub transactions { my $vc = $form->{vc} eq "customer" ? "customer" : "vendor"; + my %billed_amount; + my %billed_netamount; + if ($form->{l_remaining_amount} || $form->{l_remaining_netamount}) { + $query = <<''; + SELECT from_id, ar.amount, ar.netamount FROM ( + SELECT from_id, to_id + FROM record_links + WHERE from_table = 'oe' AND to_table = 'ar' + 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' + ) rl + LEFT JOIN ar ON ar.id = rl.to_id + + for my $ref (@{ selectall_hashref_query($form, $dbh, $query) }) { + $billed_amount{ $ref->{from_id}} += $ref->{amount}; + $billed_netamount{$ref->{from_id}} += $ref->{netamount}; + } + } + $query = qq|SELECT o.id, o.ordnumber, o.transdate, o.reqdate, | . qq| o.amount, ct.${vc}number, ct.name, o.netamount, o.${vc}_id, o.globalproject_id, | . @@ -249,6 +271,10 @@ SQL my %id = (); $form->{OE} = []; while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + $ref->{billed_amount} = $billed_amount{$ref->{id}}; + $ref->{billed_netamount} = $billed_netamount{$ref->{id}}; + $ref->{remaining_amount} = $ref->{amount} - $ref->{billed_amount}; + $ref->{remaining_netamount} = $ref->{netamount} - $ref->{billed_netamount}; $ref->{exchangerate} = 1 unless $ref->{exchangerate}; push @{ $form->{OE} }, $ref if $ref->{id} != $id{ $ref->{id} }; $id{ $ref->{id} } = $ref->{id}; diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 619ae9f7d..a2d7175bc 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -790,6 +790,7 @@ sub orders { "cusordnumber", "customernumber", "name", "netamount", "tax", "amount", + "remaining_netamount", "remaining_amount", "curr", "employee", "salesman", "shipvia", "globalprojectnumber", @@ -857,6 +858,8 @@ sub orders { 'netamount' => { 'text' => $locale->text('Amount'), }, 'tax' => { 'text' => $locale->text('Tax'), }, 'amount' => { 'text' => $locale->text('Total'), }, + 'remaining_amount' => { 'text' => $locale->text('Remaining Amount'), }, + 'remaining_netamount' => { 'text' => $locale->text('Remaining Net Amount'), }, 'curr' => { 'text' => $locale->text('Curr'), }, 'employee' => { 'text' => $locale->text('Employee'), }, 'salesman' => { 'text' => $locale->text('Salesman'), }, @@ -880,7 +883,7 @@ sub orders { $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } - my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr); + my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr remaining_amount remaining_netamount); $form->{"l_type"} = "Y"; map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns; @@ -942,7 +945,7 @@ sub orders { # escape callback for href my $callback = $form->escape($href); - my @subtotal_columns = qw(netamount amount marge_total marge_percent); + my @subtotal_columns = qw(netamount amount marge_total marge_percent remaining_amount remaining_netamount); my %totals = map { $_ => 0 } @subtotal_columns; my %subtotals = map { $_ => 0 } @subtotal_columns; @@ -965,7 +968,7 @@ sub orders { $subtotals{marge_percent} = $subtotals{netamount} ? ($subtotals{marge_total} * 100 / $subtotals{netamount}) : 0; $totals{marge_percent} = $totals{netamount} ? ($totals{marge_total} * 100 / $totals{netamount} ) : 0; - map { $oe->{$_} = $form->format_amount(\%myconfig, $oe->{$_}, 2) } qw(netamount tax amount marge_total marge_percent); + map { $oe->{$_} = $form->format_amount(\%myconfig, $oe->{$_}, 2) } qw(netamount tax amount marge_total marge_percent remaining_amount remaining_netamount); my $row = { }; diff --git a/locale/de/all b/locale/de/all index c39b85fb6..7711fb24f 100755 --- a/locale/de/all +++ b/locale/de/all @@ -923,6 +923,7 @@ $self->{texts} = { 'Ertrag' => 'Ertrag', 'Ertrag prozentual' => 'Ertrag prozentual', 'Escape character' => 'Escape-Zeichen', + 'Etikett' => '', 'EuR' => 'EuR', 'Everyone can log in.' => 'Alle können sich anmelden.', 'Exact' => 'Genau', @@ -1515,6 +1516,7 @@ $self->{texts} = { 'PRINTED' => 'Gedruckt', 'Package name' => 'Paketname', 'Packing Lists' => 'Lieferschein', + 'Packliste' => '', 'Page' => 'Seite', 'Page #1/#2' => 'Seite #1/#2', 'Paid' => 'bezahlt', @@ -1536,6 +1538,7 @@ $self->{texts} = { 'Parts must have an entry type.' => 'Waren müssen eine Buchungsgruppe haben.', 'Parts with existing part numbers' => 'Artikel mit existierender Artikelnummer', 'Parts, services and assemblies' => 'Waren, Dienstleistungen und Erzeugnisse', + 'Partsedit' => '', 'Partsgroup (database ID)' => 'Warengruppe (Datenbank-ID)', 'Partsgroup (name)' => 'Warengruppe (Name)', 'Password' => 'Passwort', @@ -1744,6 +1747,8 @@ $self->{texts} = { 'Reference missing!' => 'Referenz fehlt!', 'Release From Stock' => 'Lagerausgang', 'Remaining' => 'Rest', + 'Remaining Amount' => 'abzurechnender Betrag', + 'Remaining Net Amount' => 'abzurechnender Nettobetrag', 'Remittance information prefix' => 'Verwendungszweckvorbelegung (Präfix)', 'Removal' => 'Entnahme', 'Removal from Warehouse' => 'Lagerentnahme', diff --git a/templates/webpages/oe/search.html b/templates/webpages/oe/search.html index 66be6b4ea..1fccfc415 100644 --- a/templates/webpages/oe/search.html +++ b/templates/webpages/oe/search.html @@ -250,6 +250,16 @@ + + + + + + + + + + [% HTML.escape(vclabel) %] -- 2.20.1