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_thirdparty();
|
||||||
$object->fetch_lines();
|
$object->fetch_lines();
|
||||||
|
|
||||||
if (! $object->paye) // protection against multiple submit
|
if (!empty($object->paye)) // protection against multiple submit
|
||||||
{
|
{
|
||||||
// Boucle sur chaque taux de tva
|
// Boucle sur chaque taux de tva
|
||||||
$i=0;
|
$i=0;
|
||||||
@ -601,8 +601,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
|||||||
if ($object->type == 2) $discount->description='(CREDIT_NOTE)';
|
if ($object->type == 2) $discount->description='(CREDIT_NOTE)';
|
||||||
elseif ($object->type == 3) $discount->description='(DEPOSIT)';
|
elseif ($object->type == 3) $discount->description='(DEPOSIT)';
|
||||||
else {
|
else {
|
||||||
$this->error="CantConvertToReducAnInvoiceOfThisType";
|
setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors');
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
$discount->tva_tx=abs($object->total_ttc);
|
$discount->tva_tx=abs($object->total_ttc);
|
||||||
$discount->fk_soc=$object->socid;
|
$discount->fk_soc=$object->socid;
|
||||||
@ -617,6 +616,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
|||||||
$discount->tva_tx=abs($tva_tx);
|
$discount->tva_tx=abs($tva_tx);
|
||||||
|
|
||||||
$result=$discount->create($user);
|
$result=$discount->create($user);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -624,24 +624,24 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (empty($error))
|
||||||
{
|
{
|
||||||
// Classe facture
|
// Classe facture
|
||||||
$result=$object->set_paid($user);
|
$result=$object->set_paid($user);
|
||||||
if ($result > 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
//$mesgs[]='OK'.$discount->id;
|
//$mesgs[]='OK'.$discount->id;
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesgs[]='<div class="error">'.$object->error.'</div>';
|
setEventMessage($object->error,'errors');
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesgs[]='<div class="error">'.$discount->error.'</div>';
|
setEventMessage($discount->error,'errors');
|
||||||
$db->rollback();
|
$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>';
|
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
|
// 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>';
|
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)."'";
|
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -1486,8 +1487,7 @@ class Facture extends CommonInvoice
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
dol_print_error($this->db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
|
|||||||
@ -154,7 +154,7 @@ class DiscountAbsolute
|
|||||||
$sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
|
$sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
|
||||||
$sql.= " fk_facture_source";
|
$sql.= " fk_facture_source";
|
||||||
$sql.= ")";
|
$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->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
|
||||||
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
|
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
|
||||||
$sql.= ")";
|
$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_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
|
$this->export_entities_array[$r]=array(); // We define here only fields that use another picto
|
||||||
// Add extra fields
|
// 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);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql) // This can fail when class is used on old database (during migration for example)
|
if ($resql) // This can fail when class is used on old database (during migration for example)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user