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

(-)a/C4/Acquisition.pm (-6 / +6 lines)
Lines 2408-2414 Return a list of invoices that match all given criteria. Link Here
2408
2408
2409
$order_by is "column_name (asc|desc)", where column_name is any of
2409
$order_by is "column_name (asc|desc)", where column_name is any of
2410
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
2410
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
2411
'shipmentcost', 'shipmentcost_budgetid'.
2411
'shipping', 'shipmentcost_budgetid'.
2412
2412
2413
asc is the default if omitted
2413
asc is the default if omitted
2414
2414
Lines 2418-2424 sub GetInvoices { Link Here
2418
    my %args = @_;
2418
    my %args = @_;
2419
2419
2420
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2420
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2421
        closedate shipmentcost shipmentcost_budgetid);
2421
        closedate shipping shipmentcost_budgetid);
2422
2422
2423
    my $dbh = C4::Context->dbh;
2423
    my $dbh = C4::Context->dbh;
2424
    my $query = qq{
2424
    my $query = qq{
Lines 2608-2614 sub GetInvoiceDetails { Link Here
2608
        shipmentdate => $shipmentdate,
2608
        shipmentdate => $shipmentdate,
2609
        billingdate => $billingdate,
2609
        billingdate => $billingdate,
2610
        closedate => $closedate,
2610
        closedate => $closedate,
2611
        shipmentcost => $shipmentcost,
2611
        shipping => $shipping,
2612
        shipmentcost_budgetid => $shipmentcost_budgetid
2612
        shipmentcost_budgetid => $shipmentcost_budgetid
2613
    );
2613
    );
2614
2614
Lines 2622-2628 sub AddInvoice { Link Here
2622
    return unless(%invoice and $invoice{invoicenumber});
2622
    return unless(%invoice and $invoice{invoicenumber});
2623
2623
2624
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2624
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2625
        closedate shipmentcost shipmentcost_budgetid);
2625
        closedate shipping shipmentcost_budgetid);
2626
2626
2627
    my @set_strs;
2627
    my @set_strs;
2628
    my @set_args;
2628
    my @set_args;
Lines 2656-2662 sub AddInvoice { Link Here
2656
        shipmentdate => $shipmentdate,
2656
        shipmentdate => $shipmentdate,
2657
        billingdate => $billingdate,
2657
        billingdate => $billingdate,
2658
        closedate => $closedate,
2658
        closedate => $closedate,
2659
        shipmentcost => $shipmentcost,
2659
        shipping => $shipping,
2660
        shipmentcost_budgetid => $shipmentcost_budgetid
2660
        shipmentcost_budgetid => $shipmentcost_budgetid
2661
    );
2661
    );
2662
2662
Lines 2672-2678 sub ModInvoice { Link Here
2672
    return unless(%invoice and $invoice{invoiceid});
2672
    return unless(%invoice and $invoice{invoiceid});
2673
2673
2674
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2674
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2675
        closedate shipmentcost shipmentcost_budgetid);
2675
        closedate shipping shipmentcost_budgetid);
2676
2676
2677
    my @set_strs;
2677
    my @set_strs;
2678
    my @set_args;
2678
    my @set_args;
