当前位置: 首页>>代码示例>>PHP>>正文


PHP getLocalTaxesFromRate函数代码示例

本文整理汇总了PHP中getLocalTaxesFromRate函数的典型用法代码示例。如果您正苦于以下问题:PHP getLocalTaxesFromRate函数的具体用法?PHP getLocalTaxesFromRate怎么用?PHP getLocalTaxesFromRate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getLocalTaxesFromRate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateline

 /**
  *  Mets a jour une ligne de contrat
  *
  *  @param	int			$rowid            	Id de la ligne de facture
  *  @param  string		$desc             	Description de la ligne
  *  @param  float		$pu               	Prix unitaire
  *  @param  int			$qty              	Quantite
  *  @param  float		$remise_percent   	Pourcentage de remise de la ligne
  *  @param  int			$date_start       	Date de debut prevue
  *  @param  int			$date_end         	Date de fin prevue
  *  @param  float		$tvatx            	Taux TVA
  *  @param  float		$localtax1tx      	Local tax 1 rate
  *  @param  float		$localtax2tx      	Local tax 2 rate
  *  @param  int|string	$date_debut_reel  	Date de debut reelle
  *  @param  int|string	$date_fin_reel    	Date de fin reelle
  *	@param	string		$price_base_type	HT or TTC
  * 	@param  int			$info_bits			Bits de type de lignes
  * 	@param  int			$fk_fournprice		Fourn price id
  *  @param  int			$pa_ht				Buying price HT
  *  @return int              				< 0 si erreur, > 0 si ok
  */
 function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0)
 {
     global $user, $conf, $langs, $mysoc;
     // Nettoyage parametres
     $qty = trim($qty);
     $desc = trim($desc);
     $desc = trim($desc);
     $price = price2num($pu);
     $tvatx = price2num($tvatx);
     $localtax1tx = price2num($localtax1tx);
     $localtax2tx = price2num($localtax2tx);
     $pa_ht = price2num($pa_ht);
     $subprice = $price;
     $remise = 0;
     if (dol_strlen($remise_percent) > 0) {
         $remise = round($pu * $remise_percent / 100, 2);
         $price = $pu - $remise;
     } else {
         $remise_percent = 0;
     }
     dol_syslog(get_class($this) . "::updateline {$rowid}, {$desc}, {$pu}, {$qty}, {$remise_percent}, {$date_start}, {$date_end}, {$date_debut_reel}, {$date_fin_reel}, {$tvatx}, {$localtax1tx}, {$localtax2tx}, {$price_base_type}, {$info_bits}");
     $this->db->begin();
     // Calcul du total TTC et de la TVA pour la ligne a partir de
     // qty, pu, remise_percent et tvatx
     // 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($tvatx, 0, $this->societe, $mysoc);
     $tabprice = calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, '', $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];
     // TODO A virer
     // Anciens indicateurs: $price, $remise (a ne plus utiliser)
     $remise = 0;
     $price = price2num(round($pu, 2));
     if (dol_strlen($remise_percent) > 0) {
         $remise = round($pu * $remise_percent / 100, 2);
         $price = $pu - $remise;
     }
     if (empty($pa_ht)) {
         $pa_ht = 0;
     }
     // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
     if ($pa_ht == 0) {
         if ($pu > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
             $pa_ht = $pu * (1 - $remise_percent / 100);
         }
     }
     $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet set description='" . $this->db->escape($desc) . "'";
     $sql .= ",price_ht='" . price2num($price) . "'";
     $sql .= ",subprice='" . price2num($subprice) . "'";
     $sql .= ",remise='" . price2num($remise) . "'";
     $sql .= ",remise_percent='" . price2num($remise_percent) . "'";
     $sql .= ",qty='" . $qty . "'";
     $sql .= ",tva_tx='" . price2num($tvatx) . "'";
     $sql .= ",localtax1_tx='" . price2num($localtax1tx) . "'";
     $sql .= ",localtax2_tx='" . price2num($localtax2tx) . "'";
     $sql .= ",localtax1_type='" . $localtax1_type . "'";
     $sql .= ",localtax2_type='" . $localtax2_type . "'";
     $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 .= ", fk_product_fournisseur_price='" . $fk_fournprice . "'";
     $sql .= ", buy_price_ht='" . price2num($pa_ht) . "'";
     if ($date_start > 0) {
         $sql .= ",date_ouverture_prevue='" . $this->db->idate($date_start) . "'";
     } else {
         $sql .= ",date_ouverture_prevue=null";
     }
     if ($date_end > 0) {
         $sql .= ",date_fin_validite='" . $this->db->idate($date_end) . "'";
     } else {
         $sql .= ",date_fin_validite=null";
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:contrat.class.php

示例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_options		extrafields array
  * 	@param      int         $situation_percent  Situation advance percentage
  * 	@param 		string		$fk_unit 			Code of the unit to use. Null to use the default one
  *  @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_options = 0, $situation_percent = 0, $fk_unit = null)
 {
     // Deprecation warning
     if ($label) {
         dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING);
     }
     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} fk_unit={$fk_unit}", 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;
         }
         if ($situation_percent > 100 || is_null($situation_percent) || $situation_percent == "") {
             $situation_percent = 100;
         }
         $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);
         $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, $mysoc, $localtaxes_type, $situation_percent);
         $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];
         // Old properties: $price, $remise (deprecated)
         $price = $pu;
         $remise = 0;
         if ($remise_percent > 0) {
             $remise = round($pu * $remise_percent / 100, 2);
             $price = $pu - $remise;
         }
         $price = price2num($price);
         //Fetch current line from the database and then clone the object and set it in $oldline property
         $line = new FactureLigne($this->db);
         $line->fetch($rowid);
         $staticline = clone $line;
         $line->oldline = $staticline;
         $this->line = $line;
         $this->line->context = $this->context;
         // 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;
