本文整理汇总了PHP中get_localtax函数的典型用法代码示例。如果您正苦于以下问题:PHP get_localtax函数的具体用法?PHP get_localtax怎么用?PHP get_localtax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_localtax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePrice
/**
* Modify price of a product/Service
*
* @param double $newprice New price
* @param string $newpricebase HT or TTC
* @param User $user Object user that make change
* @param double $newvat New VAT Rate
* @param double $newminprice New price min
* @param int $level 0=standard, >0 = level if multilevel prices
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @param int $newpsq 1 if it has price by quantity
* @return int <0 if KO, >0 if OK
*/
function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = '', $level = 0, $newnpr = 0, $newpsq = 0)
{
global $conf, $langs;
$id = $this->id;
dol_syslog(get_class($this) . "::update_price id=" . $id . " newprice=" . $newprice . " newpricebase=" . $newpricebase . " newminprice=" . $newminprice . " level=" . $level . " npr=" . $newnpr);
// Clean parameters
if (empty($this->tva_tx)) {
$this->tva_tx = 0;
}
if (empty($newnpr)) {
$newnpr = 0;
}
// Check parameters
if ($newvat == '') {
$newvat = $this->tva_tx;
}
if (!empty($newminprice) && $newminprice > $newprice) {
$this->error = 'ErrorPriceCantBeLowerThanMinPrice';
return -1;
}
if ($newprice != '' || $newprice == 0) {
if ($newpricebase == 'TTC') {
$price_ttc = price2num($newprice, 'MU');
$price = price2num($newprice) / (1 + $newvat / 100);
$price = price2num($price, 'MU');
if ($newminprice != '' || $newminprice == 0) {
$price_min_ttc = price2num($newminprice, 'MU');
$price_min = price2num($newminprice) / (1 + $newvat / 100);
$price_min = price2num($price_min, 'MU');
} else {
$price_min = 0;
$price_min_ttc = 0;
}
} else {
$price = price2num($newprice, 'MU');
$price_ttc = $newnpr != 1 ? price2num($newprice) * (1 + $newvat / 100) : $price;
$price_ttc = price2num($price_ttc, 'MU');
if ($newminprice != '' || $newminprice == 0) {
$price_min = price2num($newminprice, 'MU');
$price_min_ttc = price2num($newminprice) * (1 + $newvat / 100);
$price_min_ttc = price2num($price_min_ttc, 'MU');
//print 'X'.$newminprice.'-'.$price_min;
} else {
$price_min = 0;
$price_min_ttc = 0;
}
}
//print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc;
//Local taxes
$localtax1 = get_localtax($newvat, 1);
$localtax2 = get_localtax($newvat, 2);
if (empty($localtax1)) {
$localtax1 = 0;
}
// If = '' then = 0
if (empty($localtax2)) {
$localtax2 = 0;
}
// If = '' then = 0
$this->db->begin();
// Ne pas mettre de quote sur les numeriques decimaux.
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
$sql = "UPDATE " . MAIN_DB_PREFIX . "product SET";
$sql .= " price_base_type='" . $newpricebase . "',";
$sql .= " price=" . $price . ",";
$sql .= " price_ttc=" . $price_ttc . ",";
$sql .= " price_min=" . $price_min . ",";
$sql .= " price_min_ttc=" . $price_min_ttc . ",";
$sql .= " localtax1_tx=" . ($localtax1 >= 0 ? $localtax1 : 'NULL') . ",";
$sql .= " localtax2_tx=" . ($localtax2 >= 0 ? $localtax2 : 'NULL') . ",";
$sql .= " tva_tx='" . price2num($newvat) . "',";
$sql .= " recuperableonly='" . $newnpr . "'";
$sql .= " WHERE rowid = " . $id;
dol_syslog(get_class($this) . "::update_price", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->price = $price;
$this->price_ttc = $price_ttc;
$this->price_min = $price_min;
$this->price_min_ttc = $price_min_ttc;
$this->price_base_type = $newpricebase;
$this->tva_tx = $newvat;
$this->tva_npr = $newnpr;
//Local taxes
$this->localtax1_tx = $localtax1;
$this->localtax2_tx = $localtax2;
// Price by quantity
//.........这里部分代码省略.........
示例2: Product
exit;
}
$prod = new Product($db);
$result = $prod->fetch($id);
if ($result <= 0)
{
dol_print_error($db,$prod->error);
exit;
}
$desc = $prod->description;
$tva_tx = get_default_tva($mysoc, $soc, $prod->id);
$localtax1_tx= get_localtax($tva_tx, 1, $soc);
$localtax2_tx= get_localtax($tva_tx, 2, $soc);
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
{
$pu_ht = $prod->multiprices[$soc->price_level];
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
$price_base_type = $prod->multiprices_base_type[$soc->price_level];
}
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
示例3: updatePrice
/**
* Modify price of a product/Service
*
* @param int $id Id of product/service to change
* @param double $newprice New price
* @param string $newpricebase HT or TTC
* @param User $user Object user that make change
* @param double $newvat New VAT Rate
* @param double $newminprice New price min
* @param int $level 0=standard, >0 = level if multilevel prices
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @return int <0 if KO, >0 if OK
*/
function updatePrice($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='',$newecotax=0, $level=0, $newnpr=0)
{
global $conf,$langs;
dol_syslog(get_class($this)."update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr);
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($newnpr)) $newnpr=0;
// Check parameters
if ($newvat == '') $newvat=$this->tva_tx;
if ($newprice!='' || $newprice==0)
{
if ($newpricebase == 'TTC')
{
$price_ttc = price2num($newprice,'MU');
$price = price2num($newprice) / (1 + ($newvat / 100));
$price = price2num($price,'MU');
if ($newminprice!='' || $newminprice==0)
{
$price_min_ttc = price2num($newminprice,'MU');
$price_min = price2num($newminprice) / (1 + ($newvat / 100));
$price_min = price2num($price_min,'MU');
}
else
{
$price_min=0;
$price_min_ttc=0;
}
$ecotax_ttc = price2num($newecotax,'MU');
$ecotax = price2num($newecotax) / (1 + ($newvat / 100));
$ecotax = price2num($ecotax,'MU');
}
else
{
$price = price2num($newprice,'MU');
$price_ttc = price2num($newprice) * (1 + ($newvat / 100));
$price_ttc = price2num($price_ttc,'MU');
if ($newminprice!='' || $newminprice==0)
{
$price_min = price2num($newminprice,'MU');
$price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100));
$price_min_ttc = price2num($price_min_ttc,'MU');
//print 'X'.$newminprice.'-'.$price_min;
}
else
{
$price_min=0;
$price_min_ttc=0;
}
$ecotax = price2num($newecotax,'MU');
$ecotax_ttc = price2num($newecotax) * (1 + ($newvat / 100));
$ecotax_ttc = price2num($ecotax_ttc,'MU');
}
//print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc;
//Local taxes
$localtax1=get_localtax($newvat,1);
$localtax2=get_localtax($newvat,2);
if (empty($localtax1)) $localtax1=0; // If = '' then = 0
if (empty($localtax2)) $localtax2=0; // If = '' then = 0
// Ne pas mettre de quote sur les numeriques decimaux.
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
$sql = "UPDATE ".MAIN_DB_PREFIX."product SET";
$sql.= " price_base_type='".$newpricebase."',";
$sql.= " price=".$price.",";
$sql.= " price_ttc=".$price_ttc.",";
$sql.= " price_min=".$price_min.",";
$sql.= " price_min_ttc=".$price_min_ttc.",";
$sql.= " ecotax=".$ecotax.",";
$sql.= " ecotax_ttc=".$ecotax_ttc.",";
$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').",";
$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').",";
$sql.= " tva_tx='".price2num($newvat)."',";
$sql.= " recuperableonly='".$newnpr."'";
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."update_price sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
//.........这里部分代码省略.........
示例4: create
//.........这里部分代码省略.........
if ($result < 0) {
$this->error = $newinvoiceline->error;
$error++;
break;
}
}
} else {
$fk_parent_line = 0;
dol_syslog("There is " . count($this->lines) . " lines that are array lines");
foreach ($this->lines as $i => $val) {
if (($this->lines[$i]->info_bits & 0x1) == 0) {
// Reset fk_parent_line for no child products and special product
if ($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line) || $this->lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
$result = $this->addline($this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, $this->lines[$i]->tva_tx, $this->lines[$i]->localtax1_tx, $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, $this->lines[$i]->remise_percent, $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->fk_code_ventilation, $this->lines[$i]->info_bits, $this->lines[$i]->fk_remise_except, 'HT', 0, $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, $this->element, $this->lines[$i]->id, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, $this->lines[$i]->situation_percent, $this->lines[$i]->fk_prev_id, $this->lines[$i]->fk_unit);
if ($result < 0) {
$this->error = $this->db->lasterror();
dol_print_error($this->db);
$this->db->rollback();
return -1;
}
// Defined the new fk_parent_line
if ($result > 0 && $this->lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
}
}
}
/*
* Insert lines of predefined invoices
*/
if (!$error && $this->fac_rec > 0) {
foreach ($_facrec->lines as $i => $val) {
if ($_facrec->lines[$i]->fk_product) {
$prod = new Product($this->db);
$res = $prod->fetch($_facrec->lines[$i]->fk_product);
}
$tva_tx = get_default_tva($mysoc, $soc, $prod->id);
$localtax1_tx = get_localtax($tva_tx, 1, $soc);
$localtax2_tx = get_localtax($tva_tx, 2, $soc);
$result_insert = $this->addline($_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $_facrec->lines[$i]->fk_product, $_facrec->lines[$i]->remise_percent, '', '', 0, 0, '', 'HT', 0, $_facrec->lines[$i]->product_type, $_facrec->lines[$i]->rang, $_facrec->lines[$i]->special_code, '', 0, 0, null, 0, $_facrec->lines[$i]->label, null, $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit);
if ($result_insert < 0) {
$error++;
$this->error = $this->db->error();
break;
}
}
}
if (!$error) {
$result = $this->update_price(1);
if ($result > 0) {
$action = 'create';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('invoicedao'));
$parameters = array('invoiceid' => $this->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
} else {
if ($reshook < 0) {
$error++;
}
}
// Call trigger
$result = $this->call_trigger('BILL_CREATE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
if (!$error) {
$this->db->commit();
return $this->id;
} else {
$this->db->rollback();
return -4;
}
} else {
$this->error = $langs->trans('FailedToUpdatePrice');
$this->db->rollback();
return -3;
}
} else {
dol_syslog(get_class($this) . "::create error " . $this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
} else {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
}
示例5: getLocalTaxesFromRate
/**
* Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
* TODO
* This function is also called to retrieve type for building PDF. Such call of function must be removed.
* Instead this function must be called when adding a line to get the array of localtax and type, and then
* provide it to the function calcul_price_total.
*
* @param float $vatrate VAT Rate
* @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2)
* @param Societe $buyer Company object
* @param Societe $seller Company object
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
*/
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
{
global $db, $mysoc;
dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
$vatratecleaned = $vatrate;
if (preg_match('/^(.*)\\s*\\((.*)\\)$/', $vatrate, $reg)) {
$vatratecleaned = $reg[1];
$vatratecode = $reg[2];
}
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
if ($mysoc->country_code == 'ES') {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
} else {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
}
$sql .= " AND t.taux = " . (double) $vatratecleaned . " AND t.active = 1";
if ($vatratecode) {
$sql .= " AND t.code ='" . $vatratecode . "'";
}
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($local == 1) {
if (!isOnlyOneLocalTax(1)) {
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, $obj->localtax1, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} elseif ($local == 2) {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} else {
if (!isOnlyOneLocalTax(1)) {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} else {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
}
}
}
return 0;
}
示例6: dol_mktime
$date_start = '';
$date_end = '';
$date_start = dol_mktime(0, 0, 0, $_POST['date_start' . $suffixe . 'month'], $_POST['date_start' . $suffixe . 'day'], $_POST['date_start' . $suffixe . 'year']);
$date_end = dol_mktime(0, 0, 0, $_POST['date_end' . $suffixe . 'month'], $_POST['date_end' . $suffixe . 'day'], $_POST['date_end' . $suffixe . 'year']);
$description = dol_htmlcleanlastbr($_POST['desc']);
$up_ht = GETPOST('pu') ? GETPOST('pu') : GETPOST('subprice');
// Define info_bits
$info_bits = 0;
if (preg_match('/\\*/', $_POST['tva_tx'])) {
$info_bits |= 0x1;
}
// Define vat_rate
$vat_rate = $_POST['tva_tx'];
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->client);
$localtax2_rate = get_localtax($vat_rate, 2, $object->client);
// Check parameters
if (empty($_POST['productid']) && $_POST["type"] < 0) {
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")) . '</div>';
$result = -1;
}
// Check minimum price
if (!empty($_POST['productid'])) {
$productid = $_POST['productid'];
$product = new Product($db);
$product->fetch($productid);
$type = $product->type;
$price_min = $product->price_min;
if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) {
$price_min = $product->multiprices_min[$object->client->price_level];
}
示例7: add_product
/**
* Add line into array
* $this->client doit etre charge
* @param idproduct Id du produit a ajouter
* @param qty Quantite
* @param remise_percent Remise relative effectuee sur le produit
* @param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @return void
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
*/
function add_product($idproduct, $qty, $remise_percent = 0, $date_start = '', $date_end = '')
{
global $conf, $mysoc;
if (!$qty) {
$qty = 1;
}
if ($idproduct > 0) {
$prod = new Product($this->db);
$prod->fetch($idproduct);
$tva_tx = get_default_tva($mysoc, $this->client, $prod->id);
$localtax1_tx = get_localtax($tva_tx, 1, $this->client);
$localtax2_tx = get_localtax($tva_tx, 2, $this->client);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) {
$price = $prod->multiprices[$this->client->price_level];
} else {
$price = $prod->price;
}
$line = new OrderLine($this->db);
$line->fk_product = $idproduct;
$line->desc = $prod->description;
$line->qty = $qty;
$line->subprice = $price;
$line->remise_percent = $remise_percent;
$line->tva_tx = $tva_tx;
$line->localtax1_tx = $localtax1_tx;
$line->localtax2_tx = $localtax2_tx;
$line->ref = $prod->ref;
$line->libelle = $prod->libelle;
$line->product_desc = $prod->description;
// Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
// Save the start and end date of the line in the object
if ($date_start) {
$line->date_start = $date_start;
}
if ($date_end) {
$line->date_end = $date_end;
}
$this->lines[] = $line;
/** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
{
$prod = new Product($this->db, $idproduct);
$prod -> get_sousproduits_arbo ();
$prods_arbo = $prod->get_each_prod();
if(sizeof($prods_arbo) > 0)
{
foreach($prods_arbo as $key => $value)
{
// print "id : ".$value[1].' :qty: '.$value[0].'<br>';
if(! in_array($value[1],$this->products))
$this->add_product($value[1], $value[0]);
}
}
}
**/
}
}
示例8: createFactureFromObject
static function createFactureFromObject(&$object)
{
global $db, $conf, $user, $langs;
dol_include_once('/compta/facture/class/facture.class.php');
$langs->load('grapefruit@grapefruit');
$dateinvoice = dol_mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$f = new Facture($db);
$f->socid = $object->socid;
$f->type = Facture::TYPE_STANDARD;
$f->number = $_POST['facnumber'];
$f->date = $dateinvoice;
$f->note_public = $object->note_public;
$f->note_private = $object->note_private;
$f->ref_client = $object->ref_client;
$f->fk_project = $object->fk_project;
$f->cond_reglement_id = $object->cond_reglement_id;
$f->mode_reglement_id = $object->mode_reglement_id;
$origin = 'commande';
$originid = $object->id;
$f->linked_objects[$origin] = $originid;
$id = $f->create($user);
$lines = $object->lines;
if (empty($lines) && method_exists($object, 'fetch_lines')) {
$object->fetch_lines();
$lines = $object->lines;
}
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++) {
$label = !empty($lines[$i]->label) ? $lines[$i]->label : '';
$desc = !empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle;
if ($f->situation_counter == 1) {
$lines[$i]->situation_percent = 0;
}
if ($lines[$i]->subprice < 0) {
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $f->socid;
$discount->amount_ht = abs($lines[$i]->total_ht);
$discount->amount_tva = abs($lines[$i]->total_tva);
$discount->amount_ttc = abs($lines[$i]->total_ttc);
$discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id;
$discount->description = $desc;
$discountid = $discount->create($user);
if ($discountid > 0) {
$result = $f->insert_discount($discountid);
// This include link_to_invoice
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
}
} else {
// Positive line
$product_type = $lines[$i]->product_type ? $lines[$i]->product_type : 0;
// Date start
$date_start = false;
if ($lines[$i]->date_debut_prevue) {
$date_start = $lines[$i]->date_debut_prevue;
}
if ($lines[$i]->date_debut_reel) {
$date_start = $lines[$i]->date_debut_reel;
}
if ($lines[$i]->date_start) {
$date_start = $lines[$i]->date_start;
}
// Date end
$date_end = false;
if ($lines[$i]->date_fin_prevue) {
$date_end = $lines[$i]->date_fin_prevue;
}
if ($lines[$i]->date_fin_reel) {
$date_end = $lines[$i]->date_fin_reel;
}
if ($lines[$i]->date_end) {
$date_end = $lines[$i]->date_end;
}
// Reset fk_parent_line for no child products and special product
if ($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
// Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
$lines[$i]->fetch_optionals($lines[$i]->rowid);
$array_options = $lines[$i]->array_options;
}
// View third's localtaxes for now
$localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $f->client);
$localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $f->client);
$result = $f->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $f->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;
} else {
$lineid = 0;
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
//.........这里部分代码省略.........
示例9: add_product
/**
* Add line into array products
* $this->client doit etre charge
*
* @param int $idproduct Product Id to add
* @param int $qty Quantity
* @param int $remise_percent Discount effected on Product
* @return int <0 if KO, >0 if OK
*
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
*/
function add_product($idproduct, $qty, $remise_percent = 0)
{
global $conf, $mysoc;
if (!$qty) {
$qty = 1;
}
dol_syslog(get_class($this) . "::add_product {$idproduct}, {$qty}, {$remise_percent}");
if ($idproduct > 0) {
$prod = new Product($this->db);
$prod->fetch($idproduct);
$productdesc = $prod->description;
$tva_tx = get_default_tva($mysoc, $this->client, $prod->id);
$tva_npr = get_default_npr($mysoc, $this->client, $prod->id);
if (empty($tva_tx)) {
$tva_npr = 0;
}
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $this->client, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $this->client, $tva_npr);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) {
$price = $prod->multiprices[$this->client->price_level];
} else {
$price = $prod->price;
}
$line = new SupplierProposalLine($this->db);
$line->fk_product = $idproduct;
$line->desc = $productdesc;
$line->qty = $qty;
$line->subprice = $price;
$line->remise_percent = $remise_percent;
$line->tva_tx = $tva_tx;
$this->lines[] = $line;
}
}
示例10: ContratLigne
}
}
}
if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"])
{
$objectline = new ContratLigne($db);
if ($objectline->fetch($_POST["elrowid"]))
{
$db->begin();
if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture;
if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture;
$localtax1_tx=get_localtax($_POST["eltva_tx"],1,$object->client);
$localtax2_tx=get_localtax($_POST["eltva_tx"],2,$object->client);
$objectline->description=$_POST["eldesc"];
$objectline->price_ht=$_POST["elprice"];
$objectline->subprice=$_POST["elprice"];
$objectline->qty=$_POST["elqty"];
$objectline->remise_percent=$_POST["elremise_percent"];
$objectline->tva_tx=$_POST["eltva_tx"];
$objectline->localtax1_tx=$localtax1_tx;
$objectline->localtax2_tx=$localtax2_tx;
$objectline->date_ouverture_prevue=$date_start_update;
$objectline->date_ouverture=$date_start_real_update;
$objectline->date_fin_validite=$date_end_update;
$objectline->date_cloture=$date_end_real_update;
$objectline->fk_user_cloture=$user->id;
示例11: updatePrice
/**
* Modify price of a product/Service
*
* @param double $newprice New price
* @param string $newpricebase HT or TTC
* @param User $user Object user that make change
* @param double $newvat New VAT Rate (For example 8.5. Should not be a string)
* @param double $newminprice New price min
* @param int $level 0=standard, >0 = level if multilevel prices
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @param int $newpsq 1 if it has price by quantity
* @param int $ignore_autogen Used to avoid infinite loops
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @return int <0 if KO, >0 if OK
*/
function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = '', $level = 0, $newnpr = 0, $newpsq = 0, $ignore_autogen = 0, $localtaxes_array = array())
{
global $conf, $langs;
$id = $this->id;
dol_syslog(get_class($this) . "::update_price id=" . $id . " newprice=" . $newprice . " newpricebase=" . $newpricebase . " newminprice=" . $newminprice . " level=" . $level . " npr=" . $newnpr);
// Clean parameters
if (empty($this->tva_tx)) {
$this->tva_tx = 0;
}
if (empty($newnpr)) {
$newnpr = 0;
}
// Check parameters
if ($newvat == '') {
$newvat = $this->tva_tx;
}
// If multiprices are enabled, then we check if the current product is subject to price autogeneration
// Price will be modified ONLY when the first one is the one that is being modified
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && $level == 1) {
return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq);
}
if (!empty($newminprice) && $newminprice > $newprice) {
$this->error = 'ErrorPriceCantBeLowerThanMinPrice';
return -1;
}
if ($newprice != '' || $newprice == 0) {
if ($newpricebase == 'TTC') {
$price_ttc = price2num($newprice, 'MU');
$price = price2num($newprice) / (1 + $newvat / 100);
$price = price2num($price, 'MU');
if ($newminprice != '' || $newminprice == 0) {
$price_min_ttc = price2num($newminprice, 'MU');
$price_min = price2num($newminprice) / (1 + $newvat / 100);
$price_min = price2num($price_min, 'MU');
} else {
$price_min = 0;
$price_min_ttc = 0;
}
} else {
$price = price2num($newprice, 'MU');
$price_ttc = $newnpr != 1 ? price2num($newprice) * (1 + $newvat / 100) : $price;
$price_ttc = price2num($price_ttc, 'MU');
if ($newminprice != '' || $newminprice == 0) {
$price_min = price2num($newminprice, 'MU');
$price_min_ttc = price2num($newminprice) * (1 + $newvat / 100);
$price_min_ttc = price2num($price_min_ttc, 'MU');
//print 'X'.$newminprice.'-'.$price_min;
} else {
$price_min = 0;
$price_min_ttc = 0;
}
}
//print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc;
if (count($localtaxes_array) > 0) {
$localtaxtype1 = $localtaxes_array['0'];
$localtax1 = $localtaxes_array['1'];
$localtaxtype2 = $localtaxes_array['2'];
$localtax2 = $localtaxes_array['3'];
} else {
$localtaxtype1 = '0';
$localtax1 = get_localtax($newvat, 1);
$localtaxtype2 = '0';
$localtax2 = get_localtax($newvat, 2);
}
if (empty($localtax1)) {
$localtax1 = 0;
}
// If = '' then = 0
if (empty($localtax2)) {
$localtax2 = 0;
}
// If = '' then = 0
$this->db->begin();
// Ne pas mettre de quote sur les numeriques decimaux.
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
$sql = "UPDATE " . MAIN_DB_PREFIX . "product SET";
$sql .= " price_base_type='" . $newpricebase . "',";
$sql .= " price=" . $price . ",";
$sql .= " price_ttc=" . $price_ttc . ",";
$sql .= " price_min=" . $price_min . ",";
$sql .= " price_min_ttc=" . $price_min_ttc . ",";
$sql .= " localtax1_tx=" . ($localtax1 >= 0 ? $localtax1 : 'NULL') . ",";
$sql .= " localtax2_tx=" . ($localtax2 >= 0 ? $localtax2 : 'NULL') . ",";
$sql .= " localtax1_type=" . ($localtaxtype1 != '' ? "'" . $localtaxtype1 . "'" : "'0'") . ",";
$sql .= " localtax2_type=" . ($localtaxtype2 != '' ? "'" . $localtaxtype2 . "'" : "'0'") . ",";
//.........这里部分代码省略.........
示例12: price2num
$type = $product->type;
$result=$facfou->addline($label, $product->fourn_pu, $tvatx, $localtax2tx, $localtax2tx ,$_POST['qty'], $idprod);
}
if ($idprod == -1)
{
// Quantity too low
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans("ErrorQtyTooLowForThisSupplier").'</div>';
}
}
else
{
$tauxtva = price2num($_POST['tauxtva']);
$localtax1tx= get_localtax($tauxtva, 1, $societe);
$localtax2tx= get_localtax($tauxtva, 2, $societe);
if (! $_POST['label'])
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
}
else
{
$type = $_POST["type"];
if (! empty($_POST['amount']))
{
$ht = price2num($_POST['amount']);
$price_base_type = 'HT';
//$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0)
$result=$facfou->addline($_POST['label'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type);
示例13: getLocalTaxesFromRate
/**
* Get type and rate of localtaxes for a particular vat rate/country fo thirdparty
* TODO
* This function is also called to retrieve type for building PDF. Such call of function must be removed.
* Instead this function must be called when adding a line to get (array of localtax and type) and
* provide it to the function calcul_price_total.
*
* @param float $vatrate VAT Rate
* @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2)
* @param Societe $buyer Company object
* @param Societe $seller Company object
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
*/
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller)
{
global $db;
dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
$sql .= " AND t.taux = " . (double) $vatrate . " AND t.active = 1";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($local == 1) {
if (!isOnlyOneLocalTax(1)) {
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, $obj->localtax1, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} elseif ($local == 2) {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} else {
if (!isOnlyOneLocalTax(1)) {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
} else {
if (!isOnlyOneLocalTax(2)) {
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
} else {
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
}
}
}
}
return 0;
}
示例14: get_localtax
$localtax2tx = get_localtax($tvatx, 2, $mysoc, $object->thirdparty);
$remise_percent = GETPOST('remise_percent');
$type = $product->type;
$result = $object->addline($label, $product->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $_POST['qty'], $idprod, $remise_percent, '', '', 0, $npr);
}
if ($idprod == -1) {
// Quantity too low
$langs->load("errors");
$mesg = '<div class="error">' . $langs->trans("ErrorQtyTooLowForThisSupplier") . '</div>';
}
} else {
$npr = preg_match('/\\*/', $_POST['tauxtva']) ? 1 : 0;
$tauxtva = str_replace('*', '', $_POST["tauxtva"]);
$tauxtva = price2num($tauxtva);
$localtax1tx = get_localtax($tauxtva, 1, $mysoc, $object->thirdparty);
$localtax2tx = get_localtax($tauxtva, 2, $mysoc, $object->thirdparty);
$remise_percent = GETPOST('remise_percent');
if (!$_POST['dp_desc']) {
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")) . '</div>';
} else {
$type = $_POST["type"];
if (!empty($_POST['amount'])) {
$ht = price2num($_POST['amount']);
$price_base_type = 'HT';
//$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0)
$result = $object->addline($_POST['dp_desc'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
} else {
$ttc = price2num($_POST['amountttc']);
$ht = $ttc / (1 + $tauxtva / 100);
$price_base_type = 'HT';
$result = $object->addline($_POST['dp_desc'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type);
示例15: Societe
}
if ($thirpdartyid > 0) {
$soc = new Societe($db);
$result = $soc->fetch($thirpdartyid);
if ($result <= 0) {
dol_print_error($db, $soc->error);
exit;
}
$desc = $object->description;
$tva_tx = get_default_tva($mysoc, $soc, $object->id);
$tva_npr = get_default_npr($mysoc, $soc, $object->id);
if (empty($tva_tx)) {
$tva_npr = 0;
}
$localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
$pu_ht = $object->price;
$pu_ttc = $object->price_ttc;
$price_base_type = $object->price_base_type;
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
$pu_ht = $object->multiprices[$soc->price_level];
$pu_ttc = $object->multiprices_ttc[$soc->price_level];
$price_base_type = $object->multiprices_base_type[$soc->price_level];
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) {
if (count($prodcustprice->lines) > 0) {