Add testing mode for declaration submission
- Temporarily disable status validation to allow re-submission - Add resetDeclarationStatus() method for testing - Add reset button for submitted declarations - Add French language strings for reset functionality - Allows multiple submission attempts during testing
This commit is contained in:
parent
e34403d3e4
commit
1aa471e85e
@ -1285,10 +1285,13 @@ class DeclarationTVA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if declaration is validated
|
// Check if declaration is validated
|
||||||
|
// TEMPORARILY DISABLED FOR TESTING - allows re-submission
|
||||||
|
/*
|
||||||
if ($declaration->status !== 'validated') {
|
if ($declaration->status !== 'validated') {
|
||||||
$this->error = 'Declaration must be validated before submission';
|
$this->error = 'Declaration must be validated before submission';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Check if accounting entries are enabled
|
// Check if accounting entries are enabled
|
||||||
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
|
||||||
@ -1317,6 +1320,28 @@ class DeclarationTVA
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset declaration status to validated (for testing purposes)
|
||||||
|
*
|
||||||
|
* @param int $declaration_id Declaration ID
|
||||||
|
* @return bool Success
|
||||||
|
*/
|
||||||
|
public function resetDeclarationStatus($declaration_id)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE " . MAIN_DB_PREFIX . "declarationtva_declarations
|
||||||
|
SET status = 'validated',
|
||||||
|
date_submitted = NULL
|
||||||
|
WHERE rowid = " . (int)$declaration_id . " AND entity = " . $this->entity;
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
$this->error = 'Database error: ' . $this->db->lasterror();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update declaration status
|
* Update declaration status
|
||||||
*
|
*
|
||||||
|
|||||||
@ -121,6 +121,15 @@ if ($action == 'submit' && $token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'reset_status' && $token) {
|
||||||
|
// Reset declaration status to validated (for testing purposes)
|
||||||
|
if ($declarationtva->resetDeclarationStatus($id)) {
|
||||||
|
setEventMessages($langs->trans("DeclarationStatusReset"), null, 'mesgs');
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans("ErrorResettingDeclarationStatus") . ": " . $declarationtva->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch declaration
|
// Fetch declaration
|
||||||
if ($declarationtva->fetch($id) < 0) {
|
if ($declarationtva->fetch($id) < 0) {
|
||||||
setEventMessages($langs->trans("DeclarationNotFound"), null, 'errors');
|
setEventMessages($langs->trans("DeclarationNotFound"), null, 'errors');
|
||||||
@ -449,6 +458,9 @@ if ($declarationtva->status == 'draft') {
|
|||||||
print '<a href="#" onclick="confirmSubmission(' . $id . '); return false;" class="butAction">' . $langs->trans("Submit") . '</a> ';
|
print '<a href="#" onclick="confirmSubmission(' . $id . '); return false;" class="butAction">' . $langs->trans("Submit") . '</a> ';
|
||||||
// Add unvalidate button for testing
|
// Add unvalidate button for testing
|
||||||
print '<a href="#" onclick="confirmUnvalidation(' . $id . '); return false;" class="butAction" style="background-color: #dc3545;">' . $langs->trans("Unvalidate") . '</a> ';
|
print '<a href="#" onclick="confirmUnvalidation(' . $id . '); return false;" class="butAction" style="background-color: #dc3545;">' . $langs->trans("Unvalidate") . '</a> ';
|
||||||
|
} elseif ($declarationtva->status == 'submitted') {
|
||||||
|
// Add reset button for testing purposes
|
||||||
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&action=reset_status&token=' . newToken() . '" class="butAction" style="background-color: #ffc107; color: #000;">' . $langs->trans("ResetStatus") . '</a> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<a href="declarationtvaindex.php" class="butAction">' . $langs->trans("BackToList") . '</a>';
|
print '<a href="declarationtvaindex.php" class="butAction">' . $langs->trans("BackToList") . '</a>';
|
||||||
|
|||||||
@ -542,3 +542,6 @@ Submit = Soumettre
|
|||||||
ConfirmSubmission = Confirmer la soumission
|
ConfirmSubmission = Confirmer la soumission
|
||||||
ConfirmSubmissionMessage = Êtes-vous sûr de vouloir soumettre cette déclaration ? Cette action créera les écritures comptables et marquera la déclaration comme soumise.
|
ConfirmSubmissionMessage = Êtes-vous sûr de vouloir soumettre cette déclaration ? Cette action créera les écritures comptables et marquera la déclaration comme soumise.
|
||||||
SubmissionWarning = Attention : Cette action est irréversible. Les écritures comptables seront créées automatiquement.
|
SubmissionWarning = Attention : Cette action est irréversible. Les écritures comptables seront créées automatiquement.
|
||||||
|
ResetStatus = Réinitialiser le statut
|
||||||
|
DeclarationStatusReset = Statut de la déclaration réinitialisé à "validé"
|
||||||
|
ErrorResettingDeclarationStatus = Erreur lors de la réinitialisation du statut de la déclaration
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user