Jump to content
Fab456

Passer de HT vers TTC sans changer de prix TTC

Recommended Posts

Bonsoir,

Je vais être assujetti à la TVA et j'aimerai appliquer le taux a 20% sans changer le prix TTC.
Hors lorsque j'applique la règle, la TVA s'joute au HT (normal) mais je ne souhaite pas modifier le montant.
J'ai parcouru le forum et n'est pas trouvé de soluce...
Je pense qu'il faut agir sur les tables ps_product_shop, ps_product_attribute et ps_product_attribute_shop....

Si quelqu'un peux "jeter" une petite requête, ça m'aiderai beaucoup 🙂

Merci d'avance.
Bonne soirée.
Edit: j'ai un PS 1.6.1.23

Edited by Fab456
Oubli (see edit history)

Share this post


Link to post
Share on other sites

Je pense qu'un "petit script" serait plus pratique et moins "dangereux" qu'une grosse requête qui attaque la base.

Share this post


Link to post
Share on other sites

Ah?
Genre un fichier php comme ça
 

-- Statements for update price and tax rules group
UPDATE ps_product SET price = price / 1.2, id_tax_rules_group = 8 WHERE id_tax_rules_group = 0;
UPDATE ps_product_shop SET price = price / 1.2, id_tax_rules_group = 8 WHERE id_tax_rules_group = 0;
 
-- Statements if you want to round ht price to 2 decimals
UPDATE ps_product SET price = ROUND(price, 2)
UPDATE ps_product_shop SET price = ROUND(price, 2)

Ou je remplacerai le tax rule group 8 par 4 car ma règle de taxe 20% est id4?

Share this post


Link to post
Share on other sites

Surtout ne pas arrondir les prix ht, sinon vous aurez des problème de totaux.

 

Share this post


Link to post
Share on other sites

Bonjour,
Alors j'ai trouvé ce code mais ça ne fonctionne pas, lorsque je mets la TVA ensuite, le prix prends 20%

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

echo '<div id="center_column">';
	$i = 0;
	$results = array();
	$sql_prod = 'SELECT id_product, id_tax_rules_group, price FROM '._DB_PREFIX_.'product WHERE id_tax_rules_group = 0 AND price <> 0;';
	$prods = Db::getInstance()->ExecuteS($sql_prod);
	
	if (!$prods)
	{
		echo ('<p class="warning">Une erreur est survenu lors de l\'execution de la requ&ecirc;te.</p>');
		echo ('<p class="breadcrumb warning_inline">'.$sql_prod.'</p>');
	}
	else
	{
		foreach ($prods AS $prod) 
		{
			$results[$i]['id_product']= $prod['id_product'];
			$results[$i]['id_tax_rules_group']= $prod['id_tax_rules_group'];
			$results[$i]['price']= $prod['price'];
			$i++;
		}
		
		if ($_POST)
		{
			for ($y = 0; $y < $i; $y++)
			{
				$rc = $results[$y]['price'] / 1.2;
				$rc = explode('.', $rc);
				$resultat_calcul = $rc[0].'.'.substr($rc[1], 0, 6);
				$id_product = $results[$y]['id_product'];
				
				$update_prod = "UPDATE "._DB_PREFIX_."product SET price = '".$resultat_calcul."', id_tax_rules_group = '1' WHERE id_product = ".$id_product." LIMIT 1;";
				$up_prods = Db::getInstance()->Execute($update_prod);
				if (!$up_prods)
				{
					echo ('<p class="warning warning_inline">Une erreur est survenu lors de l\'execution de la requ&ecirc;te.</p>');
					echo ('<p class="breadcrumb">'.$update_prod.'</p>');
				}
				else
				{
					echo ('<p class="success success_inline">'.$update_prod.'<br />OK</p>');
				}
			}
		}
		
		$style = 'border:1px solid #595A5E;';
		
		$style_tr .= 'background:#595A5E url(../img/block_header.gif) no-repeat scroll left top;';
		$style_tr .= 'border-bottom:1px solid #595A5E;';
		$style_tr .= 'color: #FFFFFF;';
		
		echo '<br />';

		echo '<form name="valid" action="update.php" method="post">';
		echo '<table summary="id" width="80%" cellpadding="2" cellspacing="1" border="0" align="center" style="'.$style.'">';
		echo '<tr style="'.$style_tr.'">';
		echo '<th align="center">#</th>';
		echo '<th align="center">Ancien prix</th>';
		echo '<th align="center">Nouveau prix</th>';
		echo '</tr>';	
		for ($y = 0; $y < $i; $y++)
		{
			$id_product = $results[$y]['id_product'];
			$oldrc = $results[$y]['price'];
			$rc = $oldrc / 1.2;
			$rc = explode('.', $rc);
			$newrc = $rc[0].'.'.substr($rc[1], 0, 6);
			
			$row_color = ( !($y % 2) ) ? 'background-color: #EAEAEC; color: #374853;' : 'background-color: #BDC2C9; color: #374853;';
			
			echo '<tr style="'.$row_color.'">';
			echo '<td align="center">'.$id_product.'</td>';
			echo '<td align="center">'.$oldrc.'</td>';
			echo '<td align="center">'.$newrc.'</td>';
			echo '</tr>';
		}
		echo '</table>';
		echo '<br />';
		if (!$_POST)
		{
			echo '<input type="submit" name="valide" value="Valider ?">';
		}
		echo '</form>';
		echo '<br />';

	}
echo '</div>';	

include(dirname(__FILE__).'/footer.php');
?>

 

Share this post


Link to post
Share on other sites

Bonjour,
J'ai donc effectué cette requête :
 

UPDATE ps_product SET price = price / 1.2, id_tax_rules_group = 4 WHERE id_tax_rules_group = 0;
UPDATE ps_product_shop SET price = price / 1.2, id_tax_rules_group = 4 WHERE id_tax_rules_group = 0;

Tout est ok.
Merci pourvoir aide

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More