Fix deposit invoice
This commit is contained in:
parent
317134c29d
commit
3f6b319d41
@ -584,7 +584,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
||||
$object->fetch_thirdparty();
|
||||
$object->fetch_lines();
|
||||
|
||||
if (! $object->paye) // protection against multiple submit
|
||||
if (!empty($object->paye)) // protection against multiple submit
|
||||
{
|
||||
// Boucle sur chaque taux de tva
|
||||
$i=0;
|
||||
@ -601,8 +601,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
||||
if ($object->type == 2) $discount->description='(CREDIT_NOTE)';
|
||||
elseif ($object->type == 3) $discount->description='(DEPOSIT)';
|
||||
else {
|
||||
$this->error="CantConvertToReducAnInvoiceOfThisType";
|
||||
return -1;
|
||||
setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors');
|
||||
}
|
||||
$discount->tva_tx=abs($object->total_ttc);
|
||||
$discount->fk_soc=$object->socid;
|
||||
@ -617,6 +616,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
||||
$discount->tva_tx=abs($tva_tx);
|
||||
|
||||
$result=$discount->create($user);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -624,24 +624,24 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (empty($error))
|
||||
{
|
||||
// Classe facture
|
||||
$result=$object->set_paid($user);
|
||||
if ($result > 0)
|
||||
if ($result >= 0)
|
||||
{
|
||||
//$mesgs[]='OK'.$discount->id;
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$object->error.'</div>';
|
||||
setEventMessage($object->error,'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesgs[]='<div class="error">'.$discount->error.'</div>';
|
||||
setEventMessage($discount->error,'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
@ -3687,7 +3687,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||
}
|
||||
// For deposit invoice
|
||||
if ($object->type == 3 && $object->statut == 1 && $resteapayer == 0 && $user->rights->facture->creer)
|
||||
if ($object->type == 3 && $object->statut == 2 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||
}
|
||||
|
||||
@ -1471,6 +1471,7 @@ class Facture extends CommonInvoice
|
||||
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1486,8 +1487,7 @@ class Facture extends CommonInvoice
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$this->error=$this->db->error();
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@ -154,7 +154,7 @@ class DiscountAbsolute
|
||||
$sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
|
||||
$sql.= " fk_facture_source";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (".$this->db->idate($this->datec!=''?$this->datec:dol_now()).", ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',";
|
||||
$sql.= " VALUES ('".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',";
|
||||
$sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
|
||||
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
@ -270,7 +270,7 @@ class modSociete extends DolibarrModules
|
||||
$this->export_TypeFields_array[$r]=array('s.nom'=>"Text",'s.status'=>"Number",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'p.libelle'=>"List:c_pays:libelle:libelle",'p.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Number",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text');
|
||||
$this->export_entities_array[$r]=array(); // We define here only fields that use another picto
|
||||
// Add extra fields
|
||||
$sql="SELECT name, label, type FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
|
||||
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql) // This can fail when class is used on old database (during migration for example)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user