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, | .
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};
"cusordnumber", "customernumber",
"name", "netamount",
"tax", "amount",
+ "remaining_netamount", "remaining_amount",
"curr", "employee",
"salesman",
"shipvia", "globalprojectnumber",
'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'), },
$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;
# 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;
$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 = { };
'Ertrag' => 'Ertrag',
'Ertrag prozentual' => 'Ertrag prozentual',
'Escape character' => 'Escape-Zeichen',
+ 'Etikett' => '',
'EuR' => 'EuR',
'Everyone can log in.' => 'Alle können sich anmelden.',
'Exact' => 'Genau',
'PRINTED' => 'Gedruckt',
'Package name' => 'Paketname',
'Packing Lists' => 'Lieferschein',
+ 'Packliste' => '',
'Page' => 'Seite',
'Page #1/#2' => 'Seite #1/#2',
'Paid' => 'bezahlt',
'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',
'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',
<label for="l_salesman">[% 'Salesman' | $T8 %]</label>
</td>
</tr>
+ <tr>
+ <td>
+ <input name="l_remaining_amount" id="l_remaining_amount" class="checkbox" type="checkbox" value="Y">
+ <label for="l_remaining_amount">[% 'Remaining Amount' | $T8 %]</label>
+ </td>
+ <td>
+ <input name="l_remaining_netamount" id="l_remaining_netamount" class="checkbox" type="checkbox" value="Y">
+ <label for="l_remaining_netamount">[% 'Remaining Net Amount' | $T8 %]</label>
+ </td>
+ </tr>
<tr>
<td colspan=4 align=left><b>[% HTML.escape(vclabel) %]</td>
</tr>