Lines 1437-1448
sub ModReceiveOrder {
Link Here
|
1437 |
| if defined $order->{unitprice}; |
1437 |
| if defined $order->{unitprice}; |
1438 |
|
1438 |
|
1439 |
$query .= q| |
1439 |
$query .= q| |
1440 |
, rrp = ?, rrp_tax_included = ?, rrp_tax_excluded = ? |
1440 |
,tax_value_on_receiving = ? |
1441 |
| if defined $order->{rrp}; |
1441 |
| if defined $order->{tax_value_on_receiving}; |
1442 |
|
1442 |
|
1443 |
$query .= q| |
1443 |
$query .= q| |
1444 |
, ecost = ?, ecost_tax_included = ?, ecost_tax_excluded = ? |
1444 |
,tax_rate_on_receiving = ? |
1445 |
| if defined $order->{ecost}; |
1445 |
| if defined $order->{tax_rate_on_receiving}; |
1446 |
|
1446 |
|
1447 |
$query .= q| |
1447 |
$query .= q| |
1448 |
, order_internalnote = ? |
1448 |
, order_internalnote = ? |
Lines 1456-1467
sub ModReceiveOrder {
Link Here
|
1456 |
if ( defined $order->{unitprice} ) { |
1456 |
if ( defined $order->{unitprice} ) { |
1457 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1457 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1458 |
} |
1458 |
} |
1459 |
if ( defined $order->{rrp} ) { |
1459 |
|
1460 |
push @params, $order->{rrp}, $order->{rrp_tax_included}, $order->{rrp_tax_excluded}; |
1460 |
if ( defined $order->{tax_value_on_receiving} ) { |
|
|
1461 |
push @params, $order->{tax_value_on_receiving}; |
1461 |
} |
1462 |
} |
1462 |
if ( defined $order->{ecost} ) { |
1463 |
|
1463 |
push @params, $order->{ecost}, $order->{ecost_tax_included}, $order->{ecost_tax_excluded}; |
1464 |
if ( defined $order->{tax_rate_on_receiving} ) { |
|
|
1465 |
push @params, $order->{tax_rate_on_receiving}; |
1464 |
} |
1466 |
} |
|
|
1467 |
|
1465 |
if ( defined $order->{order_internalnote} ) { |
1468 |
if ( defined $order->{order_internalnote} ) { |
1466 |
push @params, $order->{order_internalnote}; |
1469 |
push @params, $order->{order_internalnote}; |
1467 |
} |
1470 |
} |
Lines 2858-2869
sub populate_order_with_prices {
Link Here
|
2858 |
$discount /= 100 if $discount > 1; |
2861 |
$discount /= 100 if $discount > 1; |
2859 |
|
2862 |
|
2860 |
if ($ordering) { |
2863 |
if ($ordering) { |
|
|
2864 |
$order->{tax_rate_on_ordering} //= $order->{tax_rate}; |
2861 |
if ( $bookseller->{listincgst} ) { |
2865 |
if ( $bookseller->{listincgst} ) { |
2862 |
# The user entered the rrp tax included |
2866 |
# The user entered the rrp tax included |
2863 |
$order->{rrp_tax_included} = $order->{rrp}; |
2867 |
$order->{rrp_tax_included} = $order->{rrp}; |
2864 |
|
2868 |
|
2865 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2869 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2866 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ); |
2870 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate_on_ordering} ); |
2867 |
|
2871 |
|
2868 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2872 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2869 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2873 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2876-2882
sub populate_order_with_prices {
Link Here
|
2876 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2880 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2877 |
|
2881 |
|
2878 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2882 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2879 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2883 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate_on_ordering} ); |
2880 |
|
2884 |
|
2881 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2885 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2882 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2886 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2884-2898
sub populate_order_with_prices {
Link Here
|
2884 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2888 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2885 |
$order->{ecost_tax_included} = |
2889 |
$order->{ecost_tax_included} = |
2886 |
$order->{rrp_tax_excluded} * |
2890 |
$order->{rrp_tax_excluded} * |
2887 |
( 1 + $order->{tax_rate} ) * |
2891 |
( 1 + $order->{tax_rate_on_ordering} ) * |
2888 |
( 1 - $discount ); |
2892 |
( 1 - $discount ); |
2889 |
} |
2893 |
} |
2890 |
|
2894 |
|
2891 |
# tax value = quantity * ecost tax excluded * tax rate |
2895 |
# tax value = quantity * ecost tax excluded * tax rate |
2892 |
$order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate}; |
2896 |
$order->{tax_value_on_ordering} = |
|
|
2897 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
2893 |
} |
2898 |
} |
2894 |
|
2899 |
|
2895 |
if ($receiving) { |
2900 |
if ($receiving) { |
|
|
2901 |
$order->{tax_rate_on_receiving} //= $order->{tax_rate}; |
2896 |
if ( $bookseller->{invoiceincgst} ) { |
2902 |
if ( $bookseller->{invoiceincgst} ) { |
2897 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2903 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2898 |
# we need to keep the exact ecost value |
2904 |
# we need to keep the exact ecost value |
Lines 2904-2910
sub populate_order_with_prices {
Link Here
|
2904 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2910 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2905 |
|
2911 |
|
2906 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2912 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2907 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); |
2913 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate_on_receiving} ); |
2908 |
} |
2914 |
} |
2909 |
else { |
2915 |
else { |
2910 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2916 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
Lines 2916-2927
sub populate_order_with_prices {
Link Here
|
2916 |
# The user entered the unit price tax excluded |
2922 |
# The user entered the unit price tax excluded |
2917 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2923 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2918 |
|
2924 |
|
|
|
2925 |
|
2919 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2926 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2920 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2927 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate_on_receiving} ); |
2921 |
} |
2928 |
} |
2922 |
|
2929 |
|
2923 |
# tax value = quantity * unit price tax excluded * tax rate |
2930 |
# tax value = quantity * unit price tax excluded * tax rate |
2924 |
$order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate}; |
2931 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
2925 |
} |
2932 |
} |
2926 |
|
2933 |
|
2927 |
return $order; |
2934 |
return $order; |