From d490dd4deca15b87495c8da1c5c70ec10ac9d1cd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 12:15:43 +0100 Subject: [PATCH 1/8] NEW POS support in order Save informations for online / API shopping and push to invoice --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 6e188240a43..dc6856b719e 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -100,7 +100,6 @@ ALTER TABLE llx_prelevement_facture_demande ADD COLUMN sourcetype varchar(32); ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_id varchar(128) NULL; ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_site varchar(128) NULL; - -- Fix if table exists ALTER TABLE llx_c_units DROP INDEX uk_c_units_code; ALTER TABLE llx_c_units ADD COLUMN scale integer; @@ -119,7 +118,6 @@ CREATE TABLE llx_c_units( ALTER TABLE llx_c_units ADD UNIQUE uk_c_units_code(code); - INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('T', '3','WeightUnitton','T', 'weight', 1); INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','Kg', 'weight', 1); INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G', '-3','WeightUnitg','g', 'weight', 1); @@ -162,3 +160,7 @@ INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VAL -- Default Warehouse id for a user ALTER TABLE llx_user ADD COLUMN fk_warehouse INTEGER NULL; + +-- Save informations for online / API shopping and push to invoice +ALTER TABLE llx_commande ADD COLUMN module_source varchar(32); +ALTER TABLE llx_commande ADD COLUMN pos_source varchar(32); From c54c4f8667263e9c7ebb427ad0c4cf702fad413c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 12:18:20 +0100 Subject: [PATCH 2/8] Update llx_commande.sql --- htdocs/install/mysql/tables/llx_commande.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index d0522f7e5e3..35b6798e77a 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -57,6 +57,8 @@ create table llx_commande model_pdf varchar(255), last_main_doc varchar(255), -- relative filepath+filename of last main generated document + module_source varchar(32), -- name of module when order generated by a dedicated module (POS, ...) + pos_source varchar(32), -- name of POS station when order is generated by a POS module facture tinyint default 0, fk_account integer, -- bank account fk_currency varchar(3), -- currency code From c0de2b5b0735597eaf69ba8852b701507ed634ed Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 12:22:02 +0100 Subject: [PATCH 3/8] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8233a50aca3..acba64e6c4e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1120,6 +1120,9 @@ class Facture extends CommonInvoice $this->note_private = $object->note_private; $this->note_public = $object->note_public; + $this->module_source = $object->module_source; + $this->pos_source = $object->pos_source; + $this->origin = $object->element; $this->origin_id = $object->id; From 25d4be07722669dc4857a498e1c3279095238390 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 12:29:47 +0100 Subject: [PATCH 4/8] Update commande.class.php --- htdocs/commande/class/commande.class.php | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8272b2534bf..26151fd8b72 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -203,7 +203,12 @@ class Commande extends CommonOrder public $multicurrency_total_ttc; public $oldcopy; - + + //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) + public $module_source; + //! key of pos source ('0', '1', ...) + public $pos_source; + /** * ERR Not enough stock */ @@ -820,7 +825,7 @@ class Commande extends CommonOrder $sql.= ", fk_warehouse"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", entity"; + $sql.= ", entity, module_source, pos_source"; $sql.= ", fk_multicurrency"; $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; @@ -849,6 +854,8 @@ class Commande extends CommonOrder $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", ".$conf->entity; + $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); + $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; @@ -1633,7 +1640,8 @@ class Commande extends CommonOrder $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams'; $sql.= ', c.fk_incoterms, c.location_incoterms'; $sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; - $sql.= ", i.libelle as libelle_incoterms"; + $sql.= ", c.module_source, c.pos_source"; + $sql.= ", i.libelle as libelle_incoterms"; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', ca.code as availability_code, ca.label as availability_label'; @@ -1680,7 +1688,7 @@ class Commande extends CommonOrder $this->date_commande = $this->db->jdate($obj->date_commande); $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_validation = $this->db->jdate($obj->date_valid); - $this->date_modification = $this->db->jdate($obj->tms); + $this->date_modification = $this->db->jdate($obj->tms); $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; @@ -1707,13 +1715,15 @@ class Commande extends CommonOrder $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; - $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null; + $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null; $this->fk_delivery_address = $obj->fk_delivery_address; - + $this->module_source = $obj->module_source; + $this->pos_source = $obj->pos_source; + //Incoterms - $this->fk_incoterms = $obj->fk_incoterms; - $this->location_incoterms = $obj->location_incoterms; - $this->libelle_incoterms = $obj->libelle_incoterms; + $this->fk_incoterms = $obj->fk_incoterms; + $this->location_incoterms = $obj->location_incoterms; + $this->libelle_incoterms = $obj->libelle_incoterms; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; From 6416f24d5f2a73849353b4cdb0c900cd5075bfa2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 12:35:13 +0100 Subject: [PATCH 5/8] FIX fetch module / pos source --- htdocs/compta/facture/class/facture.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8233a50aca3..70ba4c9ede6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1324,6 +1324,7 @@ class Facture extends CommonInvoice $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; + $sql.= ', f.module_source, f.pos_source'; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; @@ -1357,7 +1358,7 @@ class Facture extends CommonInvoice $this->date_pointoftax = $this->db->jdate($obj->date_pointoftax); $this->date_creation = $this->db->jdate($obj->datec); $this->date_validation = $this->db->jdate($obj->datev); - $this->date_modification = $this->db->jdate($obj->datem); + $this->date_modification = $this->db->jdate($obj->datem); $this->datem = $this->db->jdate($obj->datem); $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; @@ -1396,9 +1397,12 @@ class Facture extends CommonInvoice $this->extraparams = (array) json_decode($obj->extraparams, true); //Incoterms - $this->fk_incoterms = $obj->fk_incoterms; - $this->location_incoterms = $obj->location_incoterms; - $this->libelle_incoterms = $obj->libelle_incoterms; + $this->fk_incoterms = $obj->fk_incoterms; + $this->location_incoterms = $obj->location_incoterms; + $this->libelle_incoterms = $obj->libelle_incoterms; + + $this->module_source = $obj->module_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; From ef5372f4762cf0e92293ace3c34e4d39ee8ad3cf Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 13:04:22 +0100 Subject: [PATCH 6/8] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 70ba4c9ede6..2a0aa66561f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1324,7 +1324,7 @@ class Facture extends CommonInvoice $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; - $sql.= ', f.module_source, f.pos_source'; + $sql.= ', f.module_source, f.pos_source'; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; @@ -1400,7 +1400,6 @@ class Facture extends CommonInvoice $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; - $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; @@ -2654,7 +2653,7 @@ class Facture extends CommonInvoice * @return int <0 if KO, Id of line if OK */ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) - { + { // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); From 152585c1b8a88d88ed05384abc930e57f12d6077 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 13:20:46 +0100 Subject: [PATCH 7/8] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2a0aa66561f..656d4eed82b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1401,7 +1401,7 @@ class Facture extends CommonInvoice $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->module_source = $obj->module_source; - $this->pos_source = $obj->pos_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; From 98affe0921c8792df769ad33fe9db2a53055127e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 20 Feb 2019 14:25:25 +0100 Subject: [PATCH 8/8] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 656d4eed82b..f7054dfc29a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1401,7 +1401,7 @@ class Facture extends CommonInvoice $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->module_source = $obj->module_source; - $this->pos_source = $obj->pos_source; + $this->pos_source = $obj->pos_source; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency;