Better suggestion for data after clone of social contribution

This commit is contained in:
Laurent Destailleur 2021-04-09 00:36:08 +02:00
parent 60711f415d
commit 2d771704d0
2 changed files with 13 additions and 4 deletions

View File

@ -235,17 +235,26 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
if (GETPOST('clone_for_next_month', 'int')) {
if (GETPOST('clone_for_next_month', 'int')) { // This can be true only if TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX has been set
$object->periode = dol_time_plus_duree($object->periode, 1, 'm');
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
} else {
// Note dateech is often a little bit higher than dateperiod
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
$newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int'));
if ($newdateperiod) {
$object->periode = $newdateperiod;
if (empty($newdateech)) {
$object->date_ech = $object->periode;
}
}
if ($newdateech) {
$object->date_ech = $newdateech;
if (empty($newdateperiod)) {
// TODO We can here get dol_get_last_day of previous month:
// $object->periode = dol_get_last_day(year of $object->date_ech - 1m, month or $object->date_ech -1m)
$object->periode = $object->date_ech;
}
}
}
@ -410,9 +419,9 @@ if ($id > 0) {
// Clone confirmation
if ($action === 'clone') {
$formquestion = array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label, 'tdclass'=>'fieldrequired'),
);
if (!empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX)) {
if (!empty($conf->global->TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX)) {
$formquestion[] = array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1);
} else {
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1);

View File

@ -197,7 +197,7 @@ class ChargeSociales extends CommonObject
{
$newamount = price2num($this->amount, 'MT');
// Validation parametres
// Validation of parameters
if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) {
return false;
}