diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index b0abeeb134a..9d030815f8b 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -263,7 +263,10 @@ if ($action == 'add' && empty($cancel)) { $db->begin(); $ret = $object->create($user); - if ($ret < 0) $error++; + if ($ret < 0) { + var_dump($ret); + $error++; + } if (!empty($auto_create_paiement) && !$error) { // Create a line of payments $paiement = new PaymentSalary($db); @@ -562,10 +565,12 @@ if ($action == 'create') { print ''; print ''; + print '
'; + // Auto create payment - print ''.$langs->trans('AutomaticCreationPayment').''; + print ''; print ''."\n"; // Date payment // Bank @@ -997,14 +1002,14 @@ if ($id) { print '
'; + print dol_get_fiche_end(); if ($action == 'edit') { print $form->buttonsSaveCancel(); print ""; } - print dol_get_fiche_end(); - + $resteapayer = price2num($resteapayer, 'MT'); /* * Action bar @@ -1023,17 +1028,13 @@ if ($id) { } // 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 '
'.$langs->trans("DoPayment")."
"; } // Classify 'paid' - if ($object->paye == 0 - && ( - (round($resteapayer) <= 0 && $object->amount > 0) - || (round($resteapayer) >= 0 && $object->amount < 0) - ) - && $user->rights->salaries->write) { + // 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) { print "
id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."
"; } diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 454a94bcf1f..2acc2117297 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -367,7 +367,7 @@ class Salary extends CommonObject $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); return -4; } - if ($this->amount < 0 || $this->amount == '') { + if ($this->amount == '') { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; }