From d728d268cad3feb1889eb03df254dbf354a8e0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:49:52 +0200 Subject: [PATCH 1/5] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index df3bd5eaf69..94c5971a416 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -143,6 +143,10 @@ class Paiement extends CommonObject */ public $fk_paiement; // Type of payment + /** + * @var string payment external reference + */ + public $ref_ext; /** * Constructor @@ -164,7 +168,7 @@ class Paiement extends CommonObject */ public function fetch($id, $ref = '', $fk_bank = '') { - $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; + $sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as type_code, c.libelle as type_label,'; $sql .= ' p.num_paiement as num_payment, p.note,'; $sql .= ' b.fk_account'; @@ -187,6 +191,7 @@ class Paiement extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref ? $obj->ref : $obj->rowid; + $this->ref_ext = $obj->ref_ext; $this->date = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp); $this->num_paiement = $obj->num_payment; // deprecated @@ -278,6 +283,10 @@ class Paiement extends CommonObject $this->db->begin(); $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); + + if (empty($this->ref_ext)) { + $this->ref_ext = ''; + } if ($way == 'dolibarr') { @@ -291,8 +300,8 @@ class Paiement extends CommonObject $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement); $note = ($this->note_public ? $this->note_public : $this->note); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; $resql = $this->db->query($sql); From 1f5419c883c24bb6f076035e31b639154884268b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:53:02 +0200 Subject: [PATCH 2/5] Update llx_paiement.sql --- htdocs/install/mysql/tables/llx_paiement.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index d19d38312a4..dabe261798b 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -22,6 +22,7 @@ create table llx_paiement ( rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30) NULL, -- payment reference number + ref_ext varchar(255) NULL, -- payment external reference entity integer DEFAULT 1 NOT NULL, -- Multi company id datec datetime, -- date de creation tms timestamp, From 29931bbdedf7e74ea6a53d4cd0ac3cca603defd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 18:55:26 +0200 Subject: [PATCH 3/5] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index defe5736aa8..e3a1d1807bc 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -320,3 +320,5 @@ ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL; ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; +ALTER TABLE llx_paiement ADD COLUMN ref_ext varchar(255) AFTER ref; + From acc995a5536708dd515c150ddbbefe06c9ac0c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Sat, 12 Sep 2020 19:05:33 +0200 Subject: [PATCH 4/5] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 628abc128f4..9e78d186172 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -297,6 +297,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiement'; $field = 'fk_facture'; $field2 = 'fk_paiement'; + $field3=', p.ref_ext'; $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -304,10 +305,11 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiementfourn'; $field = 'fk_facturefourn'; $field2 = 'fk_paiementfourn'; + $field3=''; $sharedentity = 'facture_fourn'; } - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; + $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3; $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; $sql .= ' WHERE pf.'.$field.' = '.$this->id; //$sql.= ' WHERE pf.'.$field.' = 1'; @@ -325,7 +327,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + if (!empty($field3)) { + $tmp['ref_ext'] = $obj->ref_ext; + } + $retarray[]=$tmp; $i++; } $this->db->free($resql); From 2cfe740d85df1bb1f82ee2e10ccda46fdc21507e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 12 Sep 2020 17:08:44 +0000 Subject: [PATCH 5/5] Fixing style errors. --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 94c5971a416..67ab5fc3c22 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -283,7 +283,7 @@ class Paiement extends CommonObject $this->db->begin(); $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); - + if (empty($this->ref_ext)) { $this->ref_ext = ''; }