Fix: Several fix.
New: Also allow to enter a payment with a negative value on an invoice and positive onto other.
This commit is contained in:
parent
8ff506b120
commit
153997432f
@ -777,9 +777,13 @@ if ($id > 0)
|
|||||||
if ($user->rights->facture->creer)
|
if ($user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
$langs->load("orders");
|
||||||
|
|
||||||
if($orders2invoice > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
|
if (! empty($conf->commande->enabled))
|
||||||
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
|
{
|
||||||
|
if($orders2invoice > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
|
||||||
|
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ($object->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
|
if ($object->client != 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
|
||||||
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
|
else print '<a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a>';
|
||||||
|
|||||||
@ -234,6 +234,7 @@ if ($result)
|
|||||||
// If the user can view prospects other than his'
|
// If the user can view prospects other than his'
|
||||||
if ($user->rights->societe->client->voir || $socid)
|
if ($user->rights->societe->client->voir || $socid)
|
||||||
{
|
{
|
||||||
|
$langs->load("commercial");
|
||||||
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
||||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
||||||
$moreforfilter.=' ';
|
$moreforfilter.=' ';
|
||||||
|
|||||||
@ -250,7 +250,8 @@ if ($resql)
|
|||||||
// If the user can view prospects other than his'
|
// If the user can view prospects other than his'
|
||||||
if ($user->rights->societe->client->voir || $socid)
|
if ($user->rights->societe->client->voir || $socid)
|
||||||
{
|
{
|
||||||
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
$langs->load("commercial");
|
||||||
|
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
||||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
||||||
$moreforfilter.=' ';
|
$moreforfilter.=' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -256,7 +256,8 @@ if ($resql)
|
|||||||
$moreforfilter='';
|
$moreforfilter='';
|
||||||
if ($user->rights->societe->client->voir || $socid)
|
if ($user->rights->societe->client->voir || $socid)
|
||||||
{
|
{
|
||||||
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
$langs->load("commercial");
|
||||||
|
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
||||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
|
||||||
$moreforfilter.=' ';
|
$moreforfilter.=' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,8 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
|
|||||||
|
|
||||||
$datepaye = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
$datepaye = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||||
$paiement_id = 0;
|
$paiement_id = 0;
|
||||||
|
$totalpaiement = 0;
|
||||||
|
$atleastonepaymentnotnull = 0;
|
||||||
|
|
||||||
// Verifie si des paiements sont superieurs au montant facture
|
// Verifie si des paiements sont superieurs au montant facture
|
||||||
foreach ($_POST as $key => $value)
|
foreach ($_POST as $key => $value)
|
||||||
@ -77,6 +79,7 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
|
|||||||
$cursorfacid = substr($key,7);
|
$cursorfacid = substr($key,7);
|
||||||
$amounts[$cursorfacid] = price2num(trim($_POST[$key]));
|
$amounts[$cursorfacid] = price2num(trim($_POST[$key]));
|
||||||
$totalpaiement = $totalpaiement + $amounts[$cursorfacid];
|
$totalpaiement = $totalpaiement + $amounts[$cursorfacid];
|
||||||
|
if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
|
||||||
$tmpfacture=new Facture($db);
|
$tmpfacture=new Facture($db);
|
||||||
$tmpfacture->fetch($cursorfacid);
|
$tmpfacture->fetch($cursorfacid);
|
||||||
$amountsresttopay[$cursorfacid]=price2num($tmpfacture->total_ttc-$tmpfacture->getSommePaiement());
|
$amountsresttopay[$cursorfacid]=price2num($tmpfacture->total_ttc-$tmpfacture->getSommePaiement());
|
||||||
@ -108,7 +111,7 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($totalpaiement == 0)
|
if (empty($totalpaiement) && empty($atleastonepaymentnotnull))
|
||||||
{
|
{
|
||||||
$fiche_erreur_message = '<div class="error">'.$langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')).'</div>';
|
$fiche_erreur_message = '<div class="error">'.$langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')).'</div>';
|
||||||
$error++;
|
$error++;
|
||||||
@ -154,8 +157,8 @@ if ($action == 'confirm_paiement' && $confirm == 'yes')
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0));
|
$paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0));
|
||||||
if ($paiement_id < 0)
|
if ($paiement_id < 0)
|
||||||
{
|
{
|
||||||
$errmsg=$paiement->error;
|
$errmsg=$paiement->error;
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
@ -137,17 +137,22 @@ class Paiement extends CommonObject
|
|||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$totalamount = 0;
|
$totalamount = 0;
|
||||||
|
$atleastonepaymentnotnull = 0;
|
||||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||||
{
|
{
|
||||||
$newvalue = price2num($value,'MT');
|
$newvalue = price2num($value,'MT');
|
||||||
$this->amounts[$key] = $newvalue;
|
$this->amounts[$key] = $newvalue;
|
||||||
$totalamount += $newvalue;
|
$totalamount += $newvalue;
|
||||||
|
if (! empty($newvalue)) $atleastonepaymentnotnull++;
|
||||||
}
|
}
|
||||||
$totalamount = price2num($totalamount);
|
$totalamount = price2num($totalamount);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays
|
||||||
|
{
|
||||||
|
$this->error='TotalAmountEmpty';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
|||||||
@ -506,7 +506,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
|
|||||||
print '<td align="right"> ';
|
print '<td align="right"> ';
|
||||||
if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
|
if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
|
||||||
{
|
{
|
||||||
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
|
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
|
||||||
if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
|
if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
|
||||||
$totsorties[$annee]+=$decaiss_ttc[$case];
|
$totsorties[$annee]+=$decaiss_ttc[$case];
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
|
|||||||
print '<td align="right"> ';
|
print '<td align="right"> ';
|
||||||
if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0)
|
if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0)
|
||||||
{
|
{
|
||||||
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price(price2num($encaiss_ttc[$case],'MT')).'</a>';
|
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price(price2num($encaiss_ttc[$case],'MT')).'</a>';
|
||||||
if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
|
if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
|
||||||
$totentrees[$annee]+=$encaiss_ttc[$case];
|
$totentrees[$annee]+=$encaiss_ttc[$case];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2732,12 +2732,12 @@ class Form
|
|||||||
if ($filter) $newfilter.=' AND ('.$filter.')';
|
if ($filter) $newfilter.=' AND ('.$filter.')';
|
||||||
$nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue);
|
$nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td nowrap="nowrap">';
|
||||||
if ($nbqualifiedlines > 0)
|
if ($nbqualifiedlines > 0)
|
||||||
{
|
{
|
||||||
print ' <input type="submit" class="button" value="'.$langs->trans("UseLine").'"';
|
print ' <input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
|
||||||
if ($filter && $filter != "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print '" title="'.$langs->trans("UseCreditNoteInInvoicePayment");
|
if ($filter && $filter != "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
|
||||||
print '">';
|
print '>';
|
||||||
}
|
}
|
||||||
if ($more) print $more;
|
if ($more) print $more;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user