Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5334-editDepartment
This commit is contained in:
commit
4931745cde
|
@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2328.01] - 2023-07-13
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
|
||||||
## [2326.01] - 2023-06-29
|
## [2326.01] - 2023-06-29
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -3,6 +3,7 @@ const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('renewToken', {
|
Self.remoteMethodCtx('renewToken', {
|
||||||
description: 'Checks if the token has more than renewPeriod seconds to live and if so, renews it',
|
description: 'Checks if the token has more than renewPeriod seconds to live and if so, renews it',
|
||||||
|
accessType: 'WRITE',
|
||||||
accepts: [],
|
accepts: [],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'Object',
|
type: 'Object',
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES
|
||||||
|
('VnUser', 'renewToken', 'WRITE', 'ALLOW', 'ROLE', 'employee')
|
|
@ -115,7 +115,7 @@
|
||||||
"This client is not invoiceable": "This client is not invoiceable",
|
"This client is not invoiceable": "This client is not invoiceable",
|
||||||
"INACTIVE_PROVIDER": "Inactive provider",
|
"INACTIVE_PROVIDER": "Inactive provider",
|
||||||
"reference duplicated": "reference duplicated",
|
"reference duplicated": "reference duplicated",
|
||||||
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
|
"The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
|
||||||
"This item is not available": "This item is not available",
|
"This item is not available": "This item is not available",
|
||||||
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
||||||
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
||||||
|
@ -175,5 +175,6 @@
|
||||||
"Pass expired": "The password has expired, change it from Salix",
|
"Pass expired": "The password has expired, change it from Salix",
|
||||||
"Can't transfer claimed sales": "Can't transfer claimed sales",
|
"Can't transfer claimed sales": "Can't transfer claimed sales",
|
||||||
"Invalid quantity": "Invalid quantity",
|
"Invalid quantity": "Invalid quantity",
|
||||||
"Failed to upload delivery note": "Error to upload delivery note {{id}}"
|
"Failed to upload delivery note": "Error to upload delivery note {{id}}",
|
||||||
|
"Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address"
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@
|
||||||
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
|
"You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito",
|
||||||
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
|
"You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas",
|
||||||
"Amounts do not match": "Las cantidades no coinciden",
|
"Amounts do not match": "Las cantidades no coinciden",
|
||||||
"The PDF document does not exists": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
|
"The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'",
|
||||||
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
"The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos",
|
||||||
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
"You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días",
|
||||||
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
"The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día",
|
||||||
|
@ -265,7 +265,7 @@
|
||||||
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
"It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas",
|
||||||
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
"A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.",
|
||||||
"There is no assigned email for this client": "No hay correo asignado para este cliente",
|
"There is no assigned email for this client": "No hay correo asignado para este cliente",
|
||||||
"Exists an invoice with a previous date": "Existe una factura con fecha anterior",
|
"Exists an invoice with a future date": "Existe una factura con fecha posterior",
|
||||||
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
|
"Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite",
|
||||||
"Warehouse inventory not set": "El almacén inventario no está establecido",
|
"Warehouse inventory not set": "El almacén inventario no está establecido",
|
||||||
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
|
"This locker has already been assigned": "Esta taquilla ya ha sido asignada",
|
||||||
|
@ -294,5 +294,9 @@
|
||||||
"Invalid NIF for VIES": "Invalid NIF for VIES",
|
"Invalid NIF for VIES": "Invalid NIF for VIES",
|
||||||
"Ticket does not exist": "Este ticket no existe",
|
"Ticket does not exist": "Este ticket no existe",
|
||||||
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
"Ticket is already signed": "Este ticket ya ha sido firmado",
|
||||||
|
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||||
|
"Error while generating PDF": "Error al generar PDF",
|
||||||
|
"Error when sending mail to client": "Error al enviar el correo al cliente",
|
||||||
|
"Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico",
|
||||||
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado"
|
"The renew period has not been exceeded": "El periodo de renovación no ha sido superado"
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,5 @@ columns:
|
||||||
hasInvoiceSimplified: simplified invoice
|
hasInvoiceSimplified: simplified invoice
|
||||||
typeFk: type
|
typeFk: type
|
||||||
lastSalesPersonFk: last salesperson
|
lastSalesPersonFk: last salesperson
|
||||||
|
rating: rating
|
||||||
|
recommendedCredit: recommended credit
|
||||||
|
|
|
@ -52,4 +52,5 @@ columns:
|
||||||
hasInvoiceSimplified: factura simple
|
hasInvoiceSimplified: factura simple
|
||||||
typeFk: tipo
|
typeFk: tipo
|
||||||
lastSalesPersonFk: último comercial
|
lastSalesPersonFk: último comercial
|
||||||
|
rating: clasificación
|
||||||
|
recommendedCredit: crédito recomendado
|
||||||
|
|
|
@ -75,7 +75,7 @@ module.exports = Self => {
|
||||||
value[field] = newValue;
|
value[field] = newValue;
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
ctx.args.filter = {where: filter, limit: null};
|
ctx.args = {where: filter, limit: null};
|
||||||
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
|
lines = await models.Buy.latestBuysFilter(ctx, null, myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,36 @@ describe('Buy editLatestsBuys()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {'i.typeFk': 1};
|
const filter = {'categoryFk': 1, 'tags': []};
|
||||||
|
const ctx = {
|
||||||
|
args: {
|
||||||
|
filter: filter
|
||||||
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const field = 'size';
|
||||||
|
const newValue = 88;
|
||||||
|
|
||||||
|
await models.Buy.editLatestBuys(ctx, field, newValue, null, filter, options);
|
||||||
|
|
||||||
|
const [result] = await models.Buy.latestBuysFilter(ctx, null, options);
|
||||||
|
|
||||||
|
expect(result[field]).toEqual(newValue);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change the value of a given column for filter tags', async() => {
|
||||||
|
const tx = await models.Buy.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const filter = {'tags': [{tagFk: 1, value: 'Brown'}]};
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
filter: filter
|
filter: filter
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const print = require('vn-print');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('createPdf', {
|
Self.remoteMethodCtx('createPdf', {
|
||||||
|
@ -26,9 +25,6 @@ module.exports = Self => {
|
||||||
Self.createPdf = async function(ctx, id, options) {
|
Self.createPdf = async function(ctx, id, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
if (process.env.NODE_ENV == 'test')
|
|
||||||
throw new UserError(`Action not allowed on the test environment`);
|
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
@ -41,40 +37,20 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const invoiceOut = await Self.findById(id, null, myOptions);
|
const invoiceOut = await Self.findById(id, {fields: ['hasPdf']}, myOptions);
|
||||||
const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE');
|
|
||||||
|
|
||||||
if (invoiceOut.hasPdf && !canCreatePdf)
|
if (invoiceOut.hasPdf) {
|
||||||
throw new UserError(`You don't have enough privileges`);
|
const canCreatePdf = await models.ACL.checkAccessAcl(ctx, 'InvoiceOut', 'canCreatePdf', 'WRITE');
|
||||||
|
if (!canCreatePdf)
|
||||||
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
}
|
||||||
|
|
||||||
await invoiceOut.updateAttributes({
|
await Self.makePdf(id, myOptions);
|
||||||
hasPdf: true
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
const invoiceReport = new print.Report('invoice', {
|
|
||||||
reference: invoiceOut.ref,
|
|
||||||
recipientId: invoiceOut.clientFk
|
|
||||||
});
|
|
||||||
const buffer = await invoiceReport.toPdfStream();
|
|
||||||
|
|
||||||
const issued = invoiceOut.issued;
|
|
||||||
const year = issued.getFullYear().toString();
|
|
||||||
const month = (issued.getMonth() + 1).toString();
|
|
||||||
const day = issued.getDate().toString();
|
|
||||||
|
|
||||||
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
|
||||||
|
|
||||||
// Store invoice
|
|
||||||
await print.storage.write(buffer, {
|
|
||||||
type: 'invoice',
|
|
||||||
path: `${year}/${month}/${day}`,
|
|
||||||
fileName: fileName
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,7 +43,9 @@ module.exports = Self => {
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const invoiceOut = await models.InvoiceOut.findById(id, null, myOptions);
|
const invoiceOut = await models.InvoiceOut.findById(id, {
|
||||||
|
fields: ['ref', 'issued']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
const issued = invoiceOut.issued;
|
const issued = invoiceOut.issued;
|
||||||
const year = issued.getFullYear().toString();
|
const year = issued.getFullYear().toString();
|
||||||
|
@ -73,7 +75,7 @@ module.exports = Self => {
|
||||||
return [stream, file.contentType, `filename="${file.name}"`];
|
return [stream, file.contentType, `filename="${file.name}"`];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'ENOENT')
|
if (error.code === 'ENOENT')
|
||||||
throw new UserError('The PDF document does not exists');
|
throw new UserError('The PDF document does not exist');
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ module.exports = Self => {
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
const $t = ctx.req.__; // $translate
|
||||||
|
const origin = ctx.req.headers.origin;
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
|
@ -109,17 +112,22 @@ module.exports = Self => {
|
||||||
], myOptions);
|
], myOptions);
|
||||||
|
|
||||||
const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, myOptions);
|
const [newInvoice] = await Self.rawSql(`SELECT @invoiceId id`, null, myOptions);
|
||||||
if (newInvoice.id) {
|
if (!newInvoice)
|
||||||
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
|
throw new UserError('No tickets to invoice', 'notInvoiced');
|
||||||
|
|
||||||
invoiceOut = await models.InvoiceOut.findById(newInvoice.id, {
|
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
|
||||||
include: {
|
|
||||||
relation: 'client'
|
invoiceOut = await models.InvoiceOut.findById(newInvoice.id, {
|
||||||
|
fields: ['id', 'ref', 'clientFk'],
|
||||||
|
include: {
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['email', 'isToBeMailed', 'salesPersonFk']
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
invoiceId = newInvoice.id;
|
invoiceId = newInvoice.id;
|
||||||
}
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -127,26 +135,45 @@ module.exports = Self => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoiceId) {
|
try {
|
||||||
if (!invoiceOut.client().isToBeMailed) {
|
await Self.makePdf(invoiceId);
|
||||||
const query = `
|
} catch (err) {
|
||||||
CALL vn.report_print(
|
console.error(err);
|
||||||
'invoice',
|
throw new UserError('Error while generating PDF', 'pdfError');
|
||||||
?,
|
}
|
||||||
account.myUser_getId(),
|
|
||||||
JSON_OBJECT('refFk', ?),
|
if (invoiceOut.client().isToBeMailed) {
|
||||||
'normal'
|
try {
|
||||||
);`;
|
|
||||||
await models.InvoiceOut.rawSql(query, [args.printerFk, invoiceOut.ref]);
|
|
||||||
} else {
|
|
||||||
ctx.args = {
|
ctx.args = {
|
||||||
reference: invoiceOut.ref,
|
reference: invoiceOut.ref,
|
||||||
recipientId: invoiceOut.clientFk,
|
recipientId: args.clientId,
|
||||||
recipient: invoiceOut.client().email
|
recipient: invoiceOut.client().email
|
||||||
};
|
};
|
||||||
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
await models.InvoiceOut.invoiceEmail(ctx, invoiceOut.ref);
|
||||||
|
} catch (err) {
|
||||||
|
const message = $t('Mail not sent', {
|
||||||
|
clientId: args.clientId,
|
||||||
|
clientUrl: `${origin}/#!/claim/${args.id}/summary`
|
||||||
|
});
|
||||||
|
const salesPersonId = invoiceOut.client().salesPersonFk;
|
||||||
|
|
||||||
|
if (salesPersonId)
|
||||||
|
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||||
|
|
||||||
|
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const query = `
|
||||||
|
CALL vn.report_print(
|
||||||
|
'invoice',
|
||||||
|
?,
|
||||||
|
account.myUser_getId(),
|
||||||
|
JSON_OBJECT('refFk', ?),
|
||||||
|
'normal'
|
||||||
|
);`;
|
||||||
|
await models.InvoiceOut.rawSql(query, [args.printerFk, invoiceOut.ref]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return invoiceId;
|
return invoiceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
|
@ -74,6 +75,10 @@ module.exports = Self => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
return email.send(mailOptions);
|
try {
|
||||||
|
return email.send(mailOptions);
|
||||||
|
} catch (err) {
|
||||||
|
throw new UserError('Error when sending mail to client', 'mailNotSent');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,12 +18,14 @@ describe('InvoiceOut invoiceClient()', () => {
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
__: value => {
|
__: value => {
|
||||||
return value;
|
return value;
|
||||||
}
|
},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
|
||||||
};
|
};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
|
|
||||||
it('should make a global invoicing', async() => {
|
it('should make a global invoicing', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true)));
|
||||||
spyOn(models.InvoiceOut, 'invoiceEmail');
|
spyOn(models.InvoiceOut, 'invoiceEmail');
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const print = require('vn-print');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/invoiceOut/filter')(Self);
|
require('../methods/invoiceOut/filter')(Self);
|
||||||
require('../methods/invoiceOut/summary')(Self);
|
require('../methods/invoiceOut/summary')(Self);
|
||||||
|
@ -19,4 +21,34 @@ module.exports = Self => {
|
||||||
require('../methods/invoiceOut/getInvoiceDate')(Self);
|
require('../methods/invoiceOut/getInvoiceDate')(Self);
|
||||||
require('../methods/invoiceOut/negativeBases')(Self);
|
require('../methods/invoiceOut/negativeBases')(Self);
|
||||||
require('../methods/invoiceOut/negativeBasesCsv')(Self);
|
require('../methods/invoiceOut/negativeBasesCsv')(Self);
|
||||||
|
|
||||||
|
Self.makePdf = async function(id, options) {
|
||||||
|
const fields = ['id', 'hasPdf', 'ref', 'issued'];
|
||||||
|
const invoiceOut = await Self.findById(id, {fields}, options);
|
||||||
|
const invoiceReport = new print.Report('invoice', {
|
||||||
|
reference: invoiceOut.ref
|
||||||
|
});
|
||||||
|
const buffer = await invoiceReport.toPdfStream();
|
||||||
|
|
||||||
|
const issued = invoiceOut.issued;
|
||||||
|
const year = issued.getFullYear().toString();
|
||||||
|
const month = (issued.getMonth() + 1).toString();
|
||||||
|
const day = issued.getDate().toString();
|
||||||
|
|
||||||
|
const fileName = `${year}${invoiceOut.ref}.pdf`;
|
||||||
|
|
||||||
|
// Store invoice
|
||||||
|
|
||||||
|
await invoiceOut.updateAttributes({
|
||||||
|
hasPdf: true
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
await print.storage.write(buffer, {
|
||||||
|
type: 'invoice',
|
||||||
|
path: `${year}/${month}/${day}`,
|
||||||
|
fileName: fileName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,11 @@
|
||||||
{{::error.address.nickname}}
|
{{::error.address.nickname}}
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td expand>
|
<vn-td expand>
|
||||||
<span class="chip alert">{{::error.message}}</span>
|
<span
|
||||||
|
class="chip"
|
||||||
|
ng-class="error.isWarning ? 'warning': 'alert'">
|
||||||
|
{{::error.message}}
|
||||||
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
|
|
|
@ -7,29 +7,29 @@ class Controller extends Section {
|
||||||
$onInit() {
|
$onInit() {
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
maxShipped: new Date(date.getFullYear(), date.getMonth(), 0),
|
maxShipped: new Date(date.getFullYear(), date.getMonth(), 0),
|
||||||
clientsToInvoice: 'all',
|
clientsToInvoice: 'all',
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$http.get('UserConfigs/getUserConfig')
|
this.$http.get('UserConfigs/getUserConfig')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.companyFk = res.data.companyFk;
|
this.companyFk = res.data.companyFk;
|
||||||
this.getInvoiceDate(this.companyFk);
|
this.getInvoiceDate(this.companyFk);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getInvoiceDate(companyFk) {
|
getInvoiceDate(companyFk) {
|
||||||
const params = { companyFk: companyFk };
|
const params = {companyFk: companyFk};
|
||||||
this.fetchInvoiceDate(params);
|
this.fetchInvoiceDate(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchInvoiceDate(params) {
|
fetchInvoiceDate(params) {
|
||||||
this.$http.get('InvoiceOuts/getInvoiceDate', { params })
|
this.$http.get('InvoiceOuts/getInvoiceDate', {params})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
|
this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null;
|
||||||
this.invoiceDate = this.minInvoicingDate;
|
this.invoiceDate = this.minInvoicingDate;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
stopInvoicing() {
|
stopInvoicing() {
|
||||||
this.status = 'stopping';
|
this.status = 'stopping';
|
||||||
|
@ -49,7 +49,7 @@ class Controller extends Section {
|
||||||
if (this.invoiceDate < this.maxShipped)
|
if (this.invoiceDate < this.maxShipped)
|
||||||
throw new UserError('Invoice date can\'t be less than max date');
|
throw new UserError('Invoice date can\'t be less than max date');
|
||||||
if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
|
if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime())
|
||||||
throw new UserError('Exists an invoice with a previous date');
|
throw new UserError('Exists an invoice with a future date');
|
||||||
if (!this.companyFk)
|
if (!this.companyFk)
|
||||||
throw new UserError('Choose a valid company');
|
throw new UserError('Choose a valid company');
|
||||||
if (!this.printerFk)
|
if (!this.printerFk)
|
||||||
|
@ -108,16 +108,30 @@ class Controller extends Section {
|
||||||
this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
||||||
.then(() => this.invoiceNext())
|
.then(() => this.invoiceNext())
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
const message = res.data?.error?.message || res.message;
|
|
||||||
if (res.status >= 400 && res.status < 500) {
|
if (res.status >= 400 && res.status < 500) {
|
||||||
this.errors.unshift({address, message});
|
const error = res.data?.error;
|
||||||
|
let isWarning;
|
||||||
|
const filter = {
|
||||||
|
where: {
|
||||||
|
id: address.clientId
|
||||||
|
}
|
||||||
|
};
|
||||||
|
switch (error?.code) {
|
||||||
|
case 'pdfError':
|
||||||
|
case 'mailNotSent':
|
||||||
|
isWarning = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = error?.message || res.message;
|
||||||
|
this.errors.unshift({address, message, isWarning});
|
||||||
this.invoiceNext();
|
this.invoiceNext();
|
||||||
} else {
|
} else {
|
||||||
this.invoicing = false;
|
this.invoicing = false;
|
||||||
this.status = 'done';
|
this.status = 'done';
|
||||||
throw new UserError(`Critical invoicing error, proccess stopped`);
|
throw new UserError(`Critical invoicing error, proccess stopped`);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
invoiceNext() {
|
invoiceNext() {
|
||||||
|
|
|
@ -18,4 +18,4 @@ Invoice out: Facturar
|
||||||
One client: Un solo cliente
|
One client: Un solo cliente
|
||||||
Choose a valid client: Selecciona un cliente válido
|
Choose a valid client: Selecciona un cliente válido
|
||||||
Stop: Parar
|
Stop: Parar
|
||||||
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido
|
Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "23.26.01",
|
"version": "23.28.01",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -5,10 +5,9 @@ module.exports = {
|
||||||
name: 'report-footer',
|
name: 'report-footer',
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
this.company = await db.findOne(`
|
this.company = await db.findOne(`
|
||||||
SELECT IFNULL(ci.footnotes, cl.footnotes) as footnotes
|
SELECT IFNULL(ci.footnotes, c.footnotes) footnotes
|
||||||
FROM company c
|
FROM company c
|
||||||
LEFT JOIN companyL10n cl ON c.id = cl.id
|
LEFT JOIN companyI18n ci ON ci.companyFk = c.id
|
||||||
LEFT JOIN companyI18n ci ON ci.companyFk = cl.id
|
|
||||||
AND ci.lang = (SELECT lang FROM account.user where id = ?)
|
AND ci.lang = (SELECT lang FROM account.user where id = ?)
|
||||||
WHERE c.code = ?`,
|
WHERE c.code = ?`,
|
||||||
[this.recipientId, this.companyCode]);
|
[this.recipientId, this.companyCode]);
|
||||||
|
|
|
@ -46,14 +46,21 @@ module.exports = {
|
||||||
const fileNames = attachments.join(',\n');
|
const fileNames = attachments.join(',\n');
|
||||||
|
|
||||||
await db.rawSql(`
|
await db.rawSql(`
|
||||||
INSERT INTO vn.mail (receiver, replyTo, sent, subject, body, attachment, status)
|
INSERT INTO vn.mail
|
||||||
VALUES (?, ?, 1, ?, ?, ?, ?)`, [
|
SET receiver = ?,
|
||||||
|
replyTo = ?,
|
||||||
|
sent = ?,
|
||||||
|
subject = ?,
|
||||||
|
body = ?,
|
||||||
|
attachment = ?,
|
||||||
|
status = ?`, [
|
||||||
options.to,
|
options.to,
|
||||||
options.replyTo,
|
options.replyTo,
|
||||||
|
error ? 2 : 1,
|
||||||
options.subject,
|
options.subject,
|
||||||
options.text || options.html,
|
options.text || options.html,
|
||||||
fileNames,
|
fileNames,
|
||||||
error && error.message || 'Sent'
|
error && error.message || 'OK'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ h2 {
|
||||||
font-size: 22px
|
font-size: 22px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.column-oriented td,
|
||||||
|
.column-oriented th {
|
||||||
|
padding: 6px
|
||||||
|
}
|
||||||
|
|
||||||
#nickname h2 {
|
#nickname h2 {
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
|
@ -39,4 +43,4 @@ h2 {
|
||||||
|
|
||||||
.phytosanitary-info {
|
.phytosanitary-info {
|
||||||
margin-top: 10px
|
margin-top: 10px
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="vn-mt-lg" v-for="ticket in tickets">
|
<div class="vn-mt-ml" v-for="ticket in tickets">
|
||||||
<div class="table-title clearfix">
|
<div class="table-title clearfix">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<h2>{{$t('deliveryNote')}}</h2>
|
<h2>{{$t('deliveryNote')}}</h2>
|
||||||
|
@ -106,13 +106,6 @@
|
||||||
<td class="centered">{{sale.vatType}}</td>
|
<td class="centered">{{sale.vatType}}</td>
|
||||||
<td class="number">{{saleImport(sale) | currency('EUR', $i18n.locale)}}</td>
|
<td class="number">{{saleImport(sale) | currency('EUR', $i18n.locale)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="description font light-gray">
|
|
||||||
<td colspan="7">
|
|
||||||
<span v-if="sale.value5"> <strong>{{sale.tag5}}</strong> {{sale.value5}} </span>
|
|
||||||
<span v-if="sale.value6"> <strong>{{sale.tag6}}</strong> {{sale.value6}} </span>
|
|
||||||
<span v-if="sale.value7"> <strong>{{sale.tag7}}</strong> {{sale.value7}} </span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue