Better help to explain suggested account

This commit is contained in:
Laurent Destailleur 2016-11-07 11:42:20 +01:00
parent 8cb7d508d2
commit 5fb8ba8ee7
3 changed files with 61 additions and 67 deletions

View File

@ -158,9 +158,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
llxHeader('', $langs->trans("Ventilation")); llxHeader('', $langs->trans("Ventilation"));
// Customer Invoice lines // 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 .= " 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 .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; $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"; $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 // We add search filter
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
@ -278,34 +279,32 @@ if ($result) {
$objp->code_sell_l = ''; $objp->code_sell_l = '';
$objp->code_sell_p = ''; $objp->code_sell_p = '';
$objp->aarowid_suggest = ''; $objp->aarowid_suggest = '';
$code_sell_p_l_differ = '';
$code_sell_p_notset = ''; $code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid; $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) { 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 == '') { if ($objp->aarowid == '') {
$objp->aarowid_suggest = $aarowid_s; $objp->aarowid_suggest = $aarowid_s;
} }
} elseif ($objp->type_l == 0) { } 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 == '') { if ($objp->aarowid == '') {
$objp->aarowid_suggest = $aarowid_p; $objp->aarowid_suggest = $aarowid_p;
} }
} }
if ($objp->code_sell_l != $objp->code_sell_p) if ($objp->code_sell_l == -1) $objp->code_sell_l='';
$code_sell_p_l_differ = 'color:red';
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 '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
@ -327,9 +326,9 @@ if ($result) {
print '</td>'; print '</td>';
print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>'; print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>'; print '<td>' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
print '<td align="right">'; print '<td align="right">';
print price($objp->total_ht); print price($objp->total_ht);
@ -344,13 +343,11 @@ if ($result) {
// Accounting account suggested // Accounting account suggested
print '<td align="center" style="' . $code_sell_p_notset . '">'; print '<td align="center" style="' . $code_sell_p_notset . '">';
if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product 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->code_sell_l > 0) print $objp->code_sell_l; if ($objp->product_id > 0)
else print $langs->trans("Unknown"); {
} else { print '<br>';
print $langs->trans("Default") . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown")); 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 '<br>';
print $langs->trans("Product") . ' = ' . ($objp->code_sell_p > 0 ? length_accountg($objp->code_sell_p) : $langs->trans("Unknown"));
} }
print '</td>'; print '</td>';

View File

@ -164,9 +164,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
llxHeader('', $langs->trans("SuppliersVentilation")); llxHeader('', $langs->trans("SuppliersVentilation"));
// Supplier Invoice Lines // 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 = "SELECT f.ref, f.rowid as facid, f.ref_supplier, f.datef,";
$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 .= " 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 .= " , aa.rowid as aarowid"; $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 .= " 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 .= " 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"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
@ -256,10 +257,10 @@ if ($result) {
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_desc" value="' . $search_desc . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
@ -286,36 +287,30 @@ if ($result) {
$objp->code_buy_l = ''; $objp->code_buy_l = '';
$objp->code_buy_p = ''; $objp->code_buy_p = '';
$objp->aarowid_suggest = ''; $objp->aarowid_suggest = '';
$code_buy_p_l_differ = '';
$code_buy_p_notset = ''; $code_buy_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid; $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) { 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 == '') if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_s; $objp->aarowid_suggest = $aarowid_s;
} elseif ($objp->type_l == 0) { } 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 == '') if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_p; $objp->aarowid_suggest = $aarowid_p;
} }
if ($objp->code_buy_l == -1) $objp->code_buy_l='';
if ($objp->code_buy_l != $objp->code_buy_p) if (! empty($objp->code_buy)) {
$code_buy_p_l_differ = 'color:red'; $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 '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
@ -335,11 +330,11 @@ if ($result) {
print '&nbsp;'; print '&nbsp;';
print '</td>'; print '</td>';
print '<td style="' . $code_buy_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>'; print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
// TODO: we should set a user defined value to adjust user square / wide screen size // TODO: we should set a user defined value to adjust user square / wide screen size
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td style="' . $code_buy_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>'; print '<td>' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
print '<td align="right">'; print '<td align="right">';
print price($objp->price); print price($objp->price);
@ -354,13 +349,11 @@ if ($result) {
// Accounting account suggested // Accounting account suggested
print '<td align="center" style="' . $code_buy_p_notset . '">'; print '<td align="center" style="' . $code_buy_p_notset . '">';
if ($objp->code_buy_l == $objp->code_buy_p) { // Test if there is a difference between code by default and code on product 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->code_buy_l > 0) print $objp->code_buy_l; if ($objp->product_id > 0)
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 '<br>'; print '<br>';
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 '</td>'; print '</td>';

View File

@ -8,7 +8,11 @@ ACCOUNTING_EXPORT_AMOUNT=Export amount
ACCOUNTING_EXPORT_DEVISE=Export currency ACCOUNTING_EXPORT_DEVISE=Export currency
Selectformat=Select the format for the file Selectformat=Select the format for the file
ACCOUNTING_EXPORT_PREFIX_SPEC=Specify the prefix for the file name 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 AccountancySetupDoneFromAccountancyMenu=Most setup of the accountancy is done from the menu %s
ConfigAccountingExpert=Configuration of the module accounting expert ConfigAccountingExpert=Configuration of the module accounting expert
Journalization=Journalization Journalization=Journalization
@ -49,7 +53,7 @@ ChangeAndLoad=Change and load
Addanaccount=Add an accounting account Addanaccount=Add an accounting account
AccountAccounting=Accounting account AccountAccounting=Accounting account
AccountAccountingShort=Account AccountAccountingShort=Account
AccountAccountingSuggest=Accounting account suggest AccountAccountingSuggest=Accounting account suggested
MenuDefaultAccounts=Default accounts MenuDefaultAccounts=Default accounts
MenuVatAccounts=Vat accounts MenuVatAccounts=Vat accounts
MenuTaxAccounts=Tax accounts MenuTaxAccounts=Tax accounts