From 68e923a104d1920219b8226b191b29ebf3523470 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Jan 2004 22:48:31 +0000 Subject: [PATCH] =?UTF-8?q?-=20Le=20type=20de=20paiement=20est=20aussi=20i?= =?UTF-8?q?ns=E9r=E9=20(on=20a=20l'info,=20donc=20pourqui=20ne=20pas=20la?= =?UTF-8?q?=20mettre.=20Je=20fais=20juste=20une=20conversion=20en=20plus?= =?UTF-8?q?=20dans=20mon=20code=20pour=20transform=E9=20le=20num=E9rique?= =?UTF-8?q?=20dans=20la=20chaine=20attendu=20comme=20pour=20le=20paiement?= =?UTF-8?q?=20client).=20-=20Le=20num=E9ro=20de=20ch=E8que=20ou=20virement?= =?UTF-8?q?=20est=20=E9galement=20ins=E9r=E9=20(on=20a=20l'info=20brute,?= =?UTF-8?q?=20donc=20a=20la=20stocke.=20Elle=20facilitera=20le=20rapproche?= =?UTF-8?q?ment).=20-=20Enfin=20et=20c'est=20le=20plus=20important=20la=20?= =?UTF-8?q?valeur=20du=20montant=20doit=20etre=20entr=E9e=20en=20n=E9gatif?= =?UTF-8?q?.=20En=20effet=20la=20table=20bank=20g=E8re=20les=20d=E9bits=20?= =?UTF-8?q?cr=E9dits=20grace=20au=20signe.=20Elle=20est=20en=20positif=20d?= =?UTF-8?q?ans=20paiementfourn=20mais=20doit=20etre=20n=E9gativ=E9=20pour?= =?UTF-8?q?=20insertion=20dans=20llx=5Fbank.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/facture/paiementfourn.class.php | 51 ++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/paiementfourn.class.php b/htdocs/fourn/facture/paiementfourn.class.php index b8859fc308e..959c7b06db0 100644 --- a/htdocs/fourn/facture/paiementfourn.class.php +++ b/htdocs/fourn/facture/paiementfourn.class.php @@ -30,7 +30,7 @@ class PaiementFourn var $amount; var $accountid; var $author; - var $paiementid; // numero du paiement dans le cas ou une facture paye +ieur fois + var $paiementid; // Cette variable contient le type de paiement, 7 pour CHQ, etc... (nom pas tres bien choisi) var $num_paiement; var $note; var $societe; @@ -63,10 +63,53 @@ class PaiementFourn if (isset($result)) { - $label = "Facture $this->facnumber - $this->societe"; - $sql = "INSERT INTO llx_bank (datec, dateo, amount, author, label, fk_account)"; - $sql .= " VALUES (now(), '$this->datepaye', '$this->amount', '$this->author', '$label', '$this->accountid')"; + $this->id = $this->db->last_insert_id(); + + $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 llx_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); + + // Pour l'instant ce code n'est pas actif et n'est pas nécessaire. + // Je l'activerais (Eldy) si besoin de retrouver le lien entre une transaction bancaire + // et la facture générée se fait sentir (fonction futures ?): + // Mise a jour fk_bank dans llx_paiement_fourn + //if ($result) { + // $this->bankid = $this->db->last_insert_id(); + // + // $sql = "UPDATE llx_paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id"; + // $result = $this->db->query($sql); + //} + } else {