Skip to content

Commit

Permalink
Buy: Fix VAT rate float rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Jan 4, 2025
1 parent 95c992a commit 466c6b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion site/plugins/buy/src/Paddle.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public static function visitor(string|null $country = null): Visitor
rate: $paddleProduct['list_price']['net'] / $product->rawPrice(),

// calculate VAT rate, rounded to four decimal places to avoid float mishaps
vatRate: round($paddleProduct['list_price']['tax'] / $paddleProduct['list_price']['net'] * 10000) / 10000,
vatRate: round($paddleProduct['list_price']['tax'] / $paddleProduct['list_price']['net'], 4),
);
} catch (Throwable $e) {
// on any kind of error, use the EUR prices as a fallback
Expand Down
2 changes: 1 addition & 1 deletion site/snippets/templates/buy/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
</tr>
<tr v-if="locale.vatRate > 0">
<th>
VAT ({{ vatRate * 100 }}%)
VAT ({{ (vatRate * 100).toFixed(2) }}%)
</th>
<td>{{ amount(vatAmount) }}</td>
</tr>
Expand Down

0 comments on commit 466c6b4

Please sign in to comment.