Fix: Error in price when adding a product in contract with base type that is with tax.

This commit is contained in:
Laurent Destailleur 2009-01-25 17:05:40 +00:00
parent d371bd7fe4
commit c3adbb11fe
3 changed files with 82 additions and 79 deletions

View File

@ -794,11 +794,11 @@ class Contrat extends CommonObject
// \TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
$remise = 0;
$price = price2num(round($pu, 2));
$price = price2num(round($pu_ht, 2));
if (strlen($remise_percent) > 0)
{
$remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise;
$remise = round(($pu_ht * $remise_percent / 100), 2);
$price = $pu_ht - $remise;
}
// Insertion dans la base
@ -814,7 +814,7 @@ class Contrat extends CommonObject
$sql.= ($fk_product>0 ? $fk_product : "null").",";
$sql.= " '".$qty."',";
$sql.= " '".$txtva."',";
$sql.= " ".price2num($remise_percent).",".price2num($pu).",";
$sql.= " ".price2num($remise_percent).",".price2num($pu_ht).",";
$sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_ttc).",";
$sql.= " '".$info_bits."',";
$sql.= " ".price2num($price).",".price2num( $remise); // \TODO A virer
@ -1360,11 +1360,14 @@ class ContratLigne
var $remise_percent;
var $remise;
var $fk_remise_except;
var $subprice;
var $subprice; // Unit price HT
var $price_ht;
var $total_ht;
var $total_tva;
var $total_ttc;
var $info_bits;
var $fk_user_author;
var $fk_user_ouverture;

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* 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
@ -44,6 +44,7 @@ $result=restrictedArea($user,'contrat',$contratid,'contrat');
$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
/*
* Actions
*/
@ -211,8 +212,6 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
}
}
$price_base_type = 'HT';
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
@ -260,6 +259,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
else
{
$pu_ht=$_POST['pu'];
$price_base_type = 'HT';
$tva_tx=eregi_replace('\*','',$_POST['tva_tx']);
$tva_npr=eregi('\*',$_POST['tva_tx'])?1:0;
$desc=$_POST['desc'];

View File

@ -28,7 +28,7 @@
/**
\brief Permet de calculer les parts total HT, TVA et TTC d'une ligne de
facture, propale, commande ou autre depuis:
quantity, unit price, remise_percent_ligne, txtva, remise_percent_global
quantity, unit price, remise_percent_ligne, txtva, remise_percent_global, price_base_type, info_bits
\param qty Quantity
\param pu Prix unitaire (HT ou TTC selon price_base_type)
\param remise_percent_ligne Remise ligne