Major Structure Update: - Updated to latest official CA-3 form structure (Notice 4722) - Replaced old structure with new 5-line format (A1-A5) - All changes based on official notice 4722 New CA-3 Lines (Notice 4722): - A1: HT amount of all taxable operations that form normal sales - A2: HT amount of special taxable operations not part of ordinary turnover - A3: HT amount of services purchased from non-established providers (reverse charge) - A4: HT amount of imports taxable in France (non-EU), excluding petroleum products - A5: HT amount of taxable operations at exit from suspensive fiscal regime Enhanced Configuration Interface: - Added detailed descriptions for each line - Added PCG account recommendations - Added notice reference information - Improved form layout with additional columns Updated Files: - core/class/declarationtva_config.class.php: New CA-3 line definitions - admin/setup_mvp.php: Enhanced interface with descriptions and PCG accounts - langs/en_US/declarationtva.lang: English translations for new structure - langs/fr_FR/declarationtva.lang: French translations for new structure - PLANNING.md: Updated documentation with new structure Key Features: - Official Notice 4722 compliance - Detailed line descriptions and PCG account guidance - Enhanced user interface with better information display - Bilingual support for all new content The module now uses the latest official CA-3 form structure!
208 lines
7.5 KiB
PHP
208 lines
7.5 KiB
PHP
<?php
|
|
/**
|
|
* MVP Setup page for DeclarationTVA module
|
|
* Updated for Notice 4722 - Latest Official CA-3 Structure (3310-CA3-SD)
|
|
*/
|
|
|
|
// 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_config.class.php';
|
|
|
|
// Access control
|
|
if (!$user->hasRight("declarationtva", "declarationtva", "admin")) {
|
|
accessforbidden();
|
|
}
|
|
|
|
// Load language files
|
|
$langs->load("declarationtva@declarationtva");
|
|
|
|
// Initialize objects
|
|
$config = new DeclarationTVA_Config($db, $conf->entity);
|
|
|
|
// Handle form submission
|
|
$action = GETPOST('action', 'alpha');
|
|
if ($action == 'update_mappings') {
|
|
$ca3_definitions = $config->getCA3LineDefinitions();
|
|
|
|
foreach ($ca3_definitions as $line => $definition) {
|
|
$account_code = GETPOST('account_code_' . $line, 'alpha');
|
|
$account_label = GETPOST('account_label_' . $line, 'alpha');
|
|
$vat_rate = GETPOST('vat_rate_' . $line, 'alpha');
|
|
|
|
if (!empty($account_code)) {
|
|
$config->updateAccountMapping($line, $account_code, $account_label, $vat_rate);
|
|
}
|
|
}
|
|
|
|
setEventMessages($langs->trans("ConfigurationUpdated"), null, 'mesgs');
|
|
}
|
|
|
|
// Get current mappings
|
|
$mappings = $config->getAllAccountMappings();
|
|
$account_mappings = array();
|
|
foreach ($mappings as $mapping) {
|
|
$account_mappings[$mapping['ca3_line']] = $mapping;
|
|
}
|
|
|
|
// Get available accounting accounts
|
|
$accounts = $config->getAccountingAccounts();
|
|
$vat_rates = $config->getVATRates();
|
|
$ca3_definitions = $config->getCA3LineDefinitions();
|
|
$section_headers = $config->getCA3SectionHeaders();
|
|
|
|
// Page title
|
|
$title = $langs->trans("DeclarationTVASetup");
|
|
llxHeader('', $title);
|
|
|
|
// Print page header
|
|
print load_fiche_titre($title, '', 'title_accountancy');
|
|
|
|
// Print notice information
|
|
print '<div class="info">';
|
|
print '<strong>Notice 4722 - Summary Table CA3 (3310-CA3-SD)</strong><br>';
|
|
print 'Configuration basée sur la structure officielle la plus récente du formulaire CA-3.';
|
|
print '</div><br>';
|
|
|
|
// Print configuration form
|
|
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
|
|
print '<input type="hidden" name="action" value="update_mappings">';
|
|
|
|
print '<div class="fiche">';
|
|
print '<div class="titre">' . $langs->trans("DeclarationTVAPCGMapping") . '</div>';
|
|
|
|
// Group CA-3 lines by section
|
|
$lines_by_section = array();
|
|
foreach ($ca3_definitions as $line => $definition) {
|
|
$section = $definition['section'];
|
|
if (!isset($lines_by_section[$section])) {
|
|
$lines_by_section[$section] = array();
|
|
}
|
|
$lines_by_section[$section][$line] = $definition;
|
|
}
|
|
|
|
// Print each section
|
|
foreach ($lines_by_section as $section_code => $lines) {
|
|
$section_info = $section_headers[$section_code];
|
|
|
|
// Section header
|
|
print '<div class="titre">' . $section_info['title'] . '</div>';
|
|
print '<div class="info">' . $section_info['description'] . '</div>';
|
|
if (isset($section_info['notice'])) {
|
|
print '<div class="info"><strong>Référence:</strong> ' . $section_info['notice'] . '</div>';
|
|
}
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th>' . $langs->trans("CA3Line") . '</th>';
|
|
print '<th>' . $langs->trans("LineLabel") . '</th>';
|
|
print '<th>' . $langs->trans("Description") . '</th>';
|
|
print '<th>' . $langs->trans("PCGAccounts") . '</th>';
|
|
print '<th>' . $langs->trans("AccountCode") . '</th>';
|
|
print '<th>' . $langs->trans("AccountLabel") . '</th>';
|
|
print '<th>' . $langs->trans("VATRate") . '</th>';
|
|
print '</tr>';
|
|
|
|
foreach ($lines as $line => $definition) {
|
|
$mapping = isset($account_mappings[$line]) ? $account_mappings[$line] : array();
|
|
|
|
print '<tr>';
|
|
print '<td><strong>' . $line . '</strong></td>';
|
|
print '<td>' . $definition['label'] . '</td>';
|
|
print '<td><small>' . $definition['description'] . '</small></td>';
|
|
print '<td><small>' . $definition['pcg_accounts'] . '</small></td>';
|
|
print '<td>';
|
|
print '<select name="account_code_' . $line . '" class="flat">';
|
|
print '<option value="">' . $langs->trans("SelectAccount") . '</option>';
|
|
foreach ($accounts as $account) {
|
|
$selected = (isset($mapping['account_code']) && $mapping['account_code'] == $account['account_number']) ? 'selected' : '';
|
|
print '<option value="' . $account['account_number'] . '" ' . $selected . '>' . $account['account_number'] . ' - ' . $account['label'] . '</option>';
|
|
}
|
|
print '</select>';
|
|
print '</td>';
|
|
print '<td><input type="text" name="account_label_' . $line . '" value="' . (isset($mapping['account_label']) ? $mapping['account_label'] : '') . '" class="flat" size="30"></td>';
|
|
print '<td>';
|
|
print '<select name="vat_rate_' . $line . '" class="flat">';
|
|
foreach ($vat_rates as $rate => $label) {
|
|
$selected = (isset($mapping['vat_rate']) && $mapping['vat_rate'] == $rate) ? 'selected' : '';
|
|
print '<option value="' . $rate . '" ' . $selected . '>' . $label . '</option>';
|
|
}
|
|
print '</select>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
}
|
|
|
|
print '</table>';
|
|
print '<br>';
|
|
}
|
|
|
|
print '<div class="titre">' . $langs->trans("Actions") . '</div>';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
// Print current configuration summary
|
|
print '<div class="fiche">';
|
|
print '<div class="titre">' . $langs->trans("CurrentConfiguration") . '</div>';
|
|
|
|
if (empty($mappings)) {
|
|
print '<div class="info">' . $langs->trans("NoConfigurationFound") . '</div>';
|
|
} else {
|
|
// Group by section for display
|
|
$mappings_by_section = array();
|
|
foreach ($mappings as $mapping) {
|
|
$line = $mapping['ca3_line'];
|
|
if (isset($ca3_definitions[$line])) {
|
|
$section = $ca3_definitions[$line]['section'];
|
|
if (!isset($mappings_by_section[$section])) {
|
|
$mappings_by_section[$section] = array();
|
|
}
|
|
$mappings_by_section[$section][] = $mapping;
|
|
}
|
|
}
|
|
|
|
foreach ($mappings_by_section as $section_code => $section_mappings) {
|
|
$section_info = $section_headers[$section_code];
|
|
|
|
print '<div class="titre">' . $section_info['title'] . '</div>';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th>' . $langs->trans("CA3Line") . '</th>';
|
|
print '<th>' . $langs->trans("AccountCode") . '</th>';
|
|
print '<th>' . $langs->trans("AccountLabel") . '</th>';
|
|
print '<th>' . $langs->trans("VATRate") . '</th>';
|
|
print '<th>' . $langs->trans("Status") . '</th>';
|
|
print '</tr>';
|
|
|
|
foreach ($section_mappings as $mapping) {
|
|
print '<tr>';
|
|
print '<td><strong>' . $mapping['ca3_line'] . '</strong></td>';
|
|
print '<td>' . $mapping['account_code'] . '</td>';
|
|
print '<td>' . $mapping['account_label'] . '</td>';
|
|
print '<td>' . $mapping['vat_rate'] . '%</td>';
|
|
print '<td>' . ($mapping['is_active'] ? $langs->trans("Active") : $langs->trans("Inactive")) . '</td>';
|
|
print '</tr>';
|
|
}
|
|
print '</table>';
|
|
print '<br>';
|
|
}
|
|
}
|
|
|
|
print '</div>';
|
|
|
|
// Print footer
|
|
llxFooter();
|
|
?>
|