#6276 createNewWarehouse methods migrated from silex to salix #1850

Merged
jorgep merged 158 commits from 6276-createNewWarehouse into dev 2024-03-06 11:32:11 +00:00
5 changed files with 83 additions and 65 deletions
Showing only changes of commit 9f9d953b86 - Show all commits

100
Jenkinsfile vendored
View File

@ -4,60 +4,60 @@ def PROTECTED_BRANCH
def FROM_GIT def FROM_GIT
def RUN_TESTS def RUN_TESTS
pre: {
switch (env.BRANCH_NAME) {
case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
break
default:
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
}
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
// Uncomment to enable debugging
// https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference
//env.DEBUG = 'strong-remoting:shared-method'
}
node {
stage('Setup') {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
env.GIT_COMMIT_MSG = sh(
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
setEnv()
}
}
pipeline { pipeline {
agent any agent any
options { options {
disableConcurrentBuilds() disableConcurrentBuilds()
} }
tools {
nodejs 'node-v20'
}
environment { environment {
PROJECT_NAME = 'salix' PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
tools {
nodejs 'node-v20'
}
stages { stages {
stage('Checkout') {
steps {
script {
// Uncomment to enable debugging
//env.DEBUG = 'strong-remoting:http-context,strong-remoting:shared-method'
switch (env.BRANCH_NAME) {
case 'dev':
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
break
case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
break
}
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
env.GIT_COMMIT_MSG = sh(
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
}
setEnv()
}
}
stage('Install') { stage('Install') {
environment { environment {
NODE_ENV = "" NODE_ENV = ""
@ -70,7 +70,7 @@ pipeline {
} }
stage('Frontend') { stage('Frontend') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
steps { steps {
sh 'npm install --no-audit --prefer-offline --prefix=front' sh 'npm install --no-audit --prefer-offline --prefix=front'
@ -78,7 +78,7 @@ pipeline {
} }
stage('Print') { stage('Print') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
steps { steps {
sh 'npm install --no-audit --prefer-offline --prefix=print' sh 'npm install --no-audit --prefer-offline --prefix=print'
@ -88,7 +88,7 @@ pipeline {
} }
stage('Test') { stage('Test') {
when { when {
expression { return RUN_TESTS } expression { RUN_TESTS }
} }
environment { environment {
NODE_ENV = "" NODE_ENV = ""
@ -109,7 +109,7 @@ pipeline {
} }
stage('Build') { stage('Build') {
when { when {
expression { return PROTECTED_BRANCH && FROM_GIT } expression { PROTECTED_BRANCH && FROM_GIT }
} }
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
@ -121,7 +121,7 @@ pipeline {
} }
stage('Deploy') { stage('Deploy') {
when { when {
expression { return PROTECTED_BRANCH } expression { PROTECTED_BRANCH }
} }
parallel { parallel {
stage('Database') { stage('Database') {
@ -139,7 +139,7 @@ pipeline {
} }
stage('Docker') { stage('Docker') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
environment { environment {
DOCKER_HOST = "${env.SWARM_HOST}" DOCKER_HOST = "${env.SWARM_HOST}"

View File

@ -21,11 +21,8 @@ BEGIN
DECLARE vAgencyModeFk INT; DECLARE vAgencyModeFk INT;
DECLARE vNewPrice DECIMAL(10,2); DECLARE vNewPrice DECIMAL(10,2);
DECLARE vOldPrice DECIMAL(10,2); DECLARE vOldPrice DECIMAL(10,2);
DECLARE vOption INT DEFAULT NULL; DECLARE vOption VARCHAR(255);
DECLARE vNewSaleFk INT; DECLARE vNewSaleFk INT;
DECLARE vChangePrice INT DEFAULT 1;
DECLARE vBuyerDiscount INT DEFAULT 4;
DECLARE vManaDiscount INT DEFAULT 3;
DECLARE vForceToGrouping INT DEFAULT 1; DECLARE vForceToGrouping INT DEFAULT 1;
DECLARE vForceToPacking INT DEFAULT 2; DECLARE vForceToPacking INT DEFAULT 2;
DECLARE vFinalPrice DECIMAL(10,2); DECLARE vFinalPrice DECIMAL(10,2);
@ -85,16 +82,13 @@ BEGIN
IF vNewPrice IS NULL THEN IF vNewPrice IS NULL THEN
CALL util.throw('price retrieval failed'); CALL util.throw('price retrieval failed');
END IF; END IF;
IF vNewPrice > vOldPrice THEN IF vNewPrice > vOldPrice THEN
SET vFinalPrice = vOldPrice; SET vFinalPrice = vOldPrice;
IF worker_isInDepartment('vt') THEN SET vOption = 'substitution';
SET vOption = vManaDiscount;
ELSE
SET vOption = vBuyerDiscount;
END IF;
ELSE ELSE
SET vFinalPrice = vNewPrice; SET vFinalPrice = vNewPrice;
SET vOption = vChangePrice; SET vOption = 'renewPrices';
END IF; END IF;
START TRANSACTION; START TRANSACTION;

View File

@ -337,8 +337,6 @@
"You already have the mailAlias": "Ya tienes este alias de correo", "You already have the mailAlias": "Ya tienes este alias de correo",
"The alias cant be modified": "Este alias de correo no puede ser modificado", "The alias cant be modified": "Este alias de correo no puede ser modificado",
"No tickets to invoice": "No hay tickets para facturar", "No tickets to invoice": "No hay tickets para facturar",
"No hay tickets para sacar": "No hay tickets para sacar",
"There is no zone for these parameters 999999": "There is no zone for these parameters 999999",
"This machine is already in use.": "Esta máquina ya está en uso.", "This machine is already in use.": "Esta máquina ya está en uso.",
jorgep marked this conversation as resolved Outdated

no puede estar en castellano

no puede estar en castellano
"the plate does not exist": "La máquina {{plate}} no existe", "the plate does not exist": "La máquina {{plate}} no existe",
"We do not have availability for the selected item": "No tenemos disponible el item seleccionado", "We do not have availability for the selected item": "No tenemos disponible el item seleccionado",
@ -350,5 +348,5 @@
"printerNotExists": "No existe la impresora", "printerNotExists": "No existe la impresora",
"There are not picking tickets": "No hay tickets para sacar", "There are not picking tickets": "No hay tickets para sacar",
"ticketCommercial": "El ticket {{ticket}} del comercial {{salesMan}} está en preparación.(mensaje creado automáticamente)", "ticketCommercial": "El ticket {{ticket}} del comercial {{salesMan}} está en preparación.(mensaje creado automáticamente)",
"Este trabajador no existe": "Este trabajador no existe" "An email is necessary": "Es necesario un email"
} }

View File

@ -1,3 +1,5 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = function(Self) { module.exports = function(Self) {
Self.remoteMethod('createWithUser', { Self.remoteMethod('createWithUser', {
description: 'Creates both client and its web account', description: 'Creates both client and its web account',
@ -29,7 +31,11 @@ module.exports = function(Self) {
myOptions.transaction = tx; myOptions.transaction = tx;
} }
const firstEmail = data.email ? data.email.split(',')[0] : null; if (!data.email)
throw new UserError('An email is necessary');
const firstEmail = data.email.split(',')[0];
const user = { const user = {
name: data.userName, name: data.userName,
email: firstEmail, email: firstEmail,

View File

@ -13,6 +13,8 @@ describe('Client Create', () => {
businessTypeFk: 'florist', businessTypeFk: 'florist',
provinceFk: 1 provinceFk: 1
}; };
const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount));
delete newAccountWithoutEmail.email;
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { const activeCtx = {
@ -48,6 +50,24 @@ describe('Client Create', () => {
} }
}); });
it('should not create a new account', async() => {
const tx = await models.Client.beginTransaction({});
let error;
try {
const options = {transaction: tx};
await models.Client.createWithUser(newAccountWithoutEmail, options);
await tx.rollback();
} catch (e) {
error = e.message;
await tx.rollback();
}
expect(error).toEqual(`An email is necessary`);
});
it('should create a new account', async() => { it('should create a new account', async() => {
const tx = await models.Client.beginTransaction({}); const tx = await models.Client.beginTransaction({});