X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Finvoice.pl;h=3ab2d9f7c26228df075a60a228454d438d3827a7;hb=f59484df2246c0ee11c5d44f2dca762908864fe8;hp=f56afcc5ec270aa91c7c587974ebc52bee523ec4;hpb=94029916cc8a1ac81e5c344aff32bcb656e94094;p=koha.git diff --git a/acqui/invoice.pl b/acqui/invoice.pl index f56afcc5ec..3ab2d9f7c2 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -35,7 +35,8 @@ use C4::Output; use C4::Acquisition; use C4::Budgets; -use Koha::Acquisition::Bookseller; +use Koha::Acquisition::Booksellers; +use Koha::Acquisition::Currencies; use Koha::DateUtils; use Koha::Misc::Files; @@ -79,10 +80,12 @@ elsif ( $op && $op eq 'reopen' ) { elsif ( $op && $op eq 'mod' ) { my $shipmentcost = $input->param('shipmentcost'); my $shipment_budget_id = $input->param('shipment_budget_id'); + my $invoicenumber = $input->param('invoicenumber'); ModInvoice( invoiceid => $invoiceid, - shipmentdate => output_pref( { str => $input->param('shipmentdate'), dateformat => 'iso', dateonly => 1 } ), - billingdate => output_pref( { str => $input->param('billingdate'), dateformat => 'iso', dateonly => 1 } ), + invoicenumber => $invoicenumber, + shipmentdate => output_pref( { str => scalar $input->param('shipmentdate'), dateformat => 'iso', dateonly => 1 } ), + billingdate => output_pref( { str => scalar $input->param('billingdate'), dateformat => 'iso', dateonly => 1 } ), shipmentcost => $shipmentcost, shipmentcost_budgetid => $shipment_budget_id ); @@ -91,7 +94,7 @@ elsif ( $op && $op eq 'mod' ) { } elsif ($input->param('close')) { CloseInvoice($invoiceid); } elsif ($input->param('merge')) { - my @sources = $input->param('merge'); + my @sources = $input->multi_param('merge'); MergeInvoices($invoiceid, \@sources); defined($invoice_files) && $invoice_files->MergeFileRecIds(@sources); } @@ -109,35 +112,33 @@ elsif ( $op && $op eq 'delete' ) { my $details = GetInvoiceDetails($invoiceid); -my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $details->{booksellerid} }); +my $bookseller = Koha::Acquisition::Booksellers->find( $details->{booksellerid} ); my @orders_loop = (); my $orders = $details->{'orders'}; -my $qty_total; my @foot_loop; my %foot; my $total_quantity = 0; -my $total_gste = 0; -my $total_gsti = 0; -my $total_gstvalue = 0; +my $total_tax_excluded = 0; +my $total_tax_included = 0; +my $total_tax_value = 0; foreach my $order (@$orders) { - $order = C4::Acquisition::populate_order_with_prices( - { - order => $order, - booksellerid => $bookseller->{id}, - receiving => 1, - } - ); my $line = get_infos( $order, $bookseller); - $foot{$$line{gstrate}}{gstrate} = $$line{gstrate}; - $foot{$$line{gstrate}}{gstvalue} += $$line{gstvalue}; - $total_gstvalue += $$line{gstvalue}; - $foot{$$line{gstrate}}{quantity} += $$line{quantity}; + $line->{total_tax_excluded} = $line->{unitprice_tax_excluded} * $line->{quantity}; + $line->{total_tax_included} = $line->{unitprice_tax_included} * $line->{quantity}; + + $line->{tax_value} = $line->{tax_value_on_receiving}; + $line->{tax_rate} = $line->{tax_rate_on_receiving}; + + $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate}; + $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value}; + $total_tax_value += $$line{tax_value}; + $foot{$$line{tax_rate}}{quantity} += $$line{quantity}; $total_quantity += $$line{quantity}; - $foot{$$line{gstrate}}{totalgste} += $$line{totalgste}; - $total_gste += $$line{totalgste}; - $foot{$$line{gstrate}}{totalgsti} += $$line{totalgsti}; - $total_gsti += $$line{totalgsti}; + $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded}; + $total_tax_excluded += $$line{total_tax_excluded}; + $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included}; + $total_tax_included += $$line{total_tax_included}; $line->{orderline} = $line->{parent_ordernumber}; push @orders_loop, $line; @@ -145,7 +146,6 @@ foreach my $order (@$orders) { push @foot_loop, map {$_} values %foot; -my $format = "%.2f"; my $budgets = GetBudgets(); my @budgets_loop; my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; @@ -172,13 +172,13 @@ $template->param( orders_loop => \@orders_loop, foot_loop => \@foot_loop, total_quantity => $total_quantity, - total_gste => sprintf( $format, $total_gste ), - total_gsti => sprintf( $format, $total_gsti ), - total_gstvalue => sprintf( $format, $total_gstvalue ), - total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}), - total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}), - invoiceincgst => $bookseller->{invoiceincgst}, - currency => GetCurrency()->{currency}, + total_tax_excluded => $total_tax_excluded, + total_tax_included => $total_tax_included, + total_tax_value => $total_tax_value, + total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost}, + total_tax_included_shipment => $total_tax_included + $details->{shipmentcost}, + invoiceincgst => $bookseller->invoiceincgst, + currency => Koha::Acquisition::Currencies->get_active, budgets_loop => \@budgets_loop, );