Merge pull request #15031 from FHenry/dev_add_lateOutsatndingAmount_into_customer_tab

NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late
This commit is contained in:
Laurent Destailleur 2020-10-15 20:16:45 +02:00 committed by GitHub
commit 4c684536d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 3 deletions

View File

@ -639,10 +639,11 @@ if ($object->id > 0)
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
// Box factures // Box factures
$tmp = $object->getOutstandingBills(); $tmp = $object->getOutstandingBills('customer', 0);
$outstandingOpened = $tmp['opened']; $outstandingOpened = $tmp['opened'];
$outstandingTotal = $tmp['total_ht']; $outstandingTotal = $tmp['total_ht'];
$outstandingTotalIncTax = $tmp['total_ttc']; $outstandingTotalIncTax = $tmp['total_ttc'];
$text = $langs->trans("OverAllInvoices"); $text = $langs->trans("OverAllInvoices");
$link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id; $link = DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id;
$icon = 'bill'; $icon = 'bill';
@ -668,6 +669,24 @@ if ($object->id > 0)
$boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>'; $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
$boxstat .= '</div>'; $boxstat .= '</div>';
if ($link) $boxstat .= '</a>'; if ($link) $boxstat .= '</a>';
$tmp = $object->getOutstandingBills('customer', 1);
$outstandingOpenedLate = $tmp['opened'];
if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
$warn = '';
if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) {
$warn = ' ' . img_warning($langs->trans("OutstandingBillReached"));
}
$text = $langs->trans("CurrentOutstandingBillLate");
$link = DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $object->id;
$icon = 'bill';
if ($link) $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">';
$boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>';
$boxstat .= '<span class="boxstatsindicator' . ($outstandingOpenedLate > 0 ? ' amountremaintopay' : '') . '">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . '</span>';
$boxstat .= '</div>';
if ($link) $boxstat .= '</a>';
}
} }
$parameters = array(); $parameters = array();

View File

@ -417,6 +417,20 @@ if ($object->id > 0)
$boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>'; $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
$boxstat .= '</div>'; $boxstat .= '</div>';
if ($link) $boxstat .= '</a>'; if ($link) $boxstat .= '</a>';
$tmp = $object->getOutstandingBills('supplier', 1);
$outstandingOpenedLate = $tmp['opened'];
if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
$text = $langs->trans("CurrentOutstandingBillLate");
$link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
$icon = 'bill';
if ($link) $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">';
$boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>';
$boxstat .= '<span class="boxstatsindicator' . ($outstandingOpenedLate > 0 ? ' amountremaintopay' : '') . '">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . '</span>';
$boxstat .= '</div>';
if ($link) $boxstat .= '</a>';
}
} }
$boxstat .= '</td></tr>'; $boxstat .= '</td></tr>';

View File

@ -460,3 +460,4 @@ MulticurrencyCurrency=Currency
InEEC=Europe (EEC) InEEC=Europe (EEC)
RestOfEurope=Rest of Europe (EEC) RestOfEurope=Rest of Europe (EEC)
OutOfEurope=Out of Europe (EEC) OutOfEurope=Out of Europe (EEC)
CurrentOutstandingBillLate=Current outstanding bill late

View File

@ -4092,9 +4092,10 @@ class Societe extends CommonObject
* Return amount of bill not paid and total * Return amount of bill not paid and total
* *
* @param string $mode 'customer' or 'supplier' * @param string $mode 'customer' or 'supplier'
* @param int $late 0 => all invoice, 1=> only late
* @return array array('opened'=>Amount, 'total'=>Total amount) * @return array array('opened'=>Amount, 'total'=>Total amount)
*/ */
public function getOutstandingBills($mode = 'customer') public function getOutstandingBills($mode = 'customer', $late = 0)
{ {
$table = 'facture'; $table = 'facture';
if ($mode == 'supplier') $table = 'facture_fourn'; if ($mode == 'supplier') $table = 'facture_fourn';
@ -4109,6 +4110,9 @@ class Societe extends CommonObject
if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".$this->id; $sql .= " WHERE fk_soc = ".$this->id;
if (!empty($late)) {
$sql .= " AND date_lim_reglement < '".$this->db->idate(dol_now())."'";
}
if ($mode == 'supplier') { if ($mode == 'supplier') {
$sql .= " AND entity IN (".getEntity('facture_fourn').")"; $sql .= " AND entity IN (".getEntity('facture_fourn').")";
} else { } else {