diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 5314099db1f..192585ccedd 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -92,9 +92,6 @@ if (! $user->rights->accounting->bind->write)
$hookmanager->initHooks(array('accountancycustomerlist'));
$formaccounting = new FormAccounting($db);
-$accounting = new AccountingAccount($db);
-$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
-$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
@@ -384,11 +381,11 @@ if ($result) {
print '';
print '
| ';
//print ' | ';
- print ' | ';
+ print ' | ';
print ' | ';
print ' | ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
//print '';
print ' | ';
print ' | ';
@@ -444,29 +441,50 @@ if ($result) {
$isBuyerInEEC = isInEEC($objp);
+ $suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) {
- $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
- if ($objp->aarowid == '') {
- $objp->aarowid_suggest = $aarowid_s;
- }
+ if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = '';
+ } else {
+ if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eec';
+ } else { // Foreign sale
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'export';
+ }
+ }
} elseif ($objp->type_l == 0) {
- $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
- if ($objp->aarowid == '') {
- $objp->aarowid_suggest = $aarowid_p;
+ if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = '';
+ } else {
+ if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eec';
+ } else {
+ $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'export';
+ }
}
}
if ($objp->code_sell_l == -1) $objp->code_sell_l='';
+ $suggestedaccountingaccountfor = '';
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
+ $suggestedaccountingaccountfor = '';
} else {
if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
+ $suggestedaccountingaccountfor = 'eec';
} else { // Foreign sale
$objp->code_sell_p = $objp->code_sell_export;
$objp->aarowid_suggest = $objp->aarowid_export;
+ $suggestedaccountingaccountfor = 'export';
}
}
@@ -477,8 +495,8 @@ if ($result) {
}
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
- // $objp->code_sell_p is now code of product/service
// $objp->code_sell_l is now default code of product/service
+ // $objp->code_sell_p is now code of product/service
print '';
@@ -492,7 +510,7 @@ if ($result) {
// Ref Product
print '';
- if ($product_static->id)
+ if ($product_static->id > 0)
print $product_static->getNomUrl(1);
if ($objp->product_label) print ' '.$objp->product_label;
print ' | ';
@@ -514,7 +532,7 @@ if ($result) {
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '';
- print '';
+ print ' | ';
$labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label;
print $labelcountry;
print ' | ';
@@ -523,17 +541,27 @@ if ($result) {
// Current account
print '';
- print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
- if ($objp->product_id > 0)
+ $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': ';
+ $shelp = '';
+ if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport");
+ $s.= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined"));
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ if ($objp->product_id > 0)
{
print ' ';
- print (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")) . ' = ' . (empty($objp->code_sell_p) ? $langs->trans("Unknown") : length_accountg($objp->code_sell_p));
+ $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': ';
+ $shelp = '';
+ if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
+ $s.= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p));
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print ' | ';
// Suggested accounting account
print '';
- print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
+ print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' | ';
// Column with checkbox
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 17284513650..b3a426bbf5e 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -332,8 +332,8 @@ if ($result) {
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
- if ($search_country) $param .= "&search_country=" . urlencode($search_country);
- if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
+ if ($search_country) $param.="&search_country=".urlencode($search_country);
+ if ($search_tvaintra) $param.="&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
@@ -382,11 +382,11 @@ if ($result) {
print '';
print ' | ';
//print ' | ';
- print ' | ';
+ print ' | ';
print ' | ';
print ' | ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
//print '';
print ' | ';
print ' | ';
@@ -418,7 +418,7 @@ if ($result) {
print "
\n";
$facturefourn_static = new FactureFournisseur($db);
- $productfourn_static = new ProductFournisseur($db);
+ $product_static = new Product($db);
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);
@@ -430,10 +430,10 @@ if ($result) {
$objp->code_buy_p = '';
$objp->aarowid_suggest = '';
- $productfourn_static->ref = $objp->product_ref;
- $productfourn_static->id = $objp->product_id;
- $productfourn_static->type = $objp->type;
- $productfourn_static->label = $objp->product_label;
+ $product_static->ref = $objp->product_ref;
+ $product_static->id = $objp->product_id;
+ $product_static->type = $objp->type;
+ $product_static->label = $objp->product_label;
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
@@ -479,8 +479,8 @@ if ($result) {
// Ref product
print '';
- if ($productfourn_static->id)
- print $productfourn_static->getNomUrl(1);
+ if ($product_static->id > 0)
+ print $product_static->getNomUrl(1);
if ($objp->product_label) print ' '.$objp->product_label;
print ' | ';
@@ -502,26 +502,38 @@ if ($result) {
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '';
- print '';
+ // Country
+ print ' | ';
$labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label;
print $labelcountry;
print ' | ';
+ // VAT Num
print '' . $objp->tva_intra . ' | ';
// Current account
print '';
- print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));
+ $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': ';
+ $shelp = '';
+ if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport");
+ $s.= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined"));
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0)
{
- print ' ';
- print (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")) . ' = ' . (empty($objp->code_buy_p) ? $langs->trans("Unknown") : length_accountg($objp->code_buy_p));
+ print ' ';
+ $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': ';
+ $shelp = '';
+ if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
+ $s.= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p));
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print ' | ';
// Suggested accounting account
print '';
- print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
+ print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' | ';
// Column with checkbox
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index f2384b13cf2..fc74890f150 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -1009,7 +1009,8 @@ class ProductFournisseur extends Product
/**
- * Return a link to the object card (with optionaly the picto)
+ * Return a link to the object card (with optionaly the picto).
+ * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl().
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to ('nolink', ...)
@@ -1025,11 +1026,10 @@ class ProductFournisseur extends Product
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = '';
- $companylink = '';
$label = '' . $langs->trans("SupplierRef") . '';
$label.= '
';
- $label.= '' . $langs->trans('Ref') . ': ' . $this->fourn_ref;
+ $label.= '' . $langs->trans('Ref') . ': ' . $this->ref_supplier;
$logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
if (is_array($logPrices) && count($logPrices) > 0) {
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 7797fdef7b1..3a08e422600 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -316,6 +316,9 @@ WithoutValidAccount=Without valid dedicated account
WithValidAccount=With valid dedicated account
ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account
AccountRemovedFromGroup=Account removed from group
+SaleLocal=Local sale
+SaleExport=Export sale
+SaleEEC=Sale in EEC
## Dictionary
Range=Range of accounting account
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index de0d28cee83..a5491045c16 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4059,16 +4059,18 @@ class Product extends CommonObject
}
}
- $linkstart = '';
$linkend='';
$result.=$linkstart;
if ($withpicto)
{
- if ($this->type == Product::TYPE_PRODUCT) { $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1));
+ if ($this->type == Product::TYPE_PRODUCT) {
+ $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1));
}
- if ($this->type == Product::TYPE_SERVICE) { $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1));
+ if ($this->type == Product::TYPE_SERVICE) {
+ $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1));
}
}
$result.= $newref;
@@ -4078,8 +4080,10 @@ class Product extends CommonObject
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id, 'getnomurl'=>$result);
$reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) { $result = $hookmanager->resPrint;
- } else { $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
}
return $result;