6943-fixCustomer #2754
|
@ -60,7 +60,7 @@ module.exports = Self => {
|
||||||
DISTINCT c.id clientFk,
|
DISTINCT c.id clientFk,
|
||||||
c.name clientName,
|
c.name clientName,
|
||||||
c.salesPersonFk,
|
c.salesPersonFk,
|
||||||
c.businessTypeFk,
|
c.businessTypeFk = 'worker' isWorker,
|
||||||
u.name salesPersonName,
|
u.name salesPersonName,
|
||||||
d.amount,
|
d.amount,
|
||||||
co.created,
|
co.created,
|
||||||
|
@ -71,14 +71,23 @@ module.exports = Self => {
|
||||||
d.defaulterSinced,
|
d.defaulterSinced,
|
||||||
cn.name country,
|
cn.name country,
|
||||||
c.countryFk,
|
c.countryFk,
|
||||||
pm.name payMethod
|
pm.name payMethod,
|
||||||
FROM vn.defaulter d
|
r.finished IS NULL hasRecovery,
|
||||||
JOIN vn.client c ON c.id = d.clientFk
|
dp.id departmentFk,
|
||||||
JOIN vn.country cn ON cn.id = c.countryFk
|
dp.name departmentName
|
||||||
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
FROM defaulter d
|
||||||
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
|
JOIN client c ON c.id = d.clientFk
|
||||||
|
JOIN country cn ON cn.id = c.countryFk
|
||||||
|
JOIN payMethod pm ON pm.id = c.payMethodFk
|
||||||
|
LEFT JOIN clientObservation co ON co.clientFk = c.id
|
||||||
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
LEFT JOIN account.user u ON u.id = c.salesPersonFk
|
||||||
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
LEFT JOIN account.user uw ON uw.id = co.workerFk
|
||||||
|
LEFT JOIN (
|
||||||
|
|||||||
|
SELECT MAX(started), clientFk, finished
|
||||||
|
FROM recovery
|
||||||
|
) r ON r.clientFk = c.id
|
||||||
|
LEFT JOIN workerDepartment wd ON wd.workerFk = u.id
|
||||||
|
JOIN department dp ON dp.id = wd.departmentFk
|
||||||
WHERE
|
WHERE
|
||||||
d.created = ?
|
d.created = ?
|
||||||
AND d.amount > 0
|
AND d.amount > 0
|
||||||
|
|
Loading…
Reference in New Issue
@jgallego no estoy del todo seguro de este LEFT JOIN pero mejor de como esta ahora en el front es seguro y creo que lo que se queria era asi
CUIDAOO!!! Lo que has posat sols trau un registre..i no saps de quin client!
Proposta: si sols vols vore si teu n f.finished null, fes un left join simple, sense subconsulta
LEFT JOIN recovery r ON r.clientFk = c.id AND r.finished IS NULL
i en el select si r.id entonces has Recovery
@jgallego con LEFT JOIN salen los mismos registros que hay con el código antiguo, por eso nos e pusieron cambios y se aprobó.
Esto hay que quitarlo ya que saca datos falsos