Merge branch 'dev' into 3852-client.search-panel2
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
f96fc0f91e
|
@ -13,7 +13,7 @@ RUN apt-get update \
|
|||
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
|
||||
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
|
||||
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \
|
||||
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
|
||||
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
nodejs \
|
||||
&& apt-get purge -y --auto-remove \
|
||||
|
|
|
@ -62,13 +62,13 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Backend') {
|
||||
steps {
|
||||
nodejs('node-v14') {
|
||||
sh 'npm run test:back:ci'
|
||||
}
|
||||
}
|
||||
}
|
||||
// stage('Backend') {
|
||||
// steps {
|
||||
// nodejs('node-v14') {
|
||||
// sh 'npm run test:back:ci'
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
|
|
|
@ -29,6 +29,8 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.privileges = async function(ctx, id, roleFk, hasGrant, options) {
|
||||
if (!(hasGrant != null || roleFk)) return;
|
||||
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
|
@ -37,22 +39,40 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const user = await models.Account.findById(userId, null, myOptions);
|
||||
const user = await models.Account.findById(userId, {fields: ['hasGrant']}, myOptions);
|
||||
|
||||
const userToUpdate = await models.Account.findById(id, {
|
||||
fields: ['id', 'name', 'hasGrant', 'roleFk', 'password'],
|
||||
include: {
|
||||
relation: 'role',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
if (!user.hasGrant)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
throw new UserError(`You don't have grant privilege`);
|
||||
|
||||
const hasRoleFromUser = await models.Account.hasRole(userId, userToUpdate.role().name, myOptions);
|
||||
|
||||
if (!hasRoleFromUser)
|
||||
throw new UserError(`You don't own the role and you can't assign it to another user`);
|
||||
|
||||
const userToUpdate = await models.Account.findById(id);
|
||||
if (hasGrant != null)
|
||||
return await userToUpdate.updateAttribute('hasGrant', hasGrant, myOptions);
|
||||
if (!roleFk) return;
|
||||
userToUpdate.hasGrant = hasGrant;
|
||||
|
||||
const role = await models.Role.findById(roleFk, null, myOptions);
|
||||
if (roleFk) {
|
||||
const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions);
|
||||
const hasRole = await models.Account.hasRole(userId, role.name, myOptions);
|
||||
|
||||
if (!hasRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
throw new UserError(`You don't own the role and you can't assign it to another user`);
|
||||
|
||||
await userToUpdate.updateAttribute('roleFk', roleFk, myOptions);
|
||||
userToUpdate.roleFk = roleFk;
|
||||
}
|
||||
|
||||
await userToUpdate.save(userToUpdate);
|
||||
await models.UserAccount.sync(userToUpdate.name);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,7 +4,9 @@ describe('account privileges()', () => {
|
|||
const employeeId = 1;
|
||||
const developerId = 9;
|
||||
const sysadminId = 66;
|
||||
const bruceWayneId = 1101;
|
||||
const itBossId = 104;
|
||||
const rootId = 100;
|
||||
const clarkKent = 1103;
|
||||
|
||||
it('should throw an error when user not has privileges', async() => {
|
||||
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||
|
@ -22,7 +24,7 @@ describe('account privileges()', () => {
|
|||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have enough privileges`);
|
||||
expect(error.message).toContain(`You don't have grant privilege`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role', async() => {
|
||||
|
@ -33,12 +35,7 @@ describe('account privileges()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const root = await models.Role.findOne({
|
||||
where: {
|
||||
name: 'root'
|
||||
}
|
||||
}, options);
|
||||
await models.Account.privileges(ctx, employeeId, root.id, null, options);
|
||||
await models.Account.privileges(ctx, employeeId, rootId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -46,7 +43,26 @@ describe('account privileges()', () => {
|
|||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't have enough privileges`);
|
||||
expect(error.message).toContain(`You don't own the role and you can't assign it to another user`);
|
||||
});
|
||||
|
||||
it('should throw an error when user has privileges but not has the role from user', async() => {
|
||||
const ctx = {req: {accessToken: {userId: sysadminId}}};
|
||||
const tx = await models.Account.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
await models.Account.privileges(ctx, itBossId, developerId, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
await tx.rollback();
|
||||
}
|
||||
|
||||
expect(error.message).toContain(`You don't own the role and you can't assign it to another user`);
|
||||
});
|
||||
|
||||
it('should change role', async() => {
|
||||
|
@ -63,8 +79,8 @@ describe('account privileges()', () => {
|
|||
let error;
|
||||
let result;
|
||||
try {
|
||||
await models.Account.privileges(ctx, bruceWayneId, agency.id, null, options);
|
||||
result = await models.Account.findById(bruceWayneId, null, options);
|
||||
await models.Account.privileges(ctx, clarkKent, agency.id, null, options);
|
||||
result = await models.Account.findById(clarkKent, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -84,8 +100,8 @@ describe('account privileges()', () => {
|
|||
let result;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.Account.privileges(ctx, bruceWayneId, null, true, options);
|
||||
result = await models.Account.findById(bruceWayneId, null, options);
|
||||
await models.Account.privileges(ctx, clarkKent, null, true, options);
|
||||
result = await models.Account.findById(clarkKent, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('clean', {
|
||||
description: 'clean notifications from queue',
|
||||
accessType: 'WRITE',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/clean`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.clean = async options => {
|
||||
const models = Self.app.models;
|
||||
const status = ['sent', 'error'];
|
||||
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const config = await models.NotificationConfig.findOne({}, myOptions);
|
||||
const cleanDate = new Date();
|
||||
cleanDate.setDate(cleanDate.getDate() - config.cleanDays);
|
||||
|
||||
await models.NotificationQueue.destroyAll({
|
||||
where: {status: {inq: status}},
|
||||
created: {lt: cleanDate}
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,81 @@
|
|||
const {Email} = require('vn-print');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('send', {
|
||||
description: 'Send notifications from queue',
|
||||
accessType: 'WRITE',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/send`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.send = async options => {
|
||||
const models = Self.app.models;
|
||||
const findStatus = 'pending';
|
||||
|
||||
const myOptions = {};
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const notificationQueue = await models.NotificationQueue.find({
|
||||
where: {status: findStatus},
|
||||
include: [
|
||||
{
|
||||
relation: 'notification',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'subscription',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name', 'email', 'lang']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
}, myOptions);
|
||||
|
||||
const statusSent = 'sent';
|
||||
const statusError = 'error';
|
||||
|
||||
for (const queue of notificationQueue) {
|
||||
const queueName = queue.notification().name;
|
||||
const queueParams = JSON.parse(queue.params);
|
||||
|
||||
for (const notificationUser of queue.notification().subscription()) {
|
||||
try {
|
||||
const sendParams = {
|
||||
recipient: notificationUser.user().email,
|
||||
lang: notificationUser.user().lang
|
||||
};
|
||||
|
||||
if (notificationUser.userFk == queue.authorFk) {
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
continue;
|
||||
}
|
||||
|
||||
const newParams = Object.assign({}, queueParams, sendParams);
|
||||
const email = new Email(queueName, newParams);
|
||||
|
||||
if (process.env.NODE_ENV != 'test')
|
||||
await email.send();
|
||||
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
} catch (error) {
|
||||
await queue.updateAttribute('status', statusError);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,42 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Notification Clean()', () => {
|
||||
it('should delete old rows with error', async() => {
|
||||
const userId = 9;
|
||||
const status = 'error';
|
||||
const tx = await models.NotificationQueue.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
const notification = await models.Notification.findOne({}, options);
|
||||
const notificationConfig = await models.NotificationConfig.findOne({});
|
||||
|
||||
const cleanDate = new Date();
|
||||
cleanDate.setDate(cleanDate.getDate() - (notificationConfig.cleanDays + 1));
|
||||
|
||||
let before;
|
||||
let after;
|
||||
|
||||
try {
|
||||
const notificationDelete = await models.NotificationQueue.create({
|
||||
notificationFk: notification.name,
|
||||
authorFk: userId,
|
||||
status: status,
|
||||
created: cleanDate
|
||||
}, options);
|
||||
|
||||
before = await models.NotificationQueue.findById(notificationDelete.id, null, options);
|
||||
|
||||
await models.Notification.clean(options);
|
||||
|
||||
after = await models.NotificationQueue.findById(notificationDelete.id, null, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(before.notificationFk).toEqual(notification.name);
|
||||
expect(after).toBe(null);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,33 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Notification Send()', () => {
|
||||
it('should send notification', async() => {
|
||||
const statusPending = 'pending';
|
||||
const tx = await models.NotificationQueue.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const filter = {
|
||||
where: {
|
||||
status: statusPending
|
||||
}
|
||||
};
|
||||
|
||||
let before;
|
||||
let after;
|
||||
|
||||
try {
|
||||
before = await models.NotificationQueue.find(filter, options);
|
||||
|
||||
await models.Notification.send(options);
|
||||
|
||||
after = await models.NotificationQueue.find(filter, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(before.length).toEqual(3);
|
||||
expect(after.length).toEqual(0);
|
||||
});
|
||||
});
|
|
@ -1,12 +1,13 @@
|
|||
const jsdom = require('jsdom');
|
||||
const mysql = require('mysql');
|
||||
const FormData = require('form-data');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('closeTicket', {
|
||||
description: 'Close tickets without response from the user',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -54,9 +55,9 @@ module.exports = Self => {
|
|||
});
|
||||
});
|
||||
|
||||
await requestToken();
|
||||
await getRequestToken();
|
||||
|
||||
async function requestToken() {
|
||||
async function getRequestToken() {
|
||||
const response = await fetch(ostUri);
|
||||
|
||||
const result = response.headers.get('set-cookie');
|
||||
|
@ -93,24 +94,45 @@ module.exports = Self => {
|
|||
await close(token, secondCookie);
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`;
|
||||
const data = {
|
||||
status_id: config.newStatusId,
|
||||
comments: config.comment,
|
||||
undefined: config.action
|
||||
};
|
||||
async function getLockCode(token, secondCookie, ticketId) {
|
||||
const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'X-CSRFToken': token,
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
const response = await fetch(ostUri, params);
|
||||
const body = await response.text();
|
||||
const json = JSON.parse(body);
|
||||
|
||||
return json.code;
|
||||
}
|
||||
|
||||
async function close(token, secondCookie) {
|
||||
for (const ticketId of ticketsId) {
|
||||
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
||||
let form = new FormData();
|
||||
form.append('__CSRFToken__', token);
|
||||
form.append('id', ticketId);
|
||||
form.append('a', config.responseType);
|
||||
form.append('lockCode', lockCode);
|
||||
form.append('from_email_id', config.fromEmailId);
|
||||
form.append('reply-to', config.replyTo);
|
||||
form.append('cannedResp', 0);
|
||||
form.append('response', config.comment);
|
||||
form.append('signature', 'none');
|
||||
form.append('reply_status_id', config.newStatusId);
|
||||
|
||||
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
|
||||
const params = {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
headers: {
|
||||
'Cookie': secondCookie
|
||||
}
|
||||
};
|
||||
return fetch(ostUri, params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,21 @@
|
|||
"Module": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Notification": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationAcl": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"NotificationSubscription": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Province": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -101,6 +116,9 @@
|
|||
"Town": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Url": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"UserConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -102,6 +102,13 @@
|
|||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
},
|
||||
{
|
||||
"property": "privileges",
|
||||
"accessType": "*",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$authenticated",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/notification/send')(Self);
|
||||
require('../methods/notification/clean')(Self);
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "Notification",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notification"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"subscription": {
|
||||
"type": "hasMany",
|
||||
"model": "NotificationSubscription",
|
||||
"foreignKey": "notificationFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "NotificationAcl",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationAcl"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk"
|
||||
},
|
||||
"role": {
|
||||
"type": "belongsTo",
|
||||
"model": "Role",
|
||||
"foreignKey": "roleFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "NotificationConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"cleanDays": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "NotificationQueue",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationQueue"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"params": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk",
|
||||
"primaryKey": "name"
|
||||
},
|
||||
"author": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "authorFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "NotificationSubscription",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "util.notificationSubscription"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"notificationFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"notification": {
|
||||
"type": "belongsTo",
|
||||
"model": "Notification",
|
||||
"foreignKey": "notificationFk"
|
||||
},
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,9 +27,6 @@
|
|||
"newStatusId": {
|
||||
"type": "number"
|
||||
},
|
||||
"action": {
|
||||
"type": "string"
|
||||
},
|
||||
"day": {
|
||||
"type": "number"
|
||||
},
|
||||
|
@ -47,6 +44,15 @@
|
|||
},
|
||||
"portDb": {
|
||||
"type": "number"
|
||||
},
|
||||
"responseType": {
|
||||
"type": "string"
|
||||
},
|
||||
"fromEmailId": {
|
||||
"type": "number"
|
||||
},
|
||||
"replyTo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Url",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "salix.url"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"appName": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 1
|
||||
},
|
||||
"environment": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"id": 2
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL;
|
||||
ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL;
|
|
@ -14,7 +14,3 @@ CREATE TABLE `vn`.`osTicketConfig` (
|
|||
`portDb` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`)
|
||||
VALUES
|
||||
(0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL);
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId)
|
||||
VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Business', '*', '*', 'ALLOW', 'ROLE', 'hr');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,28 @@
|
|||
DROP FUNCTION IF EXISTS `util`.`notification_send`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT)
|
||||
RETURNS INT
|
||||
MODIFIES SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Sends a notification.
|
||||
*
|
||||
* @param vNotificationName The notification name
|
||||
* @param vParams The notification parameters formatted as JSON
|
||||
* @param vAuthorFk The notification author or %NULL if there is no author
|
||||
* @return The notification id
|
||||
*/
|
||||
DECLARE vNotificationFk INT;
|
||||
|
||||
SELECT id INTO vNotificationFk
|
||||
FROM `notification`
|
||||
WHERE `name` = vNotificationName;
|
||||
|
||||
INSERT INTO notificationQueue
|
||||
SET notificationFk = vNotificationFk,
|
||||
params = vParams,
|
||||
authorFk = vAuthorFk;
|
||||
|
||||
RETURN LAST_INSERT_ID();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,63 @@
|
|||
USE util;
|
||||
|
||||
CREATE TABLE notification(
|
||||
id INT PRIMARY KEY,
|
||||
`name` VARCHAR(255) UNIQUE,
|
||||
`description` VARCHAR(255)
|
||||
);
|
||||
|
||||
CREATE TABLE notificationAcl(
|
||||
notificationFk INT,
|
||||
roleFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, roleFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role`(`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationSubscription(
|
||||
notificationFk INT,
|
||||
userFk INT(10) unsigned,
|
||||
PRIMARY KEY(notificationFk, userFk)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationQueue(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
notificationFk VARCHAR(255),
|
||||
params JSON,
|
||||
authorFk INT(10) unsigned NULL,
|
||||
`status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending',
|
||||
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX(notificationFk),
|
||||
INDEX(authorFk),
|
||||
INDEX(status)
|
||||
);
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `nnotificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification` (`name`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user`(`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
CREATE TABLE notificationConfig(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
cleanDays MEDIUMINT
|
||||
);
|
||||
|
||||
INSERT INTO notificationConfig
|
||||
SET cleanDays = 90;
|
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL;
|
||||
ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL;
|
||||
|
||||
UPDATE `vn`.`osTicketConfig`
|
||||
SET responseType='reply', fromEmailId=5, replyTo='all'
|
||||
WHERE id=0;
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Notification', '*', 'WRITE', 'ALLOW', 'ROLE', 'developer');
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`;
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelving', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ItemShelving', '*', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ItemShelvingPlacementSupplyStock', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
CREATE TABLE `vn`.`packingSiteConfig` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`shinobiUrl` varchar(255) NOT NULL,
|
||||
`shinobiToken` varchar(255) NOT NULL,
|
||||
`shinobiGroupKey` varchar(255) NOT NULL,
|
||||
`avgBoxingTime` INT(3) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,56 @@
|
|||
ALTER TABLE `vn`.`packingSite` ADD monitorId varchar(255) NULL;
|
||||
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'VbiUcajdaT'
|
||||
WHERE code = 'h1';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'qKMPn9aaVe'
|
||||
WHERE code = 'h2';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '3CtdIAGPAv'
|
||||
WHERE code = 'h3';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'Xme2hiqz1f'
|
||||
WHERE code = 'h4';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'aulxefgfJU'
|
||||
WHERE code = 'h5';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6Ou0D1bhBw'
|
||||
WHERE code = 'h6';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'eVUvnE6pNw'
|
||||
WHERE code = 'h7';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0wsmSvqmrs'
|
||||
WHERE code = 'h8';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'r2l2RyyF4I'
|
||||
WHERE code = 'h9';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'EdjHLIiDVD'
|
||||
WHERE code = 'h10';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'czC45kmwqI'
|
||||
WHERE code = 'h11';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'PNsmxPaCwQ'
|
||||
WHERE code = 'h12';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'agVssO0FDC'
|
||||
WHERE code = 'h13';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'f2SPNENHPo'
|
||||
WHERE code = 'h14';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '6UR7gUZxks'
|
||||
WHERE code = 'h15';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'bOB0f8WZ2V'
|
||||
WHERE code = 'h16';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = 'MIR1nXaL0n'
|
||||
WHERE code = 'h17';
|
||||
UPDATE `vn`.`packingSite`
|
||||
SET monitorId = '0Oj9SgGTXR'
|
||||
WHERE code = 'h18';
|
|
@ -0,0 +1,33 @@
|
|||
CREATE TABLE `salix`.`url` (
|
||||
`appName` varchar(100) NOT NULL,
|
||||
`environment` varchar(100) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`appName`,`environment`)
|
||||
);
|
||||
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'production', 'https://salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'test', 'https://test-salix.verdnatura.es/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('salix', 'dev', 'http://localhost:5000/#!/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'production', 'https://lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'test', 'https://test-lilium.verdnatura.es/#/');
|
||||
INSERT INTO `salix`.`url` (`appName`, `environment`, `url`)
|
||||
VALUES
|
||||
('lilium', 'dev', 'http://localhost:8080/#/');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Url', '*', 'WRITE', 'ALLOW', 'ROLE', 'it');
|
|
@ -45,8 +45,8 @@ INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPre
|
|||
|
||||
CALL `account`.`role_sync`;
|
||||
|
||||
INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`)
|
||||
SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd'
|
||||
INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`, `bcryptPassword`)
|
||||
SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2'
|
||||
FROM `account`.`role` WHERE id <> 20
|
||||
ORDER BY id;
|
||||
|
||||
|
@ -918,21 +918,21 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
|
|||
(3, 'Perdida', 'LOST');
|
||||
|
||||
|
||||
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
|
||||
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2),
|
||||
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(11, 7, 8, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(12, 7, 9, 71, NOW(), NULL, 1, 18, NULL, 94, 3),
|
||||
(13, 1, 10, 71, NOW(), NULL, 1, 18, NULL, 94, 3);
|
||||
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1, 'pc1'),
|
||||
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1, NULL),
|
||||
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2, NULL),
|
||||
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3, NULL),
|
||||
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3, NULL),
|
||||
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL,NULL),
|
||||
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1, NULL),
|
||||
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2, NULL),
|
||||
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL),
|
||||
(11, 7, 8, 71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL),
|
||||
(12, 7, 9, 71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL),
|
||||
(13, 1, 10,71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
|
||||
|
@ -1778,10 +1778,10 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina
|
|||
(1, 31, 4, 21, 2),
|
||||
(2, 32, 3, 21, 3);
|
||||
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`)
|
||||
INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`)
|
||||
VALUES
|
||||
(1, 'Contact description', 50),
|
||||
(2, 'Contact description', 30);
|
||||
(1, 50),
|
||||
(2, 30);
|
||||
|
||||
INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`)
|
||||
VALUES
|
||||
|
@ -2659,6 +2659,39 @@ INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`,
|
|||
VALUES
|
||||
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
|
||||
|
||||
INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
|
||||
VALUES
|
||||
(1, 'pc1', 'pc host', 1, 1);
|
||||
|
||||
INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
|
||||
VALUES
|
||||
(1, 'h1', 1, '');
|
||||
|
||||
INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`)
|
||||
VALUES
|
||||
('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000);
|
||||
INSERT INTO `util`.`notificationConfig`
|
||||
SET `cleanDays` = 90;
|
||||
|
||||
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
|
||||
VALUES
|
||||
(1, 'print-email', 'notification fixture one');
|
||||
|
||||
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
|
||||
VALUES
|
||||
(1, 9);
|
||||
|
||||
INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`)
|
||||
VALUES
|
||||
(1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()),
|
||||
(2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()),
|
||||
(3, 'print-email', null, null, 'pending', util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
|
||||
VALUES
|
||||
(1, 1109),
|
||||
(1, 1110);
|
||||
|
||||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||
VALUES
|
||||
(1, 9);
|
||||
|
@ -2678,3 +2711,7 @@ INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `lev
|
|||
UPDATE `account`.`user`
|
||||
SET `hasGrant` = 1
|
||||
WHERE `id` = 66;
|
||||
|
||||
INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`)
|
||||
VALUES
|
||||
(0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all');
|
|
@ -596,7 +596,14 @@ export default {
|
|||
submitNotesButton: 'button[type=submit]'
|
||||
},
|
||||
ticketExpedition: {
|
||||
thirdExpeditionRemoveButton: 'vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(3) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]',
|
||||
firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]',
|
||||
thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]',
|
||||
deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]',
|
||||
moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]',
|
||||
moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]',
|
||||
moreMenuWithRoute: 'vn-item[name="withRoute"]',
|
||||
newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]',
|
||||
saveButton: '.vn-dialog.shown [response="accept"]',
|
||||
expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr'
|
||||
},
|
||||
ticketPackages: {
|
||||
|
|
|
@ -18,7 +18,8 @@ describe('Ticket expeditions and log path', () => {
|
|||
});
|
||||
|
||||
it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdExpeditionRemoveButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.deleteExpeditionButton);
|
||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
||||
await page.reloadSection('ticket.card.expedition');
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Ticket expeditions', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('production', 'ticket');
|
||||
await page.accessToSearchResult('1');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it(`should move one expedition to new ticket withoute route`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute);
|
||||
await page.waitToClick(selectors.ticketExpedition.saveButton);
|
||||
await page.waitForState('ticket.card.summary');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
|
||||
await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {});
|
||||
const result = await page
|
||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should move one expedition to new ticket with route`, async() => {
|
||||
await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox);
|
||||
await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton);
|
||||
await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute);
|
||||
await page.write(selectors.ticketExpedition.newRouteId, '1');
|
||||
await page.waitToClick(selectors.ticketExpedition.saveButton);
|
||||
await page.waitForState('ticket.card.summary');
|
||||
await page.accessToSection('ticket.card.expedition');
|
||||
|
||||
await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {});
|
||||
const result = await page
|
||||
.countElement(selectors.ticketExpedition.expeditionRow);
|
||||
|
||||
expect(result).toEqual(1);
|
||||
});
|
||||
});
|
|
@ -29,4 +29,13 @@ describe('Account LDAP path', () => {
|
|||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reset data', async() => {
|
||||
await page.waitToClick(selectors.accountLdap.checkEnable);
|
||||
await page.waitToClick(selectors.accountLdap.save);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,4 +29,13 @@ describe('Account Samba path', () => {
|
|||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reset data', async() => {
|
||||
await page.waitToClick(selectors.accountSamba.checkEnable);
|
||||
await page.waitToClick(selectors.accountSamba.save);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('Account privileges path', () => {
|
|||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain(`You don't have enough privileges`);
|
||||
expect(message.text).toContain(`You don't have grant privilege`);
|
||||
});
|
||||
|
||||
it('should throw error when change role', async() => {
|
||||
|
@ -33,7 +33,7 @@ describe('Account privileges path', () => {
|
|||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain(`You don't have enough privileges`);
|
||||
expect(message.text).toContain(`You don't have grant privilege`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -56,7 +56,16 @@ describe('Account privileges path', () => {
|
|||
expect(result).toBe('checked');
|
||||
});
|
||||
|
||||
it('should change role', async() => {
|
||||
it('should throw error when change role and not own role', async() => {
|
||||
await page.autocompleteSearch(selectors.accountPrivileges.role, 'itBoss');
|
||||
await page.waitToClick(selectors.accountPrivileges.save);
|
||||
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain(`You don't own the role and you can't assign it to another user`);
|
||||
});
|
||||
|
||||
it('should change role to employee', async() => {
|
||||
await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee');
|
||||
await page.waitToClick(selectors.accountPrivileges.save);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
@ -67,6 +76,18 @@ describe('Account privileges path', () => {
|
|||
expect(message.text).toContain(`Data saved!`);
|
||||
expect(result).toContain('employee');
|
||||
});
|
||||
|
||||
it('should return role to developer', async() => {
|
||||
await page.autocompleteSearch(selectors.accountPrivileges.role, 'developer');
|
||||
await page.waitToClick(selectors.accountPrivileges.save);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
await page.reloadSection('account.card.privileges');
|
||||
const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value');
|
||||
|
||||
expect(message.text).toContain(`Data saved!`);
|
||||
expect(result).toContain('developer');
|
||||
});
|
||||
});
|
||||
|
||||
describe('as developer again', () => {
|
||||
|
@ -76,7 +97,12 @@ describe('Account privileges path', () => {
|
|||
|
||||
await page.waitToClick(selectors.accountPrivileges.checkHasGrant);
|
||||
await page.waitToClick(selectors.accountPrivileges.save);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain(`Data saved!`);
|
||||
});
|
||||
|
||||
it('should logIn in developer', async() => {
|
||||
await page.reloadSection('account.card.privileges');
|
||||
const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant);
|
||||
|
||||
|
|
|
@ -54,6 +54,21 @@ export default class App {
|
|||
localStorage.setItem('salix-version', newVersion);
|
||||
}
|
||||
}
|
||||
|
||||
getUrl(route, appName = 'lilium') {
|
||||
const env = process.env.NODE_ENV;
|
||||
const filter = {
|
||||
where: {and: [
|
||||
{appName: appName},
|
||||
{environment: env}
|
||||
]}
|
||||
};
|
||||
|
||||
return this.logger.$http.get('Urls/findOne', {filter})
|
||||
.then(res => {
|
||||
return res.data.url + route;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.service('vnApp', App);
|
||||
|
|
|
@ -51,6 +51,7 @@ Entries: Entradas
|
|||
Users: Usuarios
|
||||
Suppliers: Proveedores
|
||||
Monitors: Monitores
|
||||
Shelvings: Carros
|
||||
|
||||
# Common
|
||||
|
||||
|
|
|
@ -133,5 +133,8 @@
|
|||
"Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.",
|
||||
"Password does not meet requirements": "Password does not meet requirements",
|
||||
"You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies",
|
||||
"Not enough privileges to edit a client": "Not enough privileges to edit a client"
|
||||
"Not enough privileges to edit a client": "Not enough privileges to edit a client",
|
||||
"Claim pickup order sent": "Claim pickup order sent [({{claimId}})]({{{claimUrl}}}) to client *{{clientName}}*",
|
||||
"You don't have grant privilege": "You don't have grant privilege",
|
||||
"You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user"
|
||||
}
|
|
@ -235,5 +235,9 @@
|
|||
"Dirección incorrecta": "Dirección incorrecta",
|
||||
"Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador",
|
||||
"Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador",
|
||||
"Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente"
|
||||
"Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente",
|
||||
"This route does not exists": "Esta ruta no existe",
|
||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario"
|
||||
}
|
|
@ -1,2 +1,2 @@
|
|||
Privileges: Privilegios
|
||||
Has grant: Tiene privilegios
|
||||
Has grant: Puede delegar privilegios
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = Self => {
|
|||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The client id',
|
||||
description: 'The claim id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
|
@ -42,6 +42,11 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.claimPickupEmail = async ctx => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const origin = ctx.req.headers.origin;
|
||||
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {
|
||||
recipient: args.recipient,
|
||||
|
@ -52,6 +57,34 @@ module.exports = Self => {
|
|||
for (const param in args)
|
||||
params[param] = args[param];
|
||||
|
||||
const claim = await models.Claim.findById(args.id, {
|
||||
fields: ['id', 'clientFk'],
|
||||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['name', 'salesPersonFk']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const message = $t('Claim pickup order sent', {
|
||||
claimId: args.id,
|
||||
clientName: claim.client().name,
|
||||
claimUrl: `${origin}/#!/claim/${args.id}/summary`,
|
||||
});
|
||||
|
||||
const salesPersonId = claim.client().salesPersonFk;
|
||||
if (salesPersonId)
|
||||
await models.Chat.sendCheckingPresence(ctx, salesPersonId, message);
|
||||
|
||||
await models.ClaimLog.create({
|
||||
originFk: args.id,
|
||||
userFk: userId,
|
||||
action: 'insert',
|
||||
description: 'Claim-pickup-order sent',
|
||||
changedModel: 'Mail'
|
||||
});
|
||||
|
||||
const email = new Email('claim-pickup-order', params);
|
||||
|
||||
return email.send();
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
|
|
|
@ -57,11 +57,11 @@
|
|||
"model": "ClaimState",
|
||||
"foreignKey": "claimStateFk"
|
||||
},
|
||||
"claimRma": {
|
||||
"type": "belongsTo",
|
||||
"rmas": {
|
||||
"type": "hasMany",
|
||||
"model": "ClaimRma",
|
||||
"foreignKey": "rma",
|
||||
"primaryKey": "code"
|
||||
"foreignKey": "code",
|
||||
"primaryKey": "rma"
|
||||
},
|
||||
"client": {
|
||||
"type": "belongsTo",
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
label="Pick up"
|
||||
ng-model="$ctrl.claim.hasToPickUp"
|
||||
vn-acl="claimManager"
|
||||
info="When checked will notify to the salesPerson">
|
||||
title="{{'When checked will notify to the salesPerson' | translate}}">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -5,5 +5,5 @@ Responsability: Responsabilidad
|
|||
Company: Empresa
|
||||
Sales/Client: Comercial/Cliente
|
||||
Pick up: Recoger
|
||||
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
Packages received: Bultos recibidos
|
|
@ -25,7 +25,14 @@
|
|||
</vn-button-menu>
|
||||
</h5>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-auto>
|
||||
<h4>
|
||||
<a
|
||||
ui-sref="claim.card.basicData({id:$ctrl.claim.id})"
|
||||
target="_self">
|
||||
<span translate vn-tooltip="Go to">Basic data</span>
|
||||
</a>
|
||||
</h4>
|
||||
<vn-label-value
|
||||
label="Created"
|
||||
value="{{$ctrl.summary.claim.created | date: 'dd/MM/yyyy'}}">
|
||||
|
@ -42,7 +49,14 @@
|
|||
label="Attended by"
|
||||
value="{{$ctrl.summary.claim.worker.user.nickname}}">
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
<vn-check
|
||||
class="vn-mr-md"
|
||||
label="Pick up"
|
||||
ng-model="$ctrl.summary.claim.hasToPickUp"
|
||||
title="{{'When checked will notify to the salesPerson' | translate}}"
|
||||
disabled="true">
|
||||
</vn-check>
|
||||
</vn-auto>
|
||||
<vn-auto>
|
||||
<h4 ng-show="$ctrl.isSalesPerson && $ctrl.summary.observations.length">
|
||||
<a
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
"BankEntity": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Business": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"BusinessType": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "Business",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "business"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"department": {
|
||||
"type": "belongsTo",
|
||||
"model": "Department",
|
||||
"foreignKey": "departmentFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -425,6 +425,7 @@ module.exports = Self => {
|
|||
|
||||
account.observe('before save', async ctx => {
|
||||
if (ctx.isNewInstance) return;
|
||||
if (ctx.currentInstance)
|
||||
ctx.hookState.oldInstance = JSON.parse(JSON.stringify(ctx.currentInstance));
|
||||
});
|
||||
|
||||
|
@ -432,7 +433,11 @@ module.exports = Self => {
|
|||
const changes = ctx.data || ctx.instance;
|
||||
if (!ctx.isNewInstance && changes) {
|
||||
const oldData = ctx.hookState.oldInstance;
|
||||
const hasChanges = oldData.name != changes.name || oldData.active != changes.active;
|
||||
let hasChanges;
|
||||
|
||||
if (oldData)
|
||||
hasChanges = oldData.name != changes.name || oldData.active != changes.active;
|
||||
|
||||
if (!hasChanges) return;
|
||||
|
||||
const isClient = await Self.app.models.Client.count({id: oldData.id});
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteItemShelvings', {
|
||||
description: 'Deletes the selected item shelvings',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'itemShelvingIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The itemShelving ids to delete'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteItemShelvings`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteItemShelvings = async(itemShelvingIds, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const promises = [];
|
||||
for (let itemShelvingId of itemShelvingIds) {
|
||||
const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions);
|
||||
promises.push(itemShelvingToDelete);
|
||||
}
|
||||
|
||||
const deletedItemShelvings = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return deletedItemShelvings;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ItemShelving deleteItemShelvings()', () => {
|
||||
it('should return the deleted itemShelvings', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const itemShelvingIds = [1, 2];
|
||||
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -53,6 +53,9 @@
|
|||
"ItemShelvingSale": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemShelvingPlacementSupplyStock": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemImageQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "ItemShelvingPlacementSupplyStock",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemShelvingPlacementSupplyStock"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"itemShelvingFk": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"itemFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"longName": {
|
||||
"type": "string"
|
||||
},
|
||||
"parking": {
|
||||
"type": "string"
|
||||
},
|
||||
"shelving": {
|
||||
"type": "string"
|
||||
},
|
||||
"packing": {
|
||||
"type": "number"
|
||||
},
|
||||
"stock": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||
};
|
|
@ -24,3 +24,5 @@ import './waste/detail';
|
|||
import './fixed-price';
|
||||
import './fixed-price-search-panel';
|
||||
import './item-type';
|
||||
import './item-shelving';
|
||||
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="ItemShelvingPlacementSupplyStocks"
|
||||
link="{itemFk: $ctrl.$params.id}"
|
||||
data="$ctrl.itemShelvingPlacementSupplyStocks"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-card>
|
||||
<smart-table
|
||||
model="model"
|
||||
options="$ctrl.smartTableOptions"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
<slot-actions>
|
||||
<div>
|
||||
<div class="totalBox" style="text-align: center;">
|
||||
<h6 translate>Total</h6>
|
||||
<vn-label-value
|
||||
label="Total labels"
|
||||
value="{{$ctrl.labelTotal.toFixed(2)}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vn-pa-md">
|
||||
<vn-button
|
||||
disabled="!$ctrl.checked.length"
|
||||
ng-click="removeConfirm.show()"
|
||||
icon="delete"
|
||||
vn-tooltip="Remove selected lines"
|
||||
vn-acl="replenisherBos">
|
||||
</vn-button>
|
||||
</div>
|
||||
</slot-actions>
|
||||
<slot-table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</th>
|
||||
<th field="created">
|
||||
<span translate>Created</span>
|
||||
</th>
|
||||
<th shrink field="itemFk">
|
||||
<span translate>Item</span>
|
||||
</th>
|
||||
<th
|
||||
field="longName">
|
||||
<span translate>Concept</span>
|
||||
</th>
|
||||
<th
|
||||
field="parking">
|
||||
<span translate>Parking</span>
|
||||
</th>
|
||||
<th field="shelving">
|
||||
<span translate>Shelving</span>
|
||||
</th>
|
||||
<th
|
||||
field="label">
|
||||
<span translate>Etiqueta</span>
|
||||
</th>
|
||||
<th
|
||||
field="packing"
|
||||
shrink>
|
||||
<span translate>Packing</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
ng-repeat="itemShelvingPlacementSupplyStock in $ctrl.itemShelvingPlacementSupplyStocks"
|
||||
vn-repeat-last on-last="$ctrl.calculateTotals()">
|
||||
<td shrink>
|
||||
<vn-check
|
||||
ng-model="itemShelvingPlacementSupplyStock.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
</td>
|
||||
<td shrink-date>{{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}}</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.itemFk}}
|
||||
</td>
|
||||
<td expand title="{{::itemShelvingPlacementSupplyStock.longName}}">
|
||||
<span
|
||||
vn-click-stop="itemDescriptor.show($event, itemShelvingPlacementSupplyStock.itemFk)"
|
||||
class="link">
|
||||
{{itemShelvingPlacementSupplyStock.longName}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.parking}}
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.shelving}}
|
||||
</td>
|
||||
<td>
|
||||
{{(itemShelvingPlacementSupplyStock.stock / itemShelvingPlacementSupplyStock.packing).toFixed(2)}}
|
||||
</td>
|
||||
<td>
|
||||
{{::itemShelvingPlacementSupplyStock.packing}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</slot-table>
|
||||
</smart-table>
|
||||
</vn-card>
|
||||
<vn-item-descriptor-popover
|
||||
vn-id="item-descriptor">
|
||||
</vn-item-descriptor-popover>
|
||||
|
||||
<vn-confirm
|
||||
vn-id="removeConfirm"
|
||||
message="Selected lines will be deleted"
|
||||
question="Are you sure you want to continue?"
|
||||
on-accept="$ctrl.onRemove()">
|
||||
</vn-confirm>
|
|
@ -0,0 +1,89 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
export default class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
|
||||
this.smartTableOptions = {
|
||||
activeButtons: {
|
||||
search: true
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'parking',
|
||||
autocomplete: {
|
||||
url: 'Parkings',
|
||||
showField: 'code',
|
||||
valueField: 'code'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'shelving',
|
||||
autocomplete: {
|
||||
url: 'Shelvings',
|
||||
showField: 'code',
|
||||
valueField: 'code'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'created',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'itemFk',
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
field: 'longName',
|
||||
searchable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const itemShelvings = this.$.model.data || [];
|
||||
const checkedLines = [];
|
||||
for (let itemShelving of itemShelvings) {
|
||||
if (itemShelving.checked)
|
||||
checkedLines.push(itemShelving.itemShelvingFk);
|
||||
}
|
||||
|
||||
return checkedLines;
|
||||
}
|
||||
|
||||
calculateTotals() {
|
||||
this.labelTotal = 0;
|
||||
const itemShelvings = this.$.model.data || [];
|
||||
itemShelvings.forEach(itemShelving => {
|
||||
const label = itemShelving.stock / itemShelving.packing;
|
||||
this.labelTotal += label;
|
||||
});
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
const params = {itemShelvingIds: this.checked};
|
||||
const query = `ItemShelvings/deleteItemShelvings`;
|
||||
this.$http.post(query, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('ItemShelvings removed'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'parking':
|
||||
case 'shelving':
|
||||
case 'label':
|
||||
case 'packing':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnItemShelving', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller
|
||||
});
|
|
@ -0,0 +1,81 @@
|
|||
import './index';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('item shelving', () => {
|
||||
describe('Component vnItemShelving', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(ngModule('item'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||||
$httpBackend = _$httpBackend_;
|
||||
const $element = angular.element('<vn-item-shelving></vn-item-shelving>');
|
||||
controller = $componentController('vnItemShelving', {$element});
|
||||
controller.$.model = crudModel;
|
||||
controller.$.model.data = [
|
||||
{itemShelvingFk: 1, packing: 10, stock: 1},
|
||||
{itemShelvingFk: 2, packing: 12, stock: 5},
|
||||
{itemShelvingFk: 4, packing: 20, stock: 10}
|
||||
];
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
}));
|
||||
|
||||
describe('checked() getter', () => {
|
||||
it('should return a the selected rows', () => {
|
||||
const result = controller.checked;
|
||||
|
||||
expect(result).toEqual(expect.arrayContaining([1, 2]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateTotals()', () => {
|
||||
it('should calculate the total of labels', () => {
|
||||
controller.calculateTotals();
|
||||
|
||||
expect(controller.labelTotal).toEqual(1.0166666666666666);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onRemove()', () => {
|
||||
it('shoud remove the selected lines', () => {
|
||||
jest.spyOn(controller.$.model, 'refresh');
|
||||
const expectedParams = {itemShelvingIds: [1, 2]};
|
||||
|
||||
$httpBackend.expectPOST('ItemShelvings/deleteItemShelvings', expectedParams).respond(200);
|
||||
controller.onRemove();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$.model.refresh).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should search by parking', () => {
|
||||
const expr = controller.exprBuilder('parking', '700-01');
|
||||
|
||||
expect(expr).toEqual({'parking': '700-01'});
|
||||
});
|
||||
|
||||
it('should search by shelving', () => {
|
||||
const expr = controller.exprBuilder('shelving', 'AAA');
|
||||
|
||||
expect(expr).toEqual({'shelving': 'AAA'});
|
||||
});
|
||||
|
||||
it('should search by label', () => {
|
||||
const expr = controller.exprBuilder('label', 0.17);
|
||||
|
||||
expect(expr).toEqual({'label': 0.17});
|
||||
});
|
||||
|
||||
it('should search by packing', () => {
|
||||
const expr = controller.exprBuilder('packing', 10);
|
||||
|
||||
expect(expr).toEqual({'packing': 10});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
Shelving: Matrícula
|
||||
Remove selected lines: Eliminar líneas seleccionadas
|
||||
Selected lines will be deleted: Las líneas seleccionadas serán eliminadas
|
||||
ItemShelvings removed: Carros eliminados
|
||||
Total labels: Total etiquetas
|
|
@ -54,6 +54,7 @@ Basic data: Datos básicos
|
|||
Tax: IVA
|
||||
History: Historial
|
||||
Botanical: Botánico
|
||||
Shelvings: Carros
|
||||
Barcodes: Códigos de barras
|
||||
Diary: Histórico
|
||||
Item diary: Registro de compra-venta
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
"card": [
|
||||
{"state": "item.card.basicData", "icon": "settings"},
|
||||
{"state": "item.card.tags", "icon": "icon-tags"},
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"},
|
||||
{"state": "item.card.tax", "icon": "icon-tax"},
|
||||
{"state": "item.card.botanical", "icon": "local_florist"},
|
||||
{"state": "item.card.shelving", "icon": "icon-inventory"},
|
||||
{"state": "item.card.itemBarcode", "icon": "icon-barcode"},
|
||||
{"state": "item.card.diary", "icon": "icon-transaction"},
|
||||
{"state": "item.card.last-entries", "icon": "icon-regentry"},
|
||||
{"state": "item.card.log", "icon": "history"}
|
||||
],
|
||||
"itemType": [
|
||||
|
@ -92,6 +93,16 @@
|
|||
},
|
||||
"acl": ["buyer"]
|
||||
},
|
||||
{
|
||||
"url" : "/shelving",
|
||||
"state": "item.card.shelving",
|
||||
"component": "vn-item-shelving",
|
||||
"description": "Shelvings",
|
||||
"params": {
|
||||
"item": "$ctrl.item"
|
||||
},
|
||||
"acl": ["employee"]
|
||||
},
|
||||
{
|
||||
"url" : "/barcode",
|
||||
"state": "item.card.itemBarcode",
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
{"state": "shelving.card.log", "icon": "history"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
{"key": "s", "state": "shelving.index"}
|
||||
],
|
||||
"routes": [
|
||||
{
|
||||
"url": "/shelving",
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
const https = require('https');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getVideo', {
|
||||
description: 'Get packing video',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'Ticket id'
|
||||
},
|
||||
{
|
||||
arg: 'filename',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Time to add'
|
||||
},
|
||||
{
|
||||
arg: 'req',
|
||||
type: 'object',
|
||||
http: {source: 'req'}
|
||||
},
|
||||
{
|
||||
arg: 'res',
|
||||
type: 'object',
|
||||
http: {source: 'res'}
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/getVideo`,
|
||||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
|
||||
Self.getVideo = async(id, filename, req, res, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions);
|
||||
|
||||
const query = `
|
||||
SELECT
|
||||
e.id,
|
||||
ps.monitorId,
|
||||
e.created
|
||||
FROM expedition e
|
||||
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
||||
JOIN packingSite ps ON ps.hostFk = h.id
|
||||
WHERE e.id = ?;`;
|
||||
const [expedition] = await models.Expedition.rawSql(query, [id]);
|
||||
const monitorId = expedition.monitorId;
|
||||
|
||||
const videoUrl =
|
||||
`/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}/${filename}`;
|
||||
|
||||
const headers = Object.assign({}, req.headers, {
|
||||
host: 'shinobi.verdnatura.es'
|
||||
});
|
||||
const httpOptions = {
|
||||
host: 'shinobi.verdnatura.es',
|
||||
path: videoUrl,
|
||||
port: 443,
|
||||
headers
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.request(httpOptions, shinobiRes => {
|
||||
shinobiRes.pause();
|
||||
res.writeHeader(shinobiRes.statusCode, shinobiRes.headers);
|
||||
shinobiRes.pipe(res);
|
||||
});
|
||||
|
||||
req.on('error', () => {
|
||||
reject();
|
||||
});
|
||||
|
||||
req.on('end', () => {
|
||||
resolve();
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
};
|
||||
};
|
|
@ -0,0 +1,78 @@
|
|||
const axios = require('axios');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getVideoList', {
|
||||
description: 'Get video list of expedition id',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'Expedition id'
|
||||
}, {
|
||||
arg: 'from',
|
||||
type: 'number',
|
||||
required: false,
|
||||
}, {
|
||||
arg: 'to',
|
||||
type: 'number',
|
||||
required: false,
|
||||
}
|
||||
], returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getVideoList`,
|
||||
verb: 'GET',
|
||||
},
|
||||
});
|
||||
|
||||
Self.getVideoList = async(id, from, to, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions);
|
||||
|
||||
const query = `
|
||||
SELECT
|
||||
e.id,
|
||||
ps.monitorId,
|
||||
e.created
|
||||
FROM expedition e
|
||||
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
|
||||
JOIN packingSite ps ON ps.hostFk = h.id
|
||||
WHERE e.id = ?;`;
|
||||
const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]);
|
||||
|
||||
if (!from && !expedition) return [];
|
||||
let start = new Date(expedition.created);
|
||||
let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000));
|
||||
|
||||
if (from && to) {
|
||||
start.setHours(from, 0, 0);
|
||||
end.setHours(to, 0, 0);
|
||||
}
|
||||
const offset = start.getTimezoneOffset();
|
||||
start = new Date(start.getTime() - (offset * 60 * 1000));
|
||||
end = new Date(end.getTime() - (offset * 60 * 1000));
|
||||
|
||||
const videoUrl =
|
||||
`/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${expedition.monitorId}`;
|
||||
const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`;
|
||||
const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}`;
|
||||
|
||||
let response;
|
||||
|
||||
try {
|
||||
response = await axios.get(url);
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
return response.data.videos.map(video => video.filename);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const https = require('https');
|
||||
|
||||
xdescribe('boxing getVideo()', () => {
|
||||
it('should return data', async() => {
|
||||
const tx = await models.PackingSiteConfig.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1;
|
||||
const video = 'video.mp4';
|
||||
|
||||
const response = {
|
||||
pipe: () => {},
|
||||
on: () => {},
|
||||
end: () => {},
|
||||
};
|
||||
|
||||
const req = {
|
||||
headers: 'apiHeader',
|
||||
data: {
|
||||
pipe: () => {},
|
||||
on: () => {},
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(https, 'request').and.returnValue(response);
|
||||
|
||||
const result = await models.Boxing.getVideo(id, video, req, null, options);
|
||||
|
||||
expect(result[0]).toEqual(response.data.videos[0].filename);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const axios = require('axios');
|
||||
|
||||
describe('boxing getVideoList()', () => {
|
||||
it('should return video list', async() => {
|
||||
const tx = await models.PackingSiteConfig.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1;
|
||||
const from = 1;
|
||||
const to = 2;
|
||||
|
||||
const response = {
|
||||
data: {
|
||||
videos: [{
|
||||
id: 1,
|
||||
filename: 'video1.mp4'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
|
||||
|
||||
const result = await models.Boxing.getVideoList(id, from, to, options);
|
||||
|
||||
expect(result[0]).toEqual(response.data.videos[0].filename);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteExpeditions', {
|
||||
description: 'Delete the selected expeditions',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'expeditionIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The expeditions ids to delete'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteExpeditions`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteExpeditions = async(expeditionIds, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const promises = [];
|
||||
for (let expeditionId of expeditionIds) {
|
||||
const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions);
|
||||
promises.push(deletedExpedition);
|
||||
}
|
||||
|
||||
const deletedExpeditions = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return deletedExpeditions;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,93 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('moveExpeditions', {
|
||||
description: 'Move the selected expeditions to another ticket',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'clientId',
|
||||
type: 'number',
|
||||
description: `The client id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'landed',
|
||||
type: 'date',
|
||||
description: `The landing date`
|
||||
},
|
||||
{
|
||||
arg: 'warehouseId',
|
||||
type: 'number',
|
||||
description: `The warehouse id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'addressId',
|
||||
type: 'number',
|
||||
description: `The address id`,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'agencyModeId',
|
||||
type: 'any',
|
||||
description: `The agencyMode id`
|
||||
},
|
||||
{
|
||||
arg: 'routeId',
|
||||
type: 'any',
|
||||
description: `The route id`
|
||||
},
|
||||
{
|
||||
arg: 'expeditionIds',
|
||||
type: ['number'],
|
||||
required: true,
|
||||
description: 'The expeditions ids to move'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/moveExpeditions`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.moveExpeditions = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.routeId) {
|
||||
const route = await models.Route.findById(args.routeId, null, myOptions);
|
||||
if (!route) throw new UserError('This route does not exists');
|
||||
}
|
||||
const ticket = await models.Ticket.new(ctx, myOptions);
|
||||
const promises = [];
|
||||
for (let expeditionsId of args.expeditionIds) {
|
||||
const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions);
|
||||
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions);
|
||||
promises.push(expeditionUpdated);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return ticket;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket deleteExpeditions()', () => {
|
||||
it('should delete the selected expeditions', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expeditionIds = [12, 13];
|
||||
const result = await models.Expedition.deleteExpeditions(expeditionIds, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket moveExpeditions()', () => {
|
||||
it('should move the selected expeditions to new ticket', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}},
|
||||
args: {},
|
||||
params: {}
|
||||
};
|
||||
const myCtx = Object.assign({}, ctx);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
myCtx.args = {
|
||||
clientId: 1101,
|
||||
landed: new Date(),
|
||||
warehouseId: 1,
|
||||
addressId: 121,
|
||||
agencyModeId: 1,
|
||||
routeId: null,
|
||||
expeditionIds: [1, 2]
|
||||
|
||||
};
|
||||
|
||||
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
||||
|
||||
const newestTicketIdInFixtures = 27;
|
||||
|
||||
expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -79,10 +79,18 @@ describe('sale updatePrice()', () => {
|
|||
const price = 5.4;
|
||||
const originalSalesPersonMana = await models.WorkerMana.findById(18, null, options);
|
||||
const manaComponent = await models.Component.findOne({where: {code: 'mana'}}, options);
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Sale.updatePrice(ctx, saleId, price, options);
|
||||
const updatedSale = await models.Sale.findById(saleId, null, options);
|
||||
createdSaleComponent = await models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponent.id}}, options);
|
||||
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||
where: {
|
||||
saleFk: saleId, componentFk: manaComponent.id
|
||||
}}, options);
|
||||
|
||||
expect(updatedSale.price).toBe(price);
|
||||
expect(createdSaleComponent.value).toEqual(-2.04);
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('sale usesMana()', () => {
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 18}
|
||||
}
|
||||
};
|
||||
|
||||
it('should return that the worker uses mana', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, options);
|
||||
|
||||
expect(usesMana).toBe(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return that the worker not uses mana', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, options);
|
||||
|
||||
expect(usesMana).toBe(false);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -77,7 +77,8 @@ module.exports = Self => {
|
|||
|
||||
const oldPrice = sale.price;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const usesMana = await models.WorkerMana.findOne({where: {workerFk: userId}, fields: 'amount'}, myOptions);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, myOptions);
|
||||
const componentCode = usesMana ? 'mana' : 'buyerDiscount';
|
||||
const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions);
|
||||
const componentId = discount.id;
|
||||
|
@ -88,7 +89,6 @@ module.exports = Self => {
|
|||
saleFk: id
|
||||
};
|
||||
const saleComponent = await models.SaleComponent.findOne({where}, myOptions);
|
||||
|
||||
if (saleComponent) {
|
||||
await models.SaleComponent.updateAll(where, {
|
||||
value: saleComponent.value + componentValue
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('usesMana', {
|
||||
description: 'Returns if the worker uses mana',
|
||||
accessType: 'READ',
|
||||
accepts: [],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/usesMana`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.usesMana = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions);
|
||||
const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions);
|
||||
const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions);
|
||||
const usesMana = departments.find(department => department.id == workerDepartment.departmentFk);
|
||||
|
||||
return usesMana ? true : false;
|
||||
};
|
||||
};
|
|
@ -18,9 +18,12 @@ describe('ticket componentUpdate()', () => {
|
|||
beforeAll(async() => {
|
||||
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
|
||||
deliveryComponentId = deliveryComponenet.id;
|
||||
componentOfSaleSeven = `SELECT value FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
|
||||
componentOfSaleEight = `SELECT value FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
|
||||
|
||||
componentOfSaleSeven = `SELECT value
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
|
||||
componentOfSaleEight = `SELECT value
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
|
||||
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven);
|
||||
firstvalueBeforeChange = componentValue.value;
|
||||
|
||||
|
|
|
@ -110,6 +110,11 @@ describe('sale updateDiscount()', () => {
|
|||
const componentId = manaDiscount.id;
|
||||
const manaCode = 'mana';
|
||||
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||
|
||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||
|
@ -150,6 +155,11 @@ describe('sale updateDiscount()', () => {
|
|||
const componentId = manaDiscount.id;
|
||||
const manaCode = 'manaClaim';
|
||||
|
||||
const teamOne = 96;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
|
||||
await business.updateAttribute('departmentFk', teamOne, options);
|
||||
|
||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options);
|
||||
|
||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||
|
|
|
@ -98,12 +98,7 @@ module.exports = Self => {
|
|||
if (isLocked || (!hasAllowedRoles && alertLevel > 0))
|
||||
throw new UserError(`The sales of this ticket can't be modified`);
|
||||
|
||||
const usesMana = await models.WorkerMana.findOne({
|
||||
where: {
|
||||
workerFk: userId
|
||||
},
|
||||
fields: 'amount'}, myOptions);
|
||||
|
||||
const usesMana = await models.Sale.usesMana(ctx, myOptions);
|
||||
const componentCode = usesMana ? manaCode : 'buyerDiscount';
|
||||
const discountComponent = await models.Component.findOne({
|
||||
where: {code: componentCode}}, myOptions);
|
||||
|
@ -115,14 +110,38 @@ module.exports = Self => {
|
|||
for (let sale of sales) {
|
||||
const oldDiscount = sale.discount;
|
||||
const value = ((-sale.price * newDiscount) / 100);
|
||||
const newComponent = models.SaleComponent.upsert({
|
||||
|
||||
const manaComponent = await models.Component.findOne({
|
||||
where: {code: 'mana'}
|
||||
}, myOptions);
|
||||
|
||||
const manaClaimComponent = await models.Component.findOne({
|
||||
where: {code: 'manaClaim'}
|
||||
}, myOptions);
|
||||
|
||||
const [oldComponent] = await models.SaleComponent.find({
|
||||
where: {
|
||||
and: [
|
||||
{saleFk: sale.id},
|
||||
{componentFk: {inq: [manaComponent.id, manaClaimComponent.id]}}
|
||||
]
|
||||
}
|
||||
}, myOptions);
|
||||
|
||||
let deletedComponent;
|
||||
if (oldComponent) {
|
||||
const filter = {
|
||||
saleFk: sale.id,
|
||||
value: value,
|
||||
componentFk: componentId}, myOptions);
|
||||
componentFk: oldComponent.componentFk
|
||||
};
|
||||
deletedComponent = await models.SaleComponent.destroyAll(filter, myOptions);
|
||||
}
|
||||
|
||||
const newComponent = await createSaleComponent(sale.id, value, componentId, myOptions);
|
||||
|
||||
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
||||
|
||||
promises.push(newComponent, updatedSale);
|
||||
promises.push(newComponent, updatedSale, deletedComponent);
|
||||
|
||||
const change = `${oldDiscount}% ➔ *${newDiscount}%*`;
|
||||
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`;
|
||||
|
@ -165,4 +184,14 @@ module.exports = Self => {
|
|||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
async function createSaleComponent(saleId, value, componentId, myOptions) {
|
||||
const models = Self.app.models;
|
||||
|
||||
return models.SaleComponent.create({
|
||||
saleFk: saleId,
|
||||
value: value,
|
||||
componentFk: componentId
|
||||
}, myOptions);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
"AnnualAverageInvoiced": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Boxing": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Component": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
@ -20,6 +23,9 @@
|
|||
"Packaging": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PackingSiteConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"PrintServerQueue": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/boxing/getVideo')(Self);
|
||||
require('../methods/boxing/getVideoList')(Self);
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "Boxing",
|
||||
"base": "PersistedModel",
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/expedition/filter')(Self);
|
||||
require('../methods/expedition/deleteExpeditions')(Self);
|
||||
require('../methods/expedition/moveExpeditions')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "PackingSiteConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "packingSiteConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"description": "Identifier"
|
||||
},
|
||||
"shinobiUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"shinobiGroupKey":{
|
||||
"type":"string"
|
||||
},
|
||||
"shinobiToken":{
|
||||
"type":"string"
|
||||
},
|
||||
"avgBoxingTime":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ module.exports = Self => {
|
|||
require('../methods/sale/recalculatePrice')(Self);
|
||||
require('../methods/sale/refund')(Self);
|
||||
require('../methods/sale/canEdit')(Self);
|
||||
require('../methods/sale/usesMana')(Self);
|
||||
|
||||
Self.validatesPresenceOf('concept', {
|
||||
message: `Concept cannot be blank`
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<vn-card>
|
||||
</vn-card>
|
|
@ -0,0 +1,21 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
|
||||
async $onInit() {
|
||||
const url = await this.vnApp.getUrl(`ticket/${this.$params.id}/boxing`);
|
||||
window.open(url).focus();
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketBoxing', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
bindings: {
|
||||
ticket: '<'
|
||||
}
|
||||
});
|
|
@ -8,11 +8,35 @@
|
|||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-card class="vn-w-xl">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal class="header">
|
||||
<vn-tool-bar class="vn-mb-md">
|
||||
<vn-button icon="keyboard_arrow_down"
|
||||
label="Move"
|
||||
ng-click="moreOptions.show($event)"
|
||||
disabled="!$ctrl.totalChecked">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
disabled="!$ctrl.checked.length"
|
||||
ng-click="removeConfirm.show()"
|
||||
icon="delete"
|
||||
vn-tooltip="Delete expedition">
|
||||
</vn-button>
|
||||
</vn-tool-bar>
|
||||
<vn-one class="taxes" ng-if="$ctrl.sales.length > 0">
|
||||
<p><vn-label translate>Subtotal</vn-label> {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}</p>
|
||||
<p><vn-label translate>VAT</vn-label> {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}</p>
|
||||
<p><vn-label><strong>Total</strong></vn-label> <strong>{{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}</strong></p>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th></vn-th>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="itemFk" number>Expedition</vn-th>
|
||||
<vn-th field="itemFk" number>Item</vn-th>
|
||||
<vn-th field="packageItemName">Name</vn-th>
|
||||
|
@ -26,11 +50,10 @@
|
|||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="expedition in expeditions">
|
||||
<vn-td class="vn-px-md" style="width:30px; color:#FFA410;">
|
||||
<vn-icon-button icon="delete"
|
||||
ng-click="deleteExpedition.show(expedition.id)"
|
||||
vn-tooltip="Delete expedition">
|
||||
</vn-icon-button>
|
||||
<vn-td shrink>
|
||||
<vn-check tabindex="-1"
|
||||
ng-model="expedition.checked">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td number expand>{{expedition.id | zeroFill:6}}</vn-td>
|
||||
<vn-td number>
|
||||
|
@ -67,24 +90,24 @@
|
|||
vn-id="worker-descriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="delete-expedition"
|
||||
on-accept="$ctrl.onDialogAccept($data)"
|
||||
vn-id="removeConfirm"
|
||||
message="Are you sure you want to delete this expedition?"
|
||||
question="Delete expedition"
|
||||
message="Are you sure you want to delete this expedition?">
|
||||
on-accept="$ctrl.onRemove()">
|
||||
</vn-confirm>
|
||||
|
||||
<vn-popup vn-id="statusLog">
|
||||
<vn-crud-model
|
||||
vn-id="model"
|
||||
vn-id="modelExpeditionStates"
|
||||
url="ExpeditionStates/filter"
|
||||
link="{expeditionFk: $ctrl.expedition.id}"
|
||||
data="expeditionStates"
|
||||
order="created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-data-viewer model="modelExpeditionStates">
|
||||
<vn-card class="vn-w-md">
|
||||
<vn-table model="model">
|
||||
<vn-table model="modelExpeditionStates">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="state">State</vn-th>
|
||||
|
@ -112,3 +135,36 @@
|
|||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
</vn-popup>
|
||||
|
||||
<vn-menu vn-id="moreOptions">
|
||||
<vn-item translate
|
||||
name="withoutRoute"
|
||||
ng-click="selectLanded.show('withoutRoute')">
|
||||
New ticket without route
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
name="withRoute"
|
||||
ng-click="selectLanded.show('withRoute')">
|
||||
New ticket with route
|
||||
</vn-item>
|
||||
</vn-menu>
|
||||
|
||||
<vn-dialog
|
||||
vn-id="selectLanded"
|
||||
on-accept="$ctrl.createTicket($ctrl.landed, $ctrl.newRoute)">
|
||||
<tpl-body>
|
||||
<vn-date-picker
|
||||
label="Landed"
|
||||
ng-model="$ctrl.landed">
|
||||
</vn-date-picker>
|
||||
<vn-textfield
|
||||
ng-show="selectLanded.data == 'withRoute'"
|
||||
label="Route id"
|
||||
ng-model="$ctrl.newRoute">
|
||||
</vn-textfield>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Accept</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -2,6 +2,27 @@ import ngModule from '../module';
|
|||
import Section from 'salix/components/section';
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $scope) {
|
||||
super($element, $scope);
|
||||
this.landed = new Date();
|
||||
this.newRoute = null;
|
||||
}
|
||||
|
||||
get checked() {
|
||||
const rows = this.$.model.data || [];
|
||||
const checkedRows = [];
|
||||
for (let row of rows) {
|
||||
if (row.checked)
|
||||
checkedRows.push(row.id);
|
||||
}
|
||||
|
||||
return checkedRows;
|
||||
}
|
||||
|
||||
get totalChecked() {
|
||||
return this.checked.length;
|
||||
}
|
||||
|
||||
onDialogAccept(id) {
|
||||
return this.$http.delete(`Expeditions/${id}`)
|
||||
.then(() => this.$.model.refresh());
|
||||
|
@ -11,6 +32,33 @@ class Controller extends Section {
|
|||
this.expedition = expedition;
|
||||
this.$.statusLog.show();
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
const params = {expeditionIds: this.checked};
|
||||
const query = `Expeditions/deleteExpeditions`;
|
||||
this.$http.post(query, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Expedition removed'));
|
||||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
createTicket(landed, routeFk) {
|
||||
const params = {
|
||||
clientId: this.ticket.clientFk,
|
||||
landed: landed,
|
||||
warehouseId: this.ticket.warehouseFk,
|
||||
addressId: this.ticket.addressFk,
|
||||
agencyModeId: this.ticket.agencyModeFk,
|
||||
routeId: routeFk,
|
||||
expeditionIds: this.checked
|
||||
};
|
||||
const query = `Expeditions/moveExpeditions`;
|
||||
this.$http.post(query, params).then(res => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$state.go('ticket.card.summary', {id: res.data.id});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketExpedition', {
|
||||
|
|
|
@ -17,6 +17,14 @@ describe('Ticket', () => {
|
|||
refresh: () => {}
|
||||
};
|
||||
controller = $componentController('vnTicketExpedition', {$element: null, $scope});
|
||||
controller.$.model.data = [
|
||||
{id: 1},
|
||||
{id: 2},
|
||||
{id: 3}
|
||||
];
|
||||
const modelData = controller.$.model.data;
|
||||
modelData[0].checked = true;
|
||||
modelData[1].checked = true;
|
||||
}));
|
||||
|
||||
describe('onDialogAccept()', () => {
|
||||
|
@ -50,5 +58,51 @@ describe('Ticket', () => {
|
|||
expect(controller.$.statusLog.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onRemove()', () => {
|
||||
it('should make a query and then call to the model refresh() method', () => {
|
||||
jest.spyOn($scope.model, 'refresh');
|
||||
|
||||
const expectedParams = {expeditionIds: [1, 2]};
|
||||
$httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200);
|
||||
controller.onRemove();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($scope.model.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('createTicket()', () => {
|
||||
it('should make a query and then call to the $state go() method', () => {
|
||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
||||
|
||||
const ticket = {
|
||||
clientFk: 1101,
|
||||
landed: new Date(),
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
warehouseFk: 1
|
||||
};
|
||||
const routeId = null;
|
||||
controller.ticket = ticket;
|
||||
|
||||
const ticketToTransfer = {id: 28};
|
||||
|
||||
const expectedParams = {
|
||||
clientId: 1101,
|
||||
landed: new Date(),
|
||||
warehouseId: 1,
|
||||
addressId: 121,
|
||||
agencyModeId: 1,
|
||||
routeId: null,
|
||||
expeditionIds: [1, 2]
|
||||
};
|
||||
$httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(ticketToTransfer);
|
||||
controller.createTicket(ticket.landed, routeId);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketToTransfer.id});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
Status log: Hitorial de estados
|
||||
Expedition removed: Expedición eliminada
|
||||
Move: Mover
|
||||
New ticket without route: Nuevo ticket sin ruta
|
||||
New ticket with route: Nuevo ticket con ruta
|
||||
Route id: Id ruta
|
|
@ -33,3 +33,4 @@ import './dms/index';
|
|||
import './dms/create';
|
||||
import './dms/edit';
|
||||
import './sms';
|
||||
import './boxing';
|
||||
|
|
|
@ -4,6 +4,7 @@ Agency: Agencia
|
|||
Amount: Importe
|
||||
Base to commission: Base comisionable
|
||||
Boxes: Cajas
|
||||
Boxing: Encajado
|
||||
by: por
|
||||
Checked: Comprobado
|
||||
Client: Cliente
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
{"state": "ticket.card.saleChecked", "icon": "assignment"},
|
||||
{"state": "ticket.card.components", "icon": "icon-components"},
|
||||
{"state": "ticket.card.saleTracking", "icon": "assignment"},
|
||||
{"state": "ticket.card.dms.index", "icon": "cloud_download"}
|
||||
{"state": "ticket.card.dms.index", "icon": "cloud_download"},
|
||||
{"state": "ticket.card.boxing", "icon": "science"}
|
||||
]
|
||||
},
|
||||
"keybindings": [
|
||||
|
@ -273,6 +274,15 @@
|
|||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
},
|
||||
{
|
||||
"url": "/boxing",
|
||||
"state": "ticket.card.boxing",
|
||||
"component": "vn-ticket-boxing",
|
||||
"description": "Boxing",
|
||||
"params": {
|
||||
"ticket": "$ctrl.ticket"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -244,7 +244,7 @@
|
|||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<section class="header vn-pa-md">
|
||||
<h5>MANÁ: {{::$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
<h5>Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}}</h5>
|
||||
</section>
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number
|
||||
|
@ -264,6 +264,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<vn-horizontal >
|
||||
<vn-button
|
||||
label="Cancel"
|
||||
ng-click="$ctrl.cancel()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Save"
|
||||
ng-click="$ctrl.save()">
|
||||
</vn-button>
|
||||
</vn-horizontal>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
|
@ -288,7 +298,7 @@
|
|||
clear-disabled="true"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
<vn-vertical ng-if="$ctrl.currentWorkerMana != 0">
|
||||
<vn-vertical ng-if="$ctrl.usesMana && $ctrl.currentWorkerMana != 0">
|
||||
<vn-radio
|
||||
label="Promotion mana"
|
||||
val="mana"
|
||||
|
@ -300,7 +310,7 @@
|
|||
ng-model="$ctrl.manaCode">
|
||||
</vn-radio>
|
||||
</vn-vertical>
|
||||
<div class="simulator">
|
||||
<div class="simulator" ng-show="$ctrl.edit.sale">
|
||||
<p class="simulatorTitle" translate>New price</p>
|
||||
<p>
|
||||
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
|
||||
|
@ -321,32 +331,6 @@
|
|||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- Multiple discount dialog -->
|
||||
<vn-dialog vn-id="editDiscountDialog"
|
||||
on-open="$ctrl.getMana()"
|
||||
message="Edit discount">
|
||||
<tpl-body>
|
||||
<vn-spinner class="vn-pa-xs"
|
||||
ng-if="$ctrl.edit.mana == null"
|
||||
enable="true">
|
||||
</vn-spinner>
|
||||
<div ng-if="$ctrl.edit.mana != null">
|
||||
<div class="vn-pa-md">
|
||||
<vn-input-number vn-focus
|
||||
label="Discount"
|
||||
ng-model="$ctrl.edit.discount"
|
||||
on-change="$ctrl.changeMultipleDiscount()"
|
||||
clear-disabled="true"
|
||||
suffix="%">
|
||||
</vn-input-number>
|
||||
</div>
|
||||
<section class="header vn-pa-md">
|
||||
<span>Mana: <strong>{{::$ctrl.edit.mana | currency: 'EUR': 0}}</strong></span>
|
||||
</section>
|
||||
</div>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- Transfer Popover -->
|
||||
<vn-popover vn-id="transfer">
|
||||
<div class="vn-pa-lg transfer">
|
||||
|
@ -490,7 +474,7 @@
|
|||
</vn-item>
|
||||
<vn-item translate
|
||||
name="discount"
|
||||
ng-click="$ctrl.showEditDiscountDialog($event)">
|
||||
ng-click="$ctrl.showEditDiscountPopover($event, sale)">
|
||||
Update discount
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
|
|
|
@ -75,6 +75,7 @@ class Controller extends Section {
|
|||
this.$.editPricePopover.relocate();
|
||||
});
|
||||
});
|
||||
this.getUsesMana();
|
||||
this.getCurrentWorkerMana();
|
||||
}
|
||||
|
||||
|
@ -85,6 +86,13 @@ class Controller extends Section {
|
|||
});
|
||||
}
|
||||
|
||||
getUsesMana() {
|
||||
this.$http.get(`Sales/usesMana`)
|
||||
.then(res => {
|
||||
this.useMana = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns checked instances
|
||||
*
|
||||
|
@ -243,24 +251,19 @@ class Controller extends Section {
|
|||
|
||||
showEditDiscountPopover(event, sale) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
if (sale) {
|
||||
this.edit = {
|
||||
discount: sale.discount,
|
||||
sale: sale
|
||||
};
|
||||
|
||||
this.$.editDiscount.show(event);
|
||||
}
|
||||
|
||||
showEditDiscountDialog(event) {
|
||||
if (this.isLocked) return;
|
||||
|
||||
} else {
|
||||
this.edit = {
|
||||
discount: null,
|
||||
sales: this.selectedValidSales()
|
||||
};
|
||||
}
|
||||
|
||||
this.$.editDiscountDialog.show(event);
|
||||
this.$.editDiscount.show(event);
|
||||
}
|
||||
|
||||
changeDiscount() {
|
||||
|
@ -278,11 +281,10 @@ class Controller extends Section {
|
|||
const hasChanges = sales.some(sale => {
|
||||
return sale.discount != newDiscount;
|
||||
});
|
||||
|
||||
if (newDiscount != null && hasChanges)
|
||||
this.updateDiscount(sales);
|
||||
|
||||
this.$.editDiscountDialog.hide();
|
||||
this.$.editDiscount.hide();
|
||||
}
|
||||
|
||||
updateDiscount(sales) {
|
||||
|
@ -303,7 +305,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
getNewPrice() {
|
||||
if (this.edit) {
|
||||
if (this.edit.sale) {
|
||||
const sale = this.edit.sale;
|
||||
let newDiscount = sale.discount;
|
||||
let newPrice = this.edit.price || sale.price;
|
||||
|
@ -505,7 +507,8 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
save() {
|
||||
this.changeDiscount();
|
||||
if (this.edit.sale) this.changeDiscount();
|
||||
if (this.edit.sales) this.changeMultipleDiscount();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue