Lines 1447-1458
sub ModReceiveOrder {
Link Here
|
1447 |
| if defined $order->{unitprice}; |
1447 |
| if defined $order->{unitprice}; |
1448 |
|
1448 |
|
1449 |
$query .= q| |
1449 |
$query .= q| |
1450 |
, rrp = ?, rrp_tax_included = ?, rrp_tax_excluded = ? |
1450 |
,tax_value_on_receiving = ? |
1451 |
| if defined $order->{rrp}; |
1451 |
| if defined $order->{tax_value_on_receiving}; |
1452 |
|
1452 |
|
1453 |
$query .= q| |
1453 |
$query .= q| |
1454 |
, ecost = ?, ecost_tax_included = ?, ecost_tax_excluded = ? |
1454 |
,tax_rate_on_receiving = ? |
1455 |
| if defined $order->{ecost}; |
1455 |
| if defined $order->{tax_rate_on_receiving}; |
1456 |
|
1456 |
|
1457 |
$query .= q| |
1457 |
$query .= q| |
1458 |
, order_internalnote = ? |
1458 |
, order_internalnote = ? |
Lines 1466-1477
sub ModReceiveOrder {
Link Here
|
1466 |
if ( defined $order->{unitprice} ) { |
1466 |
if ( defined $order->{unitprice} ) { |
1467 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1467 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1468 |
} |
1468 |
} |
1469 |
if ( defined $order->{rrp} ) { |
1469 |
|
1470 |
push @params, $order->{rrp}, $order->{rrp_tax_included}, $order->{rrp_tax_excluded}; |
1470 |
if ( defined $order->{tax_value_on_receiving} ) { |
|
|
1471 |
push @params, $order->{tax_value_on_receiving}; |
1471 |
} |
1472 |
} |
1472 |
if ( defined $order->{ecost} ) { |
1473 |
|
1473 |
push @params, $order->{ecost}, $order->{ecost_tax_included}, $order->{ecost_tax_excluded}; |
1474 |
if ( defined $order->{tax_rate_on_receiving} ) { |
|
|
1475 |
push @params, $order->{tax_rate_on_receiving}; |
1474 |
} |
1476 |
} |
|
|
1477 |
|
1475 |
if ( defined $order->{order_internalnote} ) { |
1478 |
if ( defined $order->{order_internalnote} ) { |
1476 |
push @params, $order->{order_internalnote}; |
1479 |
push @params, $order->{order_internalnote}; |
1477 |
} |
1480 |
} |
Lines 2832-2843
sub populate_order_with_prices {
Link Here
|
2832 |
$discount /= 100 if $discount > 1; |
2835 |
$discount /= 100 if $discount > 1; |
2833 |
|
2836 |
|
2834 |
if ($ordering) { |
2837 |
if ($ordering) { |
|
|
2838 |
$order->{tax_rate_on_ordering} //= $order->{tax_rate}; |
2835 |
if ( $bookseller->{listincgst} ) { |
2839 |
if ( $bookseller->{listincgst} ) { |
2836 |
# The user entered the rrp tax included |
2840 |
# The user entered the rrp tax included |
2837 |
$order->{rrp_tax_included} = $order->{rrp}; |
2841 |
$order->{rrp_tax_included} = $order->{rrp}; |
2838 |
|
2842 |
|
2839 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2843 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2840 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ); |
2844 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate_on_ordering} ); |
2841 |
|
2845 |
|
2842 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2846 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2843 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2847 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2850-2856
sub populate_order_with_prices {
Link Here
|
2850 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2854 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2851 |
|
2855 |
|
2852 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2856 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2853 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2857 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate_on_ordering} ); |
2854 |
|
2858 |
|
2855 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2859 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2856 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2860 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2858-2889
sub populate_order_with_prices {
Link Here
|
2858 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2862 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2859 |
$order->{ecost_tax_included} = |
2863 |
$order->{ecost_tax_included} = |
2860 |
$order->{rrp_tax_excluded} * |
2864 |
$order->{rrp_tax_excluded} * |
2861 |
( 1 + $order->{tax_rate} ) * |
2865 |
( 1 + $order->{tax_rate_on_ordering} ) * |
2862 |
( 1 - $discount ); |
2866 |
( 1 - $discount ); |
2863 |
} |
2867 |
} |
2864 |
|
2868 |
|
2865 |
# tax value = quantity * ecost tax excluded * tax rate |
2869 |
# tax value = quantity * ecost tax excluded * tax rate |
2866 |
$order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate}; |
2870 |
$order->{tax_value_on_ordering} = |
|
|
2871 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
2867 |
} |
2872 |
} |
2868 |
|
2873 |
|
2869 |
if ($receiving) { |
2874 |
if ($receiving) { |
|
|
2875 |
$order->{tax_rate_on_receiving} //= $order->{tax_rate}; |
2870 |
if ( $bookseller->{invoiceincgst} ) { |
2876 |
if ( $bookseller->{invoiceincgst} ) { |
2871 |
# The user entered the unit price tax included |
2877 |
# The user entered the unit price tax included |
2872 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2878 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2873 |
|
2879 |
|
2874 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2880 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2875 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); |
2881 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate_on_receiving} ); |
2876 |
} |
2882 |
} |
2877 |
else { |
2883 |
else { |
2878 |
# The user entered the unit price tax excluded |
2884 |
# The user entered the unit price tax excluded |
2879 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2885 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2880 |
|
2886 |
|
|
|
2887 |
|
2881 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2888 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2882 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2889 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate_on_receiving} ); |
2883 |
} |
2890 |
} |
2884 |
|
2891 |
|
2885 |
# tax value = quantity * unit price tax excluded * tax rate |
2892 |
# tax value = quantity * unit price tax excluded * tax rate |
2886 |
$order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate}; |
2893 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
2887 |
} |
2894 |
} |
2888 |
|
2895 |
|
2889 |
return $order; |
2896 |
return $order; |