Fix can close a salary if paid partially.
This commit is contained in:
parent
b2e8d03dae
commit
5cebaae235
@ -263,7 +263,10 @@ if ($action == 'add' && empty($cancel)) {
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$ret = $object->create($user);
|
$ret = $object->create($user);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
var_dump($ret);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
if (!empty($auto_create_paiement) && !$error) {
|
if (!empty($auto_create_paiement) && !$error) {
|
||||||
// Create a line of payments
|
// Create a line of payments
|
||||||
$paiement = new PaymentSalary($db);
|
$paiement = new PaymentSalary($db);
|
||||||
@ -562,10 +565,12 @@ if ($action == 'create') {
|
|||||||
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'">'.GETPOST('note', 'restricthtml').'</textarea></td>';
|
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'">'.GETPOST('note', 'restricthtml').'</textarea></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
print '<tr><td colspan="2"><hr></td></tr>';
|
print '<tr><td colspan="2"><hr></td></tr>';
|
||||||
|
|
||||||
|
|
||||||
// Auto create payment
|
// Auto create payment
|
||||||
print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>';
|
print '<tr><td><label for="auto_create_paiement">'.$langs->trans('AutomaticCreationPayment').'</label></td>';
|
||||||
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n"; // Date payment
|
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n"; // Date payment
|
||||||
|
|
||||||
// Bank
|
// Bank
|
||||||
@ -997,14 +1002,14 @@ if ($id) {
|
|||||||
|
|
||||||
print '<div class="clearboth"></div>';
|
print '<div class="clearboth"></div>';
|
||||||
|
|
||||||
|
print dol_get_fiche_end();
|
||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
print $form->buttonsSaveCancel();
|
print $form->buttonsSaveCancel();
|
||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print dol_get_fiche_end();
|
$resteapayer = price2num($resteapayer, 'MT');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action bar
|
* Action bar
|
||||||
@ -1023,17 +1028,13 @@ if ($id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit payment
|
// Emit payment
|
||||||
if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->salaries->write) {
|
if ($object->paye == 0 && ((price2num($object->amount) < 0 && $resteapayer < 0) || (price2num($object->amount) > 0 && $resteapayer > 0)) && $user->rights->salaries->write) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT."/salaries/paiement_salary.php?id=".$object->id.'&action=create&token='.newToken().'">'.$langs->trans("DoPayment")."</a></div>";
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT."/salaries/paiement_salary.php?id=".$object->id.'&action=create&token='.newToken().'">'.$langs->trans("DoPayment")."</a></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classify 'paid'
|
// Classify 'paid'
|
||||||
if ($object->paye == 0
|
// If at least one payment was already done ($object->amount - $resteapayer > 0) or if amount is negative, we allow to classify as paid.
|
||||||
&& (
|
if ($object->paye == 0 && ((($object->amount - $resteapayer) > 0 && $object->amount > 0) || ($object->amount <= 0)) && $user->rights->salaries->write) {
|
||||||
(round($resteapayer) <= 0 && $object->amount > 0)
|
|
||||||
|| (round($resteapayer) >= 0 && $object->amount < 0)
|
|
||||||
)
|
|
||||||
&& $user->rights->salaries->write) {
|
|
||||||
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."</a></div>";
|
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."</a></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -367,7 +367,7 @@ class Salary extends CommonObject
|
|||||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
|
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
if ($this->amount < 0 || $this->amount == '') {
|
if ($this->amount == '') {
|
||||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
|
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user