Wire recalculate button to show real calculated amounts
Recalculate Button Integration: - Replaced placeholder CA-3 data with real database queries - getCA3Lines() now fetches actual calculated amounts - Shows 'No CA-3 data' message when no calculations exist - Displays real VAT amounts from database after recalculation - Added translations for 'No CA-3 data' message Now the recalculate button will: 1. Trigger calculation engine 2. Query accounting data 3. Display real calculated amounts 4. Show debugging info in error logs
This commit is contained in:
parent
2600fb6982
commit
14362712a1
@ -1,174 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* DeclarationTVA View Declaration
|
|
||||||
* French CA-3 VAT Declaration Module for Dolibarr
|
|
||||||
* MVP Version - Phase 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Load Dolibarr environment
|
|
||||||
if (file_exists('../main.inc.php')) {
|
|
||||||
$res = @include '../main.inc.php';
|
|
||||||
} elseif (file_exists('../../main.inc.php')) {
|
|
||||||
$res = @include '../../main.inc.php';
|
|
||||||
} else {
|
|
||||||
$res = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$res) {
|
|
||||||
die("Include of main fails");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load module classes
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_period.class.php';
|
|
||||||
|
|
||||||
// Access control
|
|
||||||
if (!$user->hasRight("declarationtva", "declarationtva", "read")) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load language files
|
|
||||||
$langs->load("declarationtva@declarationtva");
|
|
||||||
|
|
||||||
// Get declaration ID
|
|
||||||
$id = GETPOST('id', 'int');
|
|
||||||
if (empty($id)) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle actions
|
|
||||||
$action = GETPOST('action', 'alpha');
|
|
||||||
$token = GETPOST('token', 'alpha');
|
|
||||||
|
|
||||||
if ($action == 'recalculate' && $token) {
|
|
||||||
if ($declarationtva->recalculateCA3Amounts($id)) {
|
|
||||||
setEventMessages($langs->trans("DeclarationRecalculated"), null, 'mesgs');
|
|
||||||
} else {
|
|
||||||
setEventMessages($langs->trans("ErrorRecalculatingDeclaration"), null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize objects
|
|
||||||
$declarationtva = new DeclarationTVA($db, $conf->entity);
|
|
||||||
$config = new DeclarationTVA_Config($db, $conf->entity);
|
|
||||||
$period = new DeclarationTVA_Period($db, $conf->entity);
|
|
||||||
|
|
||||||
// Fetch declaration
|
|
||||||
if ($declarationtva->fetch($id) < 0) {
|
|
||||||
setEventMessages($langs->trans("DeclarationNotFound"), null, 'errors');
|
|
||||||
header("Location: declarationtvaindex.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use declaration's own dates
|
|
||||||
$start_date = $declarationtva->start_date;
|
|
||||||
$end_date = $declarationtva->end_date;
|
|
||||||
|
|
||||||
// Page title
|
|
||||||
$title = $langs->trans("ViewDeclaration") . ' - ' . $declarationtva->declaration_number;
|
|
||||||
llxHeader('', $title);
|
|
||||||
|
|
||||||
// Print page header
|
|
||||||
print load_fiche_titre($title, '', 'title_accountancy');
|
|
||||||
|
|
||||||
// Print declaration details
|
|
||||||
print '<div class="fiche">';
|
|
||||||
print '<div class="titre">' . $langs->trans("DeclarationDetails") . '</div>';
|
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td class="fieldrequired">' . $langs->trans("DeclarationNumber") . '</td>';
|
|
||||||
print '<td>' . $declarationtva->declaration_number . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>' . $langs->trans("DeclarationName") . '</td>';
|
|
||||||
print '<td>' . $declarationtva->declaration_name . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>' . $langs->trans("Period") . '</td>';
|
|
||||||
print '<td>' . dol_print_date($start_date, 'day') . ' - ' . dol_print_date($end_date, 'day') . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>' . $langs->trans("Status") . '</td>';
|
|
||||||
print '<td>' . $langs->trans("Status" . ucfirst($declarationtva->status)) . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>' . $langs->trans("CreatedDate") . '</td>';
|
|
||||||
print '<td>' . dol_print_date($declarationtva->created_date, 'dayhour') . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
// Print CA-3 amounts (placeholder for now)
|
|
||||||
print '<div class="fiche">';
|
|
||||||
print '<div class="titre">' . $langs->trans("CA3Amounts") . '</div>';
|
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<th>' . $langs->trans("CA3Line") . '</th>';
|
|
||||||
print '<th>' . $langs->trans("Description") . '</th>';
|
|
||||||
print '<th>' . $langs->trans("Amount") . '</th>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Placeholder CA-3 lines
|
|
||||||
$ca3_lines = array(
|
|
||||||
'A1' => array('desc' => 'Opérations imposables (ventes/prestations)', 'amount' => 0),
|
|
||||||
'A2' => array('desc' => 'Opérations imposables spéciales', 'amount' => 0),
|
|
||||||
'A3' => array('desc' => 'Services achetés non établis', 'amount' => 0),
|
|
||||||
'A4' => array('desc' => 'Importations', 'amount' => 0),
|
|
||||||
'A5' => array('desc' => 'Sorties de régimes suspensifs', 'amount' => 0),
|
|
||||||
'08' => array('desc' => 'Autres opérations imposables', 'amount' => 0),
|
|
||||||
'09' => array('desc' => 'Opérations exonérées', 'amount' => 0),
|
|
||||||
'9B' => array('desc' => 'Opérations non imposables', 'amount' => 0),
|
|
||||||
'17' => array('desc' => 'TVA due acquisitions intracommunautaires', 'amount' => 0),
|
|
||||||
'20' => array('desc' => 'TVA déductible immobilisations', 'amount' => 0),
|
|
||||||
'21' => array('desc' => 'TVA déductible autres biens/services', 'amount' => 0),
|
|
||||||
'22' => array('desc' => 'Crédit de TVA reportable', 'amount' => 0),
|
|
||||||
'25' => array('desc' => 'TVA brute due', 'amount' => 0),
|
|
||||||
'26' => array('desc' => 'TVA déductible totale', 'amount' => 0),
|
|
||||||
'28' => array('desc' => 'TVA nette à payer', 'amount' => 0),
|
|
||||||
'29' => array('desc' => 'Crédit de TVA', 'amount' => 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($ca3_lines as $line => $data) {
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>' . $line . '</td>';
|
|
||||||
print '<td>' . $data['desc'] . '</td>';
|
|
||||||
print '<td class="right">' . price($data['amount']) . '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
// Print actions
|
|
||||||
print '<div class="fiche">';
|
|
||||||
print '<div class="titre">' . $langs->trans("Actions") . '</div>';
|
|
||||||
|
|
||||||
print '<div class="center">';
|
|
||||||
|
|
||||||
// Recalculate button (always available)
|
|
||||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&action=recalculate&token=' . newToken() . '" class="butAction">' . $langs->trans("Recalculate") . '</a> ';
|
|
||||||
|
|
||||||
if ($declarationtva->status == 'draft') {
|
|
||||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&action=validate" class="butAction">' . $langs->trans("Validate") . '</a> ';
|
|
||||||
} elseif ($declarationtva->status == 'validated') {
|
|
||||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&action=submit" class="butAction">' . $langs->trans("Submit") . '</a> ';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<a href="declarationtvaindex.php" class="butAction">' . $langs->trans("BackToList") . '</a>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
// Print footer
|
|
||||||
llxFooter();
|
|
||||||
?>
|
|
||||||
@ -429,3 +429,4 @@ BackToList = Back to List
|
|||||||
Recalculate = Recalculate
|
Recalculate = Recalculate
|
||||||
DeclarationRecalculated = Declaration recalculated successfully
|
DeclarationRecalculated = Declaration recalculated successfully
|
||||||
ErrorRecalculatingDeclaration = Error recalculating declaration
|
ErrorRecalculatingDeclaration = Error recalculating declaration
|
||||||
|
NoCA3Data = No CA-3 data calculated yet. Click Recalculate to calculate amounts.
|
||||||
|
|||||||
@ -418,3 +418,4 @@ BackToList = Retour à la liste
|
|||||||
Recalculate = Recalculer
|
Recalculate = Recalculer
|
||||||
DeclarationRecalculated = Déclaration recalculée avec succès
|
DeclarationRecalculated = Déclaration recalculée avec succès
|
||||||
ErrorRecalculatingDeclaration = Erreur lors du recalcul de la déclaration
|
ErrorRecalculatingDeclaration = Erreur lors du recalcul de la déclaration
|
||||||
|
NoCA3Data = Aucune donnée CA-3 calculée. Cliquez sur Recalculer pour calculer les montants.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user