NEW : Enter amount for withdraws requests
This commit is contained in:
parent
2785bf7520
commit
f99a127a57
@ -3066,6 +3066,8 @@ class Facture extends CommonInvoice
|
||||
*/
|
||||
function demande_prelevement($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
||||
@ -3080,7 +3082,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
||||
$sql.= ' WHERE fk_facture = '.$this->id;
|
||||
$sql.= ' AND traite = 0';
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -3099,27 +3101,36 @@ class Facture extends CommonInvoice
|
||||
// For example print 239.2 - 229.3 - 9.9; does not return 0.
|
||||
//$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
$resteapayer = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
|
||||
|
||||
//$resteapayer = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
||||
$sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)';
|
||||
$sql .= ' VALUES ('.$this->id;
|
||||
$sql .= ",'".price2num($resteapayer)."'";
|
||||
$sql .= ",'".$this->db->idate($now)."'";
|
||||
$sql .= ",".$user->id;
|
||||
$sql .= ",'".$bac->code_banque."'";
|
||||
$sql .= ",'".$bac->code_guichet."'";
|
||||
$sql .= ",'".$bac->number."'";
|
||||
$sql .= ",'".$bac->cle_rib."')";
|
||||
|
||||
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this).'::demandeprelevement Erreur');
|
||||
$error++;
|
||||
}
|
||||
$amount = GETPOST('withdraw_request_amount');
|
||||
|
||||
if (is_numeric($amount) && $amount != 0) {
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
||||
$sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)';
|
||||
$sql .= ' VALUES ('.$this->id;
|
||||
$sql .= ",'".price2num($amount)."'";
|
||||
$sql .= ",'".$this->db->idate($now)."'";
|
||||
$sql .= ",".$user->id;
|
||||
$sql .= ",'".$bac->code_banque."'";
|
||||
$sql .= ",'".$bac->code_guichet."'";
|
||||
$sql .= ",'".$bac->number."'";
|
||||
$sql .= ",'".$bac->cle_rib."')";
|
||||
|
||||
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog(get_class($this).'::demandeprelevement Erreur');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$this->error=$langs->trans('WithdrawRequestErrorNilAmount');
|
||||
dol_syslog(get_class($this).'::demandeprelevement ' . $langs->trans('WithdrawRequestErrorNilAmount'));
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
@ -478,7 +478,13 @@ if ($object->id > 0)
|
||||
{
|
||||
if ($user->rights->prelevement->bons->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=new">'.$langs->trans("MakeWithdrawRequest").'</a>';
|
||||
print '<form method="POST" action="">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '" />';
|
||||
print '<input type="hidden" name="action" value="new" />';
|
||||
print '<label for="withdraw_request_amount">' . $langs->trans('WithdrawRequestAmount') . ' </label>';
|
||||
print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="' . $resteapayer . '" size="10" />';
|
||||
print '<input type="submit" class="butAction" value="'.$langs->trans("MakeWithdrawRequest").'" />';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -446,8 +446,17 @@ class BonPrelevement extends CommonObject
|
||||
$fac = new Facture($this->db);
|
||||
$fac->fetch($facs[$i][0]);
|
||||
$amounts[$fac->id] = $facs[$i][1];
|
||||
$result = $fac->set_paid($user);
|
||||
|
||||
$totalpaye = $fac->getSommePaiement();
|
||||
$totalcreditnotes = $fac->getSumCreditNotesUsed();
|
||||
$totaldeposits = $fac->getSumDepositsUsed();
|
||||
$alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits;
|
||||
|
||||
if ($alreadypayed + $facs[$i][1] >= $fac->total_ttc) {
|
||||
$result = $fac->set_paid($user);
|
||||
}
|
||||
}
|
||||
|
||||
$paiement = new Paiement($this->db);
|
||||
$paiement->datepaye = $date ;
|
||||
$paiement->amounts = $amounts;
|
||||
@ -651,7 +660,7 @@ class BonPrelevement extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT sum(f.total_ttc) as nb";
|
||||
$sql = "SELECT sum(pfd.amount) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
//$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
@ -759,7 +768,7 @@ class BonPrelevement extends CommonObject
|
||||
$factures_result = array();
|
||||
$factures_prev_id=array();
|
||||
$factures_errors=array();
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
|
||||
@ -813,7 +822,7 @@ class BonPrelevement extends CommonObject
|
||||
// Check RIB
|
||||
$i = 0;
|
||||
dol_syslog(__METHOD__."::Check RIB", LOG_DEBUG);
|
||||
|
||||
|
||||
if (count($factures) > 0)
|
||||
{
|
||||
foreach ($factures as $key => $fac)
|
||||
@ -825,7 +834,7 @@ class BonPrelevement extends CommonObject
|
||||
{
|
||||
$bac = new CompanyBankAccount($this->db);
|
||||
$bac->fetch(0,$soc->id);
|
||||
|
||||
|
||||
if ($bac->verif() >= 1)
|
||||
//if (true)
|
||||
{
|
||||
@ -924,7 +933,8 @@ class BonPrelevement extends CommonObject
|
||||
if ($resql)
|
||||
{
|
||||
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
||||
|
||||
$this->id = $prev_id;
|
||||
|
||||
$dir=$conf->prelevement->dir_output.'/receipts';
|
||||
$file=$filebonprev;
|
||||
if (! is_dir($dir)) dol_mkdir($dir);
|
||||
@ -981,6 +991,7 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if (! $resql)
|
||||
{
|
||||
$error++;
|
||||
|
||||
@ -161,7 +161,7 @@ print '<br>';
|
||||
*/
|
||||
|
||||
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
|
||||
$sql.= " pfd.date_demande";
|
||||
$sql.= " pfd.date_demande, pfd.amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
@ -212,7 +212,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
// Amount
|
||||
print '<td align="right">';
|
||||
print price($obj->total_ttc,0,$langs,0,0,-1,$conf->currency);
|
||||
print price($obj->amount,0,$langs,0,0,-1,$conf->currency);
|
||||
print '</td>';
|
||||
// Date
|
||||
print '<td align="right">';
|
||||
|
||||
@ -96,7 +96,7 @@ print '</td></tr></table><br>';
|
||||
* Invoices waiting for withdraw
|
||||
*/
|
||||
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
|
||||
$sql.= " pfd.date_demande,";
|
||||
$sql.= " pfd.date_demande, pfd.amount,";
|
||||
$sql.= " s.nom as name, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
@ -143,7 +143,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print price($obj->total_ttc);
|
||||
print price($obj->amount);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
|
||||
@ -87,6 +87,8 @@ StatisticsByLineStatus=Statistics by status of lines
|
||||
RUM=RUM
|
||||
RUMWillBeGenerated=RUM number will be generated once bank account information are saved
|
||||
WithdrawMode=Withdraw mode (FRST or RECUR)
|
||||
WithdrawRequestAmount=Withdraw request amount:
|
||||
WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount.
|
||||
|
||||
### Notifications
|
||||
InfoCreditSubject=Payment of standing order %s by the bank
|
||||
|
||||
@ -84,6 +84,8 @@ WithdrawalFile=Fichier de prélèvement
|
||||
SetToStatusSent=Mettre au statut "Fichier envoyé"
|
||||
ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées
|
||||
StatisticsByLineStatus=Statistiques par statut des lignes
|
||||
WithdrawRequestAmount=Montant de la demande de prélèvement :
|
||||
WithdrawRequestErrorNilAmount=Impossible de créer une demande de prélèvement avec un montant nul.
|
||||
|
||||
### Notifications
|
||||
InfoCreditSubject=Crédit prélèvement %s à la banque
|
||||
|
||||
Loading…
Reference in New Issue
Block a user