Lines 1421-1432
sub ModReceiveOrder {
Link Here
|
1421 |
| if defined $order->{unitprice}; |
1421 |
| if defined $order->{unitprice}; |
1422 |
|
1422 |
|
1423 |
$query .= q| |
1423 |
$query .= q| |
1424 |
, rrp = ?, rrp_tax_included = ?, rrp_tax_excluded = ? |
1424 |
,tax_value_on_receiving = ? |
1425 |
| if defined $order->{rrp}; |
1425 |
| if defined $order->{tax_value_on_receiving}; |
1426 |
|
1426 |
|
1427 |
$query .= q| |
1427 |
$query .= q| |
1428 |
, ecost = ?, ecost_tax_included = ?, ecost_tax_excluded = ? |
1428 |
,tax_rate_on_receiving = ? |
1429 |
| if defined $order->{ecost}; |
1429 |
| if defined $order->{tax_rate_on_receiving}; |
1430 |
|
1430 |
|
1431 |
$query .= q| |
1431 |
$query .= q| |
1432 |
, order_internalnote = ? |
1432 |
, order_internalnote = ? |
Lines 1440-1451
sub ModReceiveOrder {
Link Here
|
1440 |
if ( defined $order->{unitprice} ) { |
1440 |
if ( defined $order->{unitprice} ) { |
1441 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1441 |
push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; |
1442 |
} |
1442 |
} |
1443 |
if ( defined $order->{rrp} ) { |
1443 |
|
1444 |
push @params, $order->{rrp}, $order->{rrp_tax_included}, $order->{rrp_tax_excluded}; |
1444 |
if ( defined $order->{tax_value_on_receiving} ) { |
|
|
1445 |
push @params, $order->{tax_value_on_receiving}; |
1445 |
} |
1446 |
} |
1446 |
if ( defined $order->{ecost} ) { |
1447 |
|
1447 |
push @params, $order->{ecost}, $order->{ecost_tax_included}, $order->{ecost_tax_excluded}; |
1448 |
if ( defined $order->{tax_rate_on_receiving} ) { |
|
|
1449 |
push @params, $order->{tax_rate_on_receiving}; |
1448 |
} |
1450 |
} |
|
|
1451 |
|
1449 |
if ( defined $order->{order_internalnote} ) { |
1452 |
if ( defined $order->{order_internalnote} ) { |
1450 |
push @params, $order->{order_internalnote}; |
1453 |
push @params, $order->{order_internalnote}; |
1451 |
} |
1454 |
} |
Lines 2834-2845
sub populate_order_with_prices {
Link Here
|
2834 |
$discount /= 100 if $discount > 1; |
2837 |
$discount /= 100 if $discount > 1; |
2835 |
|
2838 |
|
2836 |
if ($ordering) { |
2839 |
if ($ordering) { |
|
|
2840 |
$order->{tax_rate_on_ordering} //= $order->{tax_rate}; |
2837 |
if ( $bookseller->{listincgst} ) { |
2841 |
if ( $bookseller->{listincgst} ) { |
2838 |
# The user entered the rrp tax included |
2842 |
# The user entered the rrp tax included |
2839 |
$order->{rrp_tax_included} = $order->{rrp}; |
2843 |
$order->{rrp_tax_included} = $order->{rrp}; |
2840 |
|
2844 |
|
2841 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2845 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2842 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ); |
2846 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate_on_ordering} ); |
2843 |
|
2847 |
|
2844 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2848 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2845 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2849 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2852-2858
sub populate_order_with_prices {
Link Here
|
2852 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2856 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2853 |
|
2857 |
|
2854 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2858 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2855 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2859 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate_on_ordering} ); |
2856 |
|
2860 |
|
2857 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2861 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2858 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2862 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2860-2874
sub populate_order_with_prices {
Link Here
|
2860 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2864 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2861 |
$order->{ecost_tax_included} = |
2865 |
$order->{ecost_tax_included} = |
2862 |
$order->{rrp_tax_excluded} * |
2866 |
$order->{rrp_tax_excluded} * |
2863 |
( 1 + $order->{tax_rate} ) * |
2867 |
( 1 + $order->{tax_rate_on_ordering} ) * |
2864 |
( 1 - $discount ); |
2868 |
( 1 - $discount ); |
2865 |
} |
2869 |
} |
2866 |
|
2870 |
|
2867 |
# tax value = quantity * ecost tax excluded * tax rate |
2871 |
# tax value = quantity * ecost tax excluded * tax rate |
2868 |
$order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate}; |
2872 |
$order->{tax_value_on_ordering} = |
|
|
2873 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
2869 |
} |
2874 |
} |
2870 |
|
2875 |
|
2871 |
if ($receiving) { |
2876 |
if ($receiving) { |
|
|
2877 |
$order->{tax_rate_on_receiving} //= $order->{tax_rate}; |
2872 |
if ( $bookseller->{invoiceincgst} ) { |
2878 |
if ( $bookseller->{invoiceincgst} ) { |
2873 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2879 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2874 |
# we need to keep the exact ecost value |
2880 |
# we need to keep the exact ecost value |
Lines 2880-2886
sub populate_order_with_prices {
Link Here
|
2880 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2886 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2881 |
|
2887 |
|
2882 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2888 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2883 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); |
2889 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate_on_receiving} ); |
2884 |
} |
2890 |
} |
2885 |
else { |
2891 |
else { |
2886 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2892 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
Lines 2892-2903
sub populate_order_with_prices {
Link Here
|
2892 |
# The user entered the unit price tax excluded |
2898 |
# The user entered the unit price tax excluded |
2893 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2899 |
$order->{unitprice_tax_excluded} = $order->{unitprice}; |
2894 |
|
2900 |
|
|
|
2901 |
|
2895 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2902 |
# unit price tax included = unit price tax included * ( 1 + tax rate ) |
2896 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2903 |
$order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate_on_receiving} ); |
2897 |
} |
2904 |
} |
2898 |
|
2905 |
|
2899 |
# tax value = quantity * unit price tax excluded * tax rate |
2906 |
# tax value = quantity * unit price tax excluded * tax rate |
2900 |
$order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate}; |
2907 |
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving}; |
2901 |
} |
2908 |
} |
2902 |
|
2909 |
|
2903 |
return $order; |
2910 |
return $order; |