diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index 4f77d2f5e1e..2ddcfca4b88 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -68,46 +68,23 @@ class PaiementFourn $label = "Règlement facture $this->facnumber - $this->societe"; - // Portion de code qui mériterait de se baser sur la table des types - // de paiement, mais comme cette portion est aussi en dur dans l'ajout - // des factures clients, je fais pareil pour les factures fournisseurs - switch ($this->paiementid) - { - case 1: - $this->paiementid = 'TIP'; - break; - case 2: - $this->paiementid = 'VIR'; - break; - case 3: - $this->paiementid = 'PRE'; - break; - case 4: - $this->paiementid = 'LIQ'; - break; - case 5: - $this->paiementid = 'WWW'; - break; - case 6: - $this->paiementid = 'CB'; - break; - case 7: - $this->paiementid = 'CHQ'; - break; - } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (datec, dateo, amount, author, label, fk_type, fk_account, num_chq)"; - $sql .= " VALUES (now(), '$this->datepaye', -$this->amount, '$this->author', '$label', '$this->paiementid', '$this->accountid', '$this->num_paiement')"; - $result = $this->db->query($sql); + $account = new Account($this->db, $this->accountid); + + $result = $account->addline($this->datepaye, + $this->paiementid, + $label, + -$this->amount, + $this->num_paiement); + // Mise a jour fk_bank dans llx_paiement_fourn - if ($result) { - $this->bankid = $this->db->last_insert_id(); + if ($result) + { + $this->bankid = $this->db->last_insert_id(); - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; - $result = $this->db->query($sql); - } - + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; + $result = $this->db->query($sql); + } } else {