FIX problem with sign of various payment in project preview

This commit is contained in:
Laurent Destailleur 2019-03-18 10:16:08 +01:00
parent 227f5f8f92
commit 34034787af
5 changed files with 53 additions and 24 deletions

View File

@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
@ -367,6 +368,7 @@ $paymentstatic=new Paiement($db);
$paymentsupplierstatic=new PaiementFourn($db); $paymentsupplierstatic=new PaiementFourn($db);
$paymentvatstatic=new TVA($db); $paymentvatstatic=new TVA($db);
$paymentsalstatic=new PaymentSalary($db); $paymentsalstatic=new PaymentSalary($db);
$paymentvariousstatic=new PaymentVarious($db);
$donstatic=new Don($db); $donstatic=new Don($db);
$paymentexpensereportstatic=new PaymentExpenseReport($db); $paymentexpensereportstatic=new PaymentExpenseReport($db);
$bankstatic=new Account($db); $bankstatic=new Account($db);
@ -1146,13 +1148,13 @@ if ($resql)
if ($links[$key]['type']=='payment') if ($links[$key]['type']=='payment')
{ {
$paymentstatic->id=$links[$key]['url_id']; $paymentstatic->id=$links[$key]['url_id'];
$paymentstatic->ref=$links[$key]['url_id']; $paymentstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment
print ' '.$paymentstatic->getNomUrl(2); print ' '.$paymentstatic->getNomUrl(2);
} }
elseif ($links[$key]['type']=='payment_supplier') elseif ($links[$key]['type']=='payment_supplier')
{ {
$paymentsupplierstatic->id=$links[$key]['url_id']; $paymentsupplierstatic->id=$links[$key]['url_id'];
$paymentsupplierstatic->ref=$links[$key]['url_id']; $paymentsupplierstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment
print ' '.$paymentsupplierstatic->getNomUrl(2); print ' '.$paymentsupplierstatic->getNomUrl(2);
} }
elseif ($links[$key]['type']=='payment_sc') elseif ($links[$key]['type']=='payment_sc')
@ -1192,6 +1194,12 @@ if ($resql)
$paymentexpensereportstatic->ref=$links[$key]['url_id']; $paymentexpensereportstatic->ref=$links[$key]['url_id'];
print ' '.$paymentexpensereportstatic->getNomUrl(2); print ' '.$paymentexpensereportstatic->getNomUrl(2);
} }
elseif ($links[$key]['type']=='payment_various')
{
$paymentvariousstatic->id=$links[$key]['url_id'];
$paymentvariousstatic->ref=$links[$key]['url_id'];
print ' '.$paymentvariousstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='banktransfert') elseif ($links[$key]['type']=='banktransfert')
{ {
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.

View File

@ -1180,7 +1180,7 @@ class Paiement extends CommonObject
$result=''; $result='';
$label = '<u>'.$langs->trans("ShowPayment").'</u><br>'; $label = '<u>'.$langs->trans("ShowPayment").'</u><br>';
$label.= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref; $label.= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref;
$label.= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->date, 'dayhour'); if ($this->date) $label.= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->date, 'dayhour');
if ($mode == 'withlistofinvoices') if ($mode == 'withlistofinvoices')
{ {
$arraybill = $this->getBillsArray(); $arraybill = $this->getBillsArray();

View File

@ -694,16 +694,16 @@ class Tva extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result=''; $result='';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
$label = '<u>' . $langs->trans("ShowVatPayment") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
$linkclose=''; $linkclose='';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label=$langs->trans("ShowMyObject"); $label=$langs->trans("ShowMyObject");

View File

@ -583,7 +583,7 @@ class PaiementFourn extends Paiement
$label = '<u>'.$langs->trans("ShowPayment").'</u><br>'; $label = '<u>'.$langs->trans("ShowPayment").'</u><br>';
$label.= '<strong>'.$langs->trans("Ref").':</strong> '.$text; $label.= '<strong>'.$langs->trans("Ref").':</strong> '.$text;
$label.= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); if ($this->datepaye ? $this->datepaye : $this->date) $label.= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
$linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>'; $linkend = '</a>';

View File

@ -579,7 +579,7 @@ foreach ($listofreferent as $key => $value)
$qualified=$value['test']; $qualified=$value['test'];
$margin = $value['margin']; $margin = $value['margin'];
$project_field = $value['project_field']; $project_field = $value['project_field'];
if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'plus') if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'plus' or 'auto')
{ {
$element = new $classname($db); $element = new $classname($db);
@ -600,6 +600,7 @@ foreach ($listofreferent as $key => $value)
$element->fetch($idofelement); $element->fetch($idofelement);
if ($idofelementuser) $elementuser->fetch($idofelementuser); if ($idofelementuser) $elementuser->fetch($idofelementuser);
// Define if record must be used for total or not
$qualifiedfortotal=true; $qualifiedfortotal=true;
if ($key == 'invoice') if ($key == 'invoice')
{ {
@ -642,6 +643,16 @@ foreach ($listofreferent as $key => $value)
} }
else $total_ttc_by_line=$element->total_ttc; else $total_ttc_by_line=$element->total_ttc;
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
if ($tablename == 'payment_various')
{
if ($element->sens == 1)
{
$total_ht_by_line = -$total_ht_by_line;
$total_ttc_by_line = -$total_ttc_by_line;
}
}
// Add total if we have to // Add total if we have to
if ($qualifiedfortotal) if ($qualifiedfortotal)
{ {
@ -658,23 +669,14 @@ foreach ($listofreferent as $key => $value)
// Calculate margin // Calculate margin
if ($qualifiedforfinalprofit) if ($qualifiedforfinalprofit)
{ {
if ($margin=="add") if ($margin != "add")
{
$balance_ht+= $total_ht;
$balance_ttc+= $total_ttc;
}
else
{
$balance_ht-= $total_ht;
$balance_ttc-= $total_ttc;
}
// Show $total_ht & $total_ttc -- add a minus when necessary
if ($margin!="add")
{ {
$total_ht = -$total_ht; $total_ht = -$total_ht;
$total_ttc = -$total_ttc; $total_ttc = -$total_ttc;
} }
$balance_ht += $total_ht;
$balance_ttc += $total_ttc;
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -856,8 +858,7 @@ foreach ($listofreferent as $key => $value)
$expensereport->fetch($element->fk_expensereport); $expensereport->fetch($element->fk_expensereport);
} }
//print 'xxx'.$tablename; //print 'xxx'.$tablename.'yyy'.$classname;
//print $classname;
if ($breakline && $saved_third_id != $element->thirdparty->id) if ($breakline && $saved_third_id != $element->thirdparty->id)
{ {
@ -1032,6 +1033,16 @@ foreach ($listofreferent as $key => $value)
{ {
$total_ht_by_line=$element->total_ht; $total_ht_by_line=$element->total_ht;
} }
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
if ($tablename == 'payment_various')
{
if ($element->sens == 0)
{
$total_ht_by_line = -$total_ht_by_line;
}
}
print '<td align="right">'; print '<td align="right">';
if ($othermessage) print $othermessage; if ($othermessage) print $othermessage;
if (isset($total_ht_by_line)) if (isset($total_ht_by_line))
@ -1069,6 +1080,16 @@ foreach ($listofreferent as $key => $value)
{ {
$total_ttc_by_line=$element->total_ttc; $total_ttc_by_line=$element->total_ttc;
} }
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
if ($tablename == 'payment_various')
{
if ($element->sens == 0)
{
$total_ttc_by_line = -$total_ttc_by_line;
}
}
print '<td align="right">'; print '<td align="right">';
if ($othermessage) print $othermessage; if ($othermessage) print $othermessage;
if (isset($total_ttc_by_line)) if (isset($total_ttc_by_line))