Merge branch 'dev' into 6822-entryTransfer
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-07-19 05:21:27 +00:00
commit 24e64fe607
2 changed files with 28 additions and 10 deletions

View File

@ -60,7 +60,7 @@ module.exports = Self => {
DISTINCT c.id clientFk,
c.name clientName,
c.salesPersonFk,
c.businessTypeFk,
c.businessTypeFk = 'worker' isWorker,
u.name salesPersonName,
d.amount,
co.created,
@ -71,14 +71,23 @@ module.exports = Self => {
d.defaulterSinced,
cn.name country,
c.countryFk,
pm.name payMethod
FROM vn.defaulter d
JOIN vn.client c ON c.id = d.clientFk
JOIN vn.country cn ON cn.id = c.countryFk
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
LEFT JOIN vn.clientObservation co ON co.clientFk = c.id
pm.name payMethod,
r.finished IS NULL hasRecovery,
dp.id departmentFk,
dp.name departmentName
FROM defaulter d
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 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
d.created = ?
AND d.amount > 0

View File

@ -53,13 +53,22 @@ module.exports = Self => {
const stmts = [];
const stmt = new ParameterizedSQL(
`SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay,
wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk
`SELECT t.id AS ticketFk,
c.id AS clientFk,
c.name AS clientName,
tw.weekDay,
wh.name AS warehouseName,
u.id AS workerFk,
u.name AS userName,
u.nickName,
tw.agencyModeFk,
am.name agencyModeName
FROM ticketWeekly tw
JOIN ticket t ON t.id = tw.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN account.user u ON u.id = c.salesPersonFk
JOIN warehouse wh ON wh.id = t.warehouseFk`
JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk`
);
stmt.merge(conn.makeSuffix(filter));