Refactor authorization and token refresh logic; update tax handling and invoice generation

- Changed variable name from `$stmt_service` to `$stmt_refreshkey` for clarity in `authorization.php` and `token_refresh.php`.
- Added null coalescing operator to ensure criteria are set to an empty string if not provided in `products_software_versions.php`.
- Modified SQL script to add `eu` column to `taxes` table and update tax rates based on EU membership.
- Enhanced invoice generation logic in `functions.php` to include VAT notes based on customer country and VAT number.
- Updated email and PDF templates to display VAT notes and percentages correctly.
- Adjusted JavaScript tax calculation logic to handle VAT based on country and VAT number.
- Fixed API URL in `index.php` for token refresh endpoint.
- Updated countries data structure in `countries.php` to include EU membership status.
This commit is contained in:
“VeLiTi”
2026-02-05 15:26:41 +01:00
parent c4cb99b945
commit d7b9b91bb6
10 changed files with 271 additions and 168 deletions

View File

@@ -122,14 +122,24 @@ $message .= '</tbody>
</tr>';
if ($tax_amount > 0) {
$tax_percentage = ($subtotal > 0) ? round(($tax_amount / $subtotal) * 100, 2) : 0;
$vat_label = htmlspecialchars($lbl_tax) . ' (' . $tax_percentage . '%)';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 11px; color: #888;">(' . htmlspecialchars($vat_note) . ')</small>';
}
$message .= '<tr>
<td style="text-align: left; padding: 5px 0;">' . htmlspecialchars($lbl_tax) . '</td>
<td style="text-align: left; padding: 5px 0;">' . $vat_label . '</td>
<td style="text-align: right; padding: 5px 0;">€ ' . number_format($tax_amount, 2) . '</td>
</tr>';
} else {
$vat_label = 'VAT';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 11px; color: #888;">(' . htmlspecialchars($vat_note) . ')</small>';
}
$vat_amount_display = !empty($vat_note) ? '€ 0.00' : 'included';
$message .= '<tr>
<td style="text-align: left; padding: 5px 0;">VAT</td>
<td style="text-align: right; padding: 5px 0;">included</td>
<td style="text-align: left; padding: 5px 0;">' . $vat_label . '</td>
<td style="text-align: right; padding: 5px 0;">' . $vat_amount_display . '</td>
</tr>';
}

View File

@@ -299,14 +299,23 @@ $pdf .= '</tbody>
if ($tax_amount > 0) {
$tax_percentage = ($subtotal > 0) ? round(($tax_amount / $subtotal) * 100, 2) : 0;
$vat_label = htmlspecialchars($lbl_tax) . ' (' . $tax_percentage . '%)';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 9px; color: #666;">(' . htmlspecialchars($vat_note) . ')</small>';
}
$pdf .= '<div class="total-row">
<div class="total-label">' . htmlspecialchars($lbl_tax) . ' (' . $tax_percentage . '%)</div>
<div class="total-label">' . $vat_label . '</div>
<div class="total-amount">€ ' . number_format($tax_amount, 2) . '</div>
</div>';
} else {
$vat_label = 'VAT';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 9px; color: #666;">(' . htmlspecialchars($vat_note) . ')</small>';
}
$vat_amount_display = !empty($vat_note) ? '€ 0.00' : 'included';
$pdf .= '<div class="total-row">
<div class="total-label">VAT</div>
<div class="total-amount">included</div>
<div class="total-label">' . $vat_label . '</div>
<div class="total-amount">' . $vat_amount_display . '</div>
</div>';
}