Merge pull request 'feat(closure): should mail the PDF invoice invoiceable clients' (#754) from 3211-closure_invoicing into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #754 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
a6dbf2c43c
|
@ -485,7 +485,8 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF
|
||||||
VALUES
|
VALUES
|
||||||
('A', 'Global nacional', 1, 'NATIONAL', 0),
|
('A', 'Global nacional', 1, 'NATIONAL', 0),
|
||||||
('T', 'Española rapida', 1, 'NATIONAL', 0),
|
('T', 'Española rapida', 1, 'NATIONAL', 0),
|
||||||
('V', 'Intracomunitaria global', 0, 'CEE', 1);
|
('V', 'Intracomunitaria global', 0, 'CEE', 1),
|
||||||
|
('M', 'Múltiple nacional', 1, 'NATIONAL', 0);
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
|
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -190,8 +190,7 @@ module.exports = app => {
|
||||||
try {
|
try {
|
||||||
await db.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]);
|
await db.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id]);
|
||||||
|
|
||||||
const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice;
|
if (!ticket.salesPersonFk || !ticket.isToBeMailed) continue;
|
||||||
if (!ticket.salesPersonFk || !ticket.isToBeMailed || hasToInvoice) continue;
|
|
||||||
|
|
||||||
if (!ticket.recipient) {
|
if (!ticket.recipient) {
|
||||||
const body = `No se ha podido enviar el albarán <strong>${ticket.id}</strong>
|
const body = `No se ha podido enviar el albarán <strong>${ticket.id}</strong>
|
||||||
|
@ -206,6 +205,25 @@ module.exports = app => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasToInvoice = ticket.hasToInvoice && ticket.hasDailyInvoice;
|
||||||
|
if (hasToInvoice) {
|
||||||
|
const invoiceId = await db.findValue(`
|
||||||
|
SELECT io.id
|
||||||
|
FROM ticket t
|
||||||
|
JOIN invoiceOut io ON io.ref = t.refFk
|
||||||
|
WHERE t.id = ?
|
||||||
|
`, [ticket.id]);
|
||||||
|
|
||||||
|
const args = Object.assign({
|
||||||
|
invoiceId: invoiceId,
|
||||||
|
recipientId: ticket.clientFk,
|
||||||
|
recipient: ticket.recipient,
|
||||||
|
replyTo: ticket.salesPersonEmail
|
||||||
|
}, reqArgs);
|
||||||
|
|
||||||
|
const email = new Email('invoice', args);
|
||||||
|
await email.send();
|
||||||
|
} else {
|
||||||
const args = Object.assign({
|
const args = Object.assign({
|
||||||
ticketId: ticket.id,
|
ticketId: ticket.id,
|
||||||
recipientId: ticket.clientFk,
|
recipientId: ticket.clientFk,
|
||||||
|
@ -215,6 +233,7 @@ module.exports = app => {
|
||||||
|
|
||||||
const email = new Email('delivery-note-link', args);
|
const email = new Email('delivery-note-link', args);
|
||||||
await email.send();
|
await email.send();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Domain not found
|
// Domain not found
|
||||||
if (error.responseCode == 450)
|
if (error.responseCode == 450)
|
||||||
|
|
Loading…
Reference in New Issue