Skip to content

Commit

Permalink
Removing retuns and refunds from invoices (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldavigdis authored Aug 22, 2024
1 parent 935ff9c commit 0e1cf7d
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/Export/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use WC_Order;
use WC_Order_Item_Product;
use WP_Error;
use NineteenEightyFour\NineteenEightyWoo\Brick\Math\RoundingMode;

/**
* The Order Export class
Expand Down Expand Up @@ -222,53 +221,6 @@ public static function to_dk_order_body( WC_Order $wc_order ): array {
}
}

foreach ( $wc_order->get_refunds() as $refund ) {
foreach ( $refund->get_items() as $refund_item ) {
$order_item_product = new WC_Order_Item_Product( $item->get_id() );
$product_id = $order_item_product->get_product_id();
$product = wc_get_product( $product_id );
$sku = $product->get_sku();

if ( $refund_item->get_quantity() < -1 ) {
$qty = $refund_item->get_quantity();

$price = BigDecimal::of(
$refund->get_line_subtotal( $refund_item )
)->plus(
$refund->get_line_tax( $refund_item )
)->dividedBy(
$refund_item->get_quantity(),
12,
RoundingMode::HALF_UP
);
} else {
$qty = 1;

$price = BigDecimal::of(
$refund->get_line_subtotal( $refund_item )
)->plus(
$refund->get_line_tax( $refund_item )
);
}

if ( $refund->get_line_tax( $refund_item ) < 0 ) {
$including_vat = true;
} else {
$including_vat = false;
}

$refund_line = array(
'ItemCode' => $sku,
'Text' => $refund_item->get_name(),
'Quantity' => $qty,
'Price' => $price->toFloat(),
'IncludingVAT' => $including_vat,
);

$order_props['Lines'][] = $refund_line;
}
}

foreach ( $wc_order->get_shipping_methods() as $shipping_method ) {
$shipping_total = BigDecimal::of(
$shipping_method->get_total()
Expand Down

0 comments on commit 0e1cf7d

Please sign in to comment.