(-)a/C4/Budgets.pm (-6 / +6 lines)
Lines 344-357 sub GetBudgetSpent { Link Here
344
	my $sum =  $sth->fetchrow_array;
344
	my $sum =  $sth->fetchrow_array;
345
345
346
    $sth = $dbh->prepare(qq|
346
    $sth = $dbh->prepare(qq|
347
        SELECT SUM(shipmentcost) AS sum
347
        SELECT SUM(shipping) AS sum
348
        FROM aqinvoices
348
        FROM aqinvoices
349
        WHERE shipmentcost_budgetid = ?
349
        WHERE shipmentcost_budgetid = ?
350
          AND closedate IS NOT NULL
350
          AND closedate IS NOT NULL
351
    |);
351
    |);
352
    $sth->execute($budget_id);
352
    $sth->execute($budget_id);
353
    my ($shipmentcost_sum) = $sth->fetchrow_array;
353
    my ($shipping_sum) = $sth->fetchrow_array;
354
    $sum += $shipmentcost_sum;
354
    $sum += $shipping_sum;
355
355
356
	return $sum;
356
	return $sum;
357
}
357
}
Lines 370-383 sub GetBudgetOrdered { Link Here
370
	my $sum =  $sth->fetchrow_array;
370
	my $sum =  $sth->fetchrow_array;
371
371
372
    $sth = $dbh->prepare(qq|
372
    $sth = $dbh->prepare(qq|
373
        SELECT SUM(shipmentcost) AS sum
373
        SELECT SUM(shipping) AS sum
374
        FROM aqinvoices
374
        FROM aqinvoices
375
        WHERE shipmentcost_budgetid = ?
375
        WHERE shipmentcost_budgetid = ?
376
          AND closedate IS NULL
376
          AND closedate IS NULL
377
    |);
377
    |);
378
    $sth->execute($budget_id);
378
    $sth->execute($budget_id);
379
    my ($shipmentcost_sum) = $sth->fetchrow_array;
379
    my ($shipping_sum) = $sth->fetchrow_array;
380
    $sum += $shipmentcost_sum;
380
    $sum += $shipping_sum;
381
381
382
	return $sum;
382
	return $sum;
383
}
383
}
(-)a/acqui/invoice.pl (-5 / +5 lines)
Lines 78-90 elsif ( $op && $op eq 'reopen' ) { Link Here
78
elsif ( $op && $op eq 'mod' ) {
78
elsif ( $op && $op eq 'mod' ) {
79
    my $shipmentdate       = $input->param('shipmentdate');
79
    my $shipmentdate       = $input->param('shipmentdate');
80
    my $billingdate        = $input->param('billingdate');
80
    my $billingdate        = $input->param('billingdate');
81
    my $shipmentcost       = $input->param('shipmentcost');
81
    my $shipping           = $input->param('shipping');
82
    my $shipment_budget_id = $input->param('shipment_budget_id');
82
    my $shipment_budget_id = $input->param('shipment_budget_id');
83
    ModInvoice(
83
    ModInvoice(
84
        invoiceid             => $invoiceid,
84
        invoiceid             => $invoiceid,
85
        shipmentdate          => C4::Dates->new($shipmentdate)->output("iso"),
85
        shipmentdate          => C4::Dates->new($shipmentdate)->output("iso"),
86
        billingdate           => C4::Dates->new($billingdate)->output("iso"),
86
        billingdate           => C4::Dates->new($billingdate)->output("iso"),
87
        shipmentcost          => $shipmentcost,
87
        shipping              => $shipping,
88
        shipmentcost_budgetid => $shipment_budget_id
88
        shipmentcost_budgetid => $shipment_budget_id
89
    );
89
    );
90
    if ($input->param('reopen')) {
90
    if ($input->param('reopen')) {
Lines 167-181 $template->param( Link Here
167
    shipmentdate     => $details->{'shipmentdate'},
167
    shipmentdate     => $details->{'shipmentdate'},
168
    billingdate      => $details->{'billingdate'},
168
    billingdate      => $details->{'billingdate'},
169
    invoiceclosedate => $details->{'closedate'},
169
    invoiceclosedate => $details->{'closedate'},
170
    shipmentcost     => $details->{'shipmentcost'},
170
    shipping     => $details->{'shipping'},
171
    orders_loop      => \@orders_loop,
171
    orders_loop      => \@orders_loop,
172
    foot_loop        => \@foot_loop,
172
    foot_loop        => \@foot_loop,
173
    total_quantity   => $total_quantity,
173
    total_quantity   => $total_quantity,
174
    total_tax_excluded => $total_tax_excluded,
174
    total_tax_excluded => $total_tax_excluded,
175
    total_tax_included => $total_tax_included,
175
    total_tax_included => $total_tax_included,
176
    total_tax_value  => $total_tax_value,
176
    total_tax_value  => $total_tax_value,
177
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
177
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipping},
178
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
178
    total_tax_included_shipment => $total_tax_included + $details->{shipping},
179
    invoiceincgst    => $bookseller->{invoiceincgst},
179
    invoiceincgst    => $bookseller->{invoiceincgst},
180
    currency         => GetCurrency()->{currency},
180
    currency         => GetCurrency()->{currency},
181
    budgets_loop     => \@budgets_loop,
181
    budgets_loop     => \@budgets_loop,
(-)a/acqui/orderreceive.pl (-3 / +3 lines)
Lines 42-48 to know on what supplier this script has to display receive order. Link Here
42
42
43
the id of this invoice.
43
the id of this invoice.
44
44
45
=item freight
45
=item shipping
46
46
47
=item biblio
47
=item biblio
48
48
Lines 84-90 my $dbh = C4::Context->dbh; Link Here
84
my $invoiceid    = $input->param('invoiceid');
84
my $invoiceid    = $input->param('invoiceid');
85
my $invoice      = GetInvoice($invoiceid);
85
my $invoice      = GetInvoice($invoiceid);
86
my $booksellerid   = $invoice->{booksellerid};
86
my $booksellerid   = $invoice->{booksellerid};
87
my $freight      = $invoice->{shipmentcost};
87
my $shipping     = $invoice->{shipping};
88
my $datereceived = $invoice->{shipmentdate};
88
my $datereceived = $invoice->{shipmentdate};
89
my $ordernumber  = $input->param('ordernumber');
89
my $ordernumber  = $input->param('ordernumber');
90
90
Lines 205-211 $template->param( Link Here
205
    ordernumber           => $order->{'ordernumber'},
205
    ordernumber           => $order->{'ordernumber'},
206
    subscriptionid        => $order->{subscriptionid},
206
    subscriptionid        => $order->{subscriptionid},
207
    booksellerid          => $order->{'booksellerid'},
207
    booksellerid          => $order->{'booksellerid'},
208
    freight               => $freight,
208
    shipping              => $shipping,
209
    name                  => $bookseller->{'name'},
209
    name                  => $bookseller->{'name'},
210
    date                  => format_date($order->{entrydate}),
210
    date                  => format_date($order->{entrydate}),
211
    title                 => $order->{'title'},
211
    title                 => $order->{'title'},
(-)a/acqui/parcels.pl (-3 / +3 lines)
Lines 101-107 our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
101
101
102
my $invoicenumber = $input->param('invoice');
102
my $invoicenumber = $input->param('invoice');
103
my $shipmentdate = $input->param('shipmentdate');
103
my $shipmentdate = $input->param('shipmentdate');
104
my $shipmentcost = $input->param('shipmentcost');
104
my $shipping = $input->param('shipping');
105
my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid');
105
my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid');
106
if($shipmentdate) {
106
if($shipmentdate) {
107
    $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
107
    $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
Lines 117-123 if ( $op and $op eq 'new' ) { Link Here
117
            $template->{'VARS'}->{'duplicate_invoices'} = \@invoices;
117
            $template->{'VARS'}->{'duplicate_invoices'} = \@invoices;
118
            $template->{'VARS'}->{'invoicenumber'}      = $invoicenumber;
118
            $template->{'VARS'}->{'invoicenumber'}      = $invoicenumber;
119
            $template->{'VARS'}->{'shipmentdate'}       = $shipmentdate;
119
            $template->{'VARS'}->{'shipmentdate'}       = $shipmentdate;
120
            $template->{'VARS'}->{'shipmentcost'}       = $shipmentcost;
120
            $template->{'VARS'}->{'shipping'}       = $shipping;
121
            $template->{'VARS'}->{'shipmentcost_budgetid'} =
121
            $template->{'VARS'}->{'shipmentcost_budgetid'} =
122
              $shipmentcost_budgetid;
122
              $shipmentcost_budgetid;
123
        }
123
        }
Lines 129-135 if ($op and $op eq 'confirm') { Link Here
129
        invoicenumber => $invoicenumber,
129
        invoicenumber => $invoicenumber,
130
        booksellerid => $booksellerid,
130
        booksellerid => $booksellerid,
131
        shipmentdate => $shipmentdate,
131
        shipmentdate => $shipmentdate,
132
        shipmentcost => $shipmentcost,
132
        shipping => $shipping,
133
        shipmentcost_budgetid => $shipmentcost_budgetid,
133
        shipmentcost_budgetid => $shipmentcost_budgetid,
134
    );
134
    );
135
    if(defined $invoiceid) {
135
    if(defined $invoiceid) {
(-)a/acqui/spent.pl (-6 / +6 lines)
Lines 105-123 while ( my $data = $sth->fetchrow_hashref ) { Link Here
105
105
106
my $total = $subtotal;
106
my $total = $subtotal;
107
$query = qq{
107
$query = qq{
108
    SELECT invoicenumber, shipmentcost
108
    SELECT invoicenumber, shipping
109
    FROM aqinvoices
109
    FROM aqinvoices
110
    WHERE shipmentcost_budgetid = ?
110
    WHERE shipmentcost_budgetid = ?
111
};
111
};
112
$sth = $dbh->prepare($query);
112
$sth = $dbh->prepare($query);
113
$sth->execute($bookfund);
113
$sth->execute($bookfund);
114
my @shipmentcosts;
114
my @shippings;
115
while (my $data = $sth->fetchrow_hashref) {
115
while (my $data = $sth->fetchrow_hashref) {
116
    push @shipmentcosts, {
116
    push @shippings, {
117
        shipmentcost => sprintf("%.2f", $data->{shipmentcost}),
117
        shipping => sprintf("%.2f", $data->{shipping}),
118
        invoicenumber => $data->{invoicenumber}
118
        invoicenumber => $data->{invoicenumber}
119
    };
119
    };
120
    $total += $data->{shipmentcost};
120
    $total += $data->{shipping};
121
}
121
}
122
$sth->finish;
122
$sth->finish;
123
123
Lines 127-133 $template->param( Link Here
127
    fund => $bookfund,
127
    fund => $bookfund,
128
    spent => \@spent,
128
    spent => \@spent,
129
    subtotal => $subtotal,
129
    subtotal => $subtotal,
130
    shipmentcosts => \@shipmentcosts,
130
    shippings => \@shippings,
131
    total => $total,
131
    total => $total,
132
    fund_code => $fund_code
132
    fund_code => $fund_code
133
);
133
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (-6 / +6 lines)
Lines 46-52 $(document).ready(function() { Link Here
46
                            'invoicenumber': $(row).find('td:nth-child(2) a').text(),
46
                            'invoicenumber': $(row).find('td:nth-child(2) a').text(),
47
                            'shipmentdate': $(row).attr('data-shipmentdate'),
47
                            'shipmentdate': $(row).attr('data-shipmentdate'),
48
                            'billingdate': $(row).attr('data-billingdate'),
48
                            'billingdate': $(row).attr('data-billingdate'),
49
                            'shipmentcost': $(row).attr('data-shipmentcost'),
49
                            'shipping': $(row).attr('data-shipping'),
50
                            'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
50
                            'shipment_budgetid': $(row).attr('data-shipment_budgetid'),
51
                            'closedate': $(row).attr('data-closedate'), });
51
                            'closedate': $(row).attr('data-closedate'), });
52
            $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
52
            $('#merge_invoice_form').append('<input type="hidden" name="merge" value="' + $(row).attr('data-invoiceid') + '" />');
Lines 56-68 $(document).ready(function() { Link Here
56
        } else {
56
        } else {
57
            $('#merge_table tbody').empty();
57
            $('#merge_table tbody').empty();
58
            $.each(invoices, function (idx, invoice) {
58
            $.each(invoices, function (idx, invoice) {
59
                var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipmentcost + '</td></tr>');
59
                var row = $('<tr data-invoiceid="' + invoice.invoiceid + '"><td>' + invoice.invoicenumber + '</td><td>' + invoice.shipmentdate + '</td><td>' + invoice.billingdate + '</td><td>' + invoice.shipping + '</td></tr>');
60
                $(row).appendTo('#merge_table tbody');
60
                $(row).appendTo('#merge_table tbody');
61
                $(row).click(function () {
61
                $(row).click(function () {
62
                    $('#merge_table tbody tr').removeClass('active');
62
                    $('#merge_table tbody tr').removeClass('active');
63
                    $(this).addClass('active');
63
                    $(this).addClass('active');
64
                    $('#merge_invoicenumber').text(invoice.invoicenumber);
64
                    $('#merge_invoicenumber').text(invoice.invoicenumber);
65
                    $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipmentcost', 'shipment_budgetid'], function (idx, prop) {
65
                    $.each(['invoiceid', 'shipmentdate', 'billingdate', 'shipping', 'shipment_budgetid'], function (idx, prop) {
66
                        $('#merge_' + prop).val(invoice[prop]);
66
                        $('#merge_' + prop).val(invoice[prop]);
67
                    });
67
                    });
68
                    if (invoice.closedate) {
68
                    if (invoice.closedate) {
Lines 115-121 $(document).ready(function() { Link Here
115
            </thead>
115
            </thead>
116
            <tbody>
116
            <tbody>
117
              [% FOREACH invoice IN invoices %]
117
              [% FOREACH invoice IN invoices %]
118
                <tr data-invoiceid="[% invoice.invoiceid %]" data-booksellerid="[% invoice.booksellerid %]" data-shipmentdate="[% invoice.shipmentdate | $KohaDates %]" data-billingdate="[% invoice.billingdate | $KohaDates %]" data-shipmentcost="[% invoice.shipmentcost %]" data-shipment_budgetid="[% invoice.shipmentcost_budgetid %]" data-closedate="[% invoice.closedate | $KohaDates %]">
118
                <tr data-invoiceid="[% invoice.invoiceid %]" data-booksellerid="[% invoice.booksellerid %]" data-shipmentdate="[% invoice.shipmentdate | $KohaDates %]" data-billingdate="[% invoice.billingdate | $KohaDates %]" data-shipping="[% invoice.shipping %]" data-shipment_budgetid="[% invoice.shipmentcost_budgetid %]" data-closedate="[% invoice.closedate | $KohaDates %]">
119
                  <td>[% invoice.is_linked_to_subscriptions %]</td>
119
                  <td>[% invoice.is_linked_to_subscriptions %]</td>
120
                  <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid %]" /></td>
120
                  <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid %]" /></td>
121
                  <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid %]">[% invoice.invoicenumber %]</a></td>
121
                  <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid %]">[% invoice.invoicenumber %]</a></td>
Lines 177-184 $(document).ready(function() { Link Here
177
                    <li><label for="merge_billingdate">Billing date:</label>
177
                    <li><label for="merge_billingdate">Billing date:</label>
178
                            <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" readonly="readonly" class="datepicker" /></li>
178
                            <input type="text" size="10" id="merge_billingdate" name="billingdate" value="" readonly="readonly" class="datepicker" /></li>
179
179
180
                    <li><label for="merge_shipmentcost">Shipment cost:</label>
180
                    <li><label for="merge_shipping">Shipping:</label>
181
                            <input type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" /></li>
181
                            <input type="text" size="10" id="merge_shipping" name="shipping" value="" /></li>
182
                    <li><label for="merge_shipment_budgetid">Fund:</label>
182
                    <li><label for="merge_shipment_budgetid">Fund:</label>
183
                            <select id="merge_shipment_budgetid" name="shipment_budget_id">
183
                            <select id="merge_shipment_budgetid" name="shipment_budget_id">
184
                                <option value="">No fund</option>
184
                                <option value="">No fund</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-3 / +3 lines)
Lines 71-77 Link Here
71
            <input type="hidden" name="op" value="confirm" />
71
            <input type="hidden" name="op" value="confirm" />
72
            <input type="hidden" name="invoice" value="[% invoicenumber %]" />
72
            <input type="hidden" name="invoice" value="[% invoicenumber %]" />
73
            <input type="hidden" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" />
73
            <input type="hidden" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" />
74
            <input type="hidden" name="shipmentcost" value="[% shipmentcost %]" />
74
            <input type="hidden" name="shipping" value="[% shipping %]" />
75
            <input type="hidden" name="shipmentcost_budgetid" value="[% shipmentcost_budgetid %]" />
75
            <input type="hidden" name="shipmentcost_budgetid" value="[% shipmentcost_budgetid %]" />
76
            <input type="submit" class="button" value="Create new invoice anyway" />
76
            <input type="submit" class="button" value="Create new invoice anyway" />
77
        </form>
77
        </form>
Lines 176-183 Link Here
176
            <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
176
            <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
177
        </li>
177
        </li>
178
        <li>
178
        <li>
179
            <label for="shipmentcost">Shipping cost: </label>
179
            <label for="shipping">Shipping cost: </label>
180
            <input type="text" id="shipmentcost" name="shipmentcost" size="10" />
180
            <input type="text" id="shipping" name="shipping" size="10" />
181
        </li>
181
        </li>
182
        <li>
182
        <li>
183
            <label for="shipmentcost_budgetid">Fund: </label>
183
            <label for="shipmentcost_budgetid">Fund: </label>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt (-5 / +4 lines)
Lines 91-106 Link Here
91
    </tr>
91
    </tr>
92
[% END %]
92
[% END %]
93
    <tfoot>
93
    <tfoot>
94
        [% IF shipmentcosts.size %]
94
        [% IF shippings.size %]
95
            <tr valign="top">
95
            <tr valign="top">
96
                <td colspan="9"> Sub total </td>
96
                <td colspan="9"> Sub total </td>
97
                <td class="data"> [% subtotal %] </td>
97
                <td class="data"> [% subtotal %] </td>
98
            </tr>
98
            </tr>
99
            [% FOREACH shipmentcost IN shipmentcosts %]
99
            [% FOREACH shipping IN shippings %]
100
                <tr>
100
                <tr>
101
                    <td></td>
101
                    <td></td>
102
                    <td colspan="8">Shipping cost for invoice [% shipmentcost.invoicenumber %]</td>
102
                    <td colspan="8">Shipping cost for invoice [% shipping.invoicenumber %]</td>
103
                    <td class="data total">[% shipmentcost.shipmentcost %]</td>
103
                    <td class="data total">[% shipping.shipping %]</td>
104
                </tr>
104
                </tr>
105
            [% END %]
105
            [% END %]
106
        [% END %]
106
        [% END %]
107
- 

Return to bug 11062