feat: solo coge los tickets que no esten eliminados
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d16235cba9
commit
5a5e4c5afb
|
@ -253,5 +253,5 @@
|
|||
"This receipt was not compensated": "Este recibo no ha sido compensado",
|
||||
"Client's email was not found": "No se encontró el email del cliente",
|
||||
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9",
|
||||
"Negative basis": "Negative basis"
|
||||
}
|
||||
"Negative basis": "Base negativa"
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ module.exports = Self => {
|
|||
try {
|
||||
query = `
|
||||
SELECT MAX(issued) issued
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.time t ON t.dated = io.issued
|
||||
WHERE io.serial = 'A'
|
||||
FROM vn.invoiceOut io
|
||||
JOIN vn.time t ON t.dated = io.issued
|
||||
WHERE io.serial = 'A'
|
||||
AND t.year = YEAR(?)
|
||||
AND io.companyFk = ?`;
|
||||
const [maxIssued] = await Self.rawSql(query, [
|
||||
|
@ -103,7 +103,6 @@ module.exports = Self => {
|
|||
return {
|
||||
clientId: invoiceableClient.id,
|
||||
addressId: invoiceableClient.addressFk
|
||||
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@ -131,11 +130,11 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const query = `SELECT DISTINCT clientFk AS id
|
||||
FROM ticket t
|
||||
FROM ticket t
|
||||
JOIN ticketPackaging tp ON t.id = tp.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped BETWEEN '2017-11-21' AND ?
|
||||
AND t.clientFk >= ?
|
||||
AND t.clientFk >= ?
|
||||
AND (t.clientFk <= ? OR ? IS NULL)
|
||||
AND c.isActive`;
|
||||
return models.InvoiceOut.rawSql(query, [
|
||||
|
@ -156,9 +155,9 @@ module.exports = Self => {
|
|||
c.id,
|
||||
SUM(IFNULL
|
||||
(
|
||||
s.quantity *
|
||||
s.quantity *
|
||||
s.price * (100-s.discount)/100,
|
||||
0)
|
||||
0)
|
||||
+ IFNULL(ts.quantity * ts.price,0)
|
||||
) AS sumAmount,
|
||||
c.hasToInvoiceByAddress,
|
||||
|
@ -170,11 +169,14 @@ module.exports = Self => {
|
|||
LEFT JOIN ticketService ts ON ts.ticketFk = t.id
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE ISNULL(t.refFk) AND c.id >= ?
|
||||
WHERE ISNULL(t.refFk) AND c.id >= ?
|
||||
AND (t.clientFk <= ? OR ? IS NULL)
|
||||
AND t.shipped BETWEEN ? AND util.dayEnd(?)
|
||||
AND t.companyFk = ? AND c.hasToInvoice
|
||||
AND c.isTaxDataChecked AND c.isActive
|
||||
AND t.companyFk = ?
|
||||
AND c.hasToInvoice
|
||||
AND c.isTaxDataChecked
|
||||
AND c.isActive
|
||||
AND NOT t.isDeleted
|
||||
GROUP BY c.id, IF(c.hasToInvoiceByAddress,a.id,TRUE) HAVING sumAmount > 0`;
|
||||
|
||||
return models.InvoiceOut.rawSql(query, [
|
||||
|
|
Loading…
Reference in New Issue