View | Details | Raw Unified | Return to bug 13001
Collapse All | Expand All

(-)a/acqui/parcel.pl (-77 / +29 lines)
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;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-13 / +13 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Price %]
2
[% USE currency = format('%.2f') -%]
3
[% USE currency = format('%.2f') -%]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( date ) %]
5
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( date ) %]
Lines 289-296 Link Here
289
                </td>
290
                </td>
290
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
291
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
291
                <td>[% loop_order.quantity %]</td>
292
                <td>[% loop_order.quantity %]</td>
292
                <td>[% loop_order.ecost %]</td>
293
                <td>[% loop_order.ecost | $Price %]</td>
293
                <td>[% loop_order.ordertotal %]</td>
294
                <td>[% loop_order.total | $Price %]</td>
294
                <td>[% loop_order.budget_name %]</td>
295
                <td>[% loop_order.budget_name %]</td>
295
				<td>
296
				<td>
296
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
297
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
Lines 376-403 Link Here
376
        [% FOREACH key IN funds.keys.sort %]
377
        [% FOREACH key IN funds.keys.sort %]
377
            <tr>
378
            <tr>
378
                <td colspan="6" class="total">(Tax exc.)</td>
379
                <td colspan="6" class="total">(Tax exc.)</td>
379
                <td><i>Subtotal for</i> [% key %]</td>
380
                <td colspan="2"><i>Subtotal for</i> [% key %]</td>
380
                <td>[% currency( funds.$key.estimated ) %]</td>
381
                <td>[% funds.$key.estimated | $Price %]</td>
381
                <td>[% currency( funds.$key.actual ) %]</td>
382
                <td>[% funds.$key.actual | $Price  %]</td>
382
                <td>&nbsp;</td>
383
                <td>&nbsp;</td>
383
                <td>&nbsp;</td>
384
                <td>&nbsp;</td>
384
            </tr>
385
            </tr>
385
        [% END %]
386
        [% END %]
386
        <tr>
387
        <tr>
387
            <th colspan="10" class="total">Total tax exc.</th>
388
            <th colspan="10" class="total">Total tax exc.</th>
388
            <th>[% total_gste %]</th>
389
            <th>[% total_gste | $Price %]</th>
389
            <th></th>
390
            <th></th>
390
        </tr>
391
        </tr>
391
        [% FOREACH book_foot IN book_foot_loop %]
392
        [% FOREACH book_foot IN book_foot_loop %]
392
            <tr>
393
            <tr>
393
                <th colspan="10">Total (GST [% book_foot.gstrate * 100 | format ("%.1f") %]%)</th>
394
                <th colspan="10">Total (GST [% book_foot.gstrate * 100 | $Price %]%)</th>
394
                <th>[% book_foot.value %]</th>
395
                <th>[% book_foot.gstvalue | $Price %]</th>
395
                <th></th>
396
                <th></th>
396
            </tr>
397
            </tr>
397
        [% END %]
398
        [% END %]
398
        <tr>
399
        <tr>
399
            <th colspan="10" class="total">Total tax inc.</th>
400
            <th colspan="10" class="total">Total tax inc.</th>
400
            <th>[% total_gsti %]</th>
401
            <th>[% total_gsti | $Price %]</th>
401
            <th></th>
402
            <th></th>
402
        </tr>
403
        </tr>
403
    </tfoot>
404
    </tfoot>
Lines 438-446 Link Here
438
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
439
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
439
                <td>[% order.quantityreceived %]</td>
440
                <td>[% order.quantityreceived %]</td>
440
                <td>[% order.budget.budget_name %]</td>
441
                <td>[% order.budget.budget_name %]</td>
441
                <td>[% order.ecost %]</td>
442
                <td>[% order.ecost | $Price %]</td>
442
                <td>[% order.unitprice %]</td>
443
                <td>[% order.unitprice | $Price %]</td>
443
                <td>[% order.total %]</td>
444
                <td>[% order.total | $Price %]</td>
444
                <td>
445
                <td>
445
                    [% IF loop_receive.cannot_cancel or ( Koha.Preference("AcqCreateItem") == "receiving" and loop_receive.holds > 0 ) %]
446
                    [% IF loop_receive.cannot_cancel or ( Koha.Preference("AcqCreateItem") == "receiving" and loop_receive.holds > 0 ) %]
446
                      [% IF loop_receive.cannot_cancel %]
447
                      [% IF loop_receive.cannot_cancel %]
447
- 

Return to bug 13001