//.........这里部分代码省略.........
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:facture.class.php

示例3: 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;
//.........这里部分代码省略.........
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:101,代码来源:fournisseur.commande.class.php

示例4: 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)) {
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:propal.class.php

示例5: updateline

 /**
  *  Update a line in database
  *
  *  @param    	int				$rowid            	Id of line to update
  *  @param    	string			$desc             	Description de la ligne
  *  @param    	float			$pu               	Prix unitaire
  *  @param    	float			$qty              	Quantity
  *  @param    	float			$remise_percent   	Pourcentage de remise de la ligne
  *  @param    	float			$txtva           	Taux TVA
  * 	@param		float			$txlocaltax1		Local tax 1 rate
  *  @param		float			$txlocaltax2		Local tax 2 rate
  *  @param    	string			$price_base_type	HT or TTC
  *  @param    	int				$info_bits        	Miscellaneous informations on line
  *  @param    	int		$date_start        	Start date of the line
  *  @param    	int		$date_end          	End date of the line
  * 	@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
  *  @param		int				$special_code		Special code (also used by externals modules!)
  *  @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 KO, > 0 if OK
  */
 function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null)
 {
     global $conf, $mysoc;
     dol_syslog(get_class($this) . "::updateline id={$rowid}, desc={$desc}, pu={$pu}, qty={$qty}, remise_percent={$remise_percent}, txtva={$txtva}, txlocaltax1={$txlocaltax1}, txlocaltax2={$txlocaltax2}, price_base_type={$price_base_type}, info_bits={$info_bits}, date_start={$date_start}, date_end={$date_end}, type={$type}, fk_parent_line={$fk_parent_line}, pa_ht={$pa_ht}, special_code={$special_code}");
     include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
     if (!empty($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;
         }
         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);
         // 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);
         $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, $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, $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;
         }
         //Fetch current line from the database and then clone the object and set it in $oldline property
         $line = new OrderLine($this->db);
         $line->fetch($rowid);
         $staticline = clone $line;
         $line->oldline = $staticline;
         $this->line = $line;
         $this->line->context = $this->context;
         // 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;
//.........这里部分代码省略.........
开发者ID:Albertopf,项目名称:prueba,代码行数:101,代码来源:commande.class.php

示例6: 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;
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:33,代码来源:pos.class.mañanero.php

