Fix: Error for transfert between a cash account
This commit is contained in:
parent
64c4df446a
commit
c75c0d6ea8
@ -163,7 +163,7 @@ class Account extends CommonObject
|
|||||||
/**
|
/**
|
||||||
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
||||||
\param $date Date operation
|
\param $date Date operation
|
||||||
\param $oper 1,2,3,4...
|
\param $oper 1,2,3,4... or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
|
||||||
\param $label Descripton
|
\param $label Descripton
|
||||||
\param $amount Montant
|
\param $amount Montant
|
||||||
\param $num_chq Numero cheque ou virement
|
\param $num_chq Numero cheque ou virement
|
||||||
@ -175,7 +175,7 @@ class Account extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
|
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
|
||||||
{
|
{
|
||||||
// Nettoyage parametres
|
// Clean parameters
|
||||||
$emetteur=trim($emetteur);
|
$emetteur=trim($emetteur);
|
||||||
$banque=trim($banque);
|
$banque=trim($banque);
|
||||||
switch ($oper)
|
switch ($oper)
|
||||||
@ -203,7 +203,7 @@ class Account extends CommonObject
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verification parametres
|
// Check parameters
|
||||||
if (! $oper)
|
if (! $oper)
|
||||||
{
|
{
|
||||||
$this->error="Account::addline oper not defined";
|
$this->error="Account::addline oper not defined";
|
||||||
|
|||||||
@ -79,13 +79,32 @@ if ($_POST["action"] == 'add')
|
|||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$bank_line_id_from = $accountfrom->addline($dateo, 'VIR', $label, -1*price2num($amount), '', '', $user);
|
$error=0;
|
||||||
$bank_line_id_to = $accountto->addline($dateo, 'VIR', $label, price2num($amount), '', '', $user);
|
$bank_line_id_from=0;
|
||||||
|
$bank_line_id_to=0;
|
||||||
|
$result=0;
|
||||||
|
|
||||||
$result1=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
|
// By default, electronic transfert from bank to bank
|
||||||
$result2=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
|
$typefrom='PRE';
|
||||||
|
$typeto='VIR';
|
||||||
|
if ($accountto->courant == 2 || $accountfrom->courant == 2)
|
||||||
|
{
|
||||||
|
// This is transfert of change
|
||||||
|
$typefrom='LIQ';
|
||||||
|
$typeto='LIQ';
|
||||||
|
}
|
||||||
|
|
||||||
if ($result1 > 0 && $result2 > 0)
|
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
|
||||||
|
if (! ($bank_line_id_from > 0)) $error++;
|
||||||
|
if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
|
||||||
|
if (! ($bank_line_id_to > 0)) $error++;
|
||||||
|
|
||||||
|
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
|
||||||
|
if (! ($result > 0)) $error++;
|
||||||
|
if (! $error) $result=$accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
|
||||||
|
if (! ($result > 0)) $error++;
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
$mesg.="<div class=\"ok\">";
|
$mesg.="<div class=\"ok\">";
|
||||||
$mesg.=$langs->trans("TransferFromToDone","<a href=\"account.php?account=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"account.php?account=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->monnaie));
|
$mesg.=$langs->trans("TransferFromToDone","<a href=\"account.php?account=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"account.php?account=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->monnaie));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user