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 2820-2831
sub populate_order_with_prices {
Link Here
|
2820 |
$discount /= 100 if $discount > 1; |
2823 |
$discount /= 100 if $discount > 1; |
2821 |
|
2824 |
|
2822 |
if ($ordering) { |
2825 |
if ($ordering) { |
|
|
2826 |
$order->{tax_rate_on_ordering} //= $order->{tax_rate}; |
2823 |
if ( $bookseller->{listincgst} ) { |
2827 |
if ( $bookseller->{listincgst} ) { |
2824 |
# The user entered the rrp tax included |
2828 |
# The user entered the rrp tax included |
2825 |
$order->{rrp_tax_included} = $order->{rrp}; |
2829 |
$order->{rrp_tax_included} = $order->{rrp}; |
2826 |
|
2830 |
|
2827 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2831 |
# rrp tax excluded = rrp tax included / ( 1 + tax rate ) |
2828 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ); |
2832 |
$order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate_on_ordering} ); |
2829 |
|
2833 |
|
2830 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2834 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2831 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2835 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2838-2844
sub populate_order_with_prices {
Link Here
|
2838 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2842 |
$order->{rrp_tax_excluded} = $order->{rrp}; |
2839 |
|
2843 |
|
2840 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2844 |
# rrp tax included = rrp tax excluded * ( 1 - tax rate ) |
2841 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} ); |
2845 |
$order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate_on_ordering} ); |
2842 |
|
2846 |
|
2843 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2847 |
# ecost tax excluded = rrp tax excluded * ( 1 - discount ) |
2844 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
2848 |
$order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount ); |
Lines 2846-2860
sub populate_order_with_prices {
Link Here
|
2846 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2850 |
# ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount ) |
2847 |
$order->{ecost_tax_included} = |
2851 |
$order->{ecost_tax_included} = |
2848 |
$order->{rrp_tax_excluded} * |
2852 |
$order->{rrp_tax_excluded} * |
2849 |
( 1 + $order->{tax_rate} ) * |
2853 |
( 1 + $order->{tax_rate_on_ordering} ) * |
2850 |
( 1 - $discount ); |
2854 |
( 1 - $discount ); |
2851 |
} |
2855 |
} |
2852 |
|
2856 |
|
2853 |
# tax value = quantity * ecost tax excluded * tax rate |
2857 |
# tax value = quantity * ecost tax excluded * tax rate |
2854 |
$order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate}; |
2858 |
$order->{tax_value_on_ordering} = |
|
|
2859 |
$order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering}; |
2855 |
} |
2860 |
} |
2856 |
|
2861 |
|
2857 |
if ($receiving) { |
2862 |
if ($receiving) { |
|
|
2863 |
$order->{tax_rate_on_receiving} //= $order->{tax_rate}; |
2858 |
if ( $bookseller->{invoiceincgst} ) { |
2864 |
if ( $bookseller->{invoiceincgst} ) { |
2859 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2865 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2860 |
# we need to keep the exact ecost value |
2866 |
# we need to keep the exact ecost value |
Lines 2866-2872
sub populate_order_with_prices {
Link Here
|
2866 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2872 |
$order->{unitprice_tax_included} = $order->{unitprice}; |
2867 |
|
2873 |
|
2868 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2874 |
# unit price tax excluded = unit price tax included / ( 1 + tax rate ) |
2869 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ); |
2875 |
$order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate_on_receiving} ); |
2870 |
} |
2876 |
} |
2871 |
else { |
2877 |
else { |
2872 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
2878 |
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value |
Lines 2878-2889
sub populate_order_with_prices {
Link Here
|
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; |