FIX Calculation in the activity box

This commit is contained in:
Laurent Destailleur 2017-09-17 20:17:51 +02:00
parent bb73da4c5e
commit ee774f1bf9
2 changed files with 18 additions and 16 deletions

View File

@ -376,7 +376,7 @@ class box_activity extends ModeleBoxes
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND paye=0";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=0";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
@ -403,6 +403,8 @@ class box_activity extends ModeleBoxes
if (! empty($data)) {
$j=0;
$alreadypaid=-1;
while ($line < count($cumuldata)) {
$billurl="search_status=".$data[$j]->fk_statut."&amp;paye=0";
$this->info_box_contents[$line][0] = array(
@ -431,7 +433,7 @@ class box_activity extends ModeleBoxes
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$line][4] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3),
'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid),
);
$line++;
$j++;

View File

@ -51,7 +51,7 @@ abstract class CommonInvoice extends CommonObject
const TYPE_DEPOSIT = 3;
/**
* Proforma invoice.
* Proforma invoice.
* @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice !
*/
const TYPE_PROFORMA = 4;
@ -89,7 +89,7 @@ abstract class CommonInvoice extends CommonObject
*/
const STATUS_ABANDONED = 3;
/**
* Return remain amount to pay. Property ->id and ->total_ttc must be set.
* This does not include open direct debit requests.
@ -141,7 +141,7 @@ abstract class CommonInvoice extends CommonObject
return -1;
}
}
/**
* Return amount (with tax) of all deposits invoices used by invoice.
* Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended).
@ -154,11 +154,11 @@ abstract class CommonInvoice extends CommonObject
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
// TODO
return 0;
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
if ($result >= 0)
@ -185,9 +185,9 @@ abstract class CommonInvoice extends CommonObject
// TODO
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
if ($result >= 0)
@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject
return -1;
}
}
/**
* Renvoie tableau des ids de facture avoir issus de la facture
*
@ -309,7 +309,7 @@ abstract class CommonInvoice extends CommonObject
* @param int $paye Status field paye
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise)
* @param int $type Type invoice
* @return string Libelle du statut
*/
@ -418,7 +418,7 @@ abstract class CommonInvoice extends CommonObject
if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
if (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
if (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
if ($alreadypaid <= 0)
if ($alreadypaid <= 0)
{
if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
@ -497,13 +497,13 @@ abstract class CommonInvoice extends CommonObject
}
elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant
{
$date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes
$date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes
$date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month');
$diff = $date_piece - $date_lim_current;
if($diff < 0) $datelim = $date_lim_current;
else $datelim = $date_lim_next;