示例7: getLocalTaxesFromRate

 // les variables
 $cptcli = !empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
 $compta_soc = !empty($obj->code_compta) ? $obj->code_compta : $cptcli;
 $compta_prod = $obj->accountancy_code_sell;
 if (empty($compta_prod)) {
     if ($obj->product_type == 0) {
         $compta_prod = !empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
     } else {
         $compta_prod = !empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
     }
 }
 $cpttva = !empty($conf->global->COMPTA_VAT_ACCOUNT) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef");
 $compta_tva = !empty($obj->account_tva) ? $obj->account_tva : $cpttva;
 $account_localtax1 = getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
 $compta_localtax1 = !empty($account_localtax1[3]) ? $account_localtax1[3] : $langs->trans("CodeNotDef");
 $account_localtax2 = getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
 $compta_localtax2 = !empty($account_localtax2[3]) ? $account_localtax2[3] : $langs->trans("CodeNotDef");
 //la ligne facture
 $tabfac[$obj->rowid]["date"] = $obj->datef;
 $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
 $tabfac[$obj->rowid]["type"] = $obj->type;
 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
     $tabttc[$obj->rowid][$compta_soc] = 0;
 }
 if (!isset($tabht[$obj->rowid][$compta_prod])) {
     $tabht[$obj->rowid][$compta_prod] = 0;
 }
 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
     $tabtva[$obj->rowid][$compta_tva] = 0;
 }
 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:sellsjournal.php

示例8: getLocalTaxesFromRate

     // contrôles
     $compta_soc = !empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour;
     $compta_prod = $obj->accountancy_code_buy;
     if (empty($compta_prod)) {
         if ($obj->product_type == 0) {
             $compta_prod = !empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
         } else {
             $compta_prod = !empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
         }
     }
     $compta_tva = !empty($obj->account_tva) ? $obj->account_tva : $cpttva;
     $compta_localtax1 = !empty($obj->account_localtax1) ? $obj->account_localtax1 : $langs->trans("CodeNotDef");
     $compta_localtax2 = !empty($obj->account_localtax2) ? $obj->account_localtax2 : $langs->trans("CodeNotDef");
     $account_localtax1 = getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc, $obj->thirdparty);
     $compta_localtax1 = !empty($account_localtax1[2]) ? $account_localtax1[2] : $langs->trans("CodeNotDef");
     $account_localtax2 = getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc, $obj->thirdparty);
     $compta_localtax2 = !empty($account_localtax2[2]) ? $account_localtax2[2] : $langs->trans("CodeNotDef");
     $tabfac[$obj->rowid]["date"] = $obj->datef;
     $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier;
     $tabfac[$obj->rowid]["type"] = $obj->type;
     $tabfac[$obj->rowid]["lib"] = $obj->libelle;
     $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
     $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
     if ($obj->recuperableonly != 1) {
         $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
     }
     $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
     $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
     $tabcompany[$obj->rowid] = array('id' => $obj->socid, 'name' => $obj->name);
     $i++;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:purchasesjournal.php

示例9: 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
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:fournisseur.facture.class.php

示例10: 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;
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:fournisseur.commande.class.ori.php

示例11: getLocalTaxesFromRate

     if (!empty($conf->global->MAIN_USE_LOCALTAX_TYPE_7)) {
         if ($this->total_localtax1 == 0) {
             global $mysoc;
             $localtax1_array = getLocalTaxesFromRate($vatrate, 1, $mysoc);
             if (empty($obj->localtax1_type)) {
                 $obj->localtax1_type = $localtax1_array[0];
                 $obj->localtax1_tx = $localtax1_array[1];
             }
             if ($obj->localtax1_type == '7') {
                 $total_localtax1 += $obj->localtax1_tx;
                 $total_ttc += $obj->localtax1_tx;
             }
         }
         if ($this->total_localtax2 == 0) {
             global $mysoc;
             $localtax2_array = getLocalTaxesFromRate($vatrate, 2, $mysoc);
             if (empty($obj->localtax2_type)) {
                 $obj->localtax2_type = $localtax2_array[0];
                 $obj->localtax2_tx = $localtax2_array[1];
             }
             if ($obj->localtax2_type == '7') {
                 $total_localtax2 += $obj->localtax2_tx;
                 $total_ttc += $obj->localtax2_tx;
             }
         }
     }
     $i++;
 }
 $db->free($resql);
 $fieldht = 'total_ht';
 $fieldtva = 'tva';
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:postorder.php

示例12: 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 . "',";
//.........这里部分代码省略.........
开发者ID:Albertopf,项目名称:prueba,代码行数:101,代码来源:contrat.class.php

示例13: 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;
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:facture.class.php

示例14: write_file


