Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
f84e85e443
|
@ -0,0 +1,14 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
USE vn;
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelvingBuy_FK;
|
||||||
|
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2;
|
||||||
|
ALTER TABLE vn.itemShelving DROP INDEX itemShelving_UN;
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelvingBuy_FK FOREIGN KEY (buyFk) REFERENCES vn.buy(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@
|
||||||
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
||||||
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
|
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
|
||||||
"The line could not be marked": "La linea no puede ser marcada",
|
"The line could not be marked": "La linea no puede ser marcada",
|
||||||
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
|
"Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado",
|
||||||
"They're not your subordinate": "No es tu subordinado/a.",
|
"They're not your subordinate": "No es tu subordinado/a.",
|
||||||
"No results found": "No se han encontrado resultados",
|
"No results found": "No se han encontrado resultados",
|
||||||
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
||||||
|
@ -366,4 +366,4 @@
|
||||||
"It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
|
"It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
|
||||||
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
||||||
"Payment method is required": "El método de pago es obligatorio"
|
"Payment method is required": "El método de pago es obligatorio"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.setUnverifiedPassword = async(id, pass, options) => {
|
Self.setUnverifiedPassword = async(id, pass, options) => {
|
||||||
const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options);
|
const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options);
|
||||||
if (emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves');
|
if (emailVerified) {
|
||||||
|
throw new ForbiddenError(
|
||||||
|
'Through this procedure, it is not possible to modify the password of users with verified email'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await models.VnUser.setPassword(id, pass, options);
|
await models.VnUser.setPassword(id, pass, options);
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,15 +145,10 @@ module.exports = Self => {
|
||||||
|
|
||||||
const newTicket = await models.Ticket.new(ctx, myOptions);
|
const newTicket = await models.Ticket.new(ctx, myOptions);
|
||||||
|
|
||||||
const ticketRefund = await models.TicketRefund.findOne({
|
await models.TicketRefund.create({
|
||||||
where: {refundTicketFk: ticketId}
|
originalTicketFk: ticketId,
|
||||||
|
refundTicketFk: newTicket.id
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
if (negative && (withWarehouse || !ticketRefund?.id)) {
|
|
||||||
await models.TicketRefund.create({
|
|
||||||
originalTicketFk: ticketId,
|
|
||||||
refundTicketFk: newTicket.id
|
|
||||||
}, myOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newTicket;
|
return newTicket;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('ticket state()', () => {
|
xdescribe('ticket state()', () => {
|
||||||
const salesPersonId = 18;
|
const salesPersonId = 18;
|
||||||
const employeeId = 1;
|
const employeeId = 1;
|
||||||
const productionId = 49;
|
const productionId = 49;
|
||||||
|
@ -113,6 +113,7 @@ describe('ticket state()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
||||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
activeCtx.accessToken.userId = salesPersonId;
|
activeCtx.accessToken.userId = salesPersonId;
|
||||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||||
|
@ -124,6 +125,7 @@ describe('ticket state()', () => {
|
||||||
expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
|
expect(resAssigned.userFk).toBe(paramsAssigned.userFk);
|
||||||
expect(resAssigned.userFk).toBe(1);
|
expect(resAssigned.userFk).toBe(1);
|
||||||
expect(resAssigned.id).toBeDefined();
|
expect(resAssigned.id).toBeDefined();
|
||||||
|
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
||||||
|
|
||||||
activeCtx.accessToken.userId = productionId;
|
activeCtx.accessToken.userId = productionId;
|
||||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
|
@ -183,5 +185,37 @@ describe('ticket state()', () => {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not call sendCheckingPresence if sales.length is 0 because quantities are equal', async() => {
|
||||||
|
const tx = await models.TicketTracking.beginTransaction({});
|
||||||
|
spyOn(models.Chat, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||||
|
activeCtx.accessToken.userId = productionId;
|
||||||
|
|
||||||
|
const sampleSale = {
|
||||||
|
ticketFk: ticket.id,
|
||||||
|
itemFk: 1,
|
||||||
|
concept: 'Test',
|
||||||
|
quantity: 10,
|
||||||
|
originalQuantity: 10
|
||||||
|
};
|
||||||
|
await models.Sale.create(sampleSale, options);
|
||||||
|
|
||||||
|
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||||
|
const params = {ticketFk: ticket.id, stateFk: packedState.id};
|
||||||
|
|
||||||
|
await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
|
expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
let newStateOrder;
|
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
@ -41,16 +40,11 @@ module.exports = Self => {
|
||||||
throw new UserError('State cannot be blank');
|
throw new UserError('State cannot be blank');
|
||||||
|
|
||||||
if (params.stateFk) {
|
if (params.stateFk) {
|
||||||
const {code, order} = await models.State.findById(
|
const {code} = await models.State.findById(params.stateFk, {fields: ['code']}, myOptions);
|
||||||
params.stateFk,
|
|
||||||
{fields: ['code', 'order']},
|
|
||||||
myOptions);
|
|
||||||
params.code = code;
|
params.code = code;
|
||||||
newStateOrder = order;
|
|
||||||
} else {
|
} else {
|
||||||
const {id, order} = await models.State.findOne({where: {code: params.code}}, myOptions);
|
const {id} = await models.State.findOne({where: {code: params.code}}, myOptions);
|
||||||
params.stateFk = id;
|
params.stateFk = id;
|
||||||
newStateOrder = order;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.userFk) {
|
if (!params.userFk) {
|
||||||
|
@ -70,59 +64,7 @@ module.exports = Self => {
|
||||||
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
||||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(params.ticketFk, {
|
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
||||||
include: [{
|
|
||||||
relation: 'client',
|
|
||||||
scope: {
|
|
||||||
fields: ['salesPersonFk']
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
fields: ['id', 'clientFk']
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
const salesPersonFk = ticket.client().salesPersonFk;
|
|
||||||
const stateChecked = await models.State.findOne({fields: ['order'], where: {code: 'CHECKED'}});
|
|
||||||
|
|
||||||
if (salesPersonFk && newStateOrder >= stateChecked.order) {
|
|
||||||
const sales = await Self.rawSql(`
|
|
||||||
SELECT DISTINCT s.id,
|
|
||||||
s.itemFk,
|
|
||||||
s.concept,
|
|
||||||
s.originalQuantity AS oldQuantity,
|
|
||||||
s.quantity AS newQuantity
|
|
||||||
FROM vn.sale s
|
|
||||||
WHERE s.ticketFk = ?
|
|
||||||
AND s.originalQuantity IS NOT NULL
|
|
||||||
AND s.originalQuantity <> s.quantity
|
|
||||||
`, [params.ticketFk], myOptions);
|
|
||||||
|
|
||||||
if (sales.length) {
|
|
||||||
let changes = '';
|
|
||||||
const url = await models.Url.getUrl();
|
|
||||||
const $t = ctx.req.__;
|
|
||||||
for (let sale of sales) {
|
|
||||||
changes += `\r\n-` + $t('Changes in sales', {
|
|
||||||
itemId: sale.itemFk,
|
|
||||||
concept: sale.concept,
|
|
||||||
oldQuantity: sale.oldQuantity,
|
|
||||||
newQuantity: sale.newQuantity,
|
|
||||||
itemUrl: `${url}item/${sale.itemFk}/summary`
|
|
||||||
});
|
|
||||||
const currentSale = await models.Sale.findById(sale.id, null, myOptions);
|
|
||||||
await currentSale.updateAttributes({
|
|
||||||
originalQuantity: currentSale.quantity
|
|
||||||
}, myOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
const message = $t('Changed sale quantity', {
|
|
||||||
ticketId: ticket.id,
|
|
||||||
changes: changes,
|
|
||||||
ticketUrl: `${url}ticket/${ticket.id}/sale`
|
|
||||||
});
|
|
||||||
await models.Chat.sendCheckingPresence(ctx, salesPersonFk, message, myOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticket.id, params.code], myOptions);
|
|
||||||
|
|
||||||
const ticketTracking = await models.TicketTracking.findOne({
|
const ticketTracking = await models.TicketTracking.findOne({
|
||||||
where: {ticketFk: params.ticketFk},
|
where: {ticketFk: params.ticketFk},
|
||||||
|
|
|
@ -42,7 +42,9 @@ describe('worker setPassword()', () => {
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toEqual(`This password can only be changed by the user themselves`);
|
expect(e.message).toEqual(
|
||||||
|
'Through this procedure, it is not possible to modify the password of users with verified email'
|
||||||
|
);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
? 'Click to allow the user to be disabled'
|
? 'Click to allow the user to be disabled'
|
||||||
: 'Click to exclude the user from getting disabled'}}
|
: 'Click to exclude the user from getting disabled'}}
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item ng-if="!$ctrl.worker.user.emailVerified && $ctrl.vnConfig.storage.currentUserWorkerId !=$ctrl.worker.id" ng-click="setPassword.show()" translate>
|
<vn-item ng-click="setPassword.show()" translate>
|
||||||
Change password
|
Change password
|
||||||
</vn-item>
|
</vn-item>
|
||||||
</slot-menu>
|
</slot-menu>
|
||||||
|
|
Loading…
Reference in New Issue