Lines 1420-1431
sub ModReceiveOrder {
Link Here
|
1420 |
| if defined $order->{unitprice}; |
1420 |
| if defined $order->{unitprice}; |
1421 |
|
1421 |
|
1422 |
$query .= q| |
1422 |
$query .= q| |
1423 |
, rrp = ?, rrp_tax_included = ?, rrp_tax_excluded = ? |
1423 |
,tax_value_on_receiving = ? |
1424 |
| if defined $order->{rrp}; |
1424 |
| if defined $order->{tax_value_on_receiving}; |
1425 |
|
1425 |
|
1426 |
$query .= q| |
1426 |
$query .= q| |
1427 |
, ecost = ?, ecost_tax_included = ?, ecost_tax_excluded = ? |
1427 |
,tax_rate_on_receiving = ? |
1428 |
| if defined $order->{ecost}; |
1428 |
| if defined $order->{tax_rate_on_receiving}; |
1429 |
|
1429 |
|
1430 |
$query .= q| |
1430 |
$query .= q| |
1431 |
, order_internalnote = ? |
1431 |
, order_internalnote = ? |
Lines 1439-1450
sub ModReceiveOrder {
Link Here
|
1439 |
if ( defined $order->{unitprice} ) { |
1439 |
if ( defined $order->{unitprice} ) { |
1440 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1440 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1441 |
} |
1441 |
} |
1442 |
if ( defined $order->{rrp} ) { |
1442 |
|
1443 |
push @params, $order->{rrp}, $order->{rrp_tax_included}, $order->{rrp_tax_excluded}; |
1443 |
if ( defined $order->{tax_value_on_receiving} ) { |
|
|
1444 |
push @params, $order->{tax_value_on_receiving}; |
1444 |
} |
1445 |
} |
1445 |
if ( defined $order->{ecost} ) { |
1446 |
|
1446 |
push @params, $order->{ecost}, $order->{ecost_tax_included}, $order->{ecost_tax_excluded}; |
1447 |
if ( defined $order->{tax_rate_on_receiving} ) { |
|
|
1448 |
push @params, $order->{tax_rate_on_receiving}; |
1447 |
} |
1449 |
} |
|
|
1450 |
|
1448 |
if ( defined $order->{order_internalnote} ) { |
1451 |
if ( defined $order->{order_internalnote} ) { |
1449 |
push @params, $order->{order_internalnote}; |
1452 |
push @params, $order->{order_internalnote}; |
1450 |
} |
1453 |
} |
Lines 2819-2830
sub populate_order_with_prices {
Link Here
|
2819 |
$discount /= 100 if $discount > 1; |
2822 |
$discount /= 100 if $discount > 1; |
2820 |
|
2823 |
|
2821 |
if ($ordering) { |
2824 |
if ($ordering) { |
|
|
2825 |
$order->{tax_rate_on_ordering} //= $order->{tax_rate}; |
2822 |
if ( $bookseller->{listincgst} ) { |
2826 |
if ( $bookseller->{listincgst} ) { |
2823 |
# The user entered the rrp tax included |
2827 |
# The user entered the rrp tax included |
2824 |
$order->{rrp_tax_included} = $order->{rrp}; |
2828 |
$order->{rrp_tax_included} = $order->{rrp}; |
2825 |
|
2829 |
|
2826 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2830 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2827 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ); |
2831 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate_on_ordering} ); |
2828 |
|
2832 |
|
2829 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2833 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2830 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2834 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2837-2843
sub populate_order_with_prices {
Link Here
|
2837 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2841 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2838 |
|
2842 |
|
2839 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2843 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2840 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2844 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 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 2845-2859
sub populate_order_with_prices {
Link Here
|
2845 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2849 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2846 |
$order->{ecost_tax_included} = |
2850 |
$order->{ecost_tax_included} = |
2847 |
$order->{rrp_tax_excluded} * |
2851 |
$order->{rrp_tax_excluded} * |
2848 |
( 1 + $order->{tax_rate} ) * |
2852 |
( 1 + $order->{tax_rate_on_ordering} ) * |
2849 |
( 1 - $discount ); |
2853 |
( 1 - $discount ); |
2850 |
} |
2854 |
} |
2851 |
|
2855 |
|
2852 |
# tax value = quantity * ecost tax excluded * tax rate |
2856 |
# tax value = quantity * ecost tax excluded * tax rate |
2853 |
$order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate}; |
2857 |
$order->{tax_value_on_ordering} = |
|
|
2858 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
2854 |
} |
2859 |
} |
2855 |
|
2860 |
|
2856 |
if ($receiving) { |
2861 |
if ($receiving) { |
|
|
2862 |
$order->{tax_rate_on_receiving} //= $order->{tax_rate}; |
2857 |
if ( $bookseller->{invoiceincgst} ) { |
2863 |
if ( $bookseller->{invoiceincgst} ) { |
2858 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2864 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2859 |
# we need to keep the exact ecost value |
2865 |
# we need to keep the exact ecost value |
Lines 2865-2871
sub populate_order_with_prices {
Link Here
|
2865 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2871 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2866 |
|
2872 |
|
2867 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2873 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2868 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); |
2874 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate_on_receiving} ); |
2869 |
} |
2875 |
} |
2870 |
else { |
2876 |
else { |
2871 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2877 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
Lines 2877-2888
sub populate_order_with_prices {
Link Here
|
2877 |
# The user entered the unit price tax excluded |
2883 |
# The user entered the unit price tax excluded |
2878 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2884 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2879 |
|
2885 |
|
|
|
2886 |
|
2880 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2887 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2881 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2888 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate_on_receiving} ); |
2882 |
} |
2889 |
} |
2883 |
|
2890 |
|
2884 |
# tax value = quantity * unit price tax excluded * tax rate |
2891 |
# tax value = quantity * unit price tax excluded * tax rate |
2885 |
$order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate}; |
2892 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
2886 |
} |
2893 |
} |
2887 |
|
2894 |
|
2888 |
return $order; |
2895 |
return $order; |