Debug v20 - Error message when requesting credit transfer/direct debit

This commit is contained in:
Laurent Destailleur 2024-07-30 11:16:19 +02:00
parent 0d69b5fb20
commit 53561f033b
5 changed files with 33 additions and 18 deletions

View file

@ -564,8 +564,9 @@ if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement'))
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
} elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') {
$langs->load("errors");
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
setEventMessages($objecttmp->ref.' '.$langs->trans("ErrorThisPaymentModeIsNotDirectDebit"), $objecttmp->errors, 'errors');
} else {
$listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
}

View file

@ -381,8 +381,9 @@ if (empty($reshook)) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
} elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
$langs->load("errors");
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
setEventMessages($objecttmp->ref.' '.$langs->trans("ErrorThisPaymentModeIsNotCreditTransfer"), $objecttmp->errors, 'errors');
} else {
$listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
}

View file

@ -303,7 +303,8 @@ ErrorThirpdartyOrMemberidIsMandatory=Third party or Member of partnership is man
ErrorFailedToWriteInTempDirectory=Failed to write in temp directory
ErrorQuantityIsLimitedTo=Quantity is limited to %s
ErrorFailedToLoadThirdParty=Failed to find/load third party from id=%s, email=%s, name=%s
ErrorThisPaymentModeIsNotSepa=This payment mode is not a bank account
ErrorThisPaymentModeIsNotDirectDebit=The payment mode is not direct debit
ErrorThisPaymentModeIsNotCreditTransfer=The payment mode is not credit transfer
ErrorStripeCustomerNotFoundCreateFirst=Stripe customer is not set for this third party (or set to a value deleted on Stripe side). Create (or re-attach) it first.
ErrorCharPlusNotSupportedByImapForSearch=IMAP search is not able to search into sender or recipient for a string containing the character +
ErrorTableNotFound=Table <b>%s</b> not found
@ -334,9 +335,9 @@ ErrorDictionaryNotFound=Dictionary <b>%s</b> not found
ErrorFailedToCreateSymLinkToMedias=Failed to create the symbolic link %s to point to %s
ErrorCheckTheCommandInsideTheAdvancedOptions=Check the command used for the export into the Advanced options of the export
ErrorEndTimeMustBeGreaterThanStartTime=End time must be greater than start time
ErrorIncoherentDates=Date start must be less than date end
ErrorEndHourIsNull=End date cannot be zero
ErrorStartHourIsNull=Start date cannot be zero
ErrorIncoherentDates=Start date must be earlier than end date
ErrorEndHourIsNull=End date field cannot be empty
ErrorStartHourIsNull=Start date field cannot be empty
ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter=Too many lines to process. Please use a more selective filter.
ErrorEmptyValueForQty=Quantity cannot be zero.
# Warnings

View file

@ -78,7 +78,8 @@ class Salary extends CommonObject
*/
public $fk_project;
public $type_payment;
public $type_payment; // TODO Rename into type_payment_id
public $type_payment_code;
/**
* @var string salary payments label
@ -130,6 +131,7 @@ class Salary extends CommonObject
public $resteapayer;
/**
* Constructor
*
@ -239,17 +241,21 @@ class Salary extends CommonObject
$sql .= " s.label,";
$sql .= " s.datesp,";
$sql .= " s.dateep,";
$sql .= " s.note,";
$sql .= " s.note as note_private,";
$sql .= " s.note_public,";
$sql .= " s.paye,";
$sql .= " s.fk_bank,";
$sql .= " s.fk_user_author,";
$sql .= " s.fk_user_modif,";
$sql .= " s.fk_account";
$sql .= " s.fk_account,";
$sql .= " cp.code as type_payment_code";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON s.fk_typepayment = cp.id";
$sql .= " WHERE s.rowid = ".((int) $id);
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->num_rows($resql)) {
@ -264,10 +270,13 @@ class Salary extends CommonObject
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payment = $obj->fk_typepayment;
$this->type_payment_code = $obj->type_payment_code;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->note = $obj->note_private;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->paye = $obj->paye;
$this->status = $obj->paye;
$this->fk_bank = $obj->fk_bank;
@ -601,7 +610,7 @@ class Salary extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX.$table;
$sql .= " WHERE ".$field." = ".((int) $this->id);
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
dol_syslog(get_class($this)."::getSommePaiement for salary id=".((int) $this->id), LOG_DEBUG);
$resql = $this->db->query($sql);

View file

@ -144,6 +144,8 @@ $permissiontoread = $user->hasRight('salaries', 'read');
$permissiontoadd = $user->hasRight('salaries', 'write');
$permissiontodelete = $user->hasRight('salaries', 'delete');
$error = 0;
// Security check
$socid = GETPOSTINT("socid");
if ($user->socid) {
@ -197,10 +199,10 @@ if ($massaction == 'withdrawrequest') {
if ($objecttmp->status == Salary::STATUS_PAID || $objecttmp->resteapayer == 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
} elseif ($resteapayer < 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
}
$rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
@ -221,17 +223,18 @@ if ($massaction == 'withdrawrequest') {
if ($numprlv > 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
} elseif (!empty($objecttmp->type_payment) && $objecttmp->type_payment != '2') {
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
} elseif (!empty($objecttmp->type_payment_code) && $objecttmp->type_payment_code != 'VIR') {
$langs->load("errors");
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("ErrorThisPaymentModeIsNotCreditTransfer"), $objecttmp->errors, 'errors');
} else {
$listofSalries[] = $objecttmp;
}
}
}
if (!empty($listofSalries)) {
if (!$error && !empty($listofSalries)) {
$nbwithdrawrequestok = 0;
foreach ($listofSalries as $salary) {
$db->begin();
@ -498,7 +501,7 @@ $arrayofmassactions = array(
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (isModEnabled('prelevement') && $user->hasRight('prelevement', 'bons', 'creer')) {
if (isModEnabled('paymentbybanktransfer') && $user->hasRight('paymentbybanktransfer', 'create')) {
$langs->load("withdrawals");
$arrayofmassactions['withdrawrequest'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("MakeBankTransferOrder");
}