|
Lines 75-117
use JSON;
Link Here
|
| 75 |
my $input=new CGI; |
75 |
my $input=new CGI; |
| 76 |
my $sticky_filters = $input->param('sticky_filters') || 0; |
76 |
my $sticky_filters = $input->param('sticky_filters') || 0; |
| 77 |
|
77 |
|
| 78 |
sub get_value_with_gst_params { |
|
|
| 79 |
my $value = shift; |
| 80 |
my $gstrate = shift; |
| 81 |
my $bookseller = shift; |
| 82 |
if ( $bookseller->{listincgst} ) { |
| 83 |
if ( $bookseller->{invoiceincgst} ) { |
| 84 |
return $value; |
| 85 |
} else { |
| 86 |
return $value / ( 1 + $gstrate ); |
| 87 |
} |
| 88 |
} else { |
| 89 |
if ( $bookseller->{invoiceincgst} ) { |
| 90 |
return $value * ( 1 + $gstrate ); |
| 91 |
} else { |
| 92 |
return $value; |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
sub get_gste { |
| 98 |
my $value = shift; |
| 99 |
my $gstrate = shift; |
| 100 |
my $bookseller = shift; |
| 101 |
return $bookseller->{invoiceincgst} |
| 102 |
? $value / ( 1 + $gstrate ) |
| 103 |
: $value; |
| 104 |
} |
| 105 |
|
| 106 |
sub get_gst { |
| 107 |
my $value = shift; |
| 108 |
my $gstrate = shift; |
| 109 |
my $bookseller = shift; |
| 110 |
return $bookseller->{invoiceincgst} |
| 111 |
? $value / ( 1 + $gstrate ) * $gstrate |
| 112 |
: $value * ( 1 + $gstrate ) - $value; |
| 113 |
} |
| 114 |
|
| 115 |
my ($template, $loggedinuser, $cookie) |
78 |
my ($template, $loggedinuser, $cookie) |
| 116 |
= get_template_and_user({template_name => "acqui/parcel.tt", |
79 |
= get_template_and_user({template_name => "acqui/parcel.tt", |
| 117 |
query => $input, |
80 |
query => $input, |
|
Lines 151-179
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
Link Here
|
| 151 |
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; |
114 |
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; |
| 152 |
my $datereceived = C4::Dates->new(); |
115 |
my $datereceived = C4::Dates->new(); |
| 153 |
|
116 |
|
| 154 |
my $cfstr = "%.2f"; # currency format string -- could get this from currency table. |
|
|
| 155 |
my @orders = @{ $invoice->{orders} }; |
117 |
my @orders = @{ $invoice->{orders} }; |
| 156 |
my $countlines = scalar @orders; |
118 |
my $countlines = scalar @orders; |
| 157 |
my $totalprice = 0; |
|
|
| 158 |
my $totalquantity = 0; |
| 159 |
my $total; |
| 160 |
my @loop_received = (); |
119 |
my @loop_received = (); |
| 161 |
my @book_foot_loop; |
120 |
my @book_foot_loop; |
| 162 |
my %foot; |
121 |
my %foot; |
| 163 |
my $total_quantity = 0; |
|
|
| 164 |
my $total_gste = 0; |
122 |
my $total_gste = 0; |
| 165 |
my $total_gsti = 0; |
123 |
my $total_gsti = 0; |
| 166 |
|
124 |
|
| 167 |
for my $order ( @orders ) { |
125 |
for my $order ( @orders ) { |
| 168 |
$order->{unitprice} = get_value_with_gst_params( $order->{unitprice}, $order->{gstrate}, $bookseller ); |
126 |
$order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $bookseller->{id}, receiving => 1, ordering => 1 }); |
| 169 |
$total = ( $order->{unitprice} ) * $order->{quantityreceived}; |
|
|
| 170 |
$order->{'unitprice'} += 0; |
127 |
$order->{'unitprice'} += 0; |
|
|
128 |
|
| 129 |
if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) { |
| 130 |
$order->{ecost} = $order->{ecostgste}; |
| 131 |
$order->{unitprice} = $order->{unitpricegste}; |
| 132 |
} |
| 133 |
elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) { |
| 134 |
$order->{ecost} = $order->{ecostgsti}; |
| 135 |
$order->{unitprice} = $order->{unitpricegsti}; |
| 136 |
} |
| 137 |
$order->{total} = $order->{ecost} * $order->{quantity}; |
| 138 |
|
| 171 |
my %line = %{ $order }; |
139 |
my %line = %{ $order }; |
| 172 |
my $ecost = get_value_with_gst_params( $line{ecost}, $line{gstrate}, $bookseller ); |
|
|
| 173 |
$line{ecost} = sprintf( "%.2f", $ecost ); |
| 174 |
$line{invoice} = $invoice->{invoicenumber}; |
140 |
$line{invoice} = $invoice->{invoicenumber}; |
| 175 |
$line{total} = sprintf($cfstr, $total); |
|
|
| 176 |
$line{booksellerid} = $invoice->{booksellerid}; |
| 177 |
$line{holds} = 0; |
141 |
$line{holds} = 0; |
| 178 |
my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} ); |
142 |
my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} ); |
| 179 |
for my $itemnumber ( @itemnumbers ) { |
143 |
for my $itemnumber ( @itemnumbers ) { |
|
Lines 181-195
for my $order ( @orders ) {
Link Here
|
| 181 |
$line{holds} += scalar( @$holds ); |
145 |
$line{holds} += scalar( @$holds ); |
| 182 |
} |
146 |
} |
| 183 |
$line{budget} = GetBudgetByOrderNumber( $line{ordernumber} ); |
147 |
$line{budget} = GetBudgetByOrderNumber( $line{ordernumber} ); |
| 184 |
$totalprice += $order->{unitprice}; |
|
|
| 185 |
$line{unitprice} = sprintf( $cfstr, $order->{unitprice} ); |
| 186 |
my $gste = get_gste( $line{total}, $line{gstrate}, $bookseller ); |
| 187 |
my $gst = get_gst( $line{total}, $line{gstrate}, $bookseller ); |
| 188 |
$foot{$line{gstrate}}{gstrate} = $line{gstrate}; |
148 |
$foot{$line{gstrate}}{gstrate} = $line{gstrate}; |
| 189 |
$foot{$line{gstrate}}{value} += sprintf( "%.2f", $gst ); |
149 |
$foot{$line{gstrate}}{gstvalue} += $line{gstvalue}; |
| 190 |
$total_quantity += $line{quantity}; |
150 |
$total_gste += $line{totalgste}; |
| 191 |
$total_gste += $gste; |
151 |
$total_gsti += $line{totalgsti}; |
| 192 |
$total_gsti += $gste + $gst; |
|
|
| 193 |
|
152 |
|
| 194 |
my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); |
153 |
my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); |
| 195 |
$line{suggestionid} = $suggestion->{suggestionid}; |
154 |
$line{suggestionid} = $suggestion->{suggestionid}; |
|
Lines 209-216
for my $order ( @orders ) {
Link Here
|
| 209 |
$line{budget_name} = $budget->{'budget_name'}; |
168 |
$line{budget_name} = $budget->{'budget_name'}; |
| 210 |
|
169 |
|
| 211 |
push @loop_received, \%line; |
170 |
push @loop_received, \%line; |
| 212 |
$totalquantity += $order->{quantityreceived}; |
|
|
| 213 |
|
| 214 |
} |
171 |
} |
| 215 |
push @book_foot_loop, map { $_ } values %foot; |
172 |
push @book_foot_loop, map { $_ } values %foot; |
| 216 |
|
173 |
|
|
Lines 258-278
unless( defined $invoice->{closedate} ) {
Link Here
|
| 258 |
my $countpendings = scalar @$pendingorders; |
215 |
my $countpendings = scalar @$pendingorders; |
| 259 |
|
216 |
|
| 260 |
for (my $i = 0 ; $i < $countpendings ; $i++) { |
217 |
for (my $i = 0 ; $i < $countpendings ; $i++) { |
| 261 |
my %line; |
218 |
my $order = $pendingorders->[$i]; |
| 262 |
%line = %{$pendingorders->[$i]}; |
219 |
$order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $bookseller->{id}, receiving => 1, ordering => 1 }); |
| 263 |
|
220 |
|
| 264 |
my $ecost = get_value_with_gst_params( $line{ecost}, $line{gstrate}, $bookseller ); |
221 |
if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) { |
| 265 |
$line{unitprice} = get_value_with_gst_params( $line{unitprice}, $line{gstrate}, $bookseller ); |
222 |
$order->{ecost} = $order->{ecostgste}; |
| 266 |
$line{quantity} += 0; |
223 |
} elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) { |
| 267 |
$line{quantityreceived} += 0; |
224 |
$order->{ecost} = $order->{ecostgsti}; |
| 268 |
$line{unitprice}+=0; |
225 |
} |
| 269 |
$line{ecost} = sprintf( "%.2f", $ecost ); |
226 |
$order->{total} = $order->{ecost} * $order->{quantity}; |
| 270 |
$line{ordertotal} = sprintf( "%.2f", $ecost * $line{quantity} ); |
|
|
| 271 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
| 272 |
$line{invoice} = $invoice; |
| 273 |
$line{booksellerid} = $booksellerid; |
| 274 |
|
227 |
|
|
|
228 |
my %line = %$order; |
| 275 |
|
229 |
|
|
|
230 |
$line{invoice} = $invoice; |
| 231 |
$line{booksellerid} = $booksellerid; |
| 276 |
|
232 |
|
| 277 |
my $biblionumber = $line{'biblionumber'}; |
233 |
my $biblionumber = $line{'biblionumber'}; |
| 278 |
my $countbiblio = CountBiblioInOrders($biblionumber); |
234 |
my $countbiblio = CountBiblioInOrders($biblionumber); |
|
Lines 327-342
$template->param(
Link Here
|
| 327 |
formatteddatereceived => $datereceived->output(), |
283 |
formatteddatereceived => $datereceived->output(), |
| 328 |
name => $bookseller->{'name'}, |
284 |
name => $bookseller->{'name'}, |
| 329 |
booksellerid => $bookseller->{id}, |
285 |
booksellerid => $bookseller->{id}, |
| 330 |
countreceived => $countlines, |
|
|
| 331 |
loop_received => \@loop_received, |
286 |
loop_received => \@loop_received, |
| 332 |
loop_orders => \@loop_orders, |
287 |
loop_orders => \@loop_orders, |
| 333 |
book_foot_loop => \@book_foot_loop, |
288 |
book_foot_loop => \@book_foot_loop, |
| 334 |
totalprice => sprintf($cfstr, $totalprice), |
|
|
| 335 |
totalquantity => $totalquantity, |
| 336 |
(uc(C4::Context->preference("marcflavour"))) => 1, |
289 |
(uc(C4::Context->preference("marcflavour"))) => 1, |
| 337 |
total_quantity => $total_quantity, |
290 |
total_gste => $total_gste, |
| 338 |
total_gste => sprintf( "%.2f", $total_gste ), |
291 |
total_gsti => $total_gsti, |
| 339 |
total_gsti => sprintf( "%.2f", $total_gsti ), |
|
|
| 340 |
sticky_filters => $sticky_filters, |
292 |
sticky_filters => $sticky_filters, |
| 341 |
); |
293 |
); |
| 342 |
output_html_with_http_headers $input, $cookie, $template->output; |
294 |
output_html_with_http_headers $input, $cookie, $template->output; |