Lines 93-98
BEGIN {
Link Here
|
93 |
&NotifyOrderUsers |
93 |
&NotifyOrderUsers |
94 |
|
94 |
|
95 |
&FillWithDefaultValues |
95 |
&FillWithDefaultValues |
|
|
96 |
|
97 |
&get_rounded_price |
96 |
); |
98 |
); |
97 |
} |
99 |
} |
98 |
|
100 |
|
Lines 1470-1477
sub ModReceiveOrder {
Link Here
|
1470 |
$dbh->do(q| |
1472 |
$dbh->do(q| |
1471 |
UPDATE aqorders |
1473 |
UPDATE aqorders |
1472 |
SET |
1474 |
SET |
1473 |
tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, |
1475 |
tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering, |
1474 |
tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving |
1476 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1475 |
WHERE ordernumber = ? |
1477 |
WHERE ordernumber = ? |
1476 |
|, undef, $order->{ordernumber}); |
1478 |
|, undef, $order->{ordernumber}); |
1477 |
|
1479 |
|
Lines 1483-1490
sub ModReceiveOrder {
Link Here
|
1483 |
$order->{tax_rate_on_ordering} //= 0; |
1485 |
$order->{tax_rate_on_ordering} //= 0; |
1484 |
$order->{unitprice_tax_excluded} //= 0; |
1486 |
$order->{unitprice_tax_excluded} //= 0; |
1485 |
$order->{tax_rate_on_receiving} //= 0; |
1487 |
$order->{tax_rate_on_receiving} //= 0; |
1486 |
$order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
1488 |
$order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
1487 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
1489 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
1488 |
$order->{datereceived} = $datereceived; |
1490 |
$order->{datereceived} = $datereceived; |
1489 |
$order->{invoiceid} = $invoice->{invoiceid}; |
1491 |
$order->{invoiceid} = $invoice->{invoiceid}; |
1490 |
$order->{orderstatus} = 'complete'; |
1492 |
$order->{orderstatus} = 'complete'; |
Lines 1646-1653
sub CancelReceipt {
Link Here
|
1646 |
$dbh->do(q| |
1648 |
$dbh->do(q| |
1647 |
UPDATE aqorders |
1649 |
UPDATE aqorders |
1648 |
SET |
1650 |
SET |
1649 |
tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, |
1651 |
tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering, |
1650 |
tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving |
1652 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
1651 |
WHERE ordernumber = ? |
1653 |
WHERE ordernumber = ? |
1652 |
|, undef, $parent_ordernumber); |
1654 |
|, undef, $parent_ordernumber); |
1653 |
|
1655 |
|
Lines 1998-2003
sub TransferOrder {
Link Here
|
1998 |
return $newordernumber; |
2000 |
return $newordernumber; |
1999 |
} |
2001 |
} |
2000 |
|
2002 |
|
|
|
2003 |
=head3 _get_rounding_sql |
2004 |
|
2005 |
$rounding_sql = _get_rounding_sql("mysql_variable_to_round_string"); |
2006 |
|
2007 |
returns the correct SQL routine based on OrderPriceRounding system preference. |
2008 |
|
2009 |
=cut |
2010 |
|
2011 |
sub _get_rounding_sql { |
2012 |
my $round_string = @_; |
2013 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2014 |
if ( $rounding_pref eq "nearest_cent" ) { return ("ROUND($round_string,2)"); } |
2015 |
else { return ("$round_string"); } |
2016 |
} |
2017 |
|
2018 |
=head3 get_rounded_price |
2019 |
|
2020 |
$rounded_price = get_rounded_price( $price ); |
2021 |
|
2022 |
returns a price rounded as specified in OrderPriceRounding system preference. |
2023 |
|
2024 |
=cut |
2025 |
|
2026 |
sub get_rounded_price { |
2027 |
my $price = @_; |
2028 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
2029 |
if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); } |
2030 |
else { return $price; } |
2031 |
} |
2032 |
|
2033 |
|
2001 |
=head2 FUNCTIONS ABOUT PARCELS |
2034 |
=head2 FUNCTIONS ABOUT PARCELS |
2002 |
|
2035 |
|
2003 |
=head3 GetParcels |
2036 |
=head3 GetParcels |
Lines 2149-2158
sub GetLateOrders {
Link Here
|
2149 |
AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00') |
2182 |
AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00') |
2150 |
"; |
2183 |
"; |
2151 |
my $having = ""; |
2184 |
my $having = ""; |
|
|
2185 |
my ($round_sql_start,$round_sql_end) = _get_rounding_sql(); |
2152 |
if ($dbdriver eq "mysql") { |
2186 |
if ($dbdriver eq "mysql") { |
2153 |
$select .= " |
2187 |
$select .= " |
2154 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
2188 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
2155 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, |
2189 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * $round_sql_start aqorders.rrp $round_sql_end AS subtotal, |
2156 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
2190 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
2157 |
"; |
2191 |
"; |
2158 |
if ( defined $delay ) { |
2192 |
if ( defined $delay ) { |
Lines 2164-2170
sub GetLateOrders {
Link Here
|
2164 |
# FIXME: account for IFNULL as above |
2198 |
# FIXME: account for IFNULL as above |
2165 |
$select .= " |
2199 |
$select .= " |
2166 |
aqorders.quantity AS quantity, |
2200 |
aqorders.quantity AS quantity, |
2167 |
aqorders.quantity * aqorders.rrp AS subtotal, |
2201 |
aqorders.quantity * $round_sql_start aqorders.rrp $round_sql_end AS subtotal, |
2168 |
(CAST(now() AS date) - closedate) AS latesince |
2202 |
(CAST(now() AS date) - closedate) AS latesince |
2169 |
"; |
2203 |
"; |
2170 |
if ( defined $delay ) { |
2204 |
if ( defined $delay ) { |
Lines 2978-2984
sub populate_order_with_prices {
Link Here
|
2978 |
|
3012 |
|
2979 |
# tax value = quantity * ecost tax excluded * tax rate |
3013 |
# tax value = quantity * ecost tax excluded * tax rate |
2980 |
$order->{tax_value_on_ordering} = |
3014 |
$order->{tax_value_on_ordering} = |
2981 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
3015 |
$order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
2982 |
} |
3016 |
} |
2983 |
|
3017 |
|
2984 |
if ($receiving) { |
3018 |
if ($receiving) { |
Lines 3012-3018
sub populate_order_with_prices {
Link Here
|
3012 |
} |
3046 |
} |
3013 |
|
3047 |
|
3014 |
# tax value = quantity * unit price tax excluded * tax rate |
3048 |
# tax value = quantity * unit price tax excluded * tax rate |
3015 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
3049 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
3016 |
} |
3050 |
} |
3017 |
|
3051 |
|
3018 |
return $order; |
3052 |
return $order; |