| @@ -188,19 +188,21 @@ | ||
| 188 | 188 | */ |
| 189 | 189 | public function getAmount(): float { |
| 190 | 190 | $quantity = floatval($this->data['quantity'] ?? 0); |
| 191 | 191 | $price = floatval($this->data['price'] ?? 0); |
| 192 | - $adjust_percentage = floatval($this->data['adjust_percentage'] ?? 0); | |
| 193 | 192 | |
| 194 | 193 | // Calculate base total |
| 195 | 194 | $base_total = $quantity * $price; |
| 196 | 195 | |
| 197 | - // Apply adjustment percentage if any | |
| 198 | - if ($adjust_percentage != 0) { | |
| 199 | - $base_total = $base_total * (1 + $adjust_percentage / 100); | |
| 196 | + // Only apply adjustment percentage if the adjust field setting is enabled | |
| 197 | + if (\EasyInvoice\Controllers\SettingsController::shouldShowQuoteAdjustField()) { | |
| 198 | + $adjust_percentage = floatval($this->data['adjust_percentage'] ?? 0); | |
| 199 | + if ($adjust_percentage != 0) { | |
| 200 | + $base_total = $base_total * (1 + $adjust_percentage / 100); | |
| 201 | + } | |
| 200 | 202 | } |
| 201 | 203 | |
| 202 | - return $base_total; | |
| 204 | + return easy_invoice_round_money($base_total); | |
| 203 | 205 | } |
| 204 | 206 | |
| 205 | 207 | /** |
| 206 | 208 | * Check if the item is taxable |
| @@ -263,9 +265,9 @@ | ||
| 263 | 265 | $field_name = $this->camelCaseToSnakeCase(substr($name, 3)); // Remove 'has' prefix |
| 264 | 266 | return !empty($this->__get($field_name)); |
| 265 | 267 | } |
| 266 | 268 | |
| 267 | - throw new \BadMethodCallException("Method $name does not exist"); | |
| 269 | + throw new \BadMethodCallException(esc_html("Method $name does not exist")); | |
| 268 | 270 | } |
| 269 | 271 | |
| 270 | 272 | /** |
| 271 | 273 | * Convert camelCase to snake_case |