From 840a98d8acc5015d4537aabd6c3782abc2d293a3 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 3 Oct 2014 12:20:02 +0200 Subject: [PATCH 1/3] Expedition lines from same orderline merged. When there are more expedition lines from same orderline key, merge them and get source warehouses. Usefull future possibility for creating shippinglines with same products from multiple warehouses. @KreizIT also changed some batch related items. --- htdocs/expedition/card.php | 25 ++++++++++- htdocs/expedition/class/expedition.class.php | 46 ++++++++++++++++---- htdocs/langs/en_US/sendings.lang | 4 ++ 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ade0014708d..e9083b77e21 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Marcos García * Copyright (C) 2014 Cedric GROSS + * Copyright (C) 2014 Francis Appels * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1433,6 +1434,18 @@ else if ($id || $ref) $entrepot = new Entrepot($db); $entrepot->fetch($lines[$i]->entrepot_id); print $entrepot->getNomUrl(1); + } + else if (count($lines[$i]->details_entrepot) > 1) + { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + if ($detail_entrepot->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'
'; + } + } + print $form->textwithtooltip($langs->trans("DetailWarehouseNumber"),$detail); } print ''; } @@ -1440,6 +1453,7 @@ else if ($id || $ref) // Batch number managment if (! empty($conf->productbatch->enabled)) { if (isset($lines[$i]->detail_batch) ) { + $flagBatch = true; print ''; $detail = ''; foreach ($lines[$i]->detail_batch as $dbatch) { @@ -1526,10 +1540,17 @@ else if ($id || $ref) print ''.$langs->trans($label).''; } } - + if ($user->rights->expedition->supprimer) { - print ''.$langs->trans("Delete").''; + if (empty($conf->productbatch->enabled) || (!empty($conf->productbatch->enabled) && !$conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !isset($flagBatch)) + { + print ''.$langs->trans("Delete").''; + } + else + { + print ''.$langs->trans('Delete').''; + } } print ''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d929dd067ef..019ef22f769 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Marcos García + * Copyright (C) 2014 Francis Appels * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1068,7 +1069,7 @@ class Expedition extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND ed.fk_origin_line = cd.rowid"; - $sql.= " ORDER BY cd.rang"; + $sql.= " ORDER BY cd.rang, ed.fk_origin_line"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1078,6 +1079,8 @@ class Expedition extends CommonObject $num = $this->db->num_rows($resql); $i = 0; + $lineindex = 0; + $originline = 0; $this->total_ht = 0; $this->total_tva = 0; @@ -1087,13 +1090,25 @@ class Expedition extends CommonObject while ($i < $num) { - $line = new ExpeditionLigne($this->db); - $obj = $this->db->fetch_object($resql); - + $obj = $this->db->fetch_object($resql); + + if ($originline == $obj->fk_origin_line) { + $line->entrepot_id = 0; // entrepod_id in details_entrepot + $line->qty_shipped += $obj->qty_shipped; + } else { + $line = new ExpeditionLigne($this->db); + $line->entrepot_id = $obj->fk_entrepot; + $line->qty_shipped = $obj->qty_shipped; + } + + $detail_entrepot = new stdClass; + $detail_entrepot->entrepot_id = $obj->fk_entrepot; + $detail_entrepot->qty_shipped = $obj->qty_shipped; + $line->details_entrepot[] = $detail_entrepot; + $line->line_id = $obj->line_id; $line->fk_origin_line = $obj->fk_origin_line; $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated - $line->entrepot_id = $obj->fk_entrepot; $line->fk_product = $obj->fk_product; $line->fk_product_type = $obj->fk_product_type; $line->ref = $obj->product_ref; // TODO deprecated @@ -1103,7 +1118,6 @@ class Expedition extends CommonObject $line->label = $obj->custom_label; $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; - $line->qty_shipped = $obj->qty_shipped; $line->weight = $obj->weight; $line->weight_units = $obj->weight_units; $line->length = $obj->length; @@ -1116,7 +1130,7 @@ class Expedition extends CommonObject // For invoicing $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type); // We force type to 0 $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) - $line->qty = $obj->qty_shipped; + $line->qty = $line->qty_shipped; $line->total_ht = $tabprice[0]; $line->total_localtax1 = $tabprice[9]; $line->total_localtax2 = $tabprice[10]; @@ -1141,11 +1155,25 @@ class Expedition extends CommonObject * May be conf is not well initialized for dark reason */ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - $line->detail_batch=ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id); + if ($originline != $obj->fk_origin_line) { + $line->detail_batch = ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id); + } else { + $line->detail_batch = array_merge($line->detail_batch,ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id)); + } + } + if ($originline != $obj->fk_origin_line) { + $this->lines[$lineindex] = $line; + $lineindex++; + } else { + $line->total_ht += $tabprice[0]; + $line->total_localtax1 += $tabprice[9]; + $line->total_localtax2 += $tabprice[10]; + $line->total_ttc += $tabprice[2]; + $line->total_tva += $tabprice[1]; } - $this->lines[$i] = $line; $i++; + $originline = $obj->fk_origin_line; } $this->db->free($resql); return 1; diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 170f5984c4d..2ae43f39766 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -72,3 +72,7 @@ DocumentModelTyphon=More complete document model for delivery receipts (logo...) Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined SumOfProductVolumes=Sum of product volumes SumOfProductWeights=Sum of product weights + +# warehouse details +DetailWarehouseNumber= Warehouse details +DetailWarehouseFormat= W:%s (Qty : %d) From bcc5bebd77a48762899c028384b24ed100cb5290 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 3 Oct 2014 12:28:42 +0200 Subject: [PATCH 2/3] Fix deliveryorder qty and remainingqty positions --- htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index bb9f1d155ff..76c082fa70d 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -100,8 +100,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->posxcomm=112; //$this->posxtva=112; //$this->posxup=126; - $this->posxqty=174; - $this->posxremainingqty=165; + $this->posxqty=165; + $this->posxremainingqty=185; //$this->posxdiscount=162; //$this->postotalht=174; if ($this->page_largeur < 210) // To work with US executive format From 269df77873c183eb6062a603621a77707c67ab37 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 3 Oct 2014 12:59:33 +0200 Subject: [PATCH 3/3] Fix migration sql for inserting accounting records Migration SQL could not insert accounting records because datec was set to NOT NULL --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 778b3f2b9ff..f8929765956 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -74,7 +74,7 @@ ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number; ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid; -ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity; +ALTER TABLE llx_accountingaccount add column datec datetime AFTER entity; ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec; ALTER TABLE llx_accountingaccount add column fk_user_author integer DEFAULT NULL AFTER label; ALTER TABLE llx_accountingaccount add column fk_user_modif integer DEFAULT NULL AFTER fk_user_author;