2433 - Added sage fields + e2e #414
|
@ -110,13 +110,15 @@ BEGIN
|
|||
SELECT `name` FROM `user` WHERE id = OLD.id;
|
||||
END$$
|
||||
|
||||
CREATE TRIGGER role_beforeInsert
|
||||
DROP TRIGGER IF EXISTS account.role_beforeInsert$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER role_beforeInsert
|
||||
BEFORE INSERT ON `role` FOR EACH ROW
|
||||
BEGIN
|
||||
CALL role_checkName(NEW.`name`);
|
||||
END$$
|
||||
END
|
||||
|
||||
CREATE TRIGGER role_beforeUpdate
|
||||
DROP TRIGGER IF EXISTS account.role_beforeUpdate$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER role_beforeUpdate
|
||||
BEFORE UPDATE ON `role` FOR EACH ROW
|
||||
BEGIN
|
||||
IF !(NEW.`name` <=> OLD.`name`) THEN
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DROP PROCEDURE IF EXISTS account.role_checkName;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE account.role_checkName(vRoleName VARCHAR(255))
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE account.role_checkName(vRoleName VARCHAR(255))
|
||||
BEGIN
|
||||
/**
|
||||
* Checks that role name meets the necessary syntax requirements, otherwise it
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2116,4 +2116,18 @@ INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`)
|
|||
(1, 23),
|
||||
(2, 1);
|
||||
|
||||
INSERT INTO `vn`.`campaign`(`code`, `dated`)
|
||||
VALUES
|
||||
('valentinesDay', CONCAT(YEAR(CURDATE()), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-02-14')),
|
||||
('valentinesDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-02-14')),
|
||||
('mothersDay', CONCAT(YEAR(CURDATE()), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-05-05')),
|
||||
('mothersDay', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-05-05')),
|
||||
('allSaints', CONCAT(YEAR(CURDATE()), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-11-01')),
|
||||
('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-11-01'));
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,3 +82,10 @@ TABLES=(
|
|||
workcenter
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
||||
|
||||
TABLES=(
|
||||
sage
|
||||
TiposIva
|
||||
TiposTransacciones
|
||||
)
|
||||
dump_tables ${TABLES[@]}
|
|
@ -9,6 +9,7 @@ SCHEMAS=(
|
|||
nst
|
||||
pbx
|
||||
postgresql
|
||||
sage
|
||||
salix
|
||||
stock
|
||||
util
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
"The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one",
|
||||
"Can't create stowaway for this ticket": "Can't create stowaway for this ticket",
|
||||
"Swift / BIC can't be empty": "Swift / BIC can't be empty",
|
||||
"MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} (#{{itemId}}) for the ticket id [#{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} (#{{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} (#{{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "The product from the claim (#{{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||
"This ticket is not an stowaway anymore": "The ticket id [#{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
|
||||
"MESSAGE_BOUGHT_UNITS": "Bought {{quantity}} units of {{concept}} ({{itemId}}) for the ticket id [{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "The product from the claim ({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||
"This ticket is not an stowaway anymore": "The ticket id [{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
|
||||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
||||
|
@ -70,6 +70,7 @@
|
|||
"NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day",
|
||||
"Created absence": "The worker <strong>{{author}}</strong> has added an absence of type '{{absenceType}}' to <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> for day {{dated}}.",
|
||||
"Deleted absence": "The worker <strong>{{author}}</strong> has deleted an absence of type '{{absenceType}}' to <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> for day {{dated}}.",
|
||||
"I have deleted the ticket id": "I have deleted the ticket id [#{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "I have restored the ticket id [#{{id}}]({{{url}}})"
|
||||
"I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})",
|
||||
"Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
|
||||
}
|
|
@ -121,12 +121,12 @@
|
|||
"Swift / BIC can't be empty": "Swift / BIC no puede estar vacío",
|
||||
"Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios",
|
||||
"Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios",
|
||||
"MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [#{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_BOUGHT_UNITS": "Se ha comprado {{quantity}} unidades de {{concept}} (#{{itemId}}) para el ticket id [{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*",
|
||||
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
|
||||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "Se recogerá el género de la reclamación (#{{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
|
||||
"This ticket is not an stowaway anymore": "El ticket id [#{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
|
||||
"This ticket is not an stowaway anymore": "El ticket id [{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
|
||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
||||
|
@ -146,7 +146,8 @@
|
|||
"Absence change notification on the labour calendar": "Notificacion de cambio de ausencia en el calendario laboral",
|
||||
"Created absence": "El empleado <strong>{{author}}</strong> ha añadido una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> para el día {{dated}}.",
|
||||
"Deleted absence": "El empleado <strong>{{author}}</strong> ha eliminado una ausencia de tipo '{{absenceType}}' a <a href='{{{workerUrl}}}'><strong>{{employee}}</strong></a> del día {{dated}}.",
|
||||
"I have deleted the ticket id": "He eliminado el ticket id [#{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "He restaurado el ticket id [#{{id}}]({{{url}}})",
|
||||
"You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación"
|
||||
"I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})",
|
||||
"I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})",
|
||||
"You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación",
|
||||
"Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): ```{{{changes}}}```"
|
||||
}
|
|
@ -7,7 +7,7 @@ describe('Client activeWorkersWithRole', () => {
|
|||
|
||||
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
|
||||
|
||||
expect(result.length).toEqual(16);
|
||||
expect(result.length).toEqual(17);
|
||||
expect(isSalesPerson).toBeTruthy();
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('Client listWorkers', () => {
|
|||
.then(result => {
|
||||
let amountOfEmployees = Object.keys(result).length;
|
||||
|
||||
expect(amountOfEmployees).toEqual(51);
|
||||
expect(amountOfEmployees).toEqual(53);
|
||||
done();
|
||||
})
|
||||
.catch(done.fail);
|
||||
|
|
|
@ -76,6 +76,7 @@ module.exports = Self => {
|
|||
companyFk, shipped, landed, isDeleted, option) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const isEditable = await models.Ticket.isEditable(ctx, id);
|
||||
|
||||
if (!isEditable)
|
||||
|
@ -88,29 +89,26 @@ module.exports = Self => {
|
|||
if (!zoneShipped || zoneShipped.zoneFk != zoneFk)
|
||||
throw new UserError(`You don't have privileges to change the zone`);
|
||||
}
|
||||
const originalTicket = await models.Ticket.findById(id, {fields:
|
||||
['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk',
|
||||
const originalTicket = await models.Ticket.findById(id, {
|
||||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: 'salesPersonFk'
|
||||
}
|
||||
},
|
||||
fields: ['id', 'clientFk', 'agencyModeFk', 'addressFk', 'zoneFk',
|
||||
'warehouseFk', 'companyFk', 'shipped', 'landed', 'isDeleted']
|
||||
});
|
||||
const updatedTicket = Object.assign({}, ctx.args);
|
||||
delete updatedTicket.ctx;
|
||||
delete updatedTicket.option;
|
||||
|
||||
// Force unroute
|
||||
const hasToBeUnrouted = true;
|
||||
const propertiesChange = diff(originalTicket, updatedTicket);
|
||||
const changedProperties = diff(originalTicket, updatedTicket);
|
||||
|
||||
let logRecord = {
|
||||
originFk: id,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'Ticket',
|
||||
changedModelId: id,
|
||||
oldInstance: originalTicket,
|
||||
newInstance: propertiesChange
|
||||
};
|
||||
|
||||
let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
let res = await Self.rawSql(query, [
|
||||
const query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
const res = await Self.rawSql(query, [
|
||||
id,
|
||||
clientFk,
|
||||
agencyModeFk,
|
||||
|
@ -125,7 +123,45 @@ module.exports = Self => {
|
|||
option
|
||||
]);
|
||||
|
||||
await models.TicketLog.create(logRecord);
|
||||
await models.TicketLog.create({
|
||||
originFk: id,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'Ticket',
|
||||
changedModelId: id,
|
||||
oldInstance: originalTicket,
|
||||
newInstance: changedProperties
|
||||
});
|
||||
|
||||
const salesPersonId = originalTicket.client().salesPersonFk;
|
||||
if (salesPersonId) {
|
||||
const origin = ctx.req.headers.origin;
|
||||
|
||||
let changesMade = '';
|
||||
for (let change in changedProperties) {
|
||||
let value = changedProperties[change];
|
||||
if (value instanceof Date) {
|
||||
value = new Intl.DateTimeFormat('es', {
|
||||
year: '2-digit',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
changesMade += `${change}: ${value}\r\n`;
|
||||
}
|
||||
|
||||
const message = $t('Changed this data from the ticket', {
|
||||
ticketId: id,
|
||||
ticketUrl: `${origin}/#!/ticket/${id}/summary`,
|
||||
changes: changesMade
|
||||
});
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -47,7 +47,14 @@ describe('ticket componentUpdate()', () => {
|
|||
let ctx = {
|
||||
args: {clientFk: clientID,
|
||||
agencyModeFk: agencyModeID},
|
||||
req: {accessToken: {userId: userID}}};
|
||||
req: {
|
||||
accessToken: {userId: userID},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: (value, params) => {
|
||||
return params.nickname;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await app.models.Ticket.componentUpdate(ctx, ticketID, clientID, agencyModeID, addressID,
|
||||
zoneID, warehouseID, companyID, shipped, landed, isDeleted, option);
|
||||
|
|
|
@ -56,8 +56,16 @@ class Controller extends Component {
|
|||
set warehouseId(value) {
|
||||
if (value != this.ticket.warehouseFk) {
|
||||
this.ticket.warehouseFk = value;
|
||||
|
||||
this.getShipped({
|
||||
landed: this.ticket.landed,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: value
|
||||
}).then(() => {
|
||||
if (this.zoneId == null)
|
||||
this.ticket.agencyModeFk = null;
|
||||
this.ticket.zoneFk = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,8 +185,8 @@ class Controller extends Component {
|
|||
);
|
||||
}
|
||||
|
||||
let query = `tickets/${this.ticket.id}/priceDifference`;
|
||||
let params = {
|
||||
const query = `tickets/${this.ticket.id}/priceDifference`;
|
||||
const params = {
|
||||
landed: this.ticket.landed,
|
||||
addressId: this.ticket.addressFk,
|
||||
agencyModeId: this.ticket.agencyModeFk,
|
||||
|
@ -202,9 +210,13 @@ class Controller extends Component {
|
|||
* Returns a landing date
|
||||
*/
|
||||
getLanded(params) {
|
||||
const validParams = this.shipped && this.addressId
|
||||
&& this.agencyModeId && this.warehouseId;
|
||||
if (!validParams) return this.$q.resolve();
|
||||
|
||||
this.ticket.zoneFk = null;
|
||||
const query = `Agencies/getLanded`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
return this.$http.get(query, {params}).then(res => {
|
||||
if (res.data) {
|
||||
this.ticket.zoneFk = res.data.zoneFk;
|
||||
this.ticket.landed = res.data.landed;
|
||||
|
@ -221,9 +233,13 @@ class Controller extends Component {
|
|||
* Returns a shipment date
|
||||
*/
|
||||
getShipped(params) {
|
||||
const validParams = this.landed && this.addressId
|
||||
&& this.agencyModeId && this.warehouseId;
|
||||
if (!validParams) return this.$q.resolve();
|
||||
|
||||
this.ticket.zoneFk = null;
|
||||
const query = `Agencies/getShipped`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
return this.$http.get(query, {params}).then(res => {
|
||||
if (res.data) {
|
||||
this.ticket.zoneFk = res.data.zoneFk;
|
||||
this.ticket.landed = params.landed;
|
||||
|
|
|
@ -323,6 +323,7 @@ describe('Ticket', () => {
|
|||
warehouseFk: 1
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(params);
|
||||
controller.ticket.shipped = shipped;
|
||||
|
||||
$httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult);
|
||||
controller.getLanded(params);
|
||||
|
@ -344,6 +345,7 @@ describe('Ticket', () => {
|
|||
warehouseFk: 1
|
||||
};
|
||||
const serializedParams = $httpParamSerializer(params);
|
||||
controller.ticket.landed = landed;
|
||||
|
||||
$httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult);
|
||||
controller.getShipped(params);
|
||||
|
|
|
@ -37,9 +37,12 @@ module.exports = Self => {
|
|||
Self.getLanded = async(ctx, shipped, addressFk, agencyModeFk, warehouseFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||
const roles = await models.Account.getRoles(userId);
|
||||
const canSeeExpired = roles.filter(role =>
|
||||
role == 'productionBoss' || role == 'administrative'
|
||||
);
|
||||
let showExpired = false;
|
||||
if (isProductionBoss) showExpired = true;
|
||||
if (canSeeExpired.length) showExpired = true;
|
||||
|
||||
let stmts = [];
|
||||
stmts.push(new ParameterizedSQL(
|
||||
|
|
|
@ -32,9 +32,12 @@ module.exports = Self => {
|
|||
&& where.agencyModeFk && where.warehouseFk;
|
||||
|
||||
if (filterByAvailability) {
|
||||
const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss');
|
||||
const roles = await models.Account.getRoles(userId);
|
||||
const canSeeExpired = roles.filter(role =>
|
||||
role == 'productionBoss' || role == 'administrative'
|
||||
);
|
||||
let showExpired = false;
|
||||
if (isProductionBoss) showExpired = true;
|
||||
if (canSeeExpired.length) showExpired = true;
|
||||
|
||||
stmt = new ParameterizedSQL(`CALL vn.zone_getLanded(?, ?, ?, ?, ?)`, [
|
||||
where.shipped,
|
||||
|
|
Loading…
Reference in New Issue