Add VAT refund threshold configuration to MVP setup page with UI and language strings

This commit is contained in:
Frank Cools 2025-10-08 16:29:58 +02:00
parent e00c6f89f7
commit 75aac53fca
2 changed files with 68 additions and 0 deletions

View File

@ -74,6 +74,7 @@ if ($action == 'update_journal_config') {
$journal_accounts = array(
'vat_to_pay' => GETPOST('journal_vat_to_pay', 'alpha'),
'vat_to_receive' => GETPOST('journal_vat_to_receive', 'alpha'),
'vat_refund' => GETPOST('journal_vat_refund', 'alpha'),
'other_charges' => GETPOST('journal_other_charges', 'alpha'),
'other_products' => GETPOST('journal_other_products', 'alpha')
);
@ -86,6 +87,21 @@ if ($action == 'update_journal_config') {
}
}
// Handle VAT refund threshold configuration updates
if ($action == 'update_vat_refund_threshold') {
$threshold_config = array(
'refund_threshold' => GETPOST('vat_refund_threshold', 'float'),
'refund_threshold_enabled' => GETPOST('vat_refund_threshold_enabled', 'int')
);
$updated = $config->updateVATRefundThresholdConfiguration($threshold_config);
if ($updated) {
setEventMessages($langs->trans("VATRefundThresholdConfigurationUpdated"), null, 'mesgs');
} else {
setEventMessages($langs->trans("VATRefundThresholdConfigurationUpdateFailed"), null, 'errors');
}
}
// Handle bank account configuration updates
if ($action == 'update_bank_config') {
$bank_account = GETPOST('journal_bank_account', 'int');
@ -513,6 +529,14 @@ print '</div>';
print '</td>';
print '</tr>';
print '<tr>';
print '<td><strong>' . $langs->trans("VATRefundAccount") . '</strong></td>';
print '<td>';
print '<small>' . $langs->trans("VATRefundAccountDescription") . '</small><br>';
print $form->selectarray('journal_vat_refund', $account_options, $journal_config['vat_refund'], 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
print '</td>';
print '</tr>';
print '<tr>';
print '<td><strong>' . $langs->trans("OtherChargesAccount") . '</strong></td>';
print '<td>';
@ -581,6 +605,45 @@ print '</div>';
print '</table>';
print '</form>';
// VAT Refund Threshold Configuration Section
print '<br>';
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="action" value="update_vat_refund_threshold">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2"><strong>' . $langs->trans("VATRefundThresholdConfiguration") . '</strong></td>';
print '</tr>';
// Get current threshold configuration
$threshold_config = $config->getVATRefundThresholdConfiguration();
print '<tr>';
print '<td><strong>' . $langs->trans("VATRefundThreshold") . '</strong></td>';
print '<td>';
print '<small>' . $langs->trans("VATRefundThresholdHelp") . '</small><br>';
print '<input type="number" name="vat_refund_threshold" value="' . $threshold_config['refund_threshold'] . '" step="0.01" min="0" class="minwidth200">';
print '</td>';
print '</tr>';
print '<tr>';
print '<td><strong>' . $langs->trans("VATRefundThresholdEnabled") . '</strong></td>';
print '<td>';
print '<small>' . $langs->trans("VATRefundThresholdEnabledHelp") . '</small><br>';
print $form->selectyesno('vat_refund_threshold_enabled', $threshold_config['refund_threshold_enabled'], 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="2" class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
print '</td>';
print '</tr>';
print '</table>';
print '</form>';
print '</div>';
}

View File

@ -531,3 +531,8 @@ VATRefundThreshold = Seuil de remboursement TVA (€)
VATRefundThresholdEnabled = Activer la logique de seuil de remboursement TVA
VATRefundThresholdHelp = Seuil de montant pour le remboursement immédiat de la TVA vs report. Les montants en dessous de ce seuil seront reportés à la prochaine déclaration.
VATRefundThresholdEnabledHelp = Activer ou désactiver la logique de seuil pour les remboursements de TVA.
VATRefundAccount = Compte de remboursement TVA
VATRefundAccountDescription = Compte pour les remboursements immédiats de TVA (≥ seuil)
VATRefundThresholdConfiguration = Configuration du seuil de remboursement TVA
VATRefundThresholdConfigurationUpdated = Configuration du seuil de remboursement TVA mise à jour
VATRefundThresholdConfigurationUpdateFailed = Erreur lors de la mise à jour de la configuration du seuil de remboursement TVA