NEW Can modify amount when cloning a social contribution

This commit is contained in:
Laurent Destailleur 2021-11-15 19:40:26 +01:00
parent b77fd3d312
commit 47f32ef19b
2 changed files with 10 additions and 6 deletions

View File

@ -231,8 +231,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
$object->fetch($id);
if ($object->id > 0) {
$object->paye = 0;
$object->id = $object->ref = null;
$object->paye = 0;
if (GETPOST('amount', 'alphanohtml')) {
$object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2);
}
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
@ -244,7 +247,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
$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
// Note date_ech 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) {
@ -263,7 +266,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
}
}
if ($object->check()) {
$resultcheck = $object->check();
if ($resultcheck) {
$id = $object->create($user);
if ($id > 0) {
$db->commit();
@ -431,9 +435,10 @@ if ($id > 0) {
} else {
$formquestion[] = array('type' => 'date', 'datenow'=>1, 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
$formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100');
}
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 280);
}

View File

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