Merge pull request #3072 from atm-maximep/new_set_amount_for_withdraws
NEW : Set amount for withdraws requests
This commit is contained in:
commit
8710065ca0
@ -3066,6 +3066,8 @@ class Facture extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
function demande_prelevement($user)
|
function demande_prelevement($user)
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
|
||||||
@ -3099,12 +3101,16 @@ class Facture extends CommonInvoice
|
|||||||
// For example print 239.2 - 229.3 - 9.9; does not return 0.
|
// 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($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
//$resteapayer=bcadd($resteapayer,$totalavoir,$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');
|
||||||
|
|
||||||
|
$amount = GETPOST('withdraw_request_amount');
|
||||||
|
|
||||||
|
if (is_numeric($amount) && $amount != 0) {
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
$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 .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)';
|
||||||
$sql .= ' VALUES ('.$this->id;
|
$sql .= ' VALUES ('.$this->id;
|
||||||
$sql .= ",'".price2num($resteapayer)."'";
|
$sql .= ",'".price2num($amount)."'";
|
||||||
$sql .= ",'".$this->db->idate($now)."'";
|
$sql .= ",'".$this->db->idate($now)."'";
|
||||||
$sql .= ",".$user->id;
|
$sql .= ",".$user->id;
|
||||||
$sql .= ",'".$bac->code_banque."'";
|
$sql .= ",'".$bac->code_banque."'";
|
||||||
@ -3120,6 +3126,11 @@ class Facture extends CommonInvoice
|
|||||||
dol_syslog(get_class($this).'::demandeprelevement Erreur');
|
dol_syslog(get_class($this).'::demandeprelevement Erreur');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->error=$langs->trans('WithdrawRequestErrorNilAmount');
|
||||||
|
dol_syslog(get_class($this).'::demandeprelevement ' . $langs->trans('WithdrawRequestErrorNilAmount'));
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -478,7 +478,13 @@ if ($object->id > 0)
|
|||||||
{
|
{
|
||||||
if ($user->rights->prelevement->bons->creer)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -446,8 +446,17 @@ class BonPrelevement extends CommonObject
|
|||||||
$fac = new Facture($this->db);
|
$fac = new Facture($this->db);
|
||||||
$fac->fetch($facs[$i][0]);
|
$fac->fetch($facs[$i][0]);
|
||||||
$amounts[$fac->id] = $facs[$i][1];
|
$amounts[$fac->id] = $facs[$i][1];
|
||||||
|
|
||||||
|
$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);
|
$result = $fac->set_paid($user);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$paiement = new Paiement($this->db);
|
$paiement = new Paiement($this->db);
|
||||||
$paiement->datepaye = $date ;
|
$paiement->datepaye = $date ;
|
||||||
$paiement->amounts = $amounts;
|
$paiement->amounts = $amounts;
|
||||||
@ -651,7 +660,7 @@ class BonPrelevement extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
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.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||||
//$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp";
|
//$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp";
|
||||||
@ -924,6 +933,7 @@ class BonPrelevement extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
||||||
|
$this->id = $prev_id;
|
||||||
|
|
||||||
$dir=$conf->prelevement->dir_output.'/receipts';
|
$dir=$conf->prelevement->dir_output.'/receipts';
|
||||||
$file=$filebonprev;
|
$file=$filebonprev;
|
||||||
@ -981,6 +991,7 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
|
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$error++;
|
$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 = "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.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||||
@ -212,7 +212,7 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
// Amount
|
// Amount
|
||||||
print '<td align="right">';
|
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>';
|
print '</td>';
|
||||||
// Date
|
// Date
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
|||||||
@ -96,7 +96,7 @@ print '</td></tr></table><br>';
|
|||||||
* Invoices waiting for withdraw
|
* Invoices waiting for withdraw
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
|
$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.= " s.nom as name, s.rowid as socid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||||
@ -143,7 +143,7 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print price($obj->total_ttc);
|
print price($obj->amount);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
|
|||||||
@ -87,6 +87,8 @@ StatisticsByLineStatus=Statistics by status of lines
|
|||||||
RUM=RUM
|
RUM=RUM
|
||||||
RUMWillBeGenerated=RUM number will be generated once bank account information are saved
|
RUMWillBeGenerated=RUM number will be generated once bank account information are saved
|
||||||
WithdrawMode=Withdraw mode (FRST or RECUR)
|
WithdrawMode=Withdraw mode (FRST or RECUR)
|
||||||
|
WithdrawRequestAmount=Withdraw request amount:
|
||||||
|
WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount.
|
||||||
|
|
||||||
### Notifications
|
### Notifications
|
||||||
InfoCreditSubject=Payment of standing order %s by the bank
|
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é"
|
SetToStatusSent=Mettre au statut "Fichier envoyé"
|
||||||
ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées
|
ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées
|
||||||
StatisticsByLineStatus=Statistiques par statut des lignes
|
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
|
### Notifications
|
||||||
InfoCreditSubject=Crédit prélèvement %s à la banque
|
InfoCreditSubject=Crédit prélèvement %s à la banque
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user