NEW The link "In accountancy" is now clicable to reach bookkeeping

This commit is contained in:
ldestailleur
2025-04-02 18:51:51 +02:00
parent ca6c3db534
commit b466b7ab5a
9 changed files with 40 additions and 34 deletions

View File

@@ -155,7 +155,7 @@ $formaccounting = new FormAccounting($db);
$form = new Form($db);
if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'alpha') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) {
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_mvt_num') && !GETPOST('search_accountancy_code_start')) {
$sql = "SELECT date_start, date_end";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear ";
if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) {

View File

@@ -2856,15 +2856,17 @@ class AccountLine extends CommonObjectLine
/**
* Return if a bank line was dispatched into bookkeeping
*
* @return int Return integer <0 if KO, 0=no, 1=yes
* @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num)
* @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction
*/
public function getVentilExportCompta()
public function getVentilExportCompta($mode = 0)
{
$alreadydispatched = 0;
$type = 'bank';
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -2877,7 +2879,7 @@ class AccountLine extends CommonObjectLine
}
if ($alreadydispatched) {
return 1;
return $alreadydispatched;
}
return 0;
}

View File

@@ -794,9 +794,10 @@ class PaymentVarious extends CommonObject
/**
* Return if a various payment linked to a bank line id was dispatched into bookkeeping
*
* @return int Return integer <0 if KO, 0=no, 1=yes
* @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num)
* @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction
*/
public function getVentilExportCompta()
public function getVentilExportCompta($mode = 0)
{
$banklineid = $this->fk_bank;
@@ -804,7 +805,8 @@ class PaymentVarious extends CommonObject
$type = 'bank';
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $banklineid);
$sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $banklineid);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -817,7 +819,7 @@ class PaymentVarious extends CommonObject
}
if ($alreadydispatched) {
return 1;
return $alreadydispatched;
}
return 0;
}

View File

@@ -116,11 +116,6 @@ $head[$h][1] = $langs->trans("PaymentSocialContribution");
$hselected = (string) $h;
$h++;
/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
$head[$h][1] = $langs->trans("Info");
$h++;
*/
print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment');

View File

@@ -167,8 +167,6 @@ class PaymentSocialContribution extends CommonObject
*/
public function create($user, $closepaidcontrib = 0)
{
global $conf, $langs;
$error = 0;
$now = dol_now();
@@ -812,17 +810,21 @@ class PaymentSocialContribution extends CommonObject
/**
* Return if object was dispatched into bookkeeping
* Return if object was dispatched into bookkeeping, or return the array of bookkeeping id.
*
* @return int Return integer <0 if KO, 0=no, 1=yes
* @param int $mode 0=Mode to return the nb of record, 1=Mode to return array of ID in bookkeeping table.
* @return int Return integer <0 if KO, 0=no, 1=yes or ID transaction
*/
public function getVentilExportCompta()
public function getVentilExportCompta($mode = 0)
{
$alreadydispatched = 0;
$type = 'bank';
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->bank_line);
$sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab";
$sql .= " WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->bank_line);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -835,7 +837,7 @@ class PaymentSocialContribution extends CommonObject
}
if ($alreadydispatched) {
return 1;
return $alreadydispatched;
}
return 0;
}

View File

@@ -745,9 +745,10 @@ abstract class CommonInvoice extends CommonObject
* Return if an invoice was transferred into accountnancy.
* This is true if at least on line was transferred into table accounting_bookkeeping
*
* @return int Return integer <0 if KO, 0=no, 1=yes
* @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num)
* @return int Return integer <0 if KO, 0=no, nb transaction=yes or ID transaction
*/
public function getVentilExportCompta()
public function getVentilExportCompta($mode = 0)
{
$alreadydispatched = 0;
@@ -756,8 +757,9 @@ abstract class CommonInvoice extends CommonObject
$type = 'supplier_invoice';
}
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".$this->db->prefix()."accounting_bookkeeping as ab";
$sql .= " WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb";
$sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping as ab";
$sql .= " WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
@@ -771,7 +773,7 @@ abstract class CommonInvoice extends CommonObject
}
if ($alreadydispatched) {
return 1;
return $alreadydispatched;
}
return 0;
}

View File

@@ -3398,13 +3398,13 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlstatus .= $tmptxt;
}
// Add if object was dispatched "into accountancy"
// Say if object was dispatched/transferred "into accountancy"
if (isModEnabled('accounting') && in_array($object->element, array('bank', 'paiementcharge', 'facture', 'invoice', 'invoice_supplier', 'expensereport', 'payment_various'))) {
// Note: For 'chargesociales', 'salaries'... this is the payments that are dispatched (so element = 'bank')
if (method_exists($object, 'getVentilExportCompta')) {
$accounted = $object->getVentilExportCompta();
$accounted = $object->getVentilExportCompta(1);
$langs->load("accountancy");
$morehtmlstatus .= '</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted")).'</span>';
$morehtmlstatus .= '</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_mvt_num='.urlencode($accounted).'">'.$langs->trans("Accounted").'</a>' : $langs->trans("NotYetAccounted")).'</span>';
}
}

View File

@@ -2668,17 +2668,19 @@ class ExpenseReport extends CommonObject
}
/**
* Return if object was dispatched into bookkeeping
* Return if object was dispatched into bookkeeping.
*
* @param int $mode 0=Return nb of record, 1=return the transaction ID (piece_num)
* @return int Return integer <0 if KO, 0=no, 1=yes
*/
public function getVentilExportCompta()
public function getVentilExportCompta($mode = 0)
{
$alreadydispatched = 0;
$type = 'expense_report';
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$sql = " SELECT ".($mode ? 'DISTINCT piece_num' : 'COUNT(ab.rowid)')." as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type)."' AND ab.fk_doc = ".((int) $this->id);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -2691,7 +2693,7 @@ class ExpenseReport extends CommonObject
}
if ($alreadydispatched) {
return 1;
return $alreadydispatched;
}
return 0;
}

View File

@@ -197,3 +197,4 @@ XNewLinesConciliated=%s new line(s) conciliated
InSepa=SEPA Area
CountryIsInSepa=Countries in Sepa area
Bank_line=Bank transaction line
BankId=Bank line ID