From d0265db3d2d0463c3b106ced8735a891339ea4af Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 5 Jan 2013 09:07:01 +0100 Subject: [PATCH 1/3] Fix: Modify Spanish localtax2 to new rate --- htdocs/install/mysql/data/llx_c_tva.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 03acef22d0a..4476084b780 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -190,10 +190,10 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (20 INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2023, 202, '0', '0', 'VAT Rate 0', 1); -- SPAIN (id country=4) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 41, 4,'21','0','5.2','3','-15','1','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 42, 4,'10','0','1.4','3','-15','1','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 43, 4, '4','0','0.5','3','-15','1','VAT super-reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 44, 4, '0','0', '0','3','-15','1','VAT Rate 0',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 41, 4,'21','0','5.2','3','-21','1','VAT standard rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 42, 4,'10','0','1.4','3','-21','1','VAT reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 43, 4, '4','0','0.5','3','-21','1','VAT super-reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values ( 44, 4, '0','0', '0','3','-21','1','VAT Rate 0',1); -- SWEDEN (id country=20) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (201,20, '25','0','VAT standard rate',1); From 32b19802b1e94c099c3217b5c9a03068836ee131 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 5 Jan 2013 09:43:40 +0100 Subject: [PATCH 2/3] Fix: [ bug #662 ] Bad aplication of Localtax2 for suppliers if country is Spain --- htdocs/fourn/commande/fiche.php | 37 ++++++++++++++----- htdocs/fourn/facture/fiche.php | 64 +++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 4636fd5fd3f..fe59b544e3e 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -237,8 +237,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $type = $productsupplier->type; // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty); + $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); $result=$object->addline( $desc, @@ -268,8 +268,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $tva_tx = price2num($_POST['tva_tx']); // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty); + $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); if (! $_POST['dp_desc']) { @@ -340,8 +340,8 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer if ($product->fetch($_POST["elrowid"]) < 0) dol_print_error($db); } - $localtax1_tx=get_localtax($_POST['tva_tx'],1,$object->thirdparty); - $localtax2_tx=get_localtax($_POST['tva_tx'],2,$object->thirdparty); + $localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty); + $localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty); $result = $object->updateline( $_POST['elrowid'], @@ -1065,12 +1065,17 @@ if (! empty($object->id)) if (! empty($conf->projet->enabled)) $nbrow++; //Local taxes + //TODO: Place into a function to control showing by country or study better option if ($mysoc->country_code=='ES') { if($mysoc->localtax1_assuj=="1") $nbrow++; if($mysoc->localtax2_assuj=="1") $nbrow++; } - + else + { + if($mysoc->localtax1_assuj=="1") $nbrow++; + if($object->thirdparty->localtax2_assuj=="1") $nbrow++; + } print ''; $linkback = ''.$langs->trans("BackToList").''; @@ -1224,6 +1229,7 @@ if (! empty($object->id)) print ''; // Amount Local Taxes + //TODO: Place into a function to control showing by country or study better option if ($mysoc->country_code=='ES') { if ($mysoc->localtax1_assuj=="1") //Localtax1 RE @@ -1232,7 +1238,22 @@ if (! empty($object->id)) print ''; print ''; } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + if ($object->thirdparty->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } + } + else + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 + { + print ''; + print ''; + print ''; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 { print ''; print ''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 72bf3d36824..4b3adfe8de5 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -454,8 +454,8 @@ elseif ($action == 'update_line') } - $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); - $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); + $localtax1tx= get_localtax($_POST['tauxtva'], 1, $mysoc,$object->thirdparty); + $localtax2tx= get_localtax($_POST['tauxtva'], 2, $mysoc,$object->thirdparty); $remise_percent=GETPOST('remise_percent'); $result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1tx, $localtax2tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent); @@ -502,8 +502,8 @@ elseif ($action == 'addline') $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); - $localtax1tx= get_localtax($tvatx, 1, $object->thirdparty); - $localtax2tx= get_localtax($tvatx, 2, $object->thirdparty); + $localtax1tx= get_localtax($tvatx, 1, $mysoc,$object->thirdparty); + $localtax2tx= get_localtax($tvatx, 2, $mysoc,$object->thirdparty); $remise_percent=GETPOST('remise_percent'); $type = $product->type; @@ -520,8 +520,8 @@ elseif ($action == 'addline') else { $tauxtva = price2num($_POST['tauxtva']); - $localtax1tx= get_localtax($tauxtva, 1, $object->thirdparty); - $localtax2tx= get_localtax($tauxtva, 2, $object->thirdparty); + $localtax1tx= get_localtax($tauxtva, 1, $mysoc,$object->thirdparty); + $localtax2tx= get_localtax($tauxtva, 2, $mysoc,$object->thirdparty); $remise_percent=GETPOST('remise_percent'); if (! $_POST['dp_desc']) @@ -1382,9 +1382,17 @@ else // Local taxes // TODO I use here $societe->localtax1_assuj. Before it was $mysoc->localtax1_assuj, but this is a supplier invoice, so made by supplier, so depends on supplier properties - if ($societe->localtax1_assuj=="1") $nbrows++; - if ($societe->localtax2_assuj=="1") $nbrows++; - + + if ($mysoc->country_code=='ES') + { + if($mysoc->localtax1_assuj=="1") $nbrows++; + if($societe->localtax2_assuj=="1") $nbrows++; + } + else + { + if ($societe->localtax1_assuj=="1") $nbrows++; + if ($societe->localtax2_assuj=="1") $nbrows++; + } print ''; // Amount Local Taxes - if ($societe->localtax1_assuj=="1") //Localtax1 RE + //TODO: Place into a function to control showing by country or study better option + if ($mysoc->country_code=='ES') { - print ''; - print ''; - print ''; + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print ''; + print ''; + print ''; + } + if ($societe->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } } - if ($societe->localtax2_assuj=="1") //Localtax2 IRPF - { - print ''; - print ''; - print ''; + else + { + if ($societe->localtax1_assuj=="1") //Localtax1 RE + { + print ''; + print ''; + print ''; + } + if ($societe->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } } - print ''; // Project From c639d803720609f55c13bfc9525c3503491e4951 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 5 Jan 2013 09:47:54 +0100 Subject: [PATCH 3/3] Fix: [ bug #662 ] Bad aplication of Localtax2 for suppliers if country is Spain --- htdocs/fourn/commande/fiche.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index fe59b544e3e..c055642803d 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1069,12 +1069,12 @@ if (! empty($object->id)) if ($mysoc->country_code=='ES') { if($mysoc->localtax1_assuj=="1") $nbrow++; - if($mysoc->localtax2_assuj=="1") $nbrow++; + if($object->thirdparty->localtax2_assuj=="1") $nbrow++; } else { if($mysoc->localtax1_assuj=="1") $nbrow++; - if($object->thirdparty->localtax2_assuj=="1") $nbrow++; + if($mysoc->localtax2_assuj=="1") $nbrow++; } print '
'.$langs->trans("Currency".$conf->currency).'
'.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''; $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,'; @@ -1493,19 +1501,37 @@ else print '
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$societe->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT1",$societe->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$societe->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$societe->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT1",$societe->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$societe->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
';