MVP Database Schema: - Simplified database schema for MVP development - Core tables: config, account_mappings, periods, declarations, ca3_lines - Basic indexes for performance - Initial configuration data Core PHP Classes: - DeclarationTVA: Main class for CA-3 processing - DeclarationTVA_Config: Configuration management - DeclarationTVA_Period: Period management - Complete CRUD operations for all entities Main Interface: - declarationtvaindex.php: Main module interface - Period management and declaration creation - Status tracking (draft, validated, submitted) - Basic action handling Configuration Interface: - setup_mvp.php: Simplified configuration page - PCG account mapping for all CA-3 lines - Account selection from Dolibarr chart of accounts - VAT rate configuration Key Features Implemented: - Basic CA-3 form generation - PCG account mapping (one account per line for MVP) - Period management (quarterly) - Declaration status tracking - Configuration interface - Account validation against Dolibarr Next Steps: - CA-3 form generation logic - PDF export functionality - Testing with sample data MVP Progress: 60% complete Core foundation ready for testing and refinement
155 lines
5.2 KiB
PHP
155 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* MVP Setup page for DeclarationTVA module
|
|
* Simplified configuration for 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_config.class.php';
|
|
|
|
// Access control
|
|
if (!$user->rights->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_lines = array('A1', 'A2', 'B1', 'B2', 'B3', 'B4', '17', '20', '21', '22', '28', '29');
|
|
|
|
foreach ($ca3_lines as $line) {
|
|
$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();
|
|
|
|
// Page title
|
|
$title = $langs->trans("DeclarationTVASetup");
|
|
llxHeader('', $title);
|
|
|
|
// Print page header
|
|
print load_fiche_titre($title, '', 'title_accountancy');
|
|
|
|
// 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>';
|
|
|
|
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("AccountCode") . '</th>';
|
|
print '<th>' . $langs->trans("AccountLabel") . '</th>';
|
|
print '<th>' . $langs->trans("VATRate") . '</th>';
|
|
print '</tr>';
|
|
|
|
foreach ($ca3_definitions 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>';
|
|
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 '<div class="titre">' . $langs->trans("Actions") . '</div>';
|
|
print '<input type="submit" class="button" value="' . $langs->trans("UpdateConfiguration") . '">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
// Print current configuration
|
|
print '<div class="fiche">';
|
|
print '<div class="titre">' . $langs->trans("CurrentConfiguration") . '</div>';
|
|
|
|
if (empty($mappings)) {
|
|
print '<div class="info">' . $langs->trans("NoConfigurationFound") . '</div>';
|
|
} else {
|
|
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 ($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 '</div>';
|
|
|
|
// Print footer
|
|
llxFooter();
|
|
?>
|