diff --git a/ChangeLog b/ChangeLog index 66e4a8cfd89..db9fc3b9f8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.4 compared to 3.3 ***** For users: +- New: Support revenue stamp onto invoices. - New: Add a tab "consumption" on thirdparties to list products bought/sells. - New: Some performance enhancements. - New: Can attach files onto trip and expenses modules. diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 55ad5902e13..55a8a8b8b60 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -547,7 +547,7 @@ if ($action == 'edit' || $action == 'updateedit') /* * Local Taxes */ - if ($mysoc->hasLocalTax(1)) + if ($mysoc->useLocalTax(1)) { // Local Tax 1 print '
'; @@ -579,7 +579,7 @@ if ($action == 'edit' || $action == 'updateedit') print "\n"; print ""; } - if ($mysoc->hasLocalTax(2)) + if ($mysoc->useLocalTax(2)) { // Local Tax 2 print '
'; @@ -927,7 +927,7 @@ else /* * Local Taxes */ - if ($mysoc->hasLocalTax(1)) + if ($mysoc->useLocalTax(1)) { // Local Tax 1 print '
'; @@ -960,7 +960,7 @@ else print ""; } - if ($mysoc->hasLocalTax(2)) + if ($mysoc->useLocalTax(2)) { // Local Tax 2 print '
'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index aa6f3cfec07..f792d7c6e20 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -377,22 +377,22 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu $object->fetch_thirdparty(); // Check parameters - + // Check for mandatory prof id for ($i = 1; $i < 5; $i++) { - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_INVOICE_MANDATORY'; $idprof='idprof'.$i; if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { if (! $error) $langs->load("errors"); $error++; - + setEventMessage($langs->trans('ErrorProdIdIsMandatory',$langs->transcountry('ProfId'.$i, $object->thirdparty->country_code)),'errors'); } - } - + } + //Check for warehouse if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1)) { @@ -403,7 +403,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu $action=''; } } - + if (! $error) { $result = $object->validate($user,'',$idwarehouse); @@ -625,7 +625,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $db->begin(); $error=0; - + // Get extra fields foreach($_POST as $key => $value) { @@ -1638,7 +1638,7 @@ else if ($action == 'builddoc') // En get ou en post if (GETPOST('model')) $object->setDocModel($user, GETPOST('model')); if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank'); - + // Define output language $outputlangs = $langs; $newlang=''; @@ -2280,10 +2280,10 @@ else if ($id > 0 || ! empty($ref)) */ $result=$object->fetch($id,$ref); - + // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('facture'); - + if ($result > 0) { if ($user->societe_id>0 && $user->societe_id!=$object->socid) accessforbidden('',0); @@ -2292,11 +2292,12 @@ else if ($id > 0 || ! empty($ref)) $soc = new Societe($db); $soc->fetch($object->socid); + $selleruserevenustamp=$mysoc->useRevenueStamp(); $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. @@ -2753,7 +2754,6 @@ else if ($id > 0 || ! empty($ref)) /* * List of payments */ - $selleruserevenustamp=empty($conf->global->MAIN_USE_REVENUE_STAMP)?0:1; // TODO Add method societe->useRevenueStamp() to look into table llx_c_revenue_stamp if there is one line for country $sign=1; if ($object->type == 2) $sign=-1; @@ -2764,7 +2764,7 @@ else if ($id > 0 || ! empty($ref)) if($mysoc->localtax1_assuj=="1") $nbrows++; if($mysoc->localtax2_assuj=="1") $nbrows++; if ($selleruserevenustamp) $nbrows++; - + print ''; print ''; @@ -3039,12 +3039,12 @@ else if ($id > 0 || ! empty($ref)) print ''; // Amount Local Taxes - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + if ($mysoc->localtax1_assuj=="1" && $mysoc->useLocalTax(1)) //Localtax1 (example RE) { print ''; print ''; } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + if ($mysoc->localtax2_assuj=="1" && $mysoc->useLocalTax(2)) //Localtax2 (example IRPF) { print ''; print ''; @@ -3075,7 +3075,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; } - + // Total with tax print ''; @@ -3113,14 +3113,14 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + // Other attributes $res=$object->fetch_optionals($object->id,$extralabels); $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - + if ($action == 'edit_extras') { print ''; @@ -3128,8 +3128,8 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - - + + foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); @@ -3153,16 +3153,16 @@ else if ($id > 0 || ! empty($ref)) print ''."\n"; } } - + if(count($extrafields->attribute_label) > 0) { - + if ($action == 'edit_extras' && $user->rights->facture->creer) { print ''; - + } else { if ($object->statut == 0 && $user->rights->facture->creer) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ef7698d0564..15ee4e29aba 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1020,6 +1020,17 @@ class pdf_crabe extends ModelePDFFactures //} } + // Revenue stamp + if (price2num($object->revenuestamp) != 0) + { + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1); + } + // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); diff --git a/htdocs/install/mysql/data/llx_c_revenuestamp.sql b/htdocs/install/mysql/data/llx_c_revenuestamp.sql index 8d998111218..040a8370485 100644 --- a/htdocs/install/mysql/data/llx_c_revenuestamp.sql +++ b/htdocs/install/mysql/data/llx_c_revenuestamp.sql @@ -1,13 +1,4 @@ --- Copyright (C) 2001-2004 Rodolphe Quiedeville --- Copyright (C) 2003 Jean-Louis Bergamo -- Copyright (C) 2004-2011 Laurent Destailleur --- Copyright (C) 2004 Benoit Mortier --- Copyright (C) 2004 Guillaume Delecourt --- Copyright (C) 2005-2009 Regis Houssin --- Copyright (C) 2007 Patrick Raguin --- Copyright (C) 2010-2011 Juanjo Menent --- Copyright (C) 2012 Sebastian Neuwert --- Copyright (C) 2012 Ricardo Schluter -- -- 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 @@ -35,5 +26,5 @@ delete from llx_c_revenuestamp; --- TUNISIA -- -insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, '0.4', 'Timbre fiscal', 1); +-- TUNISIA (id country=10) -- +insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, 0.4, 'Revenue stamp tunisia', 1); diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index b5f578f579b..b6d38949451 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -219,13 +219,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 6 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '0','0','VAT Rate 0', 1); -- TUNISIA (id country=10) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '6','0','VAT 6%', 1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0.4, '7'); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '0','0','VAT Rate 0', 1, 1, '4', 0.4, '7'); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (101,10, '6','0','VAT 6%', 1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (102,10, '12','0','VAT 12%',1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (103,10, '18','0','VAT 18%',1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (104,10, '7.5','0','VAT 6% Majoré à 25% (7.5%)',1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1, 1, '4', 0, null); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10, '0','0','VAT Rate 0', 1, 1, '4', 0, null); -- UKRAINE (id country=226) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '20','0','VAT standart rate',1); diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index e6b82dc565e..571ba7373a2 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -130,8 +130,6 @@ CREATE TABLE llx_c_revenuestamp insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, '0.4', 'Timbre fiscal', 1); -ALTER TABLE llx_actioncomm ADD COLUMN code varchar(32) NULL after fk_action; - ALTER TABLE llx_c_tva MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_c_tva MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_commande_fournisseurdet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0'; @@ -148,6 +146,13 @@ ALTER TABLE llx_facturedet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEF ALTER TABLE llx_facturedet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_propaldet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0'; +-- No more use type 7, use revenuse stamp instead +UPDATE llx_c_tva set localtax1=0, localtax1_type='0' where localtax1_type = '7'; +UPDATE llx_c_tva set localtax2=0, localtax2_type='0' where localtax2_type = '7'; + + +ALTER TABLE llx_actioncomm ADD COLUMN code varchar(32) NULL after fk_action; + ALTER TABLE llx_holiday ADD COLUMN note text; ALTER TABLE llx_holiday ADD COLUMN note_public text; @@ -197,5 +202,9 @@ ALTER TABLE llx_societe MODIFY COLUMN zip varchar(25); ALTER TABLE llx_user ADD COLUMN address varchar(255); ALTER TABLE llx_user ADD COLUMN zip varchar(25); ALTER TABLE llx_user ADD COLUMN town varchar(50); -ALTER TABLE llx_user ADD COLUMN fk_state integer DEFAULT 0; -- +ALTER TABLE llx_user ADD COLUMN fk_state integer DEFAULT 0; ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0; + + + + diff --git a/htdocs/install/mysql/tables/llx_c_tva.sql b/htdocs/install/mysql/tables/llx_c_tva.sql index 219b1fb9744..46aa3632faa 100644 --- a/htdocs/install/mysql/tables/llx_c_tva.sql +++ b/htdocs/install/mysql/tables/llx_c_tva.sql @@ -24,9 +24,9 @@ create table llx_c_tva fk_pays integer NOT NULL, taux double NOT NULL, localtax1 double NOT NULL DEFAULT 0, - localtax1_type varchar(10) NOT NULL DEFAULT '0', + localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2 double NOT NULL DEFAULT 0, - localtax2_type varchar(10) NOT NULL DEFAULT '0', + localtax2_type varchar(10) NOT NULL DEFAULT '0', recuperableonly integer NOT NULL DEFAULT 0, note varchar(128), active tinyint DEFAULT 1 NOT NULL, diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c87a6ef11f4..ecf387e13c2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -82,7 +82,9 @@ class Societe extends CommonObject var $idprof1; // IdProf1 (Ex: Siren in France) var $idprof2; // IdProf2 (Ex: Siret in France) var $idprof3; // IdProf3 (Ex: Ape in France) - var $idprof4; // IdProf4 (Ex: RCS in France) + var $idprof4; // IdProf4 (Ex: RCS in France) + var $idprof5; // IdProf5 + var $idprof6; // IdProf6 var $prefix_comm; @@ -2599,40 +2601,53 @@ class Societe extends CommonObject } /** - * Check if localtax define for company - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. + * Check if thirdparty may using localtax or not * - * @param localTaxNum $localTaxNum 1 or 2 - * @return boolean true / false + * @param int $localTaxNum To get info for only localtax1 or localtax2 + * @return array array(0=>boolean, 1=>boolean) */ - function hasLocalTax($localTaxNum) { - global $user,$langs,$conf; + function useLocalTax($localTaxNum=0) + { + $sql = "SELECT t.localtax1, t.localtax2"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$this->country_code."'"; + $sql .= " AND t.active = 1"; + if (empty($localTaxNum)) $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')"; + elseif ($localTaxNum == 1) $sql .= " AND t.localtax1_type <> '0'"; + elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; - // check parameter - if ($localTaxNum != 1 && $localTaxNum != 2) - return false; + dol_syslog("useLocalTax sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + return ($this->db->num_rows($resql) > 0); + } + else return false; + } - // Search local taxes - $sql = "SELECT t.localtax1, t.localtax2"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$this->country_code."'"; - $sql .= " AND t.active = 1"; - if ($localTaxNum == 1) - $sql .= " AND t.localtax1 <> 0"; - elseif ($localTaxNum == 2) - $sql .= " AND t.localtax2 <> 0"; + /** + * Check if thirdparty is from a country using revenue stamps + * + * @return boolean Yes or no + */ + function useRevenueStamp() + { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."c_revenuestamp as r, ".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE r.fk_pays = p.rowid AND p.code = '".$this->country_code."'"; + $sql .= " AND r.active = 1"; - dol_syslog("get_localtax sql=".$sql); + dol_syslog("useRevenueStamp sql=".$sql); $resql=$this->db->query($sql); if ($resql) { - return ($this->db->num_rows($resql) > 0); - + $obj=$this->db->fetch_object($resql); + return (($obj->nb > 0)?true:false); } else - return false; - + { + $this->error=$this->db->lasterror(); + return false; + } } /** @@ -2752,7 +2767,7 @@ class Societe extends CommonObject /** * Set commnunication level * - * @param User $user Utilisateur qui definie la remise + * @param User $user User making change * @return int <0 if KO, >0 if OK */ function set_commnucation_level($user)
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1,1,'',1,-1,-1,$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2,1,'',1,-1,-1,$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc,1,'',1,-1,-1,$conf->currency).'
'; print ''; print ''; print '