Revert PCP-590-incorrect-tax-details as is causing line items not sent to PayPal

This commit is contained in:
dinamiko 2022-04-04 11:35:50 +02:00
parent d6286ec6e5
commit 5369af13e2
4 changed files with 12 additions and 19 deletions

View file

@ -76,12 +76,12 @@ class AmountFactory {
$item_total = $cart->get_cart_contents_total() + $cart->get_discount_total() + $total_fees_amount;
$item_total = new Money( (float) $item_total, $this->currency );
$shipping = new Money(
(float) $cart->get_shipping_total(),
(float) $cart->get_shipping_total() + $cart->get_shipping_tax(),
$this->currency
);
$taxes = new Money(
$cart->get_subtotal_tax() + $cart->get_shipping_tax(),
$cart->get_subtotal_tax(),
$this->currency
);
@ -131,7 +131,7 @@ class AmountFactory {
$currency
);
$shipping = new Money(
(float) $order->get_shipping_total(),
(float) $order->get_shipping_total() + (float) $order->get_shipping_tax(),
$currency
);
$taxes = new Money(

View file

@ -42,9 +42,8 @@ class ItemFactory {
* @return Item[]
*/
public function from_wc_cart( \WC_Cart $cart ): array {
$shipping_tax = round( $cart->get_shipping_tax(), 2 );
$items = array_map(
function ( array $item ) use ( $shipping_tax ): Item {
$items = array_map(
function ( array $item ): Item {
$product = $item['data'];
/**
@ -58,7 +57,7 @@ class ItemFactory {
$price_without_tax = (float) wc_get_price_excluding_tax( $product );
$price_without_tax_rounded = round( $price_without_tax, 2 );
$tax = round( $price - $price_without_tax_rounded, 2 );
$tax = new Money( $tax + $shipping_tax, $this->currency );
$tax = new Money( $tax, $this->currency );
return new Item(
mb_substr( $product->get_name(), 0, 127 ),
new Money( $price_without_tax_rounded, $this->currency ),
@ -132,13 +131,12 @@ class ItemFactory {
*/
$product = $item->get_product();
$currency = $order->get_currency();
$shipping_tax = round( (float) $order->get_shipping_tax(), 2 );
$quantity = (int) $item->get_quantity();
$price = (float) $order->get_item_subtotal( $item, true );
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
$price_without_tax_rounded = round( $price_without_tax, 2 );
$tax = round( $price - $price_without_tax_rounded, 2 );
$tax = new Money( $tax + $shipping_tax, $currency );
$tax = new Money( $tax, $currency );
return new Item(
mb_substr( $product->get_name(), 0, 127 ),