Merge branch 'dev' into 5347-clientCreate-→-client_create
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
16af0c5d6c
|
@ -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')
|
|
@ -1179,8 +1179,6 @@ export default {
|
||||||
allBuyCheckbox: 'vn-entry-buy-index thead vn-check',
|
allBuyCheckbox: 'vn-entry-buy-index thead vn-check',
|
||||||
firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check',
|
firstBuyCheckbox: 'vn-entry-buy-index tbody:nth-child(2) vn-check',
|
||||||
deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]',
|
deleteBuysButton: 'vn-entry-buy-index vn-button[icon="delete"]',
|
||||||
addBuyButton: 'vn-entry-buy-index vn-icon[icon="add"]',
|
|
||||||
secondBuyPackingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price3"]',
|
|
||||||
secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]',
|
secondBuyGroupingPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.price2"]',
|
||||||
secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]',
|
secondBuyPrice: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.buyingValue"]',
|
||||||
secondBuyGrouping: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.grouping"]',
|
secondBuyGrouping: 'vn-entry-buy-index tbody:nth-child(3) > tr:nth-child(1) vn-input-number[ng-model="buy.grouping"]',
|
||||||
|
|
|
@ -66,97 +66,4 @@ describe('Entry import, create and edit buys path', () => {
|
||||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||||
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
|
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a new buy', async() => {
|
|
||||||
await page.waitToClick(selectors.entryBuys.addBuyButton);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPackingPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPrice, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGrouping, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPacking, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyWeight, '999');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyStickers, '999');
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '1');
|
|
||||||
await page.write(selectors.entryBuys.secondBuyQuantity, '999');
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyItem, '1');
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit the newest buy and check data', async() => {
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPackingPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPackingPrice, '100');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyGroupingPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGroupingPrice, '200');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPrice);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPrice, '300');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyGrouping);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyGrouping, '400');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyPacking);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyPacking, '500');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyWeight);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyWeight, '600');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyStickers);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyStickers, '700');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.autocompleteSearch(selectors.entryBuys.secondBuyPackage, '94');
|
|
||||||
await page.waitForSnackbar();
|
|
||||||
|
|
||||||
await page.clearInput(selectors.entryBuys.secondBuyQuantity);
|
|
||||||
await page.waitForTimeout(250);
|
|
||||||
await page.write(selectors.entryBuys.secondBuyQuantity, '800');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
await page.reloadSection('entry.card.buy.index');
|
|
||||||
|
|
||||||
const secondBuyPackingPrice = await page.getValue(selectors.entryBuys.secondBuyPackingPrice);
|
|
||||||
const secondBuyGroupingPrice = await page.getValue(selectors.entryBuys.secondBuyGroupingPrice);
|
|
||||||
const secondBuyPrice = await page.getValue(selectors.entryBuys.secondBuyPrice);
|
|
||||||
const secondBuyGrouping = await page.getValue(selectors.entryBuys.secondBuyGrouping);
|
|
||||||
const secondBuyPacking = await page.getValue(selectors.entryBuys.secondBuyPacking);
|
|
||||||
const secondBuyWeight = await page.getValue(selectors.entryBuys.secondBuyWeight);
|
|
||||||
const secondBuyStickers = await page.getValue(selectors.entryBuys.secondBuyStickers);
|
|
||||||
const secondBuyPackage = await page.getValue(selectors.entryBuys.secondBuyPackage);
|
|
||||||
const secondBuyQuantity = await page.getValue(selectors.entryBuys.secondBuyQuantity);
|
|
||||||
|
|
||||||
expect(secondBuyPackingPrice).toEqual('100');
|
|
||||||
expect(secondBuyGroupingPrice).toEqual('200');
|
|
||||||
expect(secondBuyPrice).toEqual('300');
|
|
||||||
expect(secondBuyGrouping).toEqual('400');
|
|
||||||
expect(secondBuyPacking).toEqual('500');
|
|
||||||
expect(secondBuyWeight).toEqual('600');
|
|
||||||
expect(secondBuyStickers).toEqual('700');
|
|
||||||
expect(secondBuyPackage).toEqual('94');
|
|
||||||
expect(secondBuyQuantity).toEqual('800');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,165 +0,0 @@
|
||||||
|
|
||||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethodCtx('addBuy', {
|
|
||||||
description: 'Inserts a new buy for the current entry',
|
|
||||||
accessType: 'WRITE',
|
|
||||||
accepts: [{
|
|
||||||
arg: 'id',
|
|
||||||
type: 'number',
|
|
||||||
required: true,
|
|
||||||
description: 'The entry id',
|
|
||||||
http: {source: 'path'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'itemFk',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'quantity',
|
|
||||||
type: 'number',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'packageFk',
|
|
||||||
type: 'string',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'packing',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'grouping',
|
|
||||||
type: 'number'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'weight',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'stickers',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'price2',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'price3',
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
arg: 'buyingValue',
|
|
||||||
type: 'number'
|
|
||||||
}],
|
|
||||||
returns: {
|
|
||||||
type: 'object',
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/:id/addBuy`,
|
|
||||||
verb: 'POST'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.addBuy = async(ctx, options) => {
|
|
||||||
const conn = Self.dataSource.connector;
|
|
||||||
let tx;
|
|
||||||
const myOptions = {};
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
|
||||||
Object.assign(myOptions, options);
|
|
||||||
|
|
||||||
if (!myOptions.transaction) {
|
|
||||||
tx = await Self.beginTransaction({});
|
|
||||||
myOptions.transaction = tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const models = Self.app.models;
|
|
||||||
|
|
||||||
ctx.args.entryFk = ctx.args.id;
|
|
||||||
|
|
||||||
// remove unwanted properties
|
|
||||||
delete ctx.args.id;
|
|
||||||
delete ctx.args.ctx;
|
|
||||||
|
|
||||||
const newBuy = await models.Buy.create(ctx.args, myOptions);
|
|
||||||
|
|
||||||
const filter = {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'itemFk',
|
|
||||||
'stickers',
|
|
||||||
'packing',
|
|
||||||
'grouping',
|
|
||||||
'quantity',
|
|
||||||
'packageFk',
|
|
||||||
'weight',
|
|
||||||
'buyingValue',
|
|
||||||
'price2',
|
|
||||||
'price3'
|
|
||||||
],
|
|
||||||
include: {
|
|
||||||
relation: 'item',
|
|
||||||
scope: {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'typeFk',
|
|
||||||
'name',
|
|
||||||
'size',
|
|
||||||
'minPrice',
|
|
||||||
'tag5',
|
|
||||||
'value5',
|
|
||||||
'tag6',
|
|
||||||
'value6',
|
|
||||||
'tag7',
|
|
||||||
'value7',
|
|
||||||
'tag8',
|
|
||||||
'value8',
|
|
||||||
'tag9',
|
|
||||||
'value9',
|
|
||||||
'tag10',
|
|
||||||
'value10',
|
|
||||||
'groupingMode'
|
|
||||||
],
|
|
||||||
include: {
|
|
||||||
relation: 'itemType',
|
|
||||||
scope: {
|
|
||||||
fields: ['code', 'description']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const stmts = [];
|
|
||||||
let stmt;
|
|
||||||
|
|
||||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc');
|
|
||||||
stmt = new ParameterizedSQL(
|
|
||||||
`CREATE TEMPORARY TABLE tmp.buyRecalc
|
|
||||||
(INDEX (id))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT ? AS id`, [newBuy.id]);
|
|
||||||
|
|
||||||
stmts.push(stmt);
|
|
||||||
stmts.push('CALL buy_recalcPrices()');
|
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
|
||||||
await conn.executeStmt(sql, myOptions);
|
|
||||||
|
|
||||||
const buy = await models.Buy.findById(newBuy.id, filter, myOptions);
|
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
|
||||||
|
|
||||||
return buy;
|
|
||||||
} catch (e) {
|
|
||||||
if (tx) await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('entry addBuy()', () => {
|
|
||||||
const activeCtx = {
|
|
||||||
accessToken: {userId: 18},
|
|
||||||
};
|
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: activeCtx
|
|
||||||
};
|
|
||||||
|
|
||||||
const entryId = 2;
|
|
||||||
it('should create a new buy for the given entry', async() => {
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
const itemId = 4;
|
|
||||||
const quantity = 10;
|
|
||||||
|
|
||||||
ctx.args = {
|
|
||||||
id: entryId,
|
|
||||||
itemFk: itemId,
|
|
||||||
quantity: quantity,
|
|
||||||
packageFk: 3
|
|
||||||
};
|
|
||||||
|
|
||||||
const tx = await models.Entry.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const newBuy = await models.Entry.addBuy(ctx, options);
|
|
||||||
|
|
||||||
expect(newBuy.itemFk).toEqual(itemId);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -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
|
||||||
|
|
|
@ -3,7 +3,6 @@ module.exports = Self => {
|
||||||
require('../methods/entry/filter')(Self);
|
require('../methods/entry/filter')(Self);
|
||||||
require('../methods/entry/getEntry')(Self);
|
require('../methods/entry/getEntry')(Self);
|
||||||
require('../methods/entry/getBuys')(Self);
|
require('../methods/entry/getBuys')(Self);
|
||||||
require('../methods/entry/addBuy')(Self);
|
|
||||||
require('../methods/entry/importBuys')(Self);
|
require('../methods/entry/importBuys')(Self);
|
||||||
require('../methods/entry/importBuysPreview')(Self);
|
require('../methods/entry/importBuysPreview')(Self);
|
||||||
require('../methods/entry/lastItemBuys')(Self);
|
require('../methods/entry/lastItemBuys')(Self);
|
||||||
|
|
|
@ -222,13 +222,6 @@
|
||||||
</vn-data-viewer>
|
</vn-data-viewer>
|
||||||
<div fixed-bottom-right>
|
<div fixed-bottom-right>
|
||||||
<vn-vertical style="align-items: center;">
|
<vn-vertical style="align-items: center;">
|
||||||
<vn-button class="round md vn-mb-sm"
|
|
||||||
ng-click="model.insert({})"
|
|
||||||
icon="add"
|
|
||||||
vn-tooltip="Add buy"
|
|
||||||
tooltip-position="left"
|
|
||||||
vn-bind="+">
|
|
||||||
</vn-button>
|
|
||||||
<a ui-sref="entry.card.buy.import" >
|
<a ui-sref="entry.card.buy.import" >
|
||||||
<vn-button class="round md vn-mb-sm"
|
<vn-button class="round md vn-mb-sm"
|
||||||
icon="publish"
|
icon="publish"
|
||||||
|
|
|
@ -13,11 +13,6 @@ export default class Controller extends Section {
|
||||||
query: `Buys/${buy.id}`,
|
query: `Buys/${buy.id}`,
|
||||||
method: 'patch'
|
method: 'patch'
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
options = {
|
|
||||||
query: `Entries/${this.entry.id}/addBuy`,
|
|
||||||
method: 'post'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
this.$http[options.method](options.query, buy).then(res => {
|
this.$http[options.method](options.query, buy).then(res => {
|
||||||
if (!res.data) return;
|
if (!res.data) return;
|
||||||
|
|
|
@ -25,17 +25,6 @@ describe('Entry buy', () => {
|
||||||
controller.saveBuy(buy);
|
controller.saveBuy(buy);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call the entry addBuy post route if the received buy has no ID`, () => {
|
|
||||||
controller.entry = {id: 1};
|
|
||||||
const buy = {itemFk: 1, quantity: 1, packageFk: 1};
|
|
||||||
|
|
||||||
const query = `Entries/${controller.entry.id}/addBuy`;
|
|
||||||
|
|
||||||
$httpBackend.expectPOST(query).respond(200);
|
|
||||||
controller.saveBuy(buy);
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteBuys()', () => {
|
describe('deleteBuys()', () => {
|
||||||
|
|
|
@ -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