fix: closeTicket idem salix refs #6549
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
dbbebbe73c
commit
ff459ea3be
|
@ -68,16 +68,21 @@ BEGIN
|
|||
DELETE ti.*
|
||||
FROM tmp.ticketToInvoice ti
|
||||
JOIN ticket t ON t.id = ti.id
|
||||
LEFT JOIN address a ON a.id = t.addressFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
|
||||
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
|
||||
AND itc.countryFk = su.countryFk
|
||||
WHERE (YEAR(t.shipped) < 2001 AND t.isDeleted)
|
||||
OR c.isTaxDataChecked = FALSE
|
||||
OR t.isDeleted
|
||||
OR c.hasToInvoice = FALSE
|
||||
OR itc.id IS NULL;
|
||||
OR itc.id IS NULL
|
||||
OR a.id IS NULL
|
||||
OR (vTaxArea = 'WORLD'
|
||||
AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL));
|
||||
|
||||
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
|
||||
INTO vIsAnySaleToInvoice
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO util.notification (id, name, description)
|
||||
SELECT MAX(id) + 1,
|
||||
'invoice-ticket-closure',
|
||||
'Tickets not invoiced during the nightly closure ticket process'
|
||||
FROM util.notification;
|
|
@ -58,6 +58,73 @@ module.exports = Self => {
|
|||
GROUP BY t.id
|
||||
`, [toDate, toDate]);
|
||||
|
||||
await Self.rawSql(`
|
||||
WITH ticketNotInvoiceable AS(
|
||||
SELECT JSON_OBJECT(
|
||||
'tickets',
|
||||
JSON_ARRAYAGG(
|
||||
JSON_OBJECT(
|
||||
'ticketId', ticketFk,
|
||||
'reason',
|
||||
LEFT(reason,LENGTH(reason) - 2)
|
||||
)
|
||||
))errors
|
||||
FROM (
|
||||
SELECT ticketFk,
|
||||
CONCAT_WS('',
|
||||
IF(hasErrorToInvoice, 'Facturar, ', ''),
|
||||
IF(hasErrorTaxDataChecked, 'Datos comprobados, ', ''),
|
||||
IF(hasErrorDeleted, 'Eliminado, ', ''),
|
||||
IF(hasErrorItemTaxCountry, 'Impuesto no informado, ', ''),
|
||||
IF(hasErrorAddress, 'Sin dirección, ', ''),
|
||||
IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones, ', '')) reason
|
||||
FROM (
|
||||
SELECT t.id ticketFk,
|
||||
SUM(NOT c.hasToInvoice) hasErrorToInvoice,
|
||||
SUM(NOT c.isTaxDataChecked) hasErrorTaxDataChecked,
|
||||
SUM(t.isDeleted) hasErrorDeleted,
|
||||
SUM(itc.id IS NULL) hasErrorItemTaxCountry,
|
||||
SUM(a.id IS NULL) hasErrorAddress,
|
||||
SUM(ios.code IS NOT NULL
|
||||
AND(ad.customsAgentFk IS NULL
|
||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld
|
||||
FROM ticket t
|
||||
LEFT JOIN address ad ON ad.id = t.addressFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN supplier su ON su.id = t.companyFk
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
LEFT JOIN autonomy a ON a.id = p.autonomyFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
|
||||
AND itc.countryFk = su.countryFk
|
||||
LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD'
|
||||
AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'M')
|
||||
WHERE (al.code = 'PACKED'
|
||||
OR (am.code = 'refund' AND al.code != 'delivered'))
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) AND util.dayEnd(?)
|
||||
AND t.refFk IS NULL
|
||||
AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice)
|
||||
GROUP BY ticketFk
|
||||
HAVING hasErrorToInvoice
|
||||
OR NOT hasErrorTaxDataChecked
|
||||
OR hasErrorDeleted
|
||||
OR hasErrorItemTaxCountry
|
||||
OR hasErrorAddress
|
||||
OR hasErrorInfoTaxAreaWorld
|
||||
)sub
|
||||
)sub2
|
||||
) SELECT IF(errors = '{"tickets": null}',
|
||||
'No errors',
|
||||
util.notification_send('invoice-ticket-closure', errors, NULL))
|
||||
FROM ticketNotInvoiceable`, [toDate, toDate]);
|
||||
|
||||
await closure(ctx, Self, tickets);
|
||||
|
||||
await Self.rawSql(`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
module.exports = new Stylesheet([
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
`${vnPrintPath}/common/css/layout.css`,
|
||||
`${vnPrintPath}/common/css/email.css`])
|
||||
.mergeStyles();
|
|
@ -0,0 +1,13 @@
|
|||
<email-body v-bind="$props">
|
||||
<div class="grid-row">
|
||||
<div class="grid-block vn-px-ml centered">
|
||||
<h1>{{ $t('title') }} {{ $t('total') }}: {{tickets.length}}</h1>
|
||||
<hr>
|
||||
</div>
|
||||
<div v-for="ticket in tickets" class="grid-block vn-px-ml">
|
||||
<p v-if="ticket.ticketId"><b>{{ $t('ticketId') }}:</b> {{ticket.ticketId}}</p>
|
||||
<p v-if="ticket.description"><b>{{ $t('description') }}:</b> {{ticket.description}}</p>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</email-body>
|
|
@ -0,0 +1,19 @@
|
|||
const Component = require(`vn-print/core/component`);
|
||||
const emailBody = new Component();
|
||||
|
||||
module.exports = {
|
||||
name: 'invoice-ticket-closure',
|
||||
components: {
|
||||
'email-body': emailBody.build(),
|
||||
},
|
||||
props: {
|
||||
ticketId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
subject: Nightly ticket closing process report
|
||||
title: Nightly ticket closing process report
|
||||
description: Description
|
||||
ticketId: Ticket No
|
|
@ -0,0 +1,4 @@
|
|||
subject: Informe proceso de cierre de tickets nocturno
|
||||
title: Informe proceso de cierre de tickets nocturno
|
||||
description: Descripción
|
||||
ticketId: Ticket nº
|
Loading…
Reference in New Issue