Lines 96-101
BEGIN {
Link Here
|
96 |
|
96 |
|
97 |
&get_rounded_price |
97 |
&get_rounded_price |
98 |
); |
98 |
); |
|
|
99 |
print STDERR "C4/Acquisition.pm 1\n"; |
99 |
} |
100 |
} |
100 |
|
101 |
|
101 |
|
102 |
|
Lines 1478-1483
sub ModReceiveOrder {
Link Here
|
1478 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1479 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1479 |
WHERE ordernumber = ? |
1480 |
WHERE ordernumber = ? |
1480 |
|, undef, $order->{ordernumber}); |
1481 |
|, undef, $order->{ordernumber}); |
|
|
1482 |
print STDERR "C4/Acquisition.pm 2\n"; |
1481 |
|
1483 |
|
1482 |
delete $order->{ordernumber}; |
1484 |
delete $order->{ordernumber}; |
1483 |
$order->{budget_id} = ( $budget_id || $order->{budget_id} ); |
1485 |
$order->{budget_id} = ( $budget_id || $order->{budget_id} ); |
Lines 1489-1494
sub ModReceiveOrder {
Link Here
|
1489 |
$order->{tax_rate_on_receiving} //= 0; |
1491 |
$order->{tax_rate_on_receiving} //= 0; |
1490 |
$order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
1492 |
$order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
1491 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
1493 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
|
|
1494 |
print STDERR "C4/Acquisition.pm 3\n"; |
1492 |
$order->{datereceived} = $datereceived; |
1495 |
$order->{datereceived} = $datereceived; |
1493 |
$order->{invoiceid} = $invoice->{invoiceid}; |
1496 |
$order->{invoiceid} = $invoice->{invoiceid}; |
1494 |
$order->{orderstatus} = 'complete'; |
1497 |
$order->{orderstatus} = 'complete'; |
Lines 1654-1659
sub CancelReceipt {
Link Here
|
1654 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1657 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1655 |
WHERE ordernumber = ? |
1658 |
WHERE ordernumber = ? |
1656 |
|, undef, $parent_ordernumber); |
1659 |
|, undef, $parent_ordernumber); |
|
|
1660 |
print STDERR "C4/Acquisition.pm 4\n"; |
1657 |
|
1661 |
|
1658 |
_cancel_items_receipt( $order_obj, $parent_ordernumber ); |
1662 |
_cancel_items_receipt( $order_obj, $parent_ordernumber ); |
1659 |
# Delete order line |
1663 |
# Delete order line |
Lines 2013-2020
returns the correct SQL routine based on OrderPriceRounding system preference.
Link Here
|
2013 |
sub _get_rounding_sql { |
2017 |
sub _get_rounding_sql { |
2014 |
my ( $round_string ) = @_; |
2018 |
my ( $round_string ) = @_; |
2015 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2019 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2016 |
if ( $rounding_pref eq "nearest_cent" ) { return ("CAST($round_string*100 AS INTEGER)/100"); } |
2020 |
if ( $rounding_pref eq "nearest_cent" ) { |
2017 |
else { return ("$round_string"); } |
2021 |
print STDERR "C4/Acquisition.pm 5\n"; |
|
|
2022 |
return ("CAST($round_string*100 AS INTEGER)/100"); } |
2023 |
else { |
2024 |
print STDERR "C4/Acquisition.pm 6\n"; |
2025 |
return ("$round_string"); } |
2018 |
} |
2026 |
} |
2019 |
|
2027 |
|
2020 |
=head3 get_rounded_price |
2028 |
=head3 get_rounded_price |
Lines 2028-2035
returns a price rounded as specified in OrderPriceRounding system preference.
Link Here
|
2028 |
sub get_rounded_price { |
2036 |
sub get_rounded_price { |
2029 |
my ( $price ) = @_; |
2037 |
my ( $price ) = @_; |
2030 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2038 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2031 |
if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); } |
2039 |
if( $rounding_pref eq 'nearest_cent' ) { |
2032 |
else { return $price; } |
2040 |
print STDERR "C4/Acquisition.pm 7\n"; |
|
|
2041 |
return Koha::Number::Price->new( $price )->format(); } |
2042 |
else { |
2043 |
print STDERR "C4/Acquisition.pm 8\n"; |
2044 |
return $price; } |
2033 |
} |
2045 |
} |
2034 |
|
2046 |
|
2035 |
|
2047 |
|
Lines 2189-2194
sub GetLateOrders {
Link Here
|
2189 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * " . _get_rounding_sql("aqorders.rrp") . " AS subtotal, |
2201 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * " . _get_rounding_sql("aqorders.rrp") . " AS subtotal, |
2190 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
2202 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
2191 |
"; |
2203 |
"; |
|
|
2204 |
print STDERR "C4/Acquisition.pm 9\n"; |
2192 |
if ( defined $delay ) { |
2205 |
if ( defined $delay ) { |
2193 |
$from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ; |
2206 |
$from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ; |
2194 |
push @query_params, $delay; |
2207 |
push @query_params, $delay; |
Lines 2201-2206
sub GetLateOrders {
Link Here
|
2201 |
aqorders.quantity * "._get_rounding_sql("aqorders.rrp")." AS subtotal, |
2214 |
aqorders.quantity * "._get_rounding_sql("aqorders.rrp")." AS subtotal, |
2202 |
(CAST(now() AS date) - closedate) AS latesince |
2215 |
(CAST(now() AS date) - closedate) AS latesince |
2203 |
"; |
2216 |
"; |
|
|
2217 |
print STDERR "C4/Acquisition.pm 10\n"; |
2204 |
if ( defined $delay ) { |
2218 |
if ( defined $delay ) { |
2205 |
$from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) "; |
2219 |
$from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) "; |
2206 |
push @query_params, $delay; |
2220 |
push @query_params, $delay; |
Lines 3034-3039
sub populate_order_with_prices {
Link Here
|
3034 |
# tax value = quantity * ecost tax excluded * tax rate |
3048 |
# tax value = quantity * ecost tax excluded * tax rate |
3035 |
$order->{tax_value_on_ordering} = |
3049 |
$order->{tax_value_on_ordering} = |
3036 |
$order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
3050 |
$order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
|
|
3051 |
print STDERR "C4/Acquisition.pm 11\n"; |
3037 |
} |
3052 |
} |
3038 |
|
3053 |
|
3039 |
if ($receiving) { |
3054 |
if ($receiving) { |
Lines 3068-3073
sub populate_order_with_prices {
Link Here
|
3068 |
|
3083 |
|
3069 |
# tax value = quantity * unit price tax excluded * tax rate |
3084 |
# tax value = quantity * unit price tax excluded * tax rate |
3070 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
3085 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
|
|
3086 |
print STDERR "C4/Acquisition.pm 12\n"; |
3071 |
} |
3087 |
} |
3072 |
|
3088 |
|
3073 |
return $order; |
3089 |
return $order; |
3074 |
- |
|
|