Refactor invoice PDF generation and VAT validation

- Updated PDF template to display a fixed software code instead of "SOFTWARE".
- Changed VAT label to include tax label dynamically and set to 0% for certain conditions.
- Enhanced JavaScript for VAT number validation with asynchronous checks against the VIES database.
- Implemented debounce for VAT number input to optimize validation calls.
- Updated country settings to include country codes for VAT validation.
- Modified email sending functions in webhook handlers to use dynamic attachment names for invoices.
This commit is contained in:
“VeLiTi”
2026-02-06 16:02:56 +01:00
parent 4b83f596f1
commit 3131c2c5b2
12 changed files with 542 additions and 163 deletions

View File

@@ -70,7 +70,7 @@ $message = '
<td style="padding: 3px 0;">' . htmlspecialchars($order_id) . '</td>
</tr>
<tr>
<td style="padding: 3px 0;"><strong>Payment Methodr:</strong></td>
<td style="padding: 3px 0;"><strong>Payment Method:</strong></td>
<td style="padding: 3px 0;">' . (${$payment_method} ?? $invoice_data['header']['payment_method'] ). '</td>
</tr>
</table>
@@ -94,7 +94,7 @@ $message = '
foreach ($items as $item) {
$line_total = $item['price'] * $item['quantity'];
$message .= '<tr>
<td style="padding: 10px 8px; border-bottom: 1px solid #dddddd; font-size: 13px;">SOFTWARE</td>
<td style="padding: 10px 8px; border-bottom: 1px solid #dddddd; font-size: 13px;">110.600.000</td>
<td style="padding: 10px 8px; border-bottom: 1px solid #dddddd; font-size: 13px;">' . htmlspecialchars($item['name']);
if ($item['serial_number'] !== 'N/A') {
@@ -132,7 +132,7 @@ if ($tax_amount > 0) {
<td style="text-align: right; padding: 5px 0;">€ ' . number_format($tax_amount, 2) . '</td>
</tr>';
} else {
$vat_label = 'VAT';
$vat_label = htmlspecialchars($lbl_tax) . ' (0%)';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 11px; color: #888;">(' . htmlspecialchars($vat_note) . ')</small>';
}

View File

@@ -271,7 +271,7 @@ $pdf = '<!DOCTYPE html>
foreach ($items as $item) {
$line_total = $item['price'] * $item['quantity'];
$pdf .= '<tr>
<td>SOFTWARE</td>
<td>110.600.000</td>
<td>' . htmlspecialchars($item['name']);
if ($item['serial_number'] !== 'N/A') {
@@ -308,7 +308,7 @@ $pdf .= '</tbody>
<div class="total-amount">€ ' . number_format($tax_amount, 2) . '</div>
</div>';
} else {
$vat_label = 'VAT';
$vat_label = htmlspecialchars($lbl_tax) . ' (0%)';
if (!empty($vat_note)) {
$vat_label .= ' <small style="font-size: 9px; color: #666;">(' . htmlspecialchars($vat_note) . ')</small>';
}