Features added: - New getCA3LineDetails() method in DeclarationTVA class - New declarationtva_line_details.php page for detailed view - All CA-3 line codes are now clickable in declaration view - Detailed breakdown shows: * Account codes and labels * Base amounts, VAT amounts, total amounts * Mapping types (A1, 08_BASE, 08_VAT, etc.) * Calculated totals vs account totals - Added comprehensive translations for detailed view - Navigation breadcrumbs and back buttons - Professional styling with Dolibarr UI components This provides complete transparency into which accounts contribute to each CA-3 line without touching the calculation logic.
184 lines
6.0 KiB
PHP
184 lines
6.0 KiB
PHP
<?php
|
|
/**
|
|
* DeclarationTVA Line Details Page
|
|
* Shows detailed breakdown of accounts for a specific CA-3 line
|
|
*/
|
|
|
|
// 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';
|
|
} elseif (file_exists('../../../main.inc.php')) {
|
|
$res = @include '../../../main.inc.php';
|
|
} else {
|
|
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';
|
|
|
|
// Access control
|
|
if (!$user->hasRight("declarationtva", "declarationtva", "read")) {
|
|
accessforbidden();
|
|
}
|
|
|
|
// Get parameters
|
|
$declaration_id = GETPOST('declaration_id', 'int');
|
|
$ca3_line = GETPOST('ca3_line', 'alpha');
|
|
|
|
// Validate parameters
|
|
if (empty($declaration_id) || empty($ca3_line)) {
|
|
setEventMessages($langs->trans("ErrorMissingParameters"), null, 'errors');
|
|
header("Location: declarationtvaindex.php");
|
|
exit;
|
|
}
|
|
|
|
// Initialize objects
|
|
$declarationtva = new DeclarationTVA($db);
|
|
$config = new DeclarationTVA_Config($db);
|
|
|
|
// Get declaration info
|
|
if (!$declarationtva->fetch($declaration_id)) {
|
|
setEventMessages($langs->trans("DeclarationNotFound"), null, 'errors');
|
|
header("Location: declarationtvaindex.php");
|
|
exit;
|
|
}
|
|
|
|
// Get detailed breakdown
|
|
$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
|
|
|
|
if (empty($line_details)) {
|
|
setEventMessages($langs->trans("NoDataFoundForLine"), null, 'errors');
|
|
header("Location: declarationtva_view.php?id=" . $declaration_id);
|
|
exit;
|
|
}
|
|
|
|
// Get CA-3 line definition
|
|
$ca3_definitions = $config->getCA3LineDefinitions();
|
|
$line_definition = isset($ca3_definitions[$ca3_line]) ? $ca3_definitions[$ca3_line] : null;
|
|
|
|
// Page title
|
|
$title = $langs->trans("CA3LineDetails") . " - " . $ca3_line;
|
|
if ($line_definition) {
|
|
$title .= " - " . $line_definition['label'];
|
|
}
|
|
|
|
// Load page header
|
|
llxHeader('', $title);
|
|
|
|
// Page header
|
|
print load_fiche_titre($title, '', 'fa-list-alt');
|
|
|
|
// Breadcrumb
|
|
print '<div class="tabsAction">';
|
|
print '<a href="declarationtvaindex.php" class="butAction">' . $langs->trans("BackToList") . '</a>';
|
|
print '<a href="declarationtva_view.php?id=' . $declaration_id . '" class="butAction">' . $langs->trans("BackToDeclaration") . '</a>';
|
|
print '</div>';
|
|
|
|
// Declaration info
|
|
print '<div class="fiche">';
|
|
print '<div class="fichehalfleft">';
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th colspan="2">' . $langs->trans("DeclarationInfo") . '</th>';
|
|
print '</tr>';
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("DeclarationNumber") . '</td>';
|
|
print '<td>' . $declarationtva->declaration_number . '</td>';
|
|
print '</tr>';
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("Period") . '</td>';
|
|
print '<td>' . dol_print_date($declarationtva->start_date, 'day') . ' - ' . dol_print_date($declarationtva->end_date, 'day') . '</td>';
|
|
print '</tr>';
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("CA3Line") . '</td>';
|
|
print '<td><strong>' . $ca3_line . '</strong></td>';
|
|
print '</tr>';
|
|
if ($line_definition) {
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("Description") . '</td>';
|
|
print '<td>' . $line_definition['label'] . '</td>';
|
|
print '</tr>';
|
|
}
|
|
print '</table>';
|
|
print '</div>';
|
|
|
|
print '<div class="fichehalfright">';
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th colspan="2">' . $langs->trans("LineSummary") . '</th>';
|
|
print '</tr>';
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("AccountCount") . '</td>';
|
|
print '<td><strong>' . $line_details['account_count'] . '</strong></td>';
|
|
print '</tr>';
|
|
if ($line_details['calculated_line']) {
|
|
print '<tr>';
|
|
print '<td>' . $langs->trans("CalculatedTotal") . '</td>';
|
|
print '<td><strong>' . price($line_details['calculated_line']->total_amount) . '</strong></td>';
|
|
print '</tr>';
|
|
}
|
|
print '</table>';
|
|
print '</div>';
|
|
print '</div>';
|
|
|
|
// Account details table
|
|
print '<div class="fiche">';
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th>' . $langs->trans("AccountCode") . '</th>';
|
|
print '<th>' . $langs->trans("AccountLabel") . '</th>';
|
|
print '<th class="right">' . $langs->trans("BaseAmount") . '</th>';
|
|
print '<th class="right">' . $langs->trans("VATAmount") . '</th>';
|
|
print '<th class="right">' . $langs->trans("TotalAmount") . '</th>';
|
|
print '<th>' . $langs->trans("MappingType") . '</th>';
|
|
print '</tr>';
|
|
|
|
$total_base = 0;
|
|
$total_vat = 0;
|
|
$total_amount = 0;
|
|
|
|
foreach ($line_details['account_details'] as $account) {
|
|
$total_base += $account['base_amount'];
|
|
$total_vat += $account['vat_amount'];
|
|
$total_amount += $account['total_amount'];
|
|
|
|
print '<tr class="oddeven">';
|
|
print '<td><strong>' . $account['account_code'] . '</strong></td>';
|
|
print '<td>' . $account['account_label'] . '</td>';
|
|
print '<td class="right">' . price($account['base_amount']) . '</td>';
|
|
print '<td class="right">' . price($account['vat_amount']) . '</td>';
|
|
print '<td class="right">' . price($account['total_amount']) . '</td>';
|
|
print '<td>' . $account['mapping_type'] . '</td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
// Totals row
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2"><strong>' . $langs->trans("Total") . '</strong></td>';
|
|
print '<td class="right"><strong>' . price($total_base) . '</strong></td>';
|
|
print '<td class="right"><strong>' . price($total_vat) . '</strong></td>';
|
|
print '<td class="right"><strong>' . price($total_amount) . '</strong></td>';
|
|
print '<td></td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
print '</div>';
|
|
|
|
// Additional info if calculated line exists
|
|
if ($line_details['calculated_line']) {
|
|
print '<div class="info">';
|
|
print '<strong>' . $langs->trans("Note") . ':</strong> ';
|
|
print $langs->trans("CalculatedLineNote");
|
|
if (!empty($line_details['calculated_line']->line_label)) {
|
|
print '<br><em>' . $line_details['calculated_line']->line_label . '</em>';
|
|
}
|
|
print '</div>';
|
|
}
|
|
|
|
// Close page
|
|
llxFooter();
|
|
?>
|