This commit is contained in:
Laurent Destailleur 2020-09-10 18:25:38 +02:00
parent 0cccaa7271
commit 358f8357f9
3 changed files with 12 additions and 8 deletions

View File

@ -476,7 +476,7 @@ class Account extends CommonObject
* @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'... * @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'...
* @param string $label Descripton * @param string $label Descripton
* @param float $amount Amount * @param float $amount Amount
* @param string $num_chq Numero cheque ou virement * @param string $num_chq Numero cheque or transfer
* @param int $categorie Category id (optionnal) * @param int $categorie Category id (optionnal)
* @param User $user User that create * @param User $user User that create
* @param string $emetteur Name of cheque writer * @param string $emetteur Name of cheque writer
@ -572,15 +572,18 @@ class Account extends CommonObject
if (!$result) { if (!$result) {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
} }
$this->db->commit(); $this->db->commit();
return $accline->id; return $accline->id;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} }

View File

@ -100,16 +100,16 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$object->label = GETPOST("label", 'alpha'); $object->label = GETPOST("label", 'alpha');
$object->note = GETPOST("note", 'none'); $object->note = GETPOST("note", 'none');
if (empty($object->datev))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateValue")), null, 'errors');
$error++;
}
if (empty($object->datep)) if (empty($object->datep))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")), null, 'errors');
$error++; $error++;
} }
if (empty($object->datev))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors');
$error++;
}
if (empty($object->type_payment) || $object->type_payment < 0) if (empty($object->type_payment) || $object->type_payment < 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');

View File

@ -519,6 +519,7 @@ class Tva extends CommonObject
$this->amount = price2num(trim($this->amount)); $this->amount = price2num(trim($this->amount));
$this->label = trim($this->label); $this->label = trim($this->label);
$this->note = trim($this->note); $this->note = trim($this->note);
$this->num_payment = trim($this->num_payment);
$this->fk_bank = (int) $this->fk_bank; $this->fk_bank = (int) $this->fk_bank;
$this->fk_user_creat = (int) $this->fk_user_creat; $this->fk_user_creat = (int) $this->fk_user_creat;
$this->fk_user_modif = (int) $this->fk_user_modif; $this->fk_user_modif = (int) $this->fk_user_modif;
@ -603,9 +604,9 @@ class Tva extends CommonObject
if ($result <= 0) dol_print_error($this->db); if ($result <= 0) dol_print_error($this->db);
if ($this->amount > 0) { if ($this->amount > 0) {
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), '', '', $user); $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user);
} else { } else {
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), '', '', $user); $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user);
} }
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction