From 91e0f358afdbffaab1c8189b01641637002543d8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 13 Aug 2012 09:53:37 +0200 Subject: [PATCH] Bug 5339: perltidy on added files Signed-off-by: Paul Poulain --- acqui/invoice.pl | 130 +++++++++++++++++++++++++--------------------- acqui/invoices.pl | 125 ++++++++++++++++++++++---------------------- 2 files changed, 135 insertions(+), 120 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 28f3841135..1dc97ee7e6 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -37,91 +37,101 @@ use C4::Bookseller qw/GetBookSellerFromId/; use C4::Budgets; my $input = new CGI; -my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { - template_name => 'acqui/invoice.tmpl', - query => $input, - type => 'intranet', - authnotrequired => 0, - flagsrequired => { 'acquisition' => '*' }, - debug => 1, -} ); +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => 'acqui/invoice.tmpl', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { 'acquisition' => '*' }, + debug => 1, + } +); my $invoiceid = $input->param('invoiceid'); -my $op = $input->param('op'); +my $op = $input->param('op'); -if($op && $op eq 'close') { +if ( $op && $op eq 'close' ) { CloseInvoice($invoiceid); my $referer = $input->param('referer'); - if($referer) { + if ($referer) { print $input->redirect($referer); exit 0; } -}elsif($op && $op eq 'reopen') { +} +elsif ( $op && $op eq 'reopen' ) { ReopenInvoice($invoiceid); my $referer = $input->param('referer'); - if($referer) { + if ($referer) { print $input->redirect($referer); exit 0; } -}elsif($op && $op eq 'mod') { - my $shipmentdate = $input->param('shipmentdate'); - my $billingdate = $input->param('billingdate'); - my $shipmentcost = $input->param('shipmentcost'); +} +elsif ( $op && $op eq 'mod' ) { + my $shipmentdate = $input->param('shipmentdate'); + my $billingdate = $input->param('billingdate'); + my $shipmentcost = $input->param('shipmentcost'); my $shipment_budget_id = $input->param('shipment_budget_id'); ModInvoice( - invoiceid => $invoiceid, - shipmentdate => C4::Dates->new($shipmentdate)->output("iso"), - billingdate => C4::Dates->new($billingdate)->output("iso"), - shipmentcost => $shipmentcost, + invoiceid => $invoiceid, + shipmentdate => C4::Dates->new($shipmentdate)->output("iso"), + billingdate => C4::Dates->new($billingdate)->output("iso"), + shipmentcost => $shipmentcost, shipmentcost_budgetid => $shipment_budget_id ); - $template->param(modified => 1); + $template->param( modified => 1 ); } -my $details = GetInvoiceDetails($invoiceid); -my $bookseller = GetBookSellerFromId($details->{booksellerid}); +my $details = GetInvoiceDetails($invoiceid); +my $bookseller = GetBookSellerFromId( $details->{booksellerid} ); my @orders_loop = (); -my $orders = $details->{'orders'}; +my $orders = $details->{'orders'}; my $qty_total; my @books_loop; my @book_foot_loop; my %foot; my $total_quantity = 0; -my $total_rrp = 0; -my $total_est = 0; +my $total_rrp = 0; +my $total_est = 0; + foreach my $order (@$orders) { - my $line = get_infos( $order, $bookseller); + my $line = get_infos( $order, $bookseller ); $total_quantity += $$line{quantity}; - $total_rrp += $order->{quantity} * $order->{rrp}; - $total_est += $order->{quantity} * $order->{'ecost'}; + $total_rrp += $order->{quantity} * $order->{rrp}; + $total_est += $order->{quantity} * $order->{'ecost'}; - my %row = (%$order, %$line); + my %row = ( %$order, %$line ); push @orders_loop, \%row; } my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; -my $discount = $bookseller->{'discount'} ? ($bookseller->{discount} / 100) : 0; +my $discount = + $bookseller->{'discount'} ? ( $bookseller->{discount} / 100 ) : 0; my $total_est_gste; my $total_est_gsti; -my $total_rrp_gsti; # RRP Total, GST included -my $total_rrp_gste; # RRP Total, GST excluded +my $total_rrp_gsti; # RRP Total, GST included +my $total_rrp_gste; # RRP Total, GST excluded my $gist_est; my $gist_rrp; -if ($gist){ +if ($gist) { + # if we have GST if ( $bookseller->{'listincgst'} ) { + # if prices already includes GST # we know $total_rrp_gsti $total_rrp_gsti = $total_rrp; + # and can reverse compute other values $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 ); $gist_rrp = $total_rrp_gsti - $total_rrp_gste; $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount ); $total_est_gsti = $total_est; - } else { + } + else { # if prices does not include GST # then we use the common way to compute other values @@ -130,34 +140,37 @@ if ($gist){ $total_rrp_gsti = $total_rrp_gste + $gist_rrp; $total_est_gste = $total_est; $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount ); - } - $gist_est = $gist_rrp - ( $gist_rrp * $discount ); -} else { + } + $gist_est = $gist_rrp - ( $gist_rrp * $discount ); +} +else { $total_rrp_gste = $total_rrp_gsti = $total_rrp; $total_est_gste = $total_est_gsti = $total_est; - $gist_rrp = $gist_est = 0; + $gist_rrp = $gist_est = 0; } my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost}; my $format = "%.2f"; $template->param( - total_rrp_gste => sprintf($format, $total_rrp_gste), - total_rrp_gsti => sprintf($format, $total_rrp_gsti), - total_est_gste => sprintf($format, $total_est_gste), - total_est_gsti => sprintf($format, $total_est_gsti), - gist_rrp => sprintf($format, $gist_rrp), - gist_est => sprintf($format, $gist_est), - total_gsti_shipment => sprintf($format, $total_gsti_shipment), - gist => sprintf($format, $gist * 100), + total_rrp_gste => sprintf( $format, $total_rrp_gste ), + total_rrp_gsti => sprintf( $format, $total_rrp_gsti ), + total_est_gste => sprintf( $format, $total_est_gste ), + total_est_gsti => sprintf( $format, $total_est_gsti ), + gist_rrp => sprintf( $format, $gist_rrp ), + gist_est => sprintf( $format, $gist_est ), + total_gsti_shipment => sprintf( $format, $total_gsti_shipment ), + gist => sprintf( $format, $gist * 100 ), ); my $budgets = GetBudgets(); my @budgets_loop; my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; foreach my $budget (@$budgets) { - next unless CanUserUseBudget($loggedinuser, $budget, $flags); - my %line = %{ $budget }; - if($shipmentcost_budgetid and $budget->{budget_id} == $shipmentcost_budgetid) { + next unless CanUserUseBudget( $loggedinuser, $budget, $flags ); + my %line = %{$budget}; + if ( $shipmentcost_budgetid + and $budget->{budget_id} == $shipmentcost_budgetid ) + { $line{selected} = 1; } push @budgets_loop, \%line; @@ -172,28 +185,28 @@ $template->param( shipmentdate => $details->{'shipmentdate'}, billingdate => $details->{'billingdate'}, invoiceclosedate => $details->{'closedate'}, - shipmentcost => sprintf($format, $details->{'shipmentcost'} || 0), + shipmentcost => sprintf( $format, $details->{'shipmentcost'} || 0 ), orders_loop => \@orders_loop, total_quantity => $total_quantity, invoiceincgst => $bookseller->{invoiceincgst}, currency => $bookseller->{listprice}, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), - budgets_loop => \@budgets_loop, + budgets_loop => \@budgets_loop, ); sub get_infos { - my $order = shift; + my $order = shift; my $bookseller = shift; - my $qty = $order->{'quantity'} || 0; + my $qty = $order->{'quantity'} || 0; if ( !defined $order->{quantityreceived} ) { $order->{quantityreceived} = 0; } my $budget = GetBudget( $order->{'budget_id'} ); - my %line = %{ $order }; + my %line = %{$order}; $line{order_received} = ( $qty == $order->{'quantityreceived'} ); $line{budget_name} = $budget->{budget_name}; - $line{total} = $qty * $order->{ecost}; + $line{total} = $qty * $order->{ecost}; if ( $line{uncertainprice} ) { $line{rrp} .= ' (Uncertain)'; @@ -203,7 +216,8 @@ sub get_infos { my $seriestitle = $order->{'seriestitle'}; $line{'title'} .= " / $seriestitle" if $seriestitle; $line{'title'} .= " / $volume" if $volume; - } else { + } + else { $line{'title'} = "Deleted bibliographic notice, can't find title."; } diff --git a/acqui/invoices.pl b/acqui/invoices.pl index fab7837cf0..4b45e31dba 100755 --- a/acqui/invoices.pl +++ b/acqui/invoices.pl @@ -38,48 +38,50 @@ use C4::Bookseller qw/GetBookSeller/; use C4::Branch; my $input = new CGI; -my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { - template_name => 'acqui/invoices.tmpl', - query => $input, - type => 'intranet', - authnotrequired => 0, - flagsrequired => { 'acquisition' => '*' }, - debug => 1, -} ); - -my $invoicenumber = $input->param('invoicenumber'); -my $supplier = $input->param('supplier'); +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( + { + template_name => 'acqui/invoices.tmpl', + query => $input, + type => 'intranet', + authnotrequired => 0, + flagsrequired => { 'acquisition' => '*' }, + debug => 1, + } +); + +my $invoicenumber = $input->param('invoicenumber'); +my $supplier = $input->param('supplier'); my $shipmentdatefrom = $input->param('shipmentdatefrom'); -my $shipmentdateto = $input->param('shipmentdateto'); -my $billingdatefrom = $input->param('billingdatefrom'); -my $billingdateto = $input->param('billingdateto'); -my $isbneanissn = $input->param('isbneanissn'); -my $title = $input->param('title'); -my $author = $input->param('author'); -my $publisher = $input->param('publisher'); -my $publicationyear = $input->param('publicationyear'); -my $branch = $input->param('branch'); -my $op = $input->param('op'); +my $shipmentdateto = $input->param('shipmentdateto'); +my $billingdatefrom = $input->param('billingdatefrom'); +my $billingdateto = $input->param('billingdateto'); +my $isbneanissn = $input->param('isbneanissn'); +my $title = $input->param('title'); +my $author = $input->param('author'); +my $publisher = $input->param('publisher'); +my $publicationyear = $input->param('publicationyear'); +my $branch = $input->param('branch'); +my $op = $input->param('op'); my @results_loop = (); -if($op and $op eq "do_search") { +if ( $op and $op eq "do_search" ) { my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output("iso"); - my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output("iso"); - my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso"); - my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso"); - my @invoices = GetInvoices( - invoicenumber => $invoicenumber, - suppliername => $supplier, + my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output("iso"); + my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso"); + my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso"); + my @invoices = GetInvoices( + invoicenumber => $invoicenumber, + suppliername => $supplier, shipmentdatefrom => $shipmentdatefrom_iso, - shipmentdateto => $shipmentdateto_iso, - billingdatefrom => $billingdatefrom_iso, - billingdateto => $billingdateto_iso, - isbneanissn => $isbneanissn, - title => $title, - author => $author, - publisher => $publisher, - publicationyear => $publicationyear, - branchcode => $branch + shipmentdateto => $shipmentdateto_iso, + billingdatefrom => $billingdatefrom_iso, + billingdateto => $billingdateto_iso, + isbneanissn => $isbneanissn, + title => $title, + author => $author, + publisher => $publisher, + publicationyear => $publicationyear, + branchcode => $branch ); foreach (@invoices) { my %row = ( @@ -90,21 +92,20 @@ if($op and $op eq "do_search") { receivedbiblios => $_->{receivedbiblios}, receiveditems => $_->{receiveditems}, subscriptionid => $_->{subscriptionid}, - closedate => $_->{closedate}, + closedate => $_->{closedate}, ); push @results_loop, \%row; } } - # Build suppliers list -my @suppliers = GetBookSeller(undef); +my @suppliers = GetBookSeller(undef); my @suppliers_loop = (); my $suppliername; foreach (@suppliers) { my $selected = 0; - if ($supplier && $supplier == $_->{'id'}) { - $selected = 1; + if ( $supplier && $supplier == $_->{'id'} ) { + $selected = 1; $suppliername = $_->{'name'}; } my %row = ( @@ -116,13 +117,13 @@ foreach (@suppliers) { } # Build branches list -my $branches = GetBranches(); +my $branches = GetBranches(); my @branches_loop = (); my $branchname; -foreach (sort keys %$branches) { +foreach ( sort keys %$branches ) { my $selected = 0; - if ($branch && $branch eq $_) { - $selected = 1; + if ( $branch && $branch eq $_ ) { + $selected = 1; $branchname = $branches->{$_}->{'branchname'}; } my %row = ( @@ -134,22 +135,22 @@ foreach (sort keys %$branches) { } $template->param( - do_search => ($op and $op eq "do_search") ? 1 : 0, - results_loop => \@results_loop, - invoicenumber => $invoicenumber, - supplier => $supplier, - suppliername => $suppliername, - billingdatefrom => $billingdatefrom, - billingdateto => $billingdateto, - isbneanissn => $isbneanissn, - title => $title, - author => $author, - publisher => $publisher, - publicationyear => $publicationyear, - branch => $branch, - branchname => $branchname, - suppliers_loop => \@suppliers_loop, - branches_loop => \@branches_loop, + do_search => ( $op and $op eq "do_search" ) ? 1 : 0, + results_loop => \@results_loop, + invoicenumber => $invoicenumber, + supplier => $supplier, + suppliername => $suppliername, + billingdatefrom => $billingdatefrom, + billingdateto => $billingdateto, + isbneanissn => $isbneanissn, + title => $title, + author => $author, + publisher => $publisher, + publicationyear => $publicationyear, + branch => $branch, + branchname => $branchname, + suppliers_loop => \@suppliers_loop, + branches_loop => \@branches_loop, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); -- 2.39.5