12 lines
399 B
SQL
12 lines
399 B
SQL
SELECT
|
|
iot.vat,
|
|
pgc.name,
|
|
IF(pe.equFk IS NULL, taxableBase, 0) AS base,
|
|
pgc.rate / 100 AS vatPercent
|
|
FROM invoiceOutTax iot
|
|
JOIN pgc ON pgc.code = iot.pgcFk
|
|
LEFT JOIN pgcEqu pe ON pe.equFk = pgc.code
|
|
JOIN invoiceOut io ON io.id = iot.invoiceOutFk
|
|
LEFT JOIN ticket t ON t.refFk = io.ref
|
|
WHERE t.refFk = ?
|
|
ORDER BY iot.id |