Debug v17

This commit is contained in:
Laurent Destailleur 2023-01-24 13:00:09 +01:00
parent c463f0972d
commit 5b5a3547e2
8 changed files with 49 additions and 26 deletions

View File

@ -723,7 +723,7 @@ class AccountingAccount extends CommonObject
}
/**
* Return Suggest accounting accounts to bind
* Return a suggested account (from chart of accounts) to bind
*
* @param Societe $buyer Object buyer
* @param Societe $seller Object seller
@ -733,6 +733,8 @@ class AccountingAccount extends CommonObject
* @param array $accountingAccount Array of Accounting account
* @param string $type Customer / Supplier
* @return array|int Accounting accounts suggested or < 0 if technical error.
* 'suggestedaccountingaccountbydefaultfor'=>Will be used for the label to show on tooltip for account by default on any product
* 'suggestedaccountingaccountfor'=>Is the account suggested for this product
*/
public function getAccountingCodeToBind(Societe $buyer, Societe $seller, Product $product, $facture, $factureDet, $accountingAccount = array(), $type = '')
{

View File

@ -519,8 +519,8 @@ if ($result) {
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@ -639,7 +639,7 @@ if ($result) {
print '<td class="center">'.dol_print_date($facture_static->date, 'day').'</td>';
// Ref Product
print '<td class="tdoverflowmax150">';
print '<td class="tdoverflowmax100">';
if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
}
@ -648,7 +648,7 @@ if ($result) {
}
print '</td>';
// Description
// Description of line
print '<td class="tdoverflowonsmartphone small">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc, 1));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@ -682,15 +682,22 @@ if ($result) {
// Found accounts
print '<td class="small">';
// First show default account for any products
$s = '1. '.(($facture_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
$shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountbydefaultfor == 'eec') {
$shelp .= $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithvat') {
$shelp = $langs->trans("SaleEECWithVAT");
} elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithoutvatnumber') {
$shelp = $langs->trans("SaleEECWithoutVATNumber");
$ttype = 'warning';
} elseif ($suggestedaccountingaccountbydefaultfor == 'export') {
$shelp .= $langs->trans("SaleExport");
}
$s .= ($code_sell_l > 0 ? length_accountg($code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
// Now show account for product
if ($product_static->id > 0) {
print '<br>';
$s = '2. '.(($facture_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';

View File

@ -58,6 +58,8 @@ $year_current = $year_start;
// Validate History
$action = GETPOST('action', 'aZ09');
$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
// Security check
if (!isModEnabled('accounting')) {
accessforbidden();
@ -65,7 +67,7 @@ if (!isModEnabled('accounting')) {
if ($user->socid > 0) {
accessforbidden();
}
if (empty($user->rights->accounting->mouvements->lire)) {
if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
@ -74,7 +76,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
* Actions
*/
if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) {
if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) {
// Clean database
$db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
@ -109,8 +111,7 @@ if ($action == 'validatehistory') {
$sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid";
$sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id";
$sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.entity =".((int) $conf->entity);
$sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as syst ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND syst.active = 1,';
$sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND accnt.entity =".((int) $conf->entity);
$sql1 .= " ".MAIN_DB_PREFIX."expensereport as er";
$sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity);
$sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
@ -176,6 +177,7 @@ llxHeader('', $langs->trans("ExpenseReportsVentilation"));
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("ExpenseReportsVentilation")."&nbsp;".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport").'</span><br>';
@ -247,7 +249,7 @@ $sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
$sql .= ' ORDER BY aa.account_number';
dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql);
dol_syslog('/accountancy/expensereport/index.php', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
@ -277,6 +279,12 @@ if ($resql) {
print '</tr>';
}
$db->free($resql);
if ($num == 0) {
print '<tr class="oddeven"><td colspan="16">';
print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
print '</td></tr>';
}
} else {
print $db->lasterror(); // Show last sql error
}

View File

@ -418,8 +418,8 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', '');
print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', '');
$checkpicto = '';
if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);

View File

@ -111,7 +111,7 @@ if (!isModEnabled('accounting')) {
if ($user->socid > 0) {
accessforbidden();
}
if (empty($user->rights->accounting->mouvements->lire)) {
if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
accessforbidden();
}
@ -531,8 +531,8 @@ if ($result) {
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@ -711,14 +711,19 @@ if ($result) {
// Found accounts
print '<td class="small">';
$s = '1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
$shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountbydefaultfor == 'eec') {
$shelp .= $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithvat') {
$shelp = $langs->trans("SaleEECWithVAT");
} elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithoutvatnumber') {
$shelp = $langs->trans("SaleEECWithoutVATNumber");
$ttype = 'warning';
} elseif ($suggestedaccountingaccountbydefaultfor == 'export') {
$shelp .= $langs->trans("SaleExport");
}
$s .= ($code_buy_l > 0 ? length_accountg($code_buy_l) : '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
if ($product_static->id > 0) {
print '<br>';
$s = '2. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';

View File

@ -6273,7 +6273,7 @@ class Form
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { // If option to have vat for end customer for services is on
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
// We also add the buyer
// We also add the buyer country code
if (is_numeric($type)) {
if ($type == 1) { // We know product is a service
$code_country .= ",'".$societe_acheteuse->country_code."'";

View File

@ -6490,7 +6490,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
if ($seller_in_cee && $buyer_in_cee) {
$isacompany = $thirdparty_buyer->isACompany();
if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
if ($isacompany && getDolGlobalString('MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!isValidVATID($thirdparty_buyer)) {
$isacompany = 0;
@ -6526,7 +6526,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
// Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle
if (($seller_in_cee && $buyer_in_cee)) {
$isacompany = $thirdparty_buyer->isACompany();
if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
if ($isacompany && getDolGlobalString('MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!isValidVATID($thirdparty_buyer)) {
$isacompany = 0;

View File

@ -14,8 +14,8 @@ ACCOUNTING_EXPORT_ENDLINE=Select the carriage return type
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
DefaultForService=Default for services
DefaultForProduct=Default for products
ProductForThisThirdparty=Product for this thirdparty
ServiceForThisThirdparty=Service for this thirdparty
CantSuggest=Can't suggest
@ -101,7 +101,8 @@ ShowAccountingAccount=Show accounting account
ShowAccountingJournal=Show accounting journal
ShowAccountingAccountInLedger=Show accounting account in ledger
ShowAccountingAccountInJournals=Show accounting account in journals
AccountAccountingSuggest=Accounting account suggested
DataUsedToSuggestAccount=Data used to suggest account
AccountAccountingSuggest=Account suggested
MenuDefaultAccounts=Default accounts
MenuBankAccounts=Bank accounts
MenuVatAccounts=Vat accounts
@ -401,7 +402,7 @@ SaleLocal=Local sale
SaleExport=Export sale
SaleEEC=Sale in EEC
SaleEECWithVAT=Sale in EEC with a VAT not null, so we suppose this is NOT an intracommunautary sale and the suggested account is the standard product account.
SaleEECWithoutVATNumber=Sale in EEC with no VAT but the VAT ID of thirdparty is not defined. We fallback on the product account for standard sales. You can fix the VAT ID of thirdparty or the product account if needed.
SaleEECWithoutVATNumber=Sale in EEC with no VAT but the VAT ID of thirdparty is not defined. We fall back on the account for standard sales. You can fix the VAT ID of the thirdparty, or change the product account suggested for binding if needed.
ForbiddenTransactionAlreadyExported=Forbidden: The transaction has been validated and/or exported.
ForbiddenTransactionAlreadyValidated=Forbidden: The transaction has been validated.
## Dictionary