Qual: Le statut des factures avait un cycle de vie qui tait 0=brouillon puis 1=valid. C'tait un autre champ qui servait pour dfinir le 3eme tat, factur trait (car pay). Cet autre champ reste aliment mais maintenant en plus le champ statut est pass 2="trait" ou 3="abandonn" (car remplace par une autre facture). Le suivi du cycle de vie d'une facture devient plus simple et plus rigoureux. On peut se baser sur le statut uniquement comme pour les autres entits.
This commit is contained in:
parent
cf8d15fd5f
commit
2b37dea3f1
@ -267,18 +267,7 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
|
||||
$close_note=$_POST["close_note"];
|
||||
if ($close_code)
|
||||
{
|
||||
if ($close_code == 'abandon')
|
||||
{
|
||||
$result = $fac->set_canceled($user,$close_code,$close_note);
|
||||
}
|
||||
elseif ($close_code == 'badcustomer')
|
||||
{
|
||||
$result = $fac->set_canceled($user,$close_code,$close_note);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $fac->set_payed($user,$close_code,$close_note);
|
||||
}
|
||||
$result = $fac->set_payed($user,$close_code,$close_note);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -137,13 +137,15 @@ class Paiement
|
||||
if ($this->total <> 0) // On accepte les montants négatifs pour les rejets de prélèvement
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)';
|
||||
$sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
|
||||
$sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.addslashes($this->note).'\', '.$user->id.')';
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
dolibarr_syslog("Paiement::Create sql=".$sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiement');
|
||||
|
||||
// Insere tableau des montants / factures
|
||||
// Insere liens montants / factures
|
||||
foreach ($this->amounts as $key => $amount)
|
||||
{
|
||||
$facid = $key;
|
||||
@ -152,7 +154,10 @@ class Paiement
|
||||
$amount = price2num($amount);
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
|
||||
$sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')';
|
||||
if (! $this->db->query($sql) )
|
||||
|
||||
dolibarr_syslog("Paiement::Create sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid);
|
||||
$error++;
|
||||
@ -208,14 +213,14 @@ class Paiement
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Vérifier si paiement porte pas sur une facture à l'état payée
|
||||
// Vérifier si paiement porte pas sur une facture classée
|
||||
// Si c'est le cas, on refuse la suppression
|
||||
$billsarray=$this->getBillsArray('paye=1');
|
||||
$billsarray=$this->getBillsArray('fk_statut > 1');
|
||||
if (is_array($billsarray))
|
||||
{
|
||||
if (sizeof($billsarray))
|
||||
{
|
||||
$this->error="Impossible de supprimer un paiement portant sur au moins une facture à l'état payé";
|
||||
$this->error="Impossible de supprimer un paiement portant sur au moins une facture fermée";
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -769,6 +769,8 @@ alter table llx_adherent add column phone_perso varchar(30) after phone;
|
||||
alter table llx_adherent add column phone_mobile varchar(30) after phone_perso;
|
||||
|
||||
update llx_facture set fk_facture_source=null where fk_facture_source is not null and type = 0;
|
||||
update llx_facture set fk_statut=2 where paye=1;
|
||||
update llx_facture set fk_statut=2 where close_code is not null and close_code != '' and close_code != 'replaced';
|
||||
|
||||
|
||||
update llx_boxes set fk_user = 0 where fk_user IS NULL;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user