本文整理汇总了PHP中get_default_tva函数的典型用法代码示例。如果您正苦于以下问题:PHP get_default_tva函数的具体用法?PHP get_default_tva怎么用?PHP get_default_tva使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_tva函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Product
{
dol_print_error($db,$soc->error);
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];
}
示例2: dol_clone
print '<input class="flat" name="qty" size="5" value="' . $quantity . '">';
}
print '</td></tr>';
// Vat rate
$default_vat = '';
// We don't have supplier, so we try to guess.
// For this we build a fictive supplier with same properties than user but using vat)
$mysoc2 = dol_clone($mysoc);
$mysoc2->name = 'Fictive seller with same country';
$mysoc2->tva_assuj = 1;
$default_vat = get_default_tva($mysoc2, $mysoc, $product->id, 0);
print '<tr><td class="fieldrequired">' . $langs->trans("VATRateForSupplierProduct") . '</td>';
print '<td>';
//print $form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
if (!empty($socid)) {
$default_vat = get_default_tva($supplier, $mysoc, $product->id);
if (empty($default_vat)) {
$default_vat = $product->tva_tx;
}
}
print '<input type="text" class="flat" size="5" name="tva_tx" value="' . (GETPOST("tva_tx") ? vatrate(GETPOST("tva_tx")) : ($default_vat != '' ? vatrate($default_vat) : '')) . '">';
print '</td></tr>';
if (!empty($conf->dynamicprices->enabled)) {
// Price mode selector
print '<tr><td class="fieldrequired">' . $langs->trans("PriceMode") . '</td><td>';
$price_expression = new PriceExpression($db);
$price_expression_list = array(0 => $langs->trans("PriceNumeric"));
//Put the numeric mode as first option
foreach ($price_expression->list_price_expression() as $entry) {
$price_expression_list[$entry->id] = $entry->title;
}
示例3: 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;
}
}
示例4: testGetDefaultTva
/**
* testGetDefaultTva
*
* @return void
*/
public function testGetDefaultTva()
{
global $conf, $user, $langs, $db;
$this->savconf = $conf;
$this->savuser = $user;
$this->savlangs = $langs;
$this->savdb = $db;
// Sellers
$companyfrnovat = new Societe($db);
$companyfrnovat->country_code = 'FR';
$companyfrnovat->tva_assuj = 0;
$companyfr = new Societe($db);
$companyfr->country_code = 'FR';
$companyfr->tva_assuj = 1;
$companyfr->tva_intra = 'FR9999';
// Buyers
$companymc = new Societe($db);
$companymc->country_code = 'MC';
$companymc->tva_assuj = 1;
$companyfr->tva_intra = 'MC9999';
$companyit = new Societe($db);
$companyit->country_code = 'IT';
$companyit->tva_assuj = 1;
$companyit->tva_intra = 'IT99999';
$companyde = new Societe($db);
$companyde->country_code = 'DE';
$companyde->tva_assuj = 1;
$companyde->tva_intra = 'DE99999';
$notcompanyde = new Societe($db);
$notcompanyde->country_code = 'DE';
$notcompanyde->tva_assuj = 0;
$notcompanyde->tva_intra = '';
$notcompanyde->typent_code = 'TE_PRIVATE';
$companyus = new Societe($db);
$companyus->country_code = 'US';
$companyus->tva_assuj = 1;
$companyus->tva_intra = '';
// Test RULE 0 (FR-DE)
// Not tested
// Test RULE 1
$vat = get_default_tva($companyfrnovat, $companymc, 0);
$this->assertEquals(0, $vat, 'RULE 1');
// Test RULE 2 (FR-FR)
$vat = get_default_tva($companyfr, $companyfr, 0);
$this->assertEquals(20, $vat, 'RULE 2');
// Test RULE 2 (FR-MC)
$vat = get_default_tva($companyfr, $companymc, 0);
$this->assertEquals(20, $vat, 'RULE 2');
// Test RULE 3 (FR-DE company)
$vat = get_default_tva($companyfr, $companyit, 0);
$this->assertEquals(0, $vat, 'RULE 3');
// Test RULE 4 (FR-DE not a company)
$vat = get_default_tva($companyfr, $notcompanyde, 0);
$this->assertEquals(20, $vat, 'RULE 4');
// Test RULE 5 (FR-US)
$vat = get_default_tva($companyfr, $companyus, 0);
$this->assertEquals(0, $vat, 'RULE 5');
// We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on.
$conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1;
// Test RULE 1 (FR-US)
$vat = get_default_tva($companyfr, $companyus, 0);
$this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');
// Test RULE 2 (FR-FR)
$vat = get_default_tva($companyfr, $companyfr, 0);
$this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC');
// Test RULE 3 (FR-DE company)
$vat = get_default_tva($companyfr, $companyde, 0);
$this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC');
// Test RULE 4 (FR-DE not a company)
$vat = get_default_tva($companyfr, $notcompanyde, 0);
$this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC');
// Test RULE 5 (FR-US)
$vat = get_default_tva($companyfr, $companyus, 0);
$this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC');
}
示例5: get_default_tva
$result = $invoice->create($user);
if ($result <= 0) {
$errmsg = $invoice->error;
$errmsgs = $invoice->errors;
$error++;
}
}
if (!$error) {
// Add line to draft invoice
$idprodsubscription = 0;
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
}
$vattouse = 0;
if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') {
$vattouse = get_default_tva($mysoc, $mysoc, $idprodsubscription);
}
//print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
$result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datecotisation, $datesubend, 0, 0, '', 'TTC', $cotisation, 1);
if ($result <= 0) {
$errmsg = $invoice->error;
$error++;
}
}
if (!$error) {
// Validate invoice
$result = $invoice->validate($user);
if ($result <= 0) {
$errmsg = $invoice->error;
$errmsgs = $invoice->errors;
$error++;
示例6: 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]);
}
}
}
**/
}
}
示例7: load_tva
/**
* \brief Output an HTML select vat rate
* \param htmlname Nom champ html
* \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
* \param societe_vendeuse Objet societe vendeuse
* \param societe_acheteuse Objet societe acheteuse
* \param idprod Id product
* \param info_bits Miscellanous information on line
* \param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* \remarks Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Sinon la TVA proposee par defaut=0. Fin de regle.
*/
function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '')
{
global $langs, $conf, $mysoc;
$return = '';
$txtva = array();
$libtva = array();
$nprtva = array();
// Define defaultnpr and defaultttx
$defaultnpr = $info_bits & 0x1;
$defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
$defaulttx = str_replace('*', '', $selectedrate);
// Check parameters
if (is_object($societe_vendeuse) && !$societe_vendeuse->pays_code) {
if ($societe_vendeuse->id == $mysoc->id) {
$return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
} else {
$return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
}
return $return;
}
//var_dump($societe_acheteuse);
//print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
//exit;
// Get list of all VAT rates to show
// First we defined code_pays to use to find list
if (is_object($societe_vendeuse)) {
$code_pays = "'" . $societe_vendeuse->pays_code . "'";
} else {
$code_pays = "'" . $mysoc->pays_code . "'";
// Pour compatibilite ascendente
}
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
if (!$societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany()) {
// We also add the buyer
if (is_numeric($type)) {
if ($type == 1) {
$code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
}
} else {
if (!$idprod) {
$code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
} else {
$prodstatic = new Product($this->db);
$prodstatic->fetch($idprod);
if ($prodstatic->type == 1) {
$code_pays .= ",'" . $societe_acheteuse->pays_code . "'";
}
}
}
}
}
// Now we get list
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_pays as p";
$sql .= " WHERE t.fk_pays = p.rowid";
$sql .= " AND t.active = 1";
$sql .= " AND p.code in (" . $code_pays . ")";
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num) {
for ($i = 0; $i < $num; $i++) {
$obj = $this->db->fetch_object($resql);
$txtva[$i] = $obj->taux;
$libtva[$i] = $obj->taux . '%';
$nprtva[$i] = $obj->recuperableonly;
}
} else {
$return .= '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $code_pays) . '</font>';
}
} else {
$return .= '<font class="error">' . $this->db->error() . '</font>';
}
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
$defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
$defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
}
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
$defaulttx = $txtva[sizeof($txtva) - 1];
}
$nbdetaux = sizeof($txtva);
//.........这里部分代码省略.........
示例8: 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);
// local taxes
$localtax1_tx = get_default_localtax($mysoc, $this->client, 1, $prod->tva_tx);
$localtax2_tx = get_default_localtax($mysoc, $this->client, 2, $prod->tva_tx);
// multiprix
if ($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) {
$price = $prod->multiprices[$this->client->price_level];
} else {
$price = $prod->price;
}
$line = new PropaleLigne($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;
}
}
示例9: testGetDefaultTva
/**
* testGetDefaultTva
*
* @return void
*/
public function testGetDefaultTva()
{
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$companyfrnovat=new Societe($db);
$companyfrnovat->country_code='FR';
$companyfrnovat->tva_assuj=0;
$companyfr=new Societe($db);
$companyfr->country_code='FR';
$companyfr->tva_assuj=1;
$companymo=new Societe($db);
$companymo->country_code='MC';
$companymo->tva_assuj=1;
$companyit=new Societe($db);
$companyit->country_code='IT';
$companyit->tva_assuj=1;
$companyit->tva_intra='IT99999';
$notcompanyit=new Societe($db);
$notcompanyit->country_code='IT';
$notcompanyit->tva_assuj=1;
$notcompanyit->tva_intra='';
$notcompanyit->typent_code='TE_PRIVATE';
$companyus=new Societe($db);
$companyus->country_code='US';
$companyus->tva_assuj=1;
$companyus->tva_intra='';
// Test RULE 1-2
$vat=get_default_tva($companyfrnovat,$companymo,0);
$this->assertEquals(0,$vat);
// Test RULE 3 (FR-FR)
$vat=get_default_tva($companyfr,$companyfr,0);
$this->assertEquals(19.6,$vat);
// Test RULE 3 (FR-MC)
$vat=get_default_tva($companyfr,$companymo,0);
$this->assertEquals(19.6,$vat);
// Test RULE 4 (FR-IT)
$vat=get_default_tva($companyfr,$companyit,0);
$this->assertEquals(0,$vat);
// Test RULE 5 (FR-IT)
$vat=get_default_tva($companyfr,$notcompanyit,0);
$this->assertEquals(19.6,$vat);
// Test RULE 6 (FR-IT)
// Not tested
// Test RULE 7 (FR-US)
$vat=get_default_tva($companyfr,$companyus,0);
$this->assertEquals(0,$vat);
}
示例10: get_default_tva
print '<td align="right">';
if (! $qualifiedfortotal) print '<strike>';
print (isset($total_ht_by_line)?price($total_ht_by_line):' ');
if (! $qualifiedfortotal) print '</strike>';
if ($warning) print ' '.img_warning($warning);
print '</td>';
}
else print '<td></td>';
// Amount inc tax
if (empty($value['disableamount']))
{
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
elseif ($tablename == 'projet_task')
{
$defaultvat = get_default_tva($mysoc, $mysoc);
$total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT');
}
else
{
$total_ttc_by_line=$element->total_ttc;
}
print '<td align="right">';
if (! $qualifiedfortotal) print '<strike>';
print (isset($total_ttc_by_line)?price($total_ttc_by_line):' ');
if (! $qualifiedfortotal) print '</strike>';
if ($warning) print ' '.img_warning($warning);
print '</td>';
}
else print '<td></td>';
示例11: load_tva
/**
* Output an HTML select vat rate
*
* @param string $htmlname Nom champ html
* @param float $selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
* @param Societe $societe_vendeuse Objet societe vendeuse
* @param Societe $societe_acheteuse Objet societe acheteuse
* @param int $idprod Id product
* @param int $info_bits Miscellaneous information on line (1 for NPR)
* @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
* Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle.
* Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
* Sinon la TVA proposee par defaut=0. Fin de regle.
* @param bool $options_only Return options only (for ajax treatment)
* @return string
*/
function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false)
{
global $langs, $conf, $mysoc;
$return = '';
$txtva = array();
$libtva = array();
$nprtva = array();
// Define defaultnpr and defaultttx
$defaultnpr = $info_bits & 0x1;
$defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
$defaulttx = str_replace('*', '', $selectedrate);
// Check parameters
if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
if ($societe_vendeuse->id == $mysoc->id) {
$return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
} else {
$return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
}
return $return;
}
//var_dump($societe_acheteuse);
//print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->country_code." buyer=".$societe_acheteuse->country_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
//exit;
// Define list of countries to use to search VAT rates to show
// First we defined code_country to use to find list
if (is_object($societe_vendeuse)) {
$code_country = "'" . $societe_vendeuse->country_code . "'";
} else {
$code_country = "'" . $mysoc->country_code . "'";
// Pour compatibilite ascendente
}
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
if (!$societe_vendeuse->isInEEC() && (!is_object($societe_acheteuse) || $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany())) {
// We also add the buyer
if (is_numeric($type)) {
if ($type == 1) {
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
}
} else {
if (!$idprod) {
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
} else {
$prodstatic = new Product($this->db);
$prodstatic->fetch($idprod);
if ($prodstatic->type == 1) {
$code_country .= ",'" . $societe_acheteuse->country_code . "'";
}
}
}
}
}
// Now we get list
$num = $this->load_cache_vatrates($code_country);
if ($num > 0) {
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
$defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
$defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
}
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
$defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
} else {
$defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
}
}
// Disabled if seller is not subject to VAT
$disabled = false;
$title = '';
if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") {
$title = ' title="' . $langs->trans('VATIsNotUsed') . '"';
$disabled = true;
}
if (!$options_only) {
$return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled="disabled"' : '') . $title . '>';
}
foreach ($this->cache_vatrates as $rate) {
// Keep only 0 if seller is not subject to VAT
if ($disabled && $rate['txtva'] != 0) {
//.........这里部分代码省略.........
示例12: load_tva
/**
* Output an HTML select vat rate
*
* @param string $htmlname Nom champ html
* @param float $selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
* @param Societe $societe_vendeuse Objet societe vendeuse
* @param Societe $societe_acheteuse Objet societe acheteuse
* @param int $idprod Id product
* @param int $info_bits Miscellaneous information on line (1 for NPR)
* @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Sinon la TVA proposee par defaut=0. Fin de regle.
* @param bool $options_only Return options only (for ajax treatment)
* @return void
*/
function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false)
{
global $langs, $conf, $mysoc;
$return = '';
$txtva = array();
$libtva = array();
$nprtva = array();
// Define defaultnpr and defaultttx
$defaultnpr = $info_bits & 0x1;
$defaultnpr = preg_match('/\\*/', $selectedrate) ? 1 : $defaultnpr;
$defaulttx = str_replace('*', '', $selectedrate);
// Check parameters
if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
if ($societe_vendeuse->id == $mysoc->id) {
$return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
} else {
$return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
}
return $return;
}
//var_dump($societe_acheteuse);
//print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->country_code." buyer=".$societe_acheteuse->country_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type";
//exit;
// Get list of all VAT rates to show
// First we defined code_pays to use to find list
if (is_object($societe_vendeuse)) {
$code_pays = "'" . $societe_vendeuse->country_code . "'";
} else {
$code_pays = "'" . $mysoc->country_code . "'";
// Pour compatibilite ascendente
}
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
// If option to have vat for end customer for services is on
if (!$societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && !$societe_acheteuse->isACompany()) {
// We also add the buyer
if (is_numeric($type)) {
if ($type == 1) {
// We know product is a service
$code_pays .= ",'" . $societe_acheteuse->country_code . "'";
}
} else {
if (!$idprod) {
// We don't know type of product
$code_pays .= ",'" . $societe_acheteuse->country_code . "'";
} else {
$prodstatic = new Product($this->db);
$prodstatic->fetch($idprod);
if ($prodstatic->type == 1) {
// We know product is a service
$code_pays .= ",'" . $societe_acheteuse->country_code . "'";
}
}
}
}
}
// Now we get list
$num = $this->load_cache_vatrates($code_pays);
if ($num > 0) {
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
$defaulttx = get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod);
$defaultnpr = get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod);
}
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
$defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
}
if (!$options_only) {
$return .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
}
foreach ($this->cache_vatrates as $rate) {
$return .= '<option value="' . $rate['txtva'];
$return .= $rate['nprtva'] ? '*' : '';
$return .= '"';
if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) {
$return .= ' selected="selected"';
}
$return .= '>' . vatrate($rate['libtva']);
$return .= $rate['nprtva'] ? ' *' : '';
$return .= '</option>';
$this->tva_taux_value[] = $rate['txtva'];
//.........这里部分代码省略.........
示例13: update_buyprice
/**
* \brief Modifie le prix d'achat pour un fournisseur
* \param qty Quantite min pour lequel le prix est valide
* \param buyprice Prix d'achat pour la quantite min
* \param user Objet user de l'utilisateur qui modifie
* \param price_base_type HT or TTC
* \param fourn Supplier
*/
function update_buyprice($qty, $buyprice, $user, $price_base_type='HT', $fourn)
{
global $mysoc;
$buyprice=price2num($buyprice);
$qty=price2num($qty);
$error=0;
$this->db->begin();
// Supprime prix courant du fournisseur pour cette quantite
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
if ($this->product_fourn_price_id)
{
$sql.= " WHERE rowid = ".$this->product_fourn_price_id;
}
else
{
$sql.= " WHERE fk_product_fournisseur = ".$this->product_fourn_id;
$sql.= " AND quantity = ".$qty;
}
$resql=$this->db->query($sql);
if ($resql)
{
if ($price_base_type == 'TTC')
{
$ttx = get_default_tva($fourn,$mysoc,$this->id);
$buyprice = $buyprice/(1+($ttx/100));
}
$unitBuyPrice = price2num($buyprice/$qty,'MU');
$now=dol_now();
// Ajoute prix courant du fournisseur pour cette quantite
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql.= "datec, fk_product_fournisseur, fk_user, price, quantity, unitprice)";
$sql.= " values('".$this->db->idate($now)."',";
$sql.= " ".$this->product_fourn_id.",";
$sql.= " ".$user->id.",";
$sql.= " ".price2num($buyprice).",";
$sql.= " ".$qty.",";
$sql.= " ".$unitBuyPrice;
$sql.=")";
dol_syslog("ProductFournisseur::update_buyprice sql=".$sql);
if (! $this->db->query($sql))
{
$error++;
}
if (! $error)
{
// Ajoute modif dans table log
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log(";
$sql.= "datec, fk_product_fournisseur,fk_user,price,quantity)";
$sql.= "values('".$this->db->idate($now)."',";
$sql.= " ".$this->product_fourn_id.",";
$sql.= " ".$user->id.",";
$sql.= " ".price2num($buyprice).",";
$sql.= " ".$qty;
$sql.=")";
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
}
}
if (! $error)
{
$this->db->commit();
return 0;
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->db->rollback();
return -1;
}
}
示例14: dol_print_error
$result = $facture->fetch(GETPOST('factureid'));
if ($result <= 0) {
dol_print_error($db, $facture->error);
exit;
}
$thirpdartyid = $facture->socid;
}
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)) {
示例15: addOrderLine
/**
* Adds a product to the order
*
* @param Commande $object Order object
* @param Product $prod Product to add
* @param int $qty Quantity of the product
* @throws Exception
*/
public static function addOrderLine(Commande $object, Product $prod, $qty)
{
global $db, $conf, $mysoc, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
$tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
}
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
$tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->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' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result >= 0) {
if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$prod->tva_tx = $prodcustprice->lines[0]->tva_tx;
} else {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
}
} else {
throw new Exception($prodcustprice->error);
}
} else {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type;
}
// if price ht is forced (ie: calculated by margin rate and cost price)
if (!empty($price_ht)) {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
} elseif ($tva_tx != $prod->tva_tx) {
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + $tva_tx / 100), 'MU');
} else {
$pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
}
}
// Define output language
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
$outputlangs = $langs;
$newlang = '';
if (empty($newlang) && GETPOST('lang_id')) {
$newlang = GETPOST('lang_id');
}
if (empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$desc = !empty($prod->multilangs[$outputlangs->defaultlang]["description"]) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
} else {
$desc = $prod->description;
}
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
$tmptxt = '(';
if (!empty($prod->customcode)) {
$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
}
if (!empty($prod->customcode) && !empty($prod->country_code)) {
$tmptxt .= ' - ';
}
if (!empty($prod->country_code)) {
$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
}
$tmptxt .= ')';
$desc = dol_concatdesc($desc, $tmptxt);
}
//3.9.0 version added support for price units
if (versioncompare(versiondolibarrarray(), array(3, 9, 0)) >= 0) {
$fk_unit = $prod->fk_unit;
} else {
$fk_unit = null;
}
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
//.........这里部分代码省略.........