diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 52e7cfd40b8..6447e1b8663 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -158,9 +158,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
llxHeader('', $langs->trans("Ventilation"));
// Customer Invoice lines
-$sql = "SELECT f.facnumber, f.rowid as facid, f.datef, f.type as ftype, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line,";
+$sql = "SELECT f.facnumber, f.rowid as facid, f.datef, f.type as ftype,";
+$sql .= " l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
-$sql .= " aa.rowid as aarowid";
+$sql .= " aa.rowid as aarowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
@@ -251,11 +252,11 @@ if ($result) {
// We add search filter
print '
';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
print ' % ';
print ' ';
print ' ';
@@ -278,35 +279,33 @@ if ($result) {
$objp->code_sell_l = '';
$objp->code_sell_p = '';
$objp->aarowid_suggest = '';
- $code_sell_p_l_differ = '';
$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
- if (! empty($objp->code_sell)) {
- $objp->code_sell_p = $objp->code_sell;
- } else {
- $code_sell_p_notset = 'color:red';
- if ($objp->type == 1) {
- $objp->code_sell_p = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
- } elseif ($objp->type == 0) {
- $objp->code_sell_p = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
- }
- }
if ($objp->type_l == 1) {
- $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $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;
}
} elseif ($objp->type_l == 0) {
- $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
+ $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->code_sell_l != $objp->code_sell_p)
- $code_sell_p_l_differ = 'color:red';
+ if ($objp->code_sell_l == -1) $objp->code_sell_l='';
+ if (! empty($objp->code_sell)) {
+ $objp->code_sell_p = $objp->code_sell; // Code on product
+ } else {
+ $code_sell_p_notset = 'color:orange';
+ }
+ 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
+
print ' ';
// Ref Invoice
@@ -327,9 +326,9 @@ if ($result) {
print '';
- print '' . dol_trunc($objp->product_label, 24) . ' ';
+ print '' . dol_trunc($objp->product_label, 24) . ' ';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
- print '' . nl2br(dol_trunc($objp->description, $trunclength)) . ' ';
+ print '' . nl2br(dol_trunc($objp->description, $trunclength)) . ' ';
print '';
print price($objp->total_ht);
@@ -344,13 +343,11 @@ if ($result) {
// Accounting account suggested
print ' ';
- if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product
- if ($objp->code_sell_l > 0) print $objp->code_sell_l;
- else print $langs->trans("Unknown");
- } else {
- print $langs->trans("Default") . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
- print ' ';
- print $langs->trans("Product") . ' = ' . ($objp->code_sell_p > 0 ? length_accountg($objp->code_sell_p) : $langs->trans("Unknown"));
+ 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)
+ {
+ 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));
}
print ' ';
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 804097c6d33..86d7fdae9c9 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -164,9 +164,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
llxHeader('', $langs->trans("SuppliersVentilation"));
// Supplier Invoice Lines
-$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, ";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod";
-$sql .= " , aa.rowid as aarowid";
+$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef,";
+$sql .= " l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, ";
+$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
+$sql .= " aa.rowid as aarowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
@@ -256,10 +257,10 @@ if ($result) {
print " \n";
print '';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
print ' ';
print ' ';
print ' ';
@@ -286,37 +287,31 @@ if ($result) {
$objp->code_buy_l = '';
$objp->code_buy_p = '';
$objp->aarowid_suggest = '';
- $code_buy_p_l_differ = '';
$code_buy_p_notset = '';
-
$objp->aarowid_suggest = $objp->aarowid;
- if (! empty($objp->code_buy)) {
- $objp->code_buy_p = $objp->code_buy;
- } else {
- $code_buy_p_notset = 'color:red';
- if ($objp->type == 1) {
- $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
- }
-
- elseif ($objp->type == 0) {
- $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
- }
- }
if ($objp->type_l == 1) {
- $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : '');
if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_s;
} elseif ($objp->type_l == 0) {
- $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
+ $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : '');
if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_p;
}
-
- if ($objp->code_buy_l != $objp->code_buy_p)
- $code_buy_p_l_differ = 'color:red';
+ if ($objp->code_buy_l == -1) $objp->code_buy_l='';
+ if (! empty($objp->code_buy)) {
+ $objp->code_buy_p = $objp->code_buy;
+ } else {
+ $code_buy_p_notset = 'color:orange';
+ }
+ if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red';
+
+ // $objp->code_buy_p is now code of product/service
+ // $objp->code_buy_l is now default code of product/service
+
print ' ';
// Ref Invoice
@@ -335,11 +330,11 @@ if ($result) {
print ' ';
print '';
- print '' . dol_trunc($objp->product_label, 24) . ' ';
+ print '' . dol_trunc($objp->product_label, 24) . ' ';
// TODO: we should set a user defined value to adjust user square / wide screen size
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
- print '' . nl2br(dol_trunc($objp->description, $trunclength)) . ' ';
+ print '' . nl2br(dol_trunc($objp->description, $trunclength)) . ' ';
print '';
print price($objp->price);
@@ -354,13 +349,11 @@ if ($result) {
// Accounting account suggested
print ' ';
- if ($objp->code_buy_l == $objp->code_buy_p) { // Test if there is a difference between code by default and code on product
- if ($objp->code_buy_l > 0) print $objp->code_buy_l;
- else print $langs->trans("Unknown");
- } else {
- print $langs->trans("Default") . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));
+ 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"));
+ if ($objp->product_id > 0)
+ {
print ' ';
- print $langs->trans("Product") . ' = ' . ($objp->code_buy_p > 0 ? length_accountg($objp->code_buy_p) : $langs->trans("Unknown"));
+ 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 ' ';
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 1619884c36f..cae29217cdb 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -8,7 +8,11 @@ ACCOUNTING_EXPORT_AMOUNT=Export amount
ACCOUNTING_EXPORT_DEVISE=Export currency
Selectformat=Select the format for the file
ACCOUNTING_EXPORT_PREFIX_SPEC=Specify the prefix for the file name
-
+ThisService=This service
+ThisProduct=This product
+DefaultForService=Default for service
+DefaultForProduct=Default for product
+CantSuggest=Can't suggest
AccountancySetupDoneFromAccountancyMenu=Most setup of the accountancy is done from the menu %s
ConfigAccountingExpert=Configuration of the module accounting expert
Journalization=Journalization
@@ -49,7 +53,7 @@ ChangeAndLoad=Change and load
Addanaccount=Add an accounting account
AccountAccounting=Accounting account
AccountAccountingShort=Account
-AccountAccountingSuggest=Accounting account suggest
+AccountAccountingSuggest=Accounting account suggested
MenuDefaultAccounts=Default accounts
MenuVatAccounts=Vat accounts
MenuTaxAccounts=Tax accounts