Fix: Use good payment type
This commit is contained in:
parent
0bf8bce765
commit
5be0cb859e
@ -140,7 +140,8 @@ class Account extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
|
dol_syslog("Account:add_url_line ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +187,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... or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
|
* \param $oper 1,2,3,4... (deprecated) 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
|
||||||
@ -201,29 +202,21 @@ class Account extends CommonObject
|
|||||||
// Clean parameters
|
// Clean parameters
|
||||||
$emetteur=trim($emetteur);
|
$emetteur=trim($emetteur);
|
||||||
$banque=trim($banque);
|
$banque=trim($banque);
|
||||||
switch ($oper)
|
if (is_numeric($oper)) // Clean oper to have a code instead of a rowid
|
||||||
{
|
{
|
||||||
case 1:
|
$sql ="SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
|
||||||
$oper = 'TIP';
|
$sql.=" WHERE id=".$oper;
|
||||||
break;
|
$resql=$this->db->query($sql);
|
||||||
case 2:
|
if ($resql)
|
||||||
$oper = 'VIR';
|
{
|
||||||
break;
|
$obj=$this->db->fetch_object($resql);
|
||||||
case 3:
|
$oper=$obj->code;
|
||||||
$oper = 'PRE';
|
}
|
||||||
break;
|
else
|
||||||
case 4:
|
{
|
||||||
$oper = 'LIQ';
|
dol_print_error($this->db,'Failed to get payment type code');
|
||||||
break;
|
return -1;
|
||||||
case 5:
|
}
|
||||||
$oper = 'VAD';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
$oper = 'CB';
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
$oper = 'CHQ';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
|
|||||||
@ -153,7 +153,7 @@ if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
|
|||||||
{
|
{
|
||||||
if ($conf->banque->enabled)
|
if ($conf->banque->enabled)
|
||||||
{
|
{
|
||||||
// Insertion dans llx_bank
|
// Insert payment into llx_bank
|
||||||
$label = "(CustomerInvoicePayment)";
|
$label = "(CustomerInvoicePayment)";
|
||||||
$acc = new Account($db, $_POST['accountid']);
|
$acc = new Account($db, $_POST['accountid']);
|
||||||
|
|
||||||
@ -171,24 +171,30 @@ if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
|
|||||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
$paiement->update_fk_bank($bank_line_id);
|
$result=$paiement->update_fk_bank($bank_line_id);
|
||||||
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
if ($result <= 0) dol_print_error($db);
|
||||||
foreach ($paiement->amounts as $key => $value)
|
// Add link in bank_url between payment and bank transaction
|
||||||
{
|
$result=$acc->add_url_line($bank_line_id,
|
||||||
$facid = $key;
|
|
||||||
$fac = new Facture($db);
|
|
||||||
$fac->fetch($facid);
|
|
||||||
$fac->fetch_thirdparty();
|
|
||||||
$acc->add_url_line($bank_line_id,
|
|
||||||
$paiement_id,
|
$paiement_id,
|
||||||
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
||||||
'(paiement)',
|
'(paiement)',
|
||||||
'payment');
|
'payment');
|
||||||
$acc->add_url_line($bank_line_id,
|
// Add link in bank_url between invoice and bank transaction (for each invoice concerned by payment)
|
||||||
|
$linkaddedforthirdparty=array();
|
||||||
|
foreach ($paiement->amounts as $key => $value)
|
||||||
|
{
|
||||||
|
$fac = new Facture($db);
|
||||||
|
$fac->fetch($key);
|
||||||
|
$fac->fetch_thirdparty();
|
||||||
|
if (! in_array($fac->client->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
|
||||||
|
{
|
||||||
|
$result=$acc->add_url_line($bank_line_id,
|
||||||
$fac->client->id,
|
$fac->client->id,
|
||||||
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
||||||
$fac->client->nom,
|
$fac->client->nom,
|
||||||
'company');
|
'company');
|
||||||
|
$linkaddedforthirdparty[$fac->client->id]=$fac->client->id; // Mark as done for this thirdparty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -162,18 +162,18 @@ class Paiement
|
|||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
|
||||||
$sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\')';
|
$sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\')';
|
||||||
|
|
||||||
dol_syslog("Paiement::Create insert paiement_facture sql=".$sql);
|
dol_syslog("Paiement::Create Amount line '.$key.' insert paiement_facture sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
dol_syslog('Paiement::Create insert paiement_facture error='.$this->error, LOG_ERR);
|
dol_syslog('Paiement::Create insert paiement_facture error='.$this->error, LOG_ERR);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog('Paiement::Create Montant non numerique');
|
dol_syslog('Paiement::Create Amount line '.$key.' not a number. We discard it.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
// \TODO Boucler sur les facture liees a ce paiement et regenerer le pdf
|
// Loop on each invoice linked to this payment to rebuild PDF
|
||||||
$factures=array();
|
$factures=array();
|
||||||
foreach($factures as $id)
|
foreach($factures as $id)
|
||||||
{
|
{
|
||||||
@ -169,8 +169,9 @@ print '<tr><td valign="top" width="140">'.$langs->trans('Ref').'</td><td colspan
|
|||||||
// Date
|
// Date
|
||||||
print '<tr><td valign="top" width="120">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>';
|
print '<tr><td valign="top" width="120">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>';
|
||||||
|
|
||||||
// Mode
|
// Payment type (VIR, LIQ, ...)
|
||||||
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$paiement->type_code).'</td></tr>';
|
$labeltype=$langs->trans("PaymentType".$paiement->type_code)!=("PaymentType".$paiement->type_code)?$langs->trans("PaymentType".$paiement->type_code):$paiement->type_libelle;
|
||||||
|
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
|
||||||
|
|
||||||
// Numero
|
// Numero
|
||||||
//if ($paiement->montant)
|
//if ($paiement->montant)
|
||||||
@ -178,7 +179,7 @@ print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$lan
|
|||||||
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
|
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Montant
|
// Amount
|
||||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user