//.........这里部分代码省略.........
                 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
                 $pdf->SetXY($this->posxqty, $curY);
                 $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 3, $qty, 0, 'R');
                 // Enough for 6 chars
                 // Discount on line
                 if ($object->lines[$i]->remise_percent) {
                     $pdf->SetXY($this->posxdiscount - 2, $curY);
                     $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
                     $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
                 }
                 // Total HT line
                 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
                 $pdf->SetXY($this->postotalht, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
                 // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
                 $tvaligne = $object->lines[$i]->total_tva;
                 $localtax1ligne = $object->lines[$i]->total_localtax1;
                 $localtax2ligne = $object->lines[$i]->total_localtax2;
                 $localtax1_rate = $object->lines[$i]->localtax1_tx;
                 $localtax2_rate = $object->lines[$i]->localtax2_tx;
                 $localtax1_type = $object->lines[$i]->localtax1_type;
                 $localtax2_type = $object->lines[$i]->localtax2_type;
                 if ($object->remise_percent) {
                     $tvaligne -= $tvaligne * $object->remise_percent / 100;
                 }
                 if ($object->remise_percent) {
                     $localtax1ligne -= $localtax1ligne * $object->remise_percent / 100;
                 }
                 if ($object->remise_percent) {
                     $localtax2ligne -= $localtax2ligne * $object->remise_percent / 100;
                 }
                 $vatrate = (string) $object->lines[$i]->tva_tx;
                 // TODO : store local taxes types into object lines and remove this
                 $localtax1_array = getLocalTaxesFromRate($vatrate, 1, $mysoc);
                 $localtax2_array = getLocalTaxesFromRate($vatrate, 2, $mysoc);
                 if (!isset($localtax1_type)) {
                     $localtax1_type = $localtax1_array[0];
                 }
                 if (!isset($localtax2_type)) {
                     $localtax2_type = $localtax2_array[0];
                 }
                 //end TODO
                 // retrieve global local tax
                 if ($localtax1_type == '7') {
                     $localtax1_rate = $localtax1_array[1];
                 }
                 if ($localtax2_type == '7') {
                     $localtax2_rate = $localtax2_array[1];
                 }
                 if ($localtax1_type && ($localtax1ligne != 0 || $localtax1_type == '7')) {
                     $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
                 }
                 if ($localtax2_type && ($localtax2ligne != 0 || $localtax2_type == '7')) {
                     $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
                 }
                 if (($object->lines[$i]->info_bits & 0x1) == 0x1) {
                     $vatrate .= '*';
                 }
                 if (!isset($this->tva[$vatrate])) {
                     $this->tva[$vatrate] = '';
                 }
                 $this->tva[$vatrate] += $tvaligne;
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$pdf->SetDrawColor(190,190,200);
开发者ID:sergioeugenio,项目名称:Dolibarr37_berrypro_Modulo,代码行数:67,代码来源:pdf_berrypro.modules.php

示例15: 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
  * @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 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, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null)
 {
     global $mysoc;
     dol_syslog(get_class($this) . "::updateline {$id},{$desc},{$pu},{$vatrate},{$qty},{$idproduct},{$price_base_type},{$info_bits},{$type},{$remise_percent},{$fk_unit}", 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, $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];
     $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;
     }
     $line = new SupplierInvoiceLine($this->db);
     if ($line->fetch($id) < 1) {
         return -1;
     }
     $line->description = $desc;
     $line->subprice = $pu_ht;
     $line->pu_ht = $pu_ht;
     $line->pu_ttc = $pu_ttc;
     $line->qty = $qty;
     $line->remise_percent = $remise_percent;
     $line->tva_tx = $vatrate;
     $line->localtax1_tx = $txlocaltax1;
     $line->localtax2_tx = $txlocaltax2;
     $line->localtax1_type = $localtaxes_type[0];
     $line->localtax2_type = $localtaxes_type[2];
     $line->total_ht = $total_ht;
     $line->total_tva = $total_tva;
     $line->total_localtax1 = $total_localtax1;
     $line->total_localtax2 = $total_localtax2;
     $line->total_ttc = $total_ttc;
     $line->fk_product = $idproduct;
     $line->product_type = $product_type;
     $line->info_bits = $info_bits;
     $line->fk_unit = $fk_unit;
     $line->array_options = $array_options;
     $res = $line->update($notrigger);
     if ($res < 1) {
//.........这里部分代码省略.........
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:101,代码来源:fournisseur.facture.class.php


注:本文中的getLocalTaxesFromRate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。