From 392ae1245fde7d9ab5dc7fc8cacebacd60f857ad Mon Sep 17 00:00:00 2001 From: Christophe Croullebois Date: Mon, 18 Mar 2013 18:46:03 +0100 Subject: [PATCH] Bug 9923: (MT #11060) actual cost not getting populated The patch 7129 introduces a bug if the unitprice is 0.0000. Instead of showing in this case the 'ecost' if there is not 'unitprice', it shows 0.00 and the 'Actual cost' must be manually entered. The line: if ( @$results[0]->{'unitprice'} == 0 ) { @$results[0]->{'unitprice'} = ''; was wrote in this perspective. But sprintf ( "%.2f", with '' or 0 or any string will return 0.00 and then, in the .tt 'unitprice' exists so we have the bad result. Signed-off-by: Mathieu Saby Signed-off-by: Paul Poulain Signed-off-by: Jared Camins-Esakov --- acqui/orderreceive.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index ec60f54b9b..fc79ccbba4 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -215,7 +215,6 @@ $template->param( quantityreceived => $order->{'quantityreceived'}, rrp => sprintf( "%.2f", $rrp ), ecost => sprintf( "%.2f", $ecost ), - unitprice => sprintf( "%.2f", $unitprice), memberfirstname => $member->{firstname} || "", membersurname => $member->{surname} || "", invoiceid => $invoice->{invoiceid}, @@ -228,6 +227,15 @@ $template->param( firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, ); +# regardless of the content of $unitprice e.g 0 or '' or any string will return in these cases 0.00 +# and the 'IF' in the .tt will show 0.00 and not 'ecost' (see BZ 7129) +# So if $unitprice == 0 we don't create unitprice +if ( $unitprice != 0) { + $template->param( + unitprice => sprintf( "%.2f", $unitprice), + ); +} + my $op = $input->param('op'); if ($op and $op eq 'edit'){ $template->param(edit => 1); -- 2.39.5