update consulte sql
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c660786e45
commit
894f95cb1f
|
@ -42,20 +42,20 @@ module.exports = Self => {
|
||||||
SUM(t.packages) packages,
|
SUM(t.packages) packages,
|
||||||
r.m3,
|
r.m3,
|
||||||
r.kmEnd - r.kmStart kmTotal,
|
r.kmEnd - r.kmStart kmTotal,
|
||||||
CAST(IFNULL(ate.routePrice,
|
CAST(IFNULL(sat.routePrice,
|
||||||
(ate.kmPrice * (GREATEST(r.kmEnd - r.kmStart , ate.minimumKm))
|
(sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm))
|
||||||
+ GREATEST(r.m3 , ate.minimumM3) * ate.m3Price)
|
+ GREATEST(r.m3 , sat.minimumM3) * sat.m3Price)
|
||||||
+ ate.packagePrice * SUM(t.packages) )
|
+ sat.packagePrice * SUM(t.packages) )
|
||||||
AS DECIMAL(10,2)) price,
|
AS DECIMAL(10,2)) price,
|
||||||
r.invoiceInFk,
|
r.invoiceInFk,
|
||||||
a.supplierFk,
|
sat.supplierFk,
|
||||||
s.name supplierName
|
s.name supplierName
|
||||||
FROM vn.route r
|
FROM vn.route r
|
||||||
LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
|
LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id
|
||||||
LEFT JOIN vn.agency a ON am.agencyFk = a.id
|
LEFT JOIN vn.agency a ON am.agencyFk = a.id
|
||||||
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
LEFT JOIN vn.ticket t ON t.routeFk = r.id
|
||||||
LEFT JOIN vn.agencyTerm ate ON ate.agencyFk = a.id
|
LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id
|
||||||
LEFT JOIN vn.supplier s ON s.id = a.supplierFk
|
LEFT JOIN vn.supplier s ON s.id = sat.supplierFk
|
||||||
WHERE r.created > DATE_ADD(CURDATE(), INTERVAL -2 MONTH) AND a.supplierFk IS NOT NULL
|
WHERE r.created > DATE_ADD(CURDATE(), INTERVAL -2 MONTH) AND a.supplierFk IS NOT NULL
|
||||||
GROUP BY r.id
|
GROUP BY r.id
|
||||||
) a`
|
) a`
|
||||||
|
|
Loading…
Reference in New Issue