Can make a credit note on an invoice with no payment made
This commit is contained in:
parent
eb081b2d20
commit
51b4ef1c68
@ -1389,24 +1389,36 @@ if ($_GET['action'] == 'create')
|
|||||||
$options="";
|
$options="";
|
||||||
foreach ($facids as $facparam)
|
foreach ($facids as $facparam)
|
||||||
{
|
{
|
||||||
$options.='<option value="'.$facparam['id'].'">'.$facparam['ref'].'</option>';
|
$options.='<option value="'.$facparam['id'].'"';
|
||||||
|
if ($facparam['id'] == $_POST['fac_replacement']) $options.=' selected="true"';
|
||||||
|
$options.='>'.$facparam['ref'];
|
||||||
|
$options.=' ('.$facturestatic->LibStatut(0,$facparam['status']).')';
|
||||||
|
$options.='</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
|
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
|
||||||
|
if ($facids < 0)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,$facturestatic);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$optionsav="";
|
$optionsav="";
|
||||||
foreach ($facids as $key => $value)
|
foreach ($facids as $key => $value)
|
||||||
{
|
{
|
||||||
$newinvoice=new Facture($db);
|
$newinvoice=new Facture($db);
|
||||||
$newinvoice->fetch($key);
|
$newinvoice->fetch($key);
|
||||||
$optionsav.='<option value="'.$key.'">';
|
$optionsav.='<option value="'.$key.'"';
|
||||||
|
if ($key == $_POST['fac_avoir']) $optionsav.=' selected="true"';
|
||||||
|
$optionsav.='>';
|
||||||
$optionsav.=$newinvoice->ref;
|
$optionsav.=$newinvoice->ref;
|
||||||
$optionsav.=' ('.$newinvoice->getLibStatut(1,$value).')';
|
$optionsav.=' ('.$newinvoice->getLibStatut(1,$value).')';
|
||||||
$optionsav.='</option>';
|
$optionsav.='</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type
|
||||||
print '<tr><td valign="top">'.$langs->trans('Type').'</td><td colspan="2">';
|
print '<tr><td valign="top">'.$langs->trans('Type').'</td><td colspan="2">';
|
||||||
print '<table class="nobordernopadding">'."\n";
|
print '<table class="nobordernopadding">'."\n";
|
||||||
|
|
||||||
// Type
|
|
||||||
print '<tr><td width="16px" valign="middle">';
|
print '<tr><td width="16px" valign="middle">';
|
||||||
print '<input type="radio" name="type" value="0"'.($_POST['type']==0?' checked="true"':'').'>';
|
print '<input type="radio" name="type" value="0"'.($_POST['type']==0?' checked="true"':'').'>';
|
||||||
print '</td><td valign="middle">';
|
print '</td><td valign="middle">';
|
||||||
|
|||||||
@ -44,7 +44,7 @@ $langs->load("compta");
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
if ($conf->commande->enabled) $langs->load("orders");
|
if ($conf->commande->enabled) $langs->load("orders");
|
||||||
|
|
||||||
// Sécurité accés client
|
// Security check
|
||||||
$socid='';
|
$socid='';
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
@ -747,7 +747,7 @@ if ($resql)
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$var = True;
|
$var = True;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $db->num_rows($resql) )
|
while ($i < $db->num_rows($resql))
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -1268,7 +1268,7 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non)
|
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non
|
||||||
* \param facid Id de la facture
|
* \param facid Id de la facture
|
||||||
* \param desc Description de la ligne
|
* \param desc Description de la ligne
|
||||||
* \param pu_ht Prix unitaire HT
|
* \param pu_ht Prix unitaire HT
|
||||||
@ -1759,7 +1759,7 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
|
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
|
||||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé lon
|
||||||
* \param alreadypayed 0=Not payment already done, 1=Some payments already done
|
* \param alreadypayed 0=Not payment already done, 1=Some payments already done
|
||||||
* \return string Libelle
|
* \return string Libelle
|
||||||
*/
|
*/
|
||||||
@ -1772,7 +1772,7 @@ class Facture extends CommonObject
|
|||||||
* \brief Renvoi le libellé d'un statut donné
|
* \brief Renvoi le libellé d'un statut donné
|
||||||
* \param paye Etat paye
|
* \param paye Etat paye
|
||||||
* \param statut Id statut
|
* \param statut Id statut
|
||||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Pict
|
||||||
* \param alreadypayed Montant deja payé
|
* \param alreadypayed Montant deja payé
|
||||||
* \param type Type facture
|
* \param type Type facture
|
||||||
* \return string Libellé du statut
|
* \return string Libellé du statut
|
||||||
@ -2114,10 +2114,10 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Renvoi liste des factures remplacables
|
* \brief Renvoi liste des factures remplacables
|
||||||
Statut validée ou abandonnée pour raison autre + non payée + aucun paiement + pas deja remplacée
|
* Statut validée ou abandonnée pour raison autre + non payée + aucun paiement + pas deja remplacée
|
||||||
\param socid Id societe
|
* \param socid Id societe
|
||||||
\return array Tableau des factures ('id'=>id, 'ref'=>ref, 'statut'=>status)
|
* \return array Tableau des factures ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1)
|
||||||
*/
|
*/
|
||||||
function list_replacable_invoices($socid=0)
|
function list_replacable_invoices($socid=0)
|
||||||
{
|
{
|
||||||
@ -2137,23 +2137,23 @@ class Facture extends CommonObject
|
|||||||
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
||||||
$sql.= " ORDER BY f.facnumber";
|
$sql.= " ORDER BY f.facnumber";
|
||||||
|
|
||||||
dolibarr_syslog("Facture.class::list_replacable_invoices sql=$sql");
|
dolibarr_syslog("Facture::list_replacable_invoices sql=$sql");
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
while ($obj=$this->db->fetch_object($resql))
|
while ($obj=$this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$return[$obj->rowid]=array( 'id' => $obj->rowid,
|
$return[$obj->rowid]=array( 'id' => $obj->rowid,
|
||||||
'ref' => $obj->facnumber,
|
'ref' => $obj->facnumber,
|
||||||
'status' => $obj->fk_status);
|
'status' => $obj->fk_statut);
|
||||||
}
|
}
|
||||||
//print_r($return);
|
//print_r($return);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Facture.class::list_replacable_invoices ".$this->error);
|
dolibarr_syslog("Facture::list_replacable_invoices ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2161,9 +2161,9 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoi liste des factures qualifiables pour correction par avoir
|
* \brief Renvoi liste des factures qualifiables pour correction par avoir
|
||||||
* Les factures qui respectent les regles suivantes sont retournees:
|
* Les factures qui respectent les regles suivantes sont retournees:
|
||||||
* (validée + paiement en cours) ou classée (payée completement ou payée partiellement) + pas deja remplacée + pas deja avoir
|
* (validée + paiement en cours) ou classée (payée completement ou payée partiellement) + pas deja remplacée + pas deja avoir
|
||||||
* \param socid Id societe
|
* \param socid Id societe
|
||||||
* \return array Tableau des factures ($id => $ref)
|
* \return array Tableau des factures ($id => $ref)
|
||||||
*/
|
*/
|
||||||
function list_qualified_avoir_invoices($socid=0)
|
function list_qualified_avoir_invoices($socid=0)
|
||||||
@ -2184,32 +2184,29 @@ class Facture extends CommonObject
|
|||||||
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
|
||||||
$sql.= " ORDER BY f.facnumber";
|
$sql.= " ORDER BY f.facnumber";
|
||||||
|
|
||||||
dolibarr_syslog("Facture.class::list_qualified_avoir_invoices sql=$sql");
|
dolibarr_syslog("Facture::list_qualified_avoir_invoices sql=$sql");
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
while ($obj=$this->db->fetch_object($resql))
|
while ($obj=$this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$qualified=0;
|
$qualified=0;
|
||||||
// if statut is 1, record is qualified only if some paiement
|
if ($obj->fk_statut == 1) $qualified=1;
|
||||||
// has already been made.
|
if ($obj->fk_statut == 2) $qualified=1;
|
||||||
// If not, we must not do credit note but a replacement invoice.
|
if ($qualified)
|
||||||
if ($obj->fk_statut == 1 && $obj->fk_paiement) $qualified=1;
|
{
|
||||||
if ($obj->fk_statut == 2) $qualified=1;
|
//$ref=$obj->facnumber;
|
||||||
if ($qualified)
|
$paymentornot=($obj->fk_paiement?1:0);
|
||||||
{
|
$return[$obj->rowid]=$paymentornot;
|
||||||
//$ref=$obj->facnumber;
|
}
|
||||||
$paymentornot=($obj->fk_paiement?1:0);
|
}
|
||||||
$return[$obj->rowid]=$paymentornot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Facture.class::list_avoir_invoices ".$this->error);
|
dolibarr_syslog("Facture::list_avoir_invoices ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2364,7 +2361,7 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise la facture avec valeurs fictives aléatoire
|
* \brief Initialise la facture avec valeurs fictives aléatoire
|
||||||
* Sert à générer une facture pour l'aperu des modèles ou demo
|
* Sert à générer une facture pour l'aperu des modèles ou dem
|
||||||
*/
|
*/
|
||||||
function initAsSpecimen()
|
function initAsSpecimen()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user