Skip to content

Commit

Permalink
πŸ› Fix problem with float numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
matbaek committed Jun 20, 2024
1 parent a9bd389 commit d606876
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Woocommerce/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ private static function addLineItems(\WC_Order $order, DraftInvoice $invoice, \W
throw new \Exception('Product not found');
}

$unitNetPrice = ((float) $item->get_total()) / $item->get_quantity();
$invoice->addLine(ProductLine::new(
product: $product,
quantity: $item->get_quantity(),
unitNetPrice: ((int) $item->get_total()) / $item->get_quantity(),
unitNetPrice: round($unitNetPrice, 2),
description: $item->get_name(),
));
});
Expand Down

0 comments on commit d606876

Please # to comment.