refactor: refs #5586 Optimized SQL negativeBases #2007
Labels
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: verdnatura/salix#2007
Loading…
Reference in New Issue
No description provided.
Delete Branch "5586-optimizeNegativeBases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -56,4 +52,0 @@
FROM ticket t
WHERE shipped BETWEEN ? AND ?
AND refFk IS NULL`, [args.from, args.to]));
stmts.push(`CALL vn.ticket_getTax(NULL)`);
si lleves esta cridà funciona igual? a mes ha canviat nom de taules de tickte a filter..
Sí, he respetat el alias taxableBase, falta que arregle els test de back que he vist que fallen
@ -83,4 +65,0 @@
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN account.user u ON u.id = w.id
LEFT JOIN (
SELECT ticketFk, taxableBase
açò valida que ninguna de les bases imponibles siguen < 0 per separat es a dir si un ticket suma 100 y te una base imponible -20 y laltra 120 es un error, en el teu plantejament mos la colarien
@carlosap
@ -96,0 +84,4 @@
GROUP BY ticketFk
HAVING taxableBase < 0
) negativeBase ON negativeBase.ticketFk = t.id
WHERE t.shipped BETWEEN ? AND util.dayEnd(?)
posar una funcio en el where pot fer que no puga indexar, revisa be que vaja rapid
Funciona mes rapid que antes.
@ -96,0 +87,4 @@
WHERE t.shipped BETWEEN ? AND util.dayEnd(?)
AND t.refFk IS NULL
AND c.typeFk IN ('normal','trust')
GROUP BY t.clientFk, t.totalWithoutVat
un ticket que tinga 2 bases imponibles ha de tindre dos linies, amb este group by ho fusiona en una..