|
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 1472-1479
sub ModReceiveOrder {
Link Here
|
| 1472 |
$dbh->do(q| |
1474 |
$dbh->do(q| |
| 1473 |
UPDATE aqorders |
1475 |
UPDATE aqorders |
| 1474 |
SET |
1476 |
SET |
| 1475 |
tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, |
1477 |
tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering, |
| 1476 |
tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving |
1478 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
| 1477 |
WHERE ordernumber = ? |
1479 |
WHERE ordernumber = ? |
| 1478 |
|, undef, $order->{ordernumber}); |
1480 |
|, undef, $order->{ordernumber}); |
| 1479 |
|
1481 |
|
|
Lines 1485-1492
sub ModReceiveOrder {
Link Here
|
| 1485 |
$order->{tax_rate_on_ordering} //= 0; |
1487 |
$order->{tax_rate_on_ordering} //= 0; |
| 1486 |
$order->{unitprice_tax_excluded} //= 0; |
1488 |
$order->{unitprice_tax_excluded} //= 0; |
| 1487 |
$order->{tax_rate_on_receiving} //= 0; |
1489 |
$order->{tax_rate_on_receiving} //= 0; |
| 1488 |
$order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
1490 |
$order->{tax_value_on_ordering} = $order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
| 1489 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
1491 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
| 1490 |
$order->{datereceived} = $datereceived; |
1492 |
$order->{datereceived} = $datereceived; |
| 1491 |
$order->{invoiceid} = $invoice->{invoiceid}; |
1493 |
$order->{invoiceid} = $invoice->{invoiceid}; |
| 1492 |
$order->{orderstatus} = 'complete'; |
1494 |
$order->{orderstatus} = 'complete'; |
|
Lines 1648-1655
sub CancelReceipt {
Link Here
|
| 1648 |
$dbh->do(q| |
1650 |
$dbh->do(q| |
| 1649 |
UPDATE aqorders |
1651 |
UPDATE aqorders |
| 1650 |
SET |
1652 |
SET |
| 1651 |
tax_value_on_ordering = quantity * ecost_tax_excluded * tax_rate_on_ordering, |
1653 |
tax_value_on_ordering = quantity * | . _get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering, |
| 1652 |
tax_value_on_receiving = quantity * unitprice_tax_excluded * tax_rate_on_receiving |
1654 |
tax_value_on_receiving = quantity * | . _get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving |
| 1653 |
WHERE ordernumber = ? |
1655 |
WHERE ordernumber = ? |
| 1654 |
|, undef, $parent_ordernumber); |
1656 |
|, undef, $parent_ordernumber); |
| 1655 |
|
1657 |
|
|
Lines 2000-2005
sub TransferOrder {
Link Here
|
| 2000 |
return $newordernumber; |
2002 |
return $newordernumber; |
| 2001 |
} |
2003 |
} |
| 2002 |
|
2004 |
|
|
|
2005 |
=head3 _get_rounding_sql |
| 2006 |
|
| 2007 |
$rounding_sql = _get_rounding_sql("mysql_variable_to_round_string"); |
| 2008 |
|
| 2009 |
returns the correct SQL routine based on OrderPriceRounding system preference. |
| 2010 |
|
| 2011 |
=cut |
| 2012 |
|
| 2013 |
sub _get_rounding_sql { |
| 2014 |
my $round_string = @_; |
| 2015 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
| 2016 |
if ( $rounding_pref eq "nearest_cent" ) { return ("ROUND($round_string,2)"); } |
| 2017 |
else { return ("$round_string"); } |
| 2018 |
} |
| 2019 |
|
| 2020 |
=head3 get_rounded_price |
| 2021 |
|
| 2022 |
$rounded_price = get_rounded_price( $price ); |
| 2023 |
|
| 2024 |
returns a price rounded as specified in OrderPriceRounding system preference. |
| 2025 |
|
| 2026 |
=cut |
| 2027 |
|
| 2028 |
sub get_rounded_price { |
| 2029 |
my $price = @_; |
| 2030 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
| 2031 |
if( $rounding_pref eq 'nearest_cent' ) { return Koha::Number::Price->new( $price )->format(); } |
| 2032 |
else { return $price; } |
| 2033 |
} |
| 2034 |
|
| 2035 |
|
| 2003 |
=head2 FUNCTIONS ABOUT PARCELS |
2036 |
=head2 FUNCTIONS ABOUT PARCELS |
| 2004 |
|
2037 |
|
| 2005 |
=head3 GetParcels |
2038 |
=head3 GetParcels |
|
Lines 2150-2159
sub GetLateOrders {
Link Here
|
| 2150 |
AND aqbasket.closedate IS NOT NULL |
2183 |
AND aqbasket.closedate IS NOT NULL |
| 2151 |
AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00') |
2184 |
AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00') |
| 2152 |
"; |
2185 |
"; |
|
|
2186 |
my ($round_sql_start,$round_sql_end) = _get_rounding_sql(); |
| 2153 |
if ($dbdriver eq "mysql") { |
2187 |
if ($dbdriver eq "mysql") { |
| 2154 |
$select .= " |
2188 |
$select .= " |
| 2155 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
2189 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
| 2156 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, |
2190 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * $round_sql_start aqorders.rrp $round_sql_end AS subtotal, |
| 2157 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
2191 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
| 2158 |
"; |
2192 |
"; |
| 2159 |
if ( defined $delay ) { |
2193 |
if ( defined $delay ) { |
|
Lines 2165-2171
sub GetLateOrders {
Link Here
|
| 2165 |
# FIXME: account for IFNULL as above |
2199 |
# FIXME: account for IFNULL as above |
| 2166 |
$select .= " |
2200 |
$select .= " |
| 2167 |
aqorders.quantity AS quantity, |
2201 |
aqorders.quantity AS quantity, |
| 2168 |
aqorders.quantity * aqorders.rrp AS subtotal, |
2202 |
aqorders.quantity * $round_sql_start aqorders.rrp $round_sql_end AS subtotal, |
| 2169 |
(CAST(now() AS date) - closedate) AS latesince |
2203 |
(CAST(now() AS date) - closedate) AS latesince |
| 2170 |
"; |
2204 |
"; |
| 2171 |
if ( defined $delay ) { |
2205 |
if ( defined $delay ) { |
|
Lines 3000-3006
sub populate_order_with_prices {
Link Here
|
| 3000 |
|
3034 |
|
| 3001 |
# tax value = quantity * ecost tax excluded * tax rate |
3035 |
# tax value = quantity * ecost tax excluded * tax rate |
| 3002 |
$order->{tax_value_on_ordering} = |
3036 |
$order->{tax_value_on_ordering} = |
| 3003 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
3037 |
$order->{quantity} * get_rounded_price($order->{ecost_tax_excluded}) * $order->{tax_rate_on_ordering}; |
| 3004 |
} |
3038 |
} |
| 3005 |
|
3039 |
|
| 3006 |
if ($receiving) { |
3040 |
if ($receiving) { |
|
Lines 3034-3040
sub populate_order_with_prices {
Link Here
|
| 3034 |
} |
3068 |
} |
| 3035 |
|
3069 |
|
| 3036 |
# tax value = quantity * unit price tax excluded * tax rate |
3070 |
# tax value = quantity * unit price tax excluded * tax rate |
| 3037 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
3071 |
$order->{tax_value_on_receiving} = $order->{quantity} * get_rounded_price($order->{unitprice_tax_excluded}) * $order->{tax_rate_on_receiving}; |
| 3038 |
} |
3072 |
} |
| 3039 |
|
3073 |
|
| 3040 |
return $order; |
3074 |
return $order; |