2023-07-18 12:15:56 +00:00
|
|
|
SELECT
|
2021-05-27 08:49:19 +00:00
|
|
|
io.ref,
|
2021-02-24 06:51:05 +00:00
|
|
|
s.ticketFk,
|
2023-07-18 12:15:56 +00:00
|
|
|
ib.ediBotanic botanical,
|
|
|
|
s.quantity,
|
|
|
|
s.price,
|
2021-02-24 06:51:05 +00:00
|
|
|
s.discount,
|
2023-07-18 12:15:56 +00:00
|
|
|
s.itemFk,
|
|
|
|
s.concept,
|
|
|
|
tc.code vatType
|
2021-05-27 08:49:19 +00:00
|
|
|
FROM vn.invoiceOut io
|
|
|
|
JOIN vn.ticket t ON t.refFk = io.ref
|
|
|
|
JOIN vn.supplier su ON su.id = io.companyFk
|
2023-07-18 12:15:56 +00:00
|
|
|
JOIN vn.client c ON c.id = t.clientFk
|
2021-05-27 08:49:19 +00:00
|
|
|
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
2023-07-18 12:15:56 +00:00
|
|
|
JOIN vn.company co ON co.id = io.companyFk
|
2021-05-27 08:49:19 +00:00
|
|
|
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
|
|
|
JOIN vn.sale s ON s.ticketFk = t.id
|
|
|
|
JOIN item i ON i.id = s.itemFk
|
|
|
|
LEFT JOIN itemType it ON it.id = i.typeFk
|
|
|
|
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
|
|
|
LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id
|
|
|
|
AND ic.code = 'plant'
|
|
|
|
AND ib.ediBotanic IS NOT NULL
|
|
|
|
JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk
|
|
|
|
AND itc.itemFk = s.itemFk
|
|
|
|
JOIN vn.taxClass tc ON tc.id = itc.taxClassFk
|
2022-07-21 08:05:37 +00:00
|
|
|
WHERE t.refFk = ?
|
2023-07-18 12:15:56 +00:00
|
|
|
UNION ALL
|
|
|
|
SELECT
|
2021-05-27 08:49:19 +00:00
|
|
|
io.ref,
|
2023-07-18 12:15:56 +00:00
|
|
|
t.id ticketFk,
|
|
|
|
NULL botanical,
|
|
|
|
ts.quantity,
|
|
|
|
ts.price,
|
|
|
|
0 discount,
|
2021-02-24 06:51:05 +00:00
|
|
|
'',
|
2023-07-18 12:15:56 +00:00
|
|
|
ts.description concept,
|
|
|
|
tc.code vatType
|
2021-05-27 08:49:19 +00:00
|
|
|
FROM vn.invoiceOut io
|
|
|
|
JOIN vn.ticket t ON t.refFk = io.ref
|
|
|
|
JOIN vn.ticketService ts ON ts.ticketFk = t.id
|
2023-07-18 12:15:56 +00:00
|
|
|
JOIN vn.client c ON c.id = t.clientFk
|
2021-05-27 08:49:19 +00:00
|
|
|
JOIN vn.payMethod pm ON pm.id = c.payMethodFk
|
2023-07-18 12:15:56 +00:00
|
|
|
JOIN vn.company co ON co.id = io.companyFk
|
2021-05-27 08:49:19 +00:00
|
|
|
JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk
|
|
|
|
JOIN vn.taxClass tc ON tc.id = ts.taxClassFk
|
2023-07-18 12:15:56 +00:00
|
|
|
WHERE t.refFk = ?
|