Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.46k stars 2.79k forks source link

Able to generate direct debit (withdraw) demand several time for same invoice #27800

Open vmaury opened 9 months ago

vmaury commented 9 months ago

Bug

I experienced the following bug

I supposed it's possible in case the withdraw is rejected, but in most cases it seems dangerous to me (in my case, the client has been debited twice :-1: )

To solve this, I made this modif in code /htdocs/compta/facture/list.php around line #516-252 delete some conditions

$rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
                $rsql .= " , pfd.date_traite as date_traite";
                $rsql .= " , pfd.amount";
                $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
                $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
                $rsql .= " , ".MAIN_DB_PREFIX."user as u";
                $rsql .= " WHERE fk_facture = ".((int) $objecttmp->id);
                // $rsql .= " AND pfd.fk_user_demande = u.rowid"; // fix this bug 
                // $rsql .= " AND pfd.traite = 0"; // fix this bug 
                $rsql .= " ORDER BY pfd.date_demande DESC";

I'll make a PR if @eldy @aspangaro have no better suggestions ...

Environment Version

all (including develop branch)

Environment OS

No response

Environment Web server

No response

Environment PHP

No response

Environment Database

No response

Environment URL(s)

No response

Expected and actual behavior

No response

Steps to reproduce the behavior

No response

Attached files

No response

eldy commented 9 months ago

I don't think the fix is a good idea. We can make several times the request to make the direct debit because user may want/need to make the payment in several times. The problem is on the page compta/facture/prelevement.php image When you go a second time on the document, you should be able to make a second request. BUT, the bug is that the amount suggested (here the 10.45) must be the amount to pay minus the amount already in the pipe. In this example it should be 10.45 - 5 = 5.45 Can you suggest a fix this way ?