Fix direct debit sql request

This commit is contained in:
Laurent Destailleur 2023-03-08 03:16:59 +01:00
parent 98a05a0ddb
commit b682fe728c

View File

@ -916,10 +916,10 @@ abstract class CommonInvoice extends CommonObject
$sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_prelevement_bons";
$sql .= " FROM ".$this->db->prefix()."prelevement_demande";
$sql .= " WHERE rowid = ".((int) $did);
if ($type != 'direct-debit') {
if ($type != 'bank-transfer' && $type != 'credit-transfer') {
$sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one
}
if ($type != 'credit-transfer') {
if ($type != 'direct-debit') {
$sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one
}
$sql .= " AND traite = 0"; // Add a protection to not process twice