本文整理汇总了PHP中calcul_price_total函数的典型用法代码示例。如果您正苦于以下问题:PHP calcul_price_total函数的具体用法?PHP calcul_price_total怎么用?PHP calcul_price_total使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calcul_price_total函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _calcTotaux
function _calcTotaux(&$object, &$line, &$qty_dispatched, &$total_ht, &$total_tva, &$total_ttc, &$total_localtax1, &$total_localtax2, $debug)
{
if ($debug) {
print 'fk_product = ' . $line->fk_product . ' :: qty cmd = ' . $line->qty . ' :: qty ventilés = ' . $qty_dispatched . '<br />';
}
$line->qty = $qty_dispatched;
// Ceci est important de le faire, j'update la qty de la ligne courante qui sera repris sur l'affichage de Dolibarr
$tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', $line->info_bits, $line->product_type, $object->thirdparty, array());
$total_ht += $tabprice[0];
$total_tva += $tabprice[1];
$total_ttc += $tabprice[2];
$total_localtax1 += $tabprice[9];
$total_localtax2 += $tabprice[10];
}
示例2: updateline
/**
* Update a detail line
*
* @param int $rowid Id of line to update
* @param string $desc Description of line
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type) (> 0 even for credit note lines)
* @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne
* @param int $date_start Date de debut de validite du service
* @param int $date_end Date de fin de validite du service
* @param double $txtva VAT Rate
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous informations
* @param int $type Type of line (0=product, 1=service)
* @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
* @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
* @param int $fk_fournprice Id of origin supplier price
* @param int $pa_ht Price (without tax) of product when it was bought
* @param string $label Label of the line (deprecated, do not use)
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_option extrafields array
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_option = 0)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
global $mysoc;
dol_syslog(get_class($this) . "::updateline rowid={$rowid}, desc={$desc}, pu={$pu}, qty={$qty}, remise_percent={$remise_percent}, date_start={$date_start}, date_end={$date_end}, txtva={$txtva}, txlocaltax1={$txlocaltax1}, txlocaltax2={$txlocaltax2}, price_base_type={$price_base_type}, info_bits={$info_bits}, type={$type}, fk_parent_line={$fk_parent_line} pa_ht={$pa_ht}, special_code={$special_code}", LOG_DEBUG);
if ($this->brouillon) {
$this->db->begin();
// Clean parameters
if (empty($qty)) {
$qty = 0;
}
if (empty($fk_parent_line) || $fk_parent_line < 0) {
$fk_parent_line = 0;
}
if (empty($special_code) || $special_code == 3) {
$special_code = 0;
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$pa_ht = price2num($pa_ht);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
// Check parameters
if ($type < 0) {
return -1;
}
// Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
// 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, $mysoc);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
// Update line into database
$this->line = new FactureLigne($this->db);
$this->line->context = $this->context;
// Stock previous line records
$staticline = new FactureLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
// Reorder if fk_parent_line change
if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) {
$rangmax = $this->line_max($fk_parent_line);
$this->line->rang = $rangmax + 1;
}
$this->line->rowid = $rowid;
$this->line->label = $label;
$this->line->desc = $desc;
$this->line->qty = $this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty;
// For credit note, quantity is always positive and unit price negative
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $this->type == 2 ? -abs($pu_ht) : $pu_ht;
// For credit note, unit price always negative, always positive otherwise
$this->line->date_start = $date_start;
$this->line->date_end = $date_end;
$this->line->total_ht = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_ht) : $total_ht;
// For credit note and if qty is negative, total is negative
$this->line->total_tva = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_tva) : $total_tva;
$this->line->total_localtax1 = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_localtax1) : $total_localtax1;
$this->line->total_localtax2 = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_localtax2) : $total_localtax2;
$this->line->total_ttc = $this->type == self::TYPE_CREDIT_NOTE || $qty < 0 ? -abs($total_ttc) : $total_ttc;
$this->line->info_bits = $info_bits;
//.........这里部分代码省略.........
示例3: update_percent
/**
* Update invoice line with percentage
*
* @param FactureLigne $line Invoice line
* @param int $percent Percentage
* @return void
*/
function update_percent($line, $percent)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
// Cap percentages to 100
if ($percent > 100) {
$percent = 100;
}
$line->situation_percent = $percent;
$tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, '', '', $percent);
$line->total_ht = $tabprice[0];
$line->total_tva = $tabprice[1];
$line->total_ttc = $tabprice[2];
$line->total_localtax1 = $tabprice[9];
$line->total_localtax2 = $tabprice[10];
$line->update();
$this->update_price(1);
$this->db->commit();
}
示例4: updateline
/**
* \brief Update a line in database
* \param rowid Id of line to update
* \param desc Description de la ligne
* \param pu Prix unitaire
* \param qty Quantity
* \param remise_percent Pourcentage de remise de la ligne
* \param tva_tx Taux TVA
* \param txlocaltax1 Local tax 1 rate
* \param txlocaltax2 Local tax 2 rate
* \param price_base_type HT or TTC
* \param info_bits Miscellanous informations on line
* \param date_start Start date of the line
* \param date_end End date of the line
* \param type Type of line (0=product, 1=service)
* \return int < 0 si erreur, > 0 si ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent = 0, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0)
{
global $conf;
dol_syslog("CustomerOrder::UpdateLine {$rowid}, {$desc}, {$pu}, {$qty}, {$remise_percent}, {$txtva}, {$txlocaltax1}, {$txlocaltax2}, {$price_base_type}, {$info_bits}, {$date_start}, {$date_end}, {$type}");
include_once DOL_DOCUMENT_ROOT . '/lib/price.lib.php';
if ($this->brouillon) {
$this->db->begin();
// Clean parameters
if (empty($qty)) {
$qty = 0;
}
if (empty($info_bits)) {
$info_bits = 0;
}
if (empty($txtva)) {
$txtva = 0;
}
if (empty($txlocaltax1)) {
$txlocaltax1 = 0;
}
if (empty($txlocaltax2)) {
$txlocaltax2 = 0;
}
if (empty($remise)) {
$remise = 0;
}
if (empty($remise_percent)) {
$remise_percent = 0;
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txtlocaltax1);
$txlocaltax2 = price2num($txtlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
$price = $pu;
$subprice = $pu;
$remise = 0;
if ($remise_percent > 0) {
$remise = round($pu * $remise_percent / 100, 2);
$price = $pu - $remise;
}
// Update line
$this->line = new OrderLine($this->db);
// Stock previous line records
$staticline = new OrderLine($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
$this->line->rowid = $rowid;
$this->line->desc = $desc;
$this->line->qty = $qty;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $subprice;
$this->line->info_bits = $info_bits;
$this->line->total_ht = $total_ht;
$this->line->total_tva = $total_tva;
$this->line->total_localtax1 = $total_localtax1;
$this->line->total_localtax2 = $total_localtax2;
$this->line->total_ttc = $total_ttc;
$this->line->date_start = $date_start;
$this->line->date_end = $date_end;
$this->line->product_type = $type;
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
// TODO deprecated
$this->line->price = $price;
$this->line->remise = $remise;
$result = $this->line->update();
if ($result > 0) {
//.........这里部分代码省略.........
示例5: ajoutArticle
/**
* Add a product into cart
*
* @return void
*/
public function ajoutArticle()
{
global $conf, $db, $mysoc;
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
$societe = new Societe($db);
$societe->fetch($thirdpartyid);
$product = new Product($db);
$product->fetch($this->id);
$sql = "SELECT taux";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_tva";
$sql .= " WHERE rowid = " . $this->tva();
dol_syslog("ajoutArticle", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$vat_rate = $obj->taux;
//var_dump($vat_rate);exit;
} else {
dol_print_error($db);
}
// Define part of HT, VAT, TTC
$resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, 0, 0, 0, 'HT', 0, $product->type, $mysoc);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
$total_vat = $resultarray[1];
$total_ttc = $resultarray[2];
// Calcul du montant de la remise
if ($this->remisePercent()) {
$remise_percent = $this->remisePercent();
} else {
$remise_percent = 0;
}
$montant_remise_ht = $resultarray[6] - $resultarray[0];
$this->montantRemise($montant_remise_ht);
$newcartarray = $_SESSION['poscart'];
$i = count($newcartarray);
$newcartarray[$i]['id'] = $i;
$newcartarray[$i]['ref'] = $product->ref;
$newcartarray[$i]['label'] = $product->label;
$newcartarray[$i]['price'] = $product->price;
$newcartarray[$i]['price_ttc'] = $product->price_ttc;
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
if (isset($product->multiprices[$societe->price_level])) {
$newcartarray[$i]['price'] = $product->multiprices[$societe->price_level];
$newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level];
}
}
$newcartarray[$i]['fk_article'] = $this->id;
$newcartarray[$i]['qte'] = $this->qte();
$newcartarray[$i]['fk_tva'] = $this->tva();
$newcartarray[$i]['remise_percent'] = $remise_percent;
$newcartarray[$i]['remise'] = price2num($montant_remise_ht);
$newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT');
$newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT');
$_SESSION['poscart'] = $newcartarray;
$this->raz();
}
示例6: updateline
/**
* Update a proposal line
*
* @param int $rowid Id de la ligne
* @param float $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param float $qty Quantity
* @param float $remise_percent Remise effectuee sur le produit
* @param float $txtva Taux de TVA
* @param float $txlocaltax1 Local tax 1 rate
* @param float $txlocaltax2 Local tax 2 rate
* @param string $desc Description
* @param string $price_base_type HT ou TTC
* @param int $info_bits Miscellaneous informations
* @param int $special_code Special code (also used by externals modules!)
* @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
* @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
* @param int $fk_fournprice Id of origin supplier price
* @param int $pa_ht Price (without tax) of product when it was bought
* @param string $label ???
* @param int $type 0/1=Product/service
* @param int $date_start Start date of the line
* @param int $date_end End date of the line
* @param array $array_option extrafields array
* @return int 0 if OK, <0 if KO
*/
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_option = 0)
{
global $mysoc;
dol_syslog(get_class($this) . "::updateLine rowid={$rowid}, pu={$pu}, qty={$qty}, remise_percent={$remise_percent}, txtva={$txtva}, desc={$desc}, price_base_type={$price_base_type}, info_bits={$info_bits}, special_code={$special_code}, fk_parent_line={$fk_parent_line}, pa_ht={$a_ht}, type={$type}, date_start={$date_start}, date_end={$date_end}");
include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
// Clean parameters
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);
if (empty($qty) && empty($special_code)) {
$special_code = 3;
}
// Set option tag
if (!empty($qty) && $special_code == 3) {
$special_code = 0;
}
// Remove option tag
if ($this->statut == 0) {
$this->db->begin();
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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, $mysoc);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
$price = $pu;
if ($remise_percent > 0) {
$remise = round($pu * $remise_percent / 100, 2);
$price = $pu - $remise;
}
// Update line
$this->line = new PropaleLigne($this->db);
$this->line->context = $this->context;
// Stock previous line records
$staticline = new PropaleLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
// Reorder if fk_parent_line change
if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) {
$rangmax = $this->line_max($fk_parent_line);
$this->line->rang = $rangmax + 1;
}
$this->line->rowid = $rowid;
$this->line->label = $label;
$this->line->desc = $desc;
$this->line->qty = $qty;
$this->line->product_type = $type;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $pu;
$this->line->info_bits = $info_bits;
$this->line->total_ht = $total_ht;
$this->line->total_tva = $total_tva;
$this->line->total_localtax1 = $total_localtax1;
$this->line->total_localtax2 = $total_localtax2;
$this->line->total_ttc = $total_ttc;
$this->line->special_code = $special_code;
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
//.........这里部分代码省略.........
示例7: updateline
/**
* Update line
*
* @param int $rowid Id de la ligne de facture
* @param string $desc Description de la ligne
* @param double $pu Prix unitaire
* @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne
* @param double $txtva Taux TVA
* @param double $txlocaltax1 Localtax1 tax
* @param double $txlocaltax2 Localtax2 tax
* @param double $price_base_type Type of price base
* @param int $info_bits Miscellaneous informations
* @param int $type Type of line (0=product, 1=service)
* @param int $notrigger Disable triggers
* @param timestamp $date_start Date start of service
* @param timestamp $date_end Date end of service
* @param array $array_options Extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if error, > 0 if ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = false, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null)
{
global $mysoc;
dol_syslog(get_class($this) . "::updateline {$rowid}, {$desc}, {$pu}, {$qty}, {$remise_percent}, {$txtva}, {$price_base_type}, {$info_bits}, {$type}, {$fk_unit}");
include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
if ($this->brouillon) {
$this->db->begin();
// Clean parameters
if (empty($qty)) {
$qty = 0;
}
if (empty($info_bits)) {
$info_bits = 0;
}
if (empty($txtva)) {
$txtva = 0;
}
if (empty($txlocaltax1)) {
$txlocaltax1 = 0;
}
if (empty($txlocaltax2)) {
$txlocaltax2 = 0;
}
if (empty($remise)) {
$remise = 0;
}
if (empty($remise_percent)) {
$remise_percent = 0;
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (!$qty) {
$qty = 1;
}
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
// Check parameters
if ($type < 0) {
return -1;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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, $mysoc, $this->thirdparty);
$txtva = preg_replace('/\\s*\\(.*\\)/', '', $txtva);
// Remove code into vatrate.
$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];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
$localtax1_type = $localtaxes_type[0];
$localtax2_type = $localtaxes_type[2];
$subprice = price2num($pu, 'MU');
// Mise a jour ligne en base
$sql = "UPDATE " . MAIN_DB_PREFIX . "commande_fournisseurdet SET";
$sql .= " description='" . $this->db->escape($desc) . "'";
$sql .= ",subprice='" . price2num($subprice) . "'";
//$sql.= ",remise='".price2num($remise)."'";
$sql .= ",remise_percent='" . price2num($remise_percent) . "'";
$sql .= ",tva_tx='" . price2num($txtva) . "'";
$sql .= ",localtax1_tx='" . price2num($txlocaltax1) . "'";
$sql .= ",localtax2_tx='" . price2num($txlocaltax2) . "'";
$sql .= ",localtax1_type='" . $localtax1_type . "'";
$sql .= ",localtax2_type='" . $localtax2_type . "'";
$sql .= ",qty='" . price2num($qty) . "'";
$sql .= ",date_start=" . (!empty($date_start) ? "'" . $this->db->idate($date_start) . "'" : "null");
$sql .= ",date_end=" . (!empty($date_end) ? "'" . $this->db->idate($date_end) . "'" : "null");
$sql .= ",info_bits='" . $info_bits . "'";
$sql .= ",total_ht='" . price2num($total_ht) . "'";
$sql .= ",total_tva='" . price2num($total_tva) . "'";
$sql .= ",total_localtax1='" . price2num($total_localtax1) . "'";
$sql .= ",total_localtax2='" . price2num($total_localtax2) . "'";
$sql .= ",total_ttc='" . price2num($total_ttc) . "'";
$sql .= ",product_type=" . $type;
//.........这里部分代码省略.........
示例8: calculePrice
public static function calculePrice($product)
{
global $db, $mysoc;
require_once DOL_DOCUMENT_ROOT . "/core/lib/price.lib.php";
$qty = $product["cant"];
if ($product["price_base_type"] == "HT") {
$pu = $product["price"];
} else {
$pu = $product["price_ttc"];
}
$remise_percent_ligne = $product["discount"] ? $product["discount"] : 0;
$txtva = $product["tva_tx"];
$uselocaltax1_rate = $product["localtax1_tx"] > 0 ? $product["localtax1_tx"] : 0;
$uselocaltax2_rate = $product["localtax2_tx"] > 0 ? $product["localtax2_tx"] : 0;
$remise_percent_global = $product["remise_percent_global"] ? $product["remise_percent_global"] : 0;
$price_base_type = $product["price_base_type"];
$type = $product["fk_product_type"] ? $product["fk_product_type"] : 0;
$info_bits = 0;
$remise_percent_ligne = $remise_percent_global + $remise_percent_ligne;
$remise_percent_global = 0;
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $mysoc);
$tabprice = calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$result["total_ht"] = $tabprice[0];
$result["total_tva"] = $tabprice[1];
$result["total_ttc"] = $tabprice[2];
$result["total_localtax1"] = $tabprice[9];
$result["total_localtax2"] = $tabprice[10];
$result["pu_ht"] = $tabprice[3];
$result["pu_tva"] = $tabprice[4];
$result["pu_ttc"] = $tabprice[5];
$result["total_ttc_without_discount"] = $tabprice[8];
return $result;
}
示例9: updateline
/**
* Update a line detail into database
* @param id Id of line invoice
* @param label Description of line
* @param pu Prix unitaire (HT ou TTC selon price_base_type)
* @param vatrate VAT Rate
* @param txlocaltax1 LocalTax1 Rate
* @param txlocaltax2 LocalTax2 Rate
* @param qty Quantity
* @param idproduct Id produit
* @param price_base_type HT or TTC
* @param info_bits Miscellanous informations of line
* @param type Type of line (0=product, 1=service)
* @return int <0 if KO, >0 if OK
*/
function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0)
{
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
$pu = price2num($pu);
$qty = price2num($qty);
// Check parameters
if (! is_numeric($pu) || ! is_numeric($qty)) return -1;
if ($type < 0) return -1;
// Clean parameters
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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.
$tabprice = calcul_price_total($qty, $pu, 0, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
if ($idproduct)
{
$product=new Product($this->db);
$result=$product->fetch($idproduct);
$product_type = $product->type;
}
else
{
$product_type = $type;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($label)."'";
$sql.= ", pu_ht = ".price2num($pu_ht);
$sql.= ", pu_ttc = ".price2num($pu_ttc);
$sql.= ", qty = ".price2num($qty);
$sql.= ", tva_tx = ".price2num($vatrate);
$sql.= ", localtax1_tx = ".price2num($txlocaltax1);
$sql.= ", localtax2_tx = ".price2num($txlocaltax2);
$sql.= ", total_ht = ".price2num($total_ht);
$sql.= ", tva= ".price2num($total_tva);
$sql.= ", total_localtax1= ".price2num($total_localtax1);
$sql.= ", total_localtax2= ".price2num($total_localtax2);
$sql.= ", total_ttc = ".price2num($total_ttc);
if ($idproduct) $sql.= ", fk_product = ".$idproduct;
else $sql.= ", fk_product = null";
$sql.= ", product_type = ".$product_type;
$sql.= " WHERE rowid = ".$id;
dol_syslog("Fournisseur.facture::updateline sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
// Update total price into invoice record
$result=$this->update_price();
return $result;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Fournisseur.facture::updateline error=".$this->error, LOG_ERR);
return -1;
}
}
示例10: update
/**
* Update database for contract line
*
* @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
// Clean parameters
$this->fk_contrat = trim($this->fk_contrat);
$this->fk_product = trim($this->fk_product);
$this->statut = trim($this->statut);
$this->label = trim($this->label);
$this->description = trim($this->description);
$this->tva_tx = trim($this->tva_tx);
$this->localtax1_tx = trim($this->localtax1_tx);
$this->localtax2_tx = trim($this->localtax2_tx);
$this->qty = trim($this->qty);
$this->remise_percent = trim($this->remise_percent);
$this->remise = trim($this->remise);
$this->fk_remise_except = trim($this->fk_remise_except);
$this->subprice = price2num($this->subprice);
$this->price_ht = price2num($this->price_ht);
$this->total_ht = trim($this->total_ht);
$this->total_tva = trim($this->total_tva);
$this->total_localtax1 = trim($this->total_localtax1);
$this->total_localtax2 = trim($this->total_localtax2);
$this->total_ttc = trim($this->total_ttc);
$this->info_bits = trim($this->info_bits);
$this->fk_user_author = trim($this->fk_user_author);
$this->fk_user_ouverture = trim($this->fk_user_ouverture);
$this->fk_user_cloture = trim($this->fk_user_cloture);
$this->commentaire = trim($this->commentaire);
// Check parameters
// Put here code to add control on parameters values
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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.
$tabprice = calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0);
$this->total_ht = $tabprice[0];
$this->total_tva = $tabprice[1];
$this->total_ttc = $tabprice[2];
$this->total_localtax1 = $tabprice[9];
$this->total_localtax2 = $tabprice[10];
// Update request
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET";
$sql .= " fk_contrat='" . $this->fk_contrat . "',";
$sql .= " fk_product=" . ($this->fk_product ? "'" . $this->fk_product . "'" : 'null') . ",";
$sql .= " statut='" . $this->statut . "',";
$sql .= " label='" . $this->db->escape($this->label) . "',";
$sql .= " description='" . $this->db->escape($this->description) . "',";
$sql .= " date_commande=" . ($this->date_commande != '' ? "'" . $this->db->idate($this->date_commande) . "'" : "null") . ",";
$sql .= " date_ouverture_prevue=" . ($this->date_ouverture_prevue != '' ? "'" . $this->db->idate($this->date_ouverture_prevue) . "'" : "null") . ",";
$sql .= " date_ouverture=" . ($this->date_ouverture != '' ? "'" . $this->db->idate($this->date_ouverture) . "'" : "null") . ",";
$sql .= " date_fin_validite=" . ($this->date_fin_validite != '' ? "'" . $this->db->idate($this->date_fin_validite) . "'" : "null") . ",";
$sql .= " date_cloture=" . ($this->date_cloture != '' ? "'" . $this->db->idate($this->date_cloture) . "'" : "null") . ",";
$sql .= " tva_tx='" . $this->tva_tx . "',";
$sql .= " localtax1_tx='" . $this->localtax1_tx . "',";
$sql .= " localtax2_tx='" . $this->localtax2_tx . "',";
$sql .= " qty='" . $this->qty . "',";
$sql .= " remise_percent='" . $this->remise_percent . "',";
$sql .= " remise=" . ($this->remise ? "'" . $this->remise . "'" : "null") . ",";
$sql .= " fk_remise_except=" . ($this->fk_remise_except ? "'" . $this->fk_remise_except . "'" : "null") . ",";
$sql .= " subprice='" . $this->subprice . "',";
$sql .= " price_ht='" . $this->price_ht . "',";
$sql .= " total_ht='" . $this->total_ht . "',";
$sql .= " total_tva='" . $this->total_tva . "',";
$sql .= " total_localtax1='" . $this->total_localtax1 . "',";
$sql .= " total_localtax2='" . $this->total_localtax2 . "',";
$sql .= " total_ttc='" . $this->total_ttc . "',";
$sql .= " info_bits='" . $this->info_bits . "',";
$sql .= " fk_user_author=" . ($this->fk_user_author >= 0 ? $this->fk_user_author : "NULL") . ",";
$sql .= " fk_user_ouverture=" . ($this->fk_user_ouverture > 0 ? $this->fk_user_ouverture : "NULL") . ",";
$sql .= " fk_user_cloture=" . ($this->fk_user_cloture > 0 ? $this->fk_user_cloture : "NULL") . ",";
$sql .= " commentaire='" . $this->db->escape($this->commentaire) . "'";
$sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$contrat = new Contrat($this->db);
$contrat->fetch($this->fk_contrat);
$result = $contrat->update_statut($user);
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
return -1;
}
if (!$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('MYOBJECT_MODIFY', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
//.........这里部分代码省略.........
示例11: updateline
/**
* Update line
*
* @param int $rowid Id de la ligne de facture
* @param string $desc Description de la ligne
* @param double $pu Prix unitaire
* @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne
* @param double $txtva Taux TVA
* @param double $txlocaltax1 Localtax1 tax
* @param double $txlocaltax2 Localtax2 tax
* @param double $price_base_type Type of price base
* @param int $info_bits Miscellaneous informations
* @param int $type Type of line (0=product, 1=service)
* @param int $notrigger Disable triggers
* @return int < 0 if error, > 0 if ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = false)
{
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';
if ($this->brouillon) {
$this->db->begin();
// Clean parameters
if (empty($qty)) {
$qty = 0;
}
if (empty($info_bits)) {
$info_bits = 0;
}
if (empty($txtva)) {
$txtva = 0;
}
if (empty($txlocaltax1)) {
$txlocaltax1 = 0;
}
if (empty($txlocaltax2)) {
$txlocaltax2 = 0;
}
if (empty($remise)) {
$remise = 0;
}
if (empty($remise_percent)) {
$remise_percent = 0;
}
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (!$qty) {
$qty = 1;
}
$pu = price2num($pu);
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
// Check parameters
if ($type < 0) {
return -1;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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);
$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];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
$localtax1_type = $localtaxes_type[0];
$localtax2_type = $localtaxes_type[2];
$subprice = price2num($pu, 'MU');
// Mise a jour ligne en base
$sql = "UPDATE " . MAIN_DB_PREFIX . "commande_fournisseurdet SET";
$sql .= " description='" . $this->db->escape($desc) . "'";
$sql .= ",subprice='" . price2num($subprice) . "'";
//$sql.= ",remise='".price2num($remise)."'";
$sql .= ",remise_percent='" . price2num($remise_percent) . "'";
$sql .= ",tva_tx='" . price2num($txtva) . "'";
$sql .= ",localtax1_tx='" . price2num($txlocaltax1) . "'";
$sql .= ",localtax2_tx='" . price2num($txlocaltax2) . "'";
$sql .= ",localtax1_type='" . $localtax1_type . "'";
$sql .= ",localtax2_type='" . $localtax2_type . "'";
$sql .= ",qty='" . price2num($qty) . "'";
/*if ($date_end) { $sql.= ",date_start='$date_end'"; }
else { $sql.=',date_start=null'; }
if ($date_end) { $sql.= ",date_end='$date_end'"; }
else { $sql.=',date_end=null'; }*/
$sql .= ",info_bits='" . $info_bits . "'";
$sql .= ",total_ht='" . price2num($total_ht) . "'";
$sql .= ",total_tva='" . price2num($total_tva) . "'";
$sql .= ",total_localtax1='" . price2num($total_localtax1) . "'";
$sql .= ",total_localtax2='" . price2num($total_localtax2) . "'";
$sql .= ",total_ttc='" . price2num($total_ttc) . "'";
$sql .= ",product_type=" . $type;
$sql .= " WHERE rowid = " . $rowid;
dol_syslog(get_class($this) . "::updateline sql=" . $sql);
$result = $this->db->query($sql);
if ($result > 0) {
$this->rowid = $rowid;
//.........这里部分代码省略.........
示例12: migrate_price_commande_fournisseur
/**
* Mise a jour des totaux lignes de commande fournisseur
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_commande_fournisseur($db, $langs, $conf)
{
$db->begin();
print '<tr><td colspan="4">';
print '<br>';
print '<b>' . $langs->trans('MigrationSupplierOrder') . "</b><br>\n";
// Liste des lignes commande non a jour
$sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
$sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd, " . MAIN_DB_PREFIX . "commande_fournisseur as c";
$sql .= " WHERE cd.fk_commande = c.rowid";
$sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
$rowid = $obj->rowid;
$qty = $obj->qty;
$pu = $obj->subprice;
$txtva = $obj->tva_taux;
$remise_percent = $obj->remise_percent;
$remise_percent_global = $obj->remise_percent_global;
$info_bits = $obj->info_bits;
// On met a jour les 3 nouveaux champs
$commandeligne = new CommandeFournisseurLigne($db);
$commandeligne->fetch($rowid);
$result = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, $remise_percent_global, 'HT', $info_bits, 0);
$total_ht = $result[0];
$total_tva = $result[1];
$total_ttc = $result[2];
$commandeligne->total_ht = $total_ht;
$commandeligne->total_tva = $total_tva;
$commandeligne->total_ttc = $total_ttc;
dolibarr_install_syslog("upgrade2: Line {$rowid}: commandeid={$obj->rowid} pu={$pu} qty={$qty} tva_taux={$txtva} remise_percent={$remise_percent} remise_global={$remise_percent_global} -> {$total_ht}, {$total_tva}, {$total_ttc}");
print ". ";
$commandeligne->update_total();
/* On touche pas a facture mere
$commande = new Commande($db);
$commande->id = $obj->rowid;
if ( $commande->fetch($commande->id) >= 0 )
{
if ( $commande->update_price() > 0 )
{
print ". ";
}
else
{
print "Error id=".$commande->id;
}
}
else
{
print "Error #3";
}
*/
$i++;
}
} else {
print $langs->trans("AlreadyDone");
}
$db->free($resql);
/*
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
$resql=$db->query($sql);
if (! $resql)
{
dol_print_error($db);
}
*/
$db->commit();
} else {
print "Error #1 " . $db->error();
$db->rollback();
}
print '<br>';
print '</td></tr>';
}
示例13: updateline
/**
* Update a line detail into database
*
* @param int $id Id of line invoice
* @param string $desc Description of line
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param double $vatrate VAT Rate
* @param double $txlocaltax1 LocalTax1 Rate
* @param double $txlocaltax2 LocalTax2 Rate
* @param double $qty Quantity
* @param int $idproduct Id produit
* @param double $price_base_type HT or TTC
* @param int $info_bits Miscellaneous informations of line
* @param int $type Type of line (0=product, 1=service)
* @param double $remise_percent Pourcentage de remise de la ligne
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
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)
{
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';
$pu = price2num($pu);
$qty = price2num($qty);
$remise_percent = price2num($remise_percent);
// Check parameters
if (!is_numeric($pu) || !is_numeric($qty)) {
return -1;
}
if ($type < 0) {
return -1;
}
// Clean parameters
if (empty($vatrate)) {
$vatrate = 0;
}
if (empty($txlocaltax1)) {
$txlocaltax1 = 0;
}
if (empty($txlocaltax2)) {
$txlocaltax2 = 0;
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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);
$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];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
if (empty($info_bits)) {
$info_bits = 0;
}
if ($idproduct) {
$product = new Product($this->db);
$result = $product->fetch($idproduct);
$product_type = $product->type;
} else {
$product_type = $type;
}
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det SET";
$sql .= " description ='" . $this->db->escape($desc) . "'";
$sql .= ", pu_ht = " . price2num($pu_ht);
$sql .= ", pu_ttc = " . price2num($pu_ttc);
$sql .= ", qty = " . price2num($qty);
$sql .= ", remise_percent = " . price2num($remise_percent);
$sql .= ", tva_tx = " . price2num($vatrate);
$sql .= ", localtax1_tx = " . price2num($txlocaltax1);
$sql .= ", localtax2_tx = " . price2num($txlocaltax2);
$sql .= ", localtax1_type = '" . $localtaxes_type[0] . "'";
$sql .= ", localtax2_type = '" . $localtaxes_type[2] . "'";
$sql .= ", total_ht = " . price2num($total_ht);
$sql .= ", tva= " . price2num($total_tva);
$sql .= ", total_localtax1= " . price2num($total_localtax1);
$sql .= ", total_localtax2= " . price2num($total_localtax2);
$sql .= ", total_ttc = " . price2num($total_ttc);
if ($idproduct) {
$sql .= ", fk_product = " . $idproduct;
} else {
$sql .= ", fk_product = null";
}
$sql .= ", product_type = " . $product_type;
$sql .= ", info_bits = " . $info_bits;
$sql .= " WHERE rowid = " . $id;
dol_syslog(get_class($this) . "::updateline sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
$this->rowid = $id;
if (!$notrigger) {
global $conf, $langs, $user;
// Appel des triggers
//.........这里部分代码省略.........
示例14: calcul_price_total
} else {
// More examples if not specific vat rate found
// This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
// were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
$s = 10 / 3;
$qty = 1;
$vat = 10;
$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0);
print $langs->trans("UnitPriceOfProduct") . ": " . price2num($s, 'MU');
print " x " . $langs->trans("Quantity") . ": " . $qty;
print " - " . $langs->trans("VAT") . ": " . $vat . '%';
print " -> " . $langs->trans("TotalPriceAfterRounding") . ": " . $tmparray[0] . ' / ' . $tmparray[1] . ' / ' . $tmparray[2] . "<br>\n";
$s = 10 / 3;
$qty = 2;
$vat = 10;
$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0);
print $langs->trans("UnitPriceOfProduct") . ": " . price2num($s, 'MU');
print " x " . $langs->trans("Quantity") . ": " . $qty;
print " - " . $langs->trans("VAT") . ": " . $vat . '%';
print " -> " . $langs->trans("TotalPriceAfterRounding") . ": " . $tmparray[0] . ' / ' . $tmparray[1] . ' / ' . $tmparray[2] . "<br>\n";
}
// Important: can debug rounding, to simulate the rounded total
/*
print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
foreach($vat_rates as $vat)
{
for ($qty=1; $qty<=2; $qty++)
{
$s1=10/3;
$s2=2/7;
示例15: update
/**
* Update database for contract line
*
* @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger = 0)
{
global $conf, $langs, $mysoc;
$error = 0;
// Clean parameters
$this->fk_contrat = trim($this->fk_contrat);
$this->fk_product = trim($this->fk_product);
$this->statut = (int) $this->statut;
$this->label = trim($this->label);
$this->description = trim($this->description);
$this->tva_tx = trim($this->tva_tx);
$this->localtax1_tx = trim($this->localtax1_tx);
$this->localtax2_tx = trim($this->localtax2_tx);
$this->qty = trim($this->qty);
$this->remise_percent = trim($this->remise_percent);
$this->remise = trim($this->remise);
$this->fk_remise_except = trim($this->fk_remise_except);
$this->subprice = price2num($this->subprice);
$this->price_ht = price2num($this->price_ht);
$this->total_ht = trim($this->total_ht);
$this->total_tva = trim($this->total_tva);
$this->total_localtax1 = trim($this->total_localtax1);
$this->total_localtax2 = trim($this->total_localtax2);
$this->total_ttc = trim($this->total_ttc);
$this->info_bits = trim($this->info_bits);
$this->fk_user_author = trim($this->fk_user_author);
$this->fk_user_ouverture = trim($this->fk_user_ouverture);
$this->fk_user_cloture = trim($this->fk_user_cloture);
$this->commentaire = trim($this->commentaire);
//if (empty($this->subprice)) $this->subprice = 0;
if (empty($this->price_ht)) {
$this->price_ht = 0;
}
if (empty($this->total_ht)) {
$this->total_ht = 0;
}
if (empty($this->total_tva)) {
$this->total_tva = 0;
}
if (empty($this->total_ttc)) {
$this->total_ttc = 0;
}
// Check parameters
// Put here code to add control on parameters values
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// 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($this->txtva, 0, $this->societe, $mysoc);
$tabprice = calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type);
$this->total_ht = $tabprice[0];
$this->total_tva = $tabprice[1];
$this->total_ttc = $tabprice[2];
$this->total_localtax1 = $tabprice[9];
$this->total_localtax2 = $tabprice[10];
if (empty($this->pa_ht)) {
$this->pa_ht = 0;
}
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0) {
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) {
return $result;
} else {
$this->pa_ht = $result;
}
}
$this->db->begin();
// Update request
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET";
$sql .= " fk_contrat='" . $this->fk_contrat . "',";
$sql .= " fk_product=" . ($this->fk_product ? "'" . $this->fk_product . "'" : 'null') . ",";
$sql .= " statut='" . $this->statut . "',";
$sql .= " label='" . $this->db->escape($this->label) . "',";
$sql .= " description='" . $this->db->escape($this->description) . "',";
$sql .= " date_commande=" . ($this->date_commande != '' ? "'" . $this->db->idate($this->date_commande) . "'" : "null") . ",";
$sql .= " date_ouverture_prevue=" . ($this->date_ouverture_prevue != '' ? "'" . $this->db->idate($this->date_ouverture_prevue) . "'" : "null") . ",";
$sql .= " date_ouverture=" . ($this->date_ouverture != '' ? "'" . $this->db->idate($this->date_ouverture) . "'" : "null") . ",";
$sql .= " date_fin_validite=" . ($this->date_fin_validite != '' ? "'" . $this->db->idate($this->date_fin_validite) . "'" : "null") . ",";
$sql .= " date_cloture=" . ($this->date_cloture != '' ? "'" . $this->db->idate($this->date_cloture) . "'" : "null") . ",";
$sql .= " tva_tx='" . $this->tva_tx . "',";
$sql .= " localtax1_tx='" . $this->localtax1_tx . "',";
$sql .= " localtax2_tx='" . $this->localtax2_tx . "',";
$sql .= " qty='" . $this->qty . "',";
$sql .= " remise_percent='" . $this->remise_percent . "',";
$sql .= " remise=" . ($this->remise ? "'" . $this->remise . "'" : "null") . ",";
$sql .= " fk_remise_except=" . ($this->fk_remise_except ? "'" . $this->fk_remise_except . "'" : "null") . ",";
$sql .= " subprice=" . ($this->subprice != '' ? $this->subprice : "null") . ",";
$sql .= " price_ht=" . ($this->price_ht != '' ? $this->price_ht : "null") . ",";
$sql .= " total_ht='" . $this->total_ht . "',";
$sql .= " total_tva='" . $this->total_tva . "',";
$sql .= " total_localtax1='" . $this->total_localtax1 . "',";
$sql .= " total_localtax2='" . $this->total_localtax2 . "',";
$sql .= " total_ttc='" . $this->total_ttc . "',";
//.........这里部分代码省略.........