[ task #1063 ] Allow edit localtaxes rate for thirds. Works with

Suppliers
This commit is contained in:
Juanjo Menent 2014-07-04 10:25:05 +02:00
parent 24b2b83b85
commit c7e20c9a80
4 changed files with 35 additions and 88 deletions

View File

@ -1178,7 +1178,7 @@ class CommandeFournisseur extends CommonOrder
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty);
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc,$this->thirdparty);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type);
$total_ht = $tabprice[0];
@ -1755,6 +1755,7 @@ class CommandeFournisseur extends CommonOrder
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1787,7 +1788,7 @@ class CommandeFournisseur extends CommonOrder
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty);
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type);
$total_ht = $tabprice[0];

View File

@ -1180,6 +1180,7 @@ class FactureFournisseur extends CommonInvoice
*/
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1204,7 +1205,7 @@ class FactureFournisseur extends CommonInvoice
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($vatrate,0,$this->thirdparty);
$localtaxes_type=getLocalTaxesFromRate($vatrate,0,$mysoc, $this->thirdparty);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type);
$total_ht = $tabprice[0];

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
@ -1288,17 +1288,9 @@ elseif (! 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($object->thirdparty->localtax2_assuj=="1") $nbrow++;
}
else
{
if($mysoc->localtax1_assuj=="1") $nbrow++;
if($mysoc->localtax2_assuj=="1") $nbrow++;
}
if($mysoc->localtax1_assuj=="1") $nbrow++;
if($mysoc->localtax2_assuj=="1") $nbrow++;
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/liste.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
@ -1514,37 +1506,19 @@ elseif (! empty($object->id))
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
// 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
{
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
if ($object->thirdparty->localtax2_assuj=="1") //Localtax2 IRPF
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
else
if ($mysoc->localtax2_assuj=="1") //Localtax2
{
if ($mysoc->localtax1_assuj=="1") //Localtax1
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
@ -1753,15 +1727,12 @@ elseif (! empty($object->id))
}
// Form to add new line
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action <> 'edit_line')
if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'edit_line')
{
// Add free products/services form
global $forceall, $senderissupplier, $dateSelector;
$forceall=1; $senderissupplier=1; $dateSelector=0;
if ($object->statut == 0 && $user->rights->propal->creer)
{
if ($action != 'editline')
{
$var = true;
// Add free products/services
@ -1769,8 +1740,7 @@ elseif (! empty($object->id))
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
}
}
print '</table>';

View File

@ -658,7 +658,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
$price_base_type = 'HT';
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1tx, $localtax2tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
}
else
{
@ -666,7 +666,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
$ht = $ttc / (1 + ($tva_tx / 100));
$price_base_type = 'HT';
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
$result=$object->addline($product_desc, $ht, $tva_tx,$localtax1tx, $localtax2tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
$result=$object->addline($product_desc, $ht, $tva_tx,$localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
}
}
@ -1634,16 +1634,9 @@ else
if (! empty($conf->banque->enabled)) $nbcols++;
// Local taxes
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++;
}
if ($societe->localtax1_assuj=="1") $nbrows++;
if ($societe->localtax2_assuj=="1") $nbrows++;
print '<td rowspan="'.$nbrows.'" valign="top">';
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
@ -1802,35 +1795,17 @@ else
// Amount Local Taxes
//TODO: Place into a function to control showing by country or study better option
if ($mysoc->country_code=='ES')
if ($societe->localtax1_assuj=="1") //Localtax1
{
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2 IRPF
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
else
{
if ($societe->localtax1_assuj=="1") //Localtax1 RE
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2 IRPF
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
if ($societe->localtax2_assuj=="1") //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
print '<td align="right">'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
print '<td colspan="2">&nbsp;</td></tr>';
}
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td><td colspan="2" align="left">&nbsp;</td></tr>';