Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6372-Delete-views-from-vn2008
This commit is contained in:
commit
6044c160f8
|
@ -1,4 +1,6 @@
|
|||
node_modules
|
||||
print/node_modules
|
||||
front/node_modules
|
||||
services
|
||||
front
|
||||
db
|
||||
e2e
|
||||
storage
|
||||
|
|
|
@ -5,34 +5,50 @@ def FROM_GIT
|
|||
def RUN_TESTS
|
||||
def RUN_BUILD
|
||||
|
||||
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
|
||||
def BRANCH_ENV = [
|
||||
test: 'test',
|
||||
master: 'production'
|
||||
]
|
||||
|
||||
node {
|
||||
stage('Setup') {
|
||||
env.BACK_REPLICAS = 1
|
||||
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
|
||||
|
||||
PROTECTED_BRANCH = [
|
||||
'dev',
|
||||
'test',
|
||||
'master'
|
||||
].contains(env.BRANCH_NAME)
|
||||
|
||||
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
|
||||
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
|
||||
RUN_BUILD = PROTECTED_BRANCH && FROM_GIT
|
||||
|
||||
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
|
||||
echo "NODE_NAME: ${env.NODE_NAME}"
|
||||
echo "WORKSPACE: ${env.WORKSPACE}"
|
||||
|
||||
configFileProvider([
|
||||
configFile(fileId: 'salix.properties',
|
||||
variable: 'PROPS_FILE')
|
||||
]) {
|
||||
def props = readProperties file: PROPS_FILE
|
||||
props.each {key, value -> env."${key}" = value }
|
||||
props.each {key, value -> echo "${key}: ${value}" }
|
||||
}
|
||||
|
||||
if (PROTECTED_BRANCH) {
|
||||
configFileProvider([
|
||||
configFile(fileId: "salix.branch.${env.BRANCH_NAME}",
|
||||
variable: 'BRANCH_PROPS_FILE')
|
||||
]) {
|
||||
def props = readProperties file: BRANCH_PROPS_FILE
|
||||
props.each {key, value -> env."${key}" = value }
|
||||
props.each {key, value -> echo "${key}: ${value}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROTECTED_BRANCH = [
|
||||
'dev',
|
||||
'test',
|
||||
'master'
|
||||
].contains(env.BRANCH_NAME)
|
||||
|
||||
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
|
||||
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
|
||||
RUN_BUILD = 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'
|
||||
}
|
||||
pipeline {
|
||||
agent any
|
||||
|
@ -47,43 +63,54 @@ pipeline {
|
|||
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
||||
}
|
||||
stages {
|
||||
stage('Stack') {
|
||||
stage('Install') {
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
TZ = 'Europe/Madrid'
|
||||
NODE_ENV = ''
|
||||
}
|
||||
parallel {
|
||||
stage('Back') {
|
||||
steps {
|
||||
sh 'pnpm install --prefer-offline'
|
||||
}
|
||||
}
|
||||
stage('Print') {
|
||||
when {
|
||||
expression { FROM_GIT }
|
||||
}
|
||||
steps {
|
||||
sh 'pnpm install --prefer-offline --prefix=print'
|
||||
}
|
||||
}
|
||||
stage('Front') {
|
||||
when {
|
||||
expression { FROM_GIT }
|
||||
}
|
||||
steps {
|
||||
sh 'pnpm install --prefer-offline --prefix=front'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Stack') {
|
||||
parallel {
|
||||
stage('Back') {
|
||||
stages {
|
||||
stage('Install') {
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
}
|
||||
steps {
|
||||
sh 'pnpm install --prefer-offline'
|
||||
sh 'pnpm install --prefer-offline --prefix=print'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
expression { RUN_TESTS }
|
||||
}
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
NODE_ENV = ''
|
||||
}
|
||||
steps {
|
||||
sh 'npm run test:back:ci'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
try {
|
||||
junit 'junitresults.xml'
|
||||
junit 'junit.xml'
|
||||
} catch (e) {
|
||||
echo e.toString()
|
||||
}
|
||||
}
|
||||
junit(
|
||||
testResults: 'junitresults.xml',
|
||||
allowEmptyResults: true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,24 +133,24 @@ pipeline {
|
|||
expression { FROM_GIT }
|
||||
}
|
||||
stages {
|
||||
stage('Install') {
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
}
|
||||
steps {
|
||||
sh 'pnpm install --prefer-offline --prefix=front'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
expression { RUN_TESTS }
|
||||
}
|
||||
environment {
|
||||
NODE_ENV = ""
|
||||
NODE_ENV = ''
|
||||
}
|
||||
steps {
|
||||
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit(
|
||||
testResults: 'junit.xml',
|
||||
allowEmptyResults: true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
when {
|
||||
|
|
|
@ -8,6 +8,26 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.validatesUniquenessOf('bic', {
|
||||
message: 'This BIC already exist.'
|
||||
message: 'This BIC already exist'
|
||||
});
|
||||
|
||||
Self.validatesPresenceOf('countryFk', {
|
||||
message: 'CountryFK cannot be empty'
|
||||
});
|
||||
|
||||
Self.validateAsync('bic', checkBic, {
|
||||
message: 'Bank entity id must be specified'
|
||||
});
|
||||
async function checkBic(err, done) {
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (code == 'es' && !this.id)
|
||||
err();
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,19 +1,36 @@
|
|||
/* eslint-disable no-console */
|
||||
const path = require('path');
|
||||
const getopts = require('getopts');
|
||||
const Myt = require('@verdnatura/myt/myt');
|
||||
const Run = require('@verdnatura/myt/myt-run');
|
||||
const helper = require('./tests-helper');
|
||||
|
||||
const opts = getopts(process.argv.slice(2), {
|
||||
string: [
|
||||
'network'
|
||||
],
|
||||
boolean: [
|
||||
'ci',
|
||||
'junit'
|
||||
]
|
||||
});
|
||||
|
||||
let server;
|
||||
const isCI = process.argv[2] === 'ci';
|
||||
const PARALLEL = false;
|
||||
const TIMEOUT = 900000;
|
||||
|
||||
process.on('SIGINT', teardown);
|
||||
process.on('exit', teardown);
|
||||
process.on('uncaughtException', onError);
|
||||
process.on('unhandledRejection', onError);
|
||||
|
||||
const exitSignals = [
|
||||
'SIGINT',
|
||||
'SIGUSR1',
|
||||
'SIGUSR2'
|
||||
];
|
||||
for (const signal of exitSignals)
|
||||
process.on(signal, () => process.exit());
|
||||
|
||||
async function setup() {
|
||||
console.log('Building and running DB container.');
|
||||
|
||||
|
@ -21,9 +38,9 @@ async function setup() {
|
|||
await myt.init({
|
||||
workspace: path.join(__dirname, '..'),
|
||||
random: true,
|
||||
ci: isCI,
|
||||
ci: opts.ci,
|
||||
tmpfs: process.platform == 'linux',
|
||||
network: isCI ? 'jenkins' : null
|
||||
network: opts.network || null
|
||||
});
|
||||
server = await myt.run(Run);
|
||||
await myt.deinit();
|
||||
|
@ -38,18 +55,19 @@ async function setup() {
|
|||
|
||||
async function teardown() {
|
||||
if (!server) return;
|
||||
const oldServer = server;
|
||||
server = null;
|
||||
|
||||
if (!PARALLEL)
|
||||
await helper.deinit();
|
||||
|
||||
console.log('Stopping and removing DB container.');
|
||||
await server.rm();
|
||||
server = null;
|
||||
await oldServer.rm();
|
||||
}
|
||||
|
||||
async function onError(err) {
|
||||
await teardown();
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
|
@ -79,8 +97,8 @@ async function test() {
|
|||
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
||||
runner.addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displaySuccessful: isCI,
|
||||
displayPending: isCI
|
||||
displaySuccessful: opts.ci,
|
||||
displayPending: opts.ci
|
||||
},
|
||||
summary: {
|
||||
displayPending: false,
|
||||
|
@ -88,11 +106,12 @@ async function test() {
|
|||
}));
|
||||
}
|
||||
|
||||
if (isCI) {
|
||||
if (opts.junit) {
|
||||
const JunitReporter = require('jasmine-reporters');
|
||||
runner.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
||||
}
|
||||
if (opts.ci)
|
||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
||||
|
||||
// runner.loadConfigFile('back/jasmine.json');
|
||||
runner.loadConfig(config);
|
||||
|
|
|
@ -73,9 +73,10 @@ INSERT INTO vn.cmr (id, truckPlate, observations, senderInstruccions, paymentIns
|
|||
|
||||
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
|
||||
|
||||
INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `warehouseAliasFk`, `isOwn`, `isAnyVolumeAllowed`) VALUES
|
||||
('Agencia', '1', '1', '1', '1'),
|
||||
('Otra agencia ', '1', '2', '0', '0');
|
||||
INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
|
||||
VALUES
|
||||
('Agencia', '1', '1', '1'),
|
||||
('Otra agencia ', '1', '0', '0');
|
||||
|
||||
INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES
|
||||
('1', '1', 1, '1', '1', '1', '1', 'pc00', 'F', 0),
|
||||
|
|
|
@ -174,23 +174,18 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`,
|
|||
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
|
||||
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
|
||||
|
||||
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`)
|
||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`)
|
||||
VALUES
|
||||
(1, 'Main Warehouse'),
|
||||
(2, 'Gotham');
|
||||
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0),
|
||||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
|
||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
|
||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
||||
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
|
||||
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
|
||||
|
||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`)
|
||||
VALUES
|
||||
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1),
|
||||
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1),
|
||||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
|
||||
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
|
||||
|
||||
INSERT INTO `vn`.`sectorType` (id,description)
|
||||
VALUES (1,'First type');
|
||||
INSERT INTO `vn`.`sectorType` (`id`, `code`)
|
||||
VALUES (1,'normal');
|
||||
|
||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `code`, `typeFk`)
|
||||
VALUES
|
||||
|
@ -271,18 +266,18 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
|
|||
(3, 'PICKUP', 'Recogida'),
|
||||
(4, 'OTHER', 'Otros');
|
||||
|
||||
INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `warehouseAliasFk`)
|
||||
INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`)
|
||||
VALUES
|
||||
(1, 'inhouse pickup' , 1, 1),
|
||||
(2, 'Super-Man delivery' , 1, 1),
|
||||
(3, 'Teleportation device' , 1, 1),
|
||||
(4, 'Entanglement' , 1, 1),
|
||||
(5, 'Quantum break device' , 1, 1),
|
||||
(6, 'Walking' , 1, 1),
|
||||
(7, 'Gotham247' , 1, 1),
|
||||
(8, 'Gotham247Expensive' , 1, 1),
|
||||
(9, 'Refund' , 1, 1),
|
||||
(10, 'Other agency' , 1, 1);
|
||||
(1, 'inhouse pickup' , 1),
|
||||
(2, 'Super-Man delivery' , 1),
|
||||
(3, 'Teleportation device' , 1),
|
||||
(4, 'Entanglement' , 1),
|
||||
(5, 'Quantum break device' , 1),
|
||||
(6, 'Walking' , 1),
|
||||
(7, 'Gotham247' , 1),
|
||||
(8, 'Gotham247Expensive' , 1),
|
||||
(9, 'Refund' , 1),
|
||||
(10, 'Other agency' , 1);
|
||||
|
||||
UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup';
|
||||
UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery';
|
||||
|
@ -569,13 +564,13 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
|
|||
|
||||
INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`)
|
||||
VALUES
|
||||
(1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(69, 'Packaging', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||
(567, 'Holland', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(791, 'Bros SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||
(1381, 'Ornamentales', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
||||
(1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'),
|
||||
(442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||
(567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'),
|
||||
(791, 'BROS SL', 'Bros nick', 5115000791, 1, '37718083S', 0, util.VN_CURDATE(), 1, 'supplier address 7', 'ASGARD', 3, 46600, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'),
|
||||
(1381, 'ORNAMENTALES', 'Ornamentales', 7185001381, 1, '07972486L', 0, util.VN_CURDATE(), 1, 'supplier address 4', 'GOTHAM', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V');
|
||||
|
||||
INSERT INTO `vn`.`supplierAddress`(`id`, `supplierFk`, `nickname`, `street`, `provinceFk`, `postalCode`, `city`, `phone`, `mobile`)
|
||||
VALUES
|
||||
|
|
|
@ -20,16 +20,16 @@ BEGIN
|
|||
c.movil,
|
||||
c.POBLACION poblacion,
|
||||
p.`name` provincia,
|
||||
vn2008.red(f.futur) futur,
|
||||
ROUND(f.futur, 2) futur,
|
||||
c.Credito credito,
|
||||
pm.`name` forma_pago,
|
||||
vn2008.red(c365 / 12) consumo_medio365,
|
||||
vn2008.red(c365) consumo365,
|
||||
vn2008.red(CmLy.peso) peso_mes_año_pasado,
|
||||
vn2008.red(CmLy.peso * 1.19) objetivo,
|
||||
ROUND(c365 / 12, 2) consumo_medio365,
|
||||
ROUND(c365, 2) consumo365,
|
||||
ROUND(CmLy.peso, 2) peso_mes_año_pasado,
|
||||
ROUND(CmLy.peso * 1.19, 2) objetivo,
|
||||
tr.CodigoTrabajador,
|
||||
vn2008.red(mes_actual.consumo) consumoMes,
|
||||
vn2008.red(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0)) como_lo_llevo,
|
||||
ROUND(mes_actual.consumo, 2) consumoMes,
|
||||
ROUND(IFNULL(mes_actual.consumo, 0) - IFNULL(CmLy.peso * 1.19, 0), 2) como_lo_llevo,
|
||||
DATE(LastTicket) ultimo_ticket,
|
||||
dead.muerto,
|
||||
g.Greuge,
|
||||
|
|
|
@ -5,7 +5,8 @@ proc: BEGIN
|
|||
DECLARE vReserveDate DATETIME;
|
||||
DECLARE vParams CHAR(100);
|
||||
DECLARE vInventoryDate DATE;
|
||||
DECLARE vIsLogifloraDay BOOLEAN;
|
||||
DECLARE vLifeScope DATE;
|
||||
DECLARE vWarehouseFkInventory INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
@ -26,43 +27,42 @@ proc: BEGIN
|
|||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
-- Invoca al procedimiento que genera el stock virtual de Logiflora, si coincide con la peticion de refresco del disponible
|
||||
IF vn.isLogifloraDay(vDated, vWarehouse) THEN
|
||||
-- CALL edi.floramondo_offerRefresh;
|
||||
SET vIsLogifloraDay = TRUE;
|
||||
ELSE
|
||||
SET vIsLogifloraDay = FALSE;
|
||||
END IF;
|
||||
|
||||
-- Calcula algunos parámetros necesarios
|
||||
SET vStartDate = TIMESTAMP(vDated, '00:00:00');
|
||||
SELECT inventoried INTO vInventoryDate FROM vn.config;
|
||||
SELECT DATE_SUB(vStartDate, INTERVAL MAX(life) DAY) INTO vLifeScope FROM vn.itemType;
|
||||
SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vReserveDate
|
||||
FROM hedera.orderConfig;
|
||||
|
||||
SELECT w.id INTO vWarehouseFkInventory
|
||||
FROM vn.warehouse w
|
||||
WHERE w.code = 'inv';
|
||||
|
||||
-- Calcula el ultimo dia de vida para cada producto
|
||||
DROP TEMPORARY TABLE IF EXISTS itemRange;
|
||||
CREATE TEMPORARY TABLE itemRange
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.itemFk,
|
||||
IF(it.life IS NULL,
|
||||
NULL,
|
||||
TIMESTAMP(TIMESTAMPADD(DAY, it.life, c.landing), '23:59:59')) ended
|
||||
FROM (
|
||||
SELECT b.itemFk, MAX(t.landed) landing
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON b.entryFk = e.id
|
||||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
WHERE t.landed BETWEEN vInventoryDate AND vStartDate
|
||||
AND t.warehouseInFk = vWarehouse
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
GROUP BY b.itemFk
|
||||
) c
|
||||
JOIN vn.item i ON i.id = c.itemFk
|
||||
SELECT i.id itemFk,
|
||||
util.dayEnd(DATE_ADD(c.maxLanded, INTERVAL it.life DAY)) ended, it.life
|
||||
FROM vn.item i
|
||||
LEFT JOIN (
|
||||
SELECT b.itemFk, MAX(t.landed) maxLanded
|
||||
FROM vn.buy b
|
||||
JOIN vn.entry e ON b.entryFk = e.id
|
||||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
WHERE t.landed BETWEEN vLifeScope AND vStartDate
|
||||
AND t.warehouseInFk = vWarehouse
|
||||
AND t.warehouseOutFk <> vWarehouseFkInventory
|
||||
AND it.life
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
GROUP BY b.itemFk
|
||||
) c ON i.id = c.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
HAVING ended >= vStartDate OR ended IS NULL;
|
||||
HAVING ended >= vStartDate OR life IS NULL;
|
||||
|
||||
-- Calcula el ATP
|
||||
DELETE FROM available WHERE calc_id = vCalc;
|
||||
|
@ -86,7 +86,7 @@ proc: BEGIN
|
|||
WHERE i.landed >= vStartDate
|
||||
AND (ir.ended IS NULL OR i.landed <= ir.ended)
|
||||
AND i.warehouseInFk = vWarehouse
|
||||
AND (ISNULL(wf.entryFk) OR vIsLogifloraDay)
|
||||
AND ISNULL(wf.entryFk)
|
||||
UNION ALL
|
||||
SELECT i.itemFk, i.shipped, i.quantity
|
||||
FROM vn.itemEntryOut i
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
|
||||
vAccount VARCHAR(20)
|
||||
)
|
||||
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y genera el código IBAN correspondiente
|
||||
* a un número de cuenta bancaria español.
|
||||
*
|
||||
* @param vAccount Número de cuenta bancaria
|
||||
* @return vIban Código IBAN de 4 caracteres.
|
||||
*/
|
||||
DECLARE vIban VARCHAR(4);
|
||||
|
||||
SELECT
|
||||
CONCAT('ES',
|
||||
RIGHT(
|
||||
CONCAT(0,
|
||||
98-MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
SUBSTRING(vAccount, 1, 8),
|
||||
97
|
||||
),
|
||||
SUBSTRING(vAccount,9,8)
|
||||
),
|
||||
97
|
||||
),
|
||||
SUBSTRING(
|
||||
CONCAT(vAccount, 142800),
|
||||
17,
|
||||
8
|
||||
)
|
||||
),
|
||||
97
|
||||
),
|
||||
SUBSTRING(
|
||||
CONCAT(vAccount, 142800),
|
||||
25,
|
||||
2
|
||||
)
|
||||
),
|
||||
97
|
||||
)
|
||||
),
|
||||
2
|
||||
)
|
||||
) INTO vIban;
|
||||
|
||||
RETURN vIban;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,32 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`(
|
||||
vSelf INT,
|
||||
vStems INT
|
||||
)
|
||||
RETURNS double
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula un valor neto estimado en función de
|
||||
* datos históricos de facturas intrastat.
|
||||
*
|
||||
* @param vSelf Id de intrastat
|
||||
* @param vStems Número de unidades
|
||||
* @return vNet
|
||||
*/
|
||||
DECLARE vNet DOUBLE;
|
||||
|
||||
SELECT ROUND(vStems / (SUM(average) / COUNT(average)), 2) INTO vNet
|
||||
FROM (
|
||||
SELECT *, stems / net average
|
||||
FROM invoiceInIntrastat
|
||||
WHERE intrastatFk = vSelf
|
||||
AND net
|
||||
AND stems > 0
|
||||
ORDER BY dated DESC
|
||||
LIMIT 20
|
||||
) sub;
|
||||
|
||||
RETURN vNet/2;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -70,9 +70,9 @@ BEGIN
|
|||
ish.created,
|
||||
ish.visible,
|
||||
IFNULL(
|
||||
IF(st.description = 'previousByPacking', ish.packing, g.`grouping`),
|
||||
IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),
|
||||
1) `grouping`,
|
||||
st.description = 'previousPrepared' isPreviousPrepared,
|
||||
st.code = 'previousPrepared' isPreviousPrepared,
|
||||
iss.id itemShelvingSaleFk,
|
||||
ts.ticketFk,
|
||||
iss.id,
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fustControl`(vFromDated DATE, vToDated DATE)
|
||||
BEGIN
|
||||
|
||||
DECLARE vSijsnerClientFk INT DEFAULT 19752;
|
||||
|
||||
DECLARE vDateStart DATETIME;
|
||||
DECLARE vDateEnd DATETIME;
|
||||
|
||||
SET vDateStart = vFromDated;
|
||||
SET vDateEnd = util.Dayend(vToDated);
|
||||
|
||||
SELECT p.id FustCode,
|
||||
CAST(sent.stucks AS DECIMAL(10,0)) FH,
|
||||
CAST(tp.stucks AS DECIMAL(10,0)) Tickets,
|
||||
CAST(-sj.stucks AS DECIMAL(10,0)) Sijsner,
|
||||
CAST(IFNULL(sent.stucks,0) - IFNULL(tp.stucks,0) + IFNULL(sj.stucks,0) AS DECIMAL(10,0)) saldo
|
||||
FROM vn.packaging p
|
||||
LEFT JOIN (
|
||||
SELECT FustCode, sum(fustQuantity) stucks
|
||||
FROM (
|
||||
SELECT IFNULL(pe.equivalentFk ,b.packagingFk) FustCode, s.quantity / b.packing AS fustQuantity
|
||||
FROM vn.sale s
|
||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk
|
||||
JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND lb.warehouse_id = t.warehouseFk
|
||||
JOIN vn.buy b ON b.id = lb.buy_id
|
||||
JOIN vn.packaging p ON p.id = b.packagingFk
|
||||
LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p2 ON p2.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p2.countryFk
|
||||
WHERE t.shipped BETWEEN vDateStart AND vDateEnd
|
||||
AND wa.name = 'VNH'
|
||||
AND p.isPackageReturnable
|
||||
AND c.country = 'FRANCIA') sub
|
||||
GROUP BY FustCode) sent ON sent.FustCode = p.id
|
||||
LEFT JOIN (
|
||||
SELECT FustCode, sum(quantity) stucks
|
||||
FROM (
|
||||
SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity
|
||||
FROM vn.ticketPackaging tp
|
||||
JOIN vn.ticket t ON t.id = tp.ticketFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk
|
||||
JOIN vn.packaging p ON p.id = tp.packagingFk
|
||||
LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p2 ON p2.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p2.countryFk
|
||||
WHERE t.shipped BETWEEN vDateStart AND vDateEnd
|
||||
AND wa.name = 'VNH'
|
||||
AND p.isPackageReturnable
|
||||
AND c.country = 'FRANCIA'
|
||||
AND t.clientFk != vSijsnerClientFk
|
||||
AND tp.quantity > 0) sub
|
||||
GROUP BY FustCode) tp ON tp.FustCode = p.id
|
||||
LEFT JOIN (
|
||||
SELECT FustCode, sum(quantity) stucks
|
||||
FROM (
|
||||
SELECT IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode, tp.quantity
|
||||
FROM vn.ticketPackaging tp
|
||||
JOIN vn.ticket t ON t.id = tp.ticketFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk
|
||||
JOIN vn.packaging p ON p.id = tp.packagingFk
|
||||
LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id
|
||||
WHERE t.shipped BETWEEN TIMESTAMPADD(DAY, 1, vDateStart ) AND TIMESTAMPADD(DAY, 1, vDateEnd )
|
||||
AND wa.name = 'VNH'
|
||||
AND p.isPackageReturnable
|
||||
AND t.clientFk = vSijsnerClientFk) sub
|
||||
GROUP BY FustCode) sj ON sj.FustCode = p.id
|
||||
WHERE sent.stucks
|
||||
OR tp.stucks
|
||||
OR sj.stucks;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,36 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fustControlDetail`(vFromDated DATE, vToDated DATE)
|
||||
BEGIN
|
||||
|
||||
DECLARE vSijsnerClientFk INT DEFAULT 19752;
|
||||
|
||||
DECLARE vDateStart DATETIME;
|
||||
DECLARE vDateEnd DATETIME;
|
||||
|
||||
SET vDateStart = vFromDated;
|
||||
SET vDateEnd = util.Dayend(vToDated);
|
||||
|
||||
SELECT a.nickname shopName,
|
||||
a.city ,
|
||||
IFNULL(pe.equivalentFk ,tp.packagingFk) FustCode,
|
||||
tp.quantity,
|
||||
tp.ticketFk,
|
||||
CONCAT('From ', vFromDated,' to ', vToDated) AS dateRange
|
||||
FROM vn.ticketPackaging tp
|
||||
JOIN vn.ticket t ON t.id = tp.ticketFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseFk
|
||||
JOIN vn.warehouseAlias wa ON wa.id = w.aliasFk
|
||||
JOIN vn.packaging p ON p.id = tp.packagingFk
|
||||
LEFT JOIN vn.packageEquivalent pe ON pe.packagingFk = p.id
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p2 ON p2.id = a.provinceFk
|
||||
JOIN vn.country c ON c.id = p2.countryFk
|
||||
WHERE t.shipped BETWEEN vFromDated AND util.dayend(vToDated)
|
||||
AND wa.name = 'VNH'
|
||||
AND p.isPackageReturnable
|
||||
AND c.country = 'FRANCIA'
|
||||
AND t.clientFk != vSijsnerClientFk
|
||||
AND tp.quantity > 0;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,234 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Traslada la info de contabilidad relacionada con las facturas recibidas
|
||||
*
|
||||
* @vInvoiceInFk Factura recibida
|
||||
* @vXDiarioFk Id tabla XDiario
|
||||
*/
|
||||
DECLARE vInvoiceInOriginalFk INT;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vBase DOUBLE;
|
||||
DECLARE vVat DOUBLE;
|
||||
DECLARE vRate DOUBLE;
|
||||
DECLARE vTransactionCode INT;
|
||||
DECLARE vCounter INT DEFAULT 0;
|
||||
DECLARE vTransactionCodeOld INT;
|
||||
DECLARE vTaxCode INT;
|
||||
DECLARE vTaxCodeOld INT;
|
||||
DECLARE vOperationCode VARCHAR(1);
|
||||
DECLARE vIsIntracommunity BOOL DEFAULT FALSE;
|
||||
DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
|
||||
DECLARE vInvoiceTypeReceived VARCHAR(1);
|
||||
DECLARE vInvoiceTypeInformative VARCHAR(1);
|
||||
DECLARE vIsInformativeExportation BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT it.taxableBase,
|
||||
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
|
||||
t.PorcentajeIva,
|
||||
it.transactionTypeSageFk,
|
||||
it.taxTypeSageFk,
|
||||
tty.isIntracommunity,
|
||||
tt.ClaveOperacionDefecto
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
|
||||
JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
|
||||
JOIN taxType tty ON tty.id = t.CodigoIva
|
||||
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
|
||||
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
|
||||
WHERE i.id = vInvoiceInFk
|
||||
AND d.id IS NULL;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
DELETE FROM movContaIVA
|
||||
WHERE id = vXDiarioFk;
|
||||
|
||||
SELECT codeSage INTO vInvoiceTypeReceived
|
||||
FROM invoiceType WHERE code ='received';
|
||||
|
||||
SELECT codeSage INTO vInvoiceTypeInformative
|
||||
FROM invoiceType WHERE code ='informative';
|
||||
|
||||
INSERT INTO movContaIVA(id, LibreA1)
|
||||
VALUES (vXDiarioFk, vInvoiceInFk);
|
||||
|
||||
OPEN vCursor;
|
||||
|
||||
l: LOOP
|
||||
FETCH vCursor INTO vBase,
|
||||
vVat,
|
||||
vRate,
|
||||
vTransactionCode,
|
||||
vTaxCode,
|
||||
vIsIntracommunity,
|
||||
vOperationCode;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
IF vOperationCode IS NOT NULL THEN
|
||||
UPDATE movContaIVA
|
||||
SET ClaveOperacionFactura = vOperationCode
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
CASE vCounter
|
||||
WHEN 1 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva1 = vBase,
|
||||
PorIva1 = vRate,
|
||||
CuotaIva1 = vVat,
|
||||
CodigoTransaccion1 = vTransactionCode,
|
||||
CodigoIva1 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
|
||||
WHEN 2 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva2 = vBase,
|
||||
PorIva2 = vRate,
|
||||
CuotaIva2 = vVat,
|
||||
CodigoTransaccion2 = vTransactionCode,
|
||||
CodigoIva2 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
WHEN 3 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva3 = vBase,
|
||||
PorIva3 = vRate,
|
||||
CuotaIva3 = vVat,
|
||||
CodigoTransaccion3 = vTransactionCode,
|
||||
CodigoIva3 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
WHEN 4 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva4 = vBase,
|
||||
PorIva4 = vRate,
|
||||
CuotaIva4 = vVat,
|
||||
CodigoTransaccion4 = vTransactionCode,
|
||||
CodigoIva4 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
ELSE
|
||||
SELECT vXDiarioFk INTO vXDiarioFk;
|
||||
END CASE;
|
||||
|
||||
IF vIsIntracommunity THEN
|
||||
UPDATE movContaIVA
|
||||
SET Intracomunitaria = TRUE
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
END LOOP;
|
||||
|
||||
CLOSE vCursor;
|
||||
|
||||
SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation
|
||||
FROM vn.dua d
|
||||
LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
|
||||
AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
|
||||
WHERE d.ASIEN = (
|
||||
SELECT ASIEN
|
||||
FROM vn.XDiario
|
||||
WHERE id = vXDiarioFk)
|
||||
LIMIT 1;
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
|
||||
JOIN vn.supplier s ON s.id = ii.supplierFk
|
||||
JOIN Naciones n ON n.countryFk = s.countryFk
|
||||
SET mci.CodigoDivisa = ii.currencyFk,
|
||||
mci.Año = YEAR(ii.issued),
|
||||
mci.Serie = ii.serial,
|
||||
mci.Factura = ii.id,
|
||||
mci.FechaFactura = ii.issued,
|
||||
mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
|
||||
IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
|
||||
IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
|
||||
IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0),
|
||||
mci.TipoFactura = IF(id.id,
|
||||
IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
|
||||
IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
|
||||
mci.CodigoCuentaFactura = x.SUBCTA,
|
||||
mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif),
|
||||
mci.Nombre = s.name,
|
||||
mci.SiglaNacion = n.SiglaNacion,
|
||||
mci.EjercicioFactura = YEAR(ii.issued),
|
||||
mci.FechaOperacion = ii.issued,
|
||||
mci.MantenerAsiento = TRUE,
|
||||
mci.SuFacturaNo = ii.supplierRef,
|
||||
mci.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.FechaFacturaOriginal = x.FECHA_EX
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
-- RETENCIONES
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
JOIN vn.supplier s ON s.id = supplierFk
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||
JOIN vn.expense e ON e.id = iit.expenseFk
|
||||
JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
|
||||
LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
|
||||
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
|
||||
FROM vn.XDiario x1
|
||||
JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
|
||||
WHERE x2.BASEEURO <> 0
|
||||
AND x1.id = vXDiarioFk
|
||||
)sub
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio'
|
||||
SET mci.CodigoRetencion = t.CodigoRetencion,
|
||||
mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura),
|
||||
mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase),
|
||||
mci.PorRetencion = t.PorcentajeRetencion,
|
||||
mci.ImporteRetencion = iit.taxableBase * - 1
|
||||
WHERE mci.id = vXDiarioFk
|
||||
AND e.name = 'Retenciones'
|
||||
AND id.id IS NULL;
|
||||
|
||||
SELECT correctedFk INTO vInvoiceInOriginalFk
|
||||
FROM vn.invoiceInCorrection
|
||||
WHERE correctingFk = vInvoiceInFk;
|
||||
|
||||
IF vInvoiceInOriginalFk THEN
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
|
||||
JOIN (SELECT issued,
|
||||
SUM(sub.taxableBase) taxableBase,
|
||||
SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
|
||||
FROM(SELECT issued,
|
||||
SUM(iit.taxableBase) taxableBase,
|
||||
ti.PorcentajeIva
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE i.id = vInvoiceInOriginalFk
|
||||
GROUP BY ti.CodigoIva)sub
|
||||
)invoiceInOriginal
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
|
||||
SET mci.TipoRectificativa = iir.refundCategoryFk,
|
||||
mci.ClaseAbonoRectificativas = iir.refundType,
|
||||
mci.FechaFacturaOriginal = invoiceInOriginal.issued,
|
||||
mci.FechaOperacion = invoiceInOriginal.issued,
|
||||
mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase,
|
||||
mci.CuotaIvaOriginal = invoiceInOriginal.vat,
|
||||
mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -8,27 +8,22 @@ BEGIN
|
|||
* @param vItemFk Identificador de vn.item
|
||||
* @param vSectorFk Identificador de vn.sector
|
||||
*/
|
||||
DECLARE vWarehouseAliasFk INT;
|
||||
|
||||
SELECT w.aliasFk INTO vWarehouseAliasFk
|
||||
FROM vn.sector s
|
||||
JOIN vn.warehouse w ON w.id = s.warehouseFk
|
||||
WHERE s.id = vSectorFk;
|
||||
|
||||
SELECT ish.shelvingFk shelving,
|
||||
p.code parking,
|
||||
sum(ish.visible) as stockTotal,
|
||||
ish.created,
|
||||
p.pickingOrder
|
||||
p.code parking,
|
||||
SUM(ish.visible) stockTotal,
|
||||
ish.created,
|
||||
p.pickingOrder
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||
JOIN vn.sector sc ON sc.id = p.sectorFk
|
||||
JOIN vn.warehouse w ON w.id = sc.warehouseFk
|
||||
WHERE w.aliasFk = vWarehouseAliasFk
|
||||
AND ish.visible > 0
|
||||
AND ish.itemFk = vItemFk
|
||||
WHERE sc.id = vSectorFk
|
||||
AND ish.visible > 0
|
||||
AND ish.itemFk = vItemFk
|
||||
GROUP BY ish.id
|
||||
ORDER BY (sc.id = vSectorFk) DESC, sh.priority DESC, ish.created, p.pickingOrder;
|
||||
ORDER BY sh.priority DESC,
|
||||
ish.created,
|
||||
p.pickingOrder;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,7 +1,13 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`(vSectorFk INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`(
|
||||
vSectorFk INT
|
||||
)
|
||||
proc:BEGIN
|
||||
|
||||
/**
|
||||
* Calcula la información detallada respecto un sector.
|
||||
*
|
||||
* @param vSectorFk Id de sector
|
||||
*/
|
||||
DECLARE vCalcVisibleFk INT;
|
||||
DECLARE vCalcAvailableFk INT;
|
||||
DECLARE hasFatherSector BOOLEAN;
|
||||
|
|
|
@ -207,7 +207,7 @@ proc: BEGIN
|
|||
ENGINE = MEMORY
|
||||
SELECT ish.itemFk,
|
||||
p.sectorFk,
|
||||
st.description = 'previousPrepared' isPreviousPrepared,
|
||||
st.code = 'previousPrepared' isPreviousPrepared,
|
||||
sc.itemPackingTypeFk
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
|
|
|
@ -85,7 +85,7 @@ BEGIN
|
|||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN tmp.productionBuffer pb ON pb.ticketFk = t.id
|
||||
JOIN packagingConfig pc
|
||||
WHERE IF(st.description = 'previousByPacking',
|
||||
WHERE IF(st.code = 'previousByPacking',
|
||||
i.`size` > pc.previousPreparationMinimumSize
|
||||
AND (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ),
|
||||
TRUE)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`warehouse_afterUpdate`
|
||||
AFTER UPDATE ON `warehouse`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.isFeedStock IS TRUE AND OLD.isFeedStock IS FALSE THEN
|
||||
INSERT IGNORE INTO warehouseAlias(`name`) VALUES(NEW.`name`);
|
||||
INSERT IGNORE INTO warehouseJoined(warehouseFk, warehouseAliasFk)
|
||||
VALUES(NEW.id,LAST_INSERT_ID());
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,7 +1,7 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`itemShelvingAvailable`
|
||||
AS SELECT `s`.`id` AS `saleFk`,
|
||||
AS SELECT `s`.`id` `saleFk`,
|
||||
`tst`.`updated` AS `Modificado`,
|
||||
`s`.`ticketFk` AS `ticketFk`,
|
||||
0 AS `isPicked`,
|
||||
|
@ -38,7 +38,7 @@ FROM (
|
|||
)
|
||||
JOIN `vn`.`agencyMode` `am` ON(`am`.`id` = `t`.`agencyModeFk`)
|
||||
)
|
||||
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticket` = `t`.`id`)
|
||||
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
|
||||
)
|
||||
JOIN `vn`.`state` `st` ON(`st`.`id` = `tst`.`state`)
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ AS SELECT `ish`.`itemFk` AS `itemFk`,
|
|||
`sh`.`parkingFk` AS `parkingFk`,
|
||||
`ish`.`id` AS `itemShelvingFk`,
|
||||
`ish`.`created` AS `created`,
|
||||
`st`.`description` = 'previousPrepared' AS `isPreviousPrepared`
|
||||
`st`.`code` = 'previousPrepared' AS `isPreviousPrepared`
|
||||
FROM (
|
||||
(
|
||||
(
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`warehouseJoined`
|
||||
AS SELECT `wj`.`warehouse_id` AS `warehouseFk`,
|
||||
`wj`.`warehouse_alias_id` AS `warehouseAliasFk`
|
||||
FROM `vn2008`.`warehouse_joined` `wj`
|
|
@ -14,7 +14,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
JOIN saleVolume sv ON sv.ticketFk = t.id
|
||||
LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
JOIN warehouseAlias wa ON wa.id = w.aliasFk
|
||||
STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk
|
||||
LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
|
||||
AND zc.dated = util.VN_CURDATE()
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn2008`.`cc_to_iban`(cc VARCHAR(20))
|
||||
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
DECLARE iban VARCHAR(4);
|
||||
select
|
||||
CONCAT('ES',
|
||||
RIGHT(
|
||||
concat(0,
|
||||
98-
|
||||
mod(
|
||||
concat(
|
||||
mod(
|
||||
concat(
|
||||
mod(
|
||||
concat(
|
||||
mod(
|
||||
substring(cc,1,8),
|
||||
97),
|
||||
substring(cc,9,8)
|
||||
),
|
||||
97),
|
||||
substring(
|
||||
concat(
|
||||
cc,
|
||||
142800
|
||||
),
|
||||
17,
|
||||
8
|
||||
)
|
||||
),
|
||||
97),
|
||||
substring(
|
||||
concat(
|
||||
cc,
|
||||
142800
|
||||
),
|
||||
25,
|
||||
2
|
||||
)
|
||||
),
|
||||
97)
|
||||
)
|
||||
,2)
|
||||
)into iban;
|
||||
RETURN iban;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,20 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn2008`.`intrastat_neto`(intINSTRASTAT INTEGER,intUNIDADES INTEGER)
|
||||
RETURNS double
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
||||
DECLARE n DOUBLE;
|
||||
|
||||
SELECT ROUND(intUNIDADES / (SUM(MEDIA) / COUNT(media)), 2) INTO n FROM
|
||||
(SELECT *, unidades / neto MEDIA
|
||||
FROM intrastat_data
|
||||
WHERE intrastat_id = intINSTRASTAT AND neto
|
||||
AND unidades > 0
|
||||
ORDER BY odbc_date DESC
|
||||
LIMIT 20) t;
|
||||
-- JGF 01/06 per a evitar Kg en negatiu
|
||||
RETURN n/2;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,14 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn2008`.`red`(intCANTIDAD DOUBLE)
|
||||
RETURNS double
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
||||
DECLARE n DOUBLE;
|
||||
|
||||
SET n = SIGN(intCANTIDAD) * TRUNCATE( (ABS(intCANTIDAD) * 100) + 0.5001 ,0) /100 ;
|
||||
|
||||
RETURN n;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,82 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`desglose_volume`(IN vAgencyFk INT)
|
||||
BEGIN
|
||||
|
||||
DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE());
|
||||
DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59');
|
||||
DECLARE vIsHolland BOOL;
|
||||
|
||||
SELECT (wa.name = 'Holanda') INTO vIsHolland
|
||||
FROM vn.agency a
|
||||
JOIN vn.warehouseAlias wa ON wa.id = a.warehouseAliasFk
|
||||
WHERE a.id = vAgencyFk;
|
||||
|
||||
IF vIsHolland THEN
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
|
||||
(
|
||||
ticketFk INT PRIMARY KEY
|
||||
,carros DECIMAL(5,1) DEFAULT 0
|
||||
);
|
||||
|
||||
INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, carros)
|
||||
SELECT sv.ticketFk, ROUND(vc.dutchCompressionRate * sum(sv.volume) / vc.trolleyM3,0)
|
||||
FROM vn.ticket t
|
||||
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN vn.volumeConfig vc
|
||||
WHERE t.shipped BETWEEN vStarted AND vEnded
|
||||
AND am.agencyFk = vAgencyFk
|
||||
GROUP BY t.id;
|
||||
|
||||
SELECT a.nickname Provincia,
|
||||
count(*) expediciones,
|
||||
0 Bultos,
|
||||
sum(tpe.carros) Prevision
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
|
||||
GROUP BY a.nickname;
|
||||
|
||||
ELSE
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
|
||||
(
|
||||
ticketFk INT PRIMARY KEY
|
||||
,boxes INT DEFAULT 0
|
||||
);
|
||||
|
||||
INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes)
|
||||
SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox)
|
||||
FROM vn.ticket t
|
||||
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN vn.volumeConfig vc
|
||||
WHERE t.shipped BETWEEN vStarted AND vEnded
|
||||
AND IFNULL(t.packages,0) = 0
|
||||
AND am.agencyFk = vAgencyFk
|
||||
GROUP BY t.id;
|
||||
|
||||
|
||||
SELECT p.name Provincia,
|
||||
count(*) expediciones,
|
||||
sum(t.packages) Bultos,
|
||||
sum(tpe.boxes) Prevision
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON a.provinceFk = p.id
|
||||
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
|
||||
WHERE t.warehouseFk = 60
|
||||
AND t.shipped BETWEEN vStarted AND vEnded
|
||||
AND am.agencyFk = vAgencyFk
|
||||
GROUP BY p.name;
|
||||
|
||||
END IF;
|
||||
SELECT * FROM tmp.ticket_PackagingEstimated;
|
||||
DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,7 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Articles_botanical`
|
||||
AS SELECT `ab`.`itemFk` AS `Id_Article`,
|
||||
`ab`.`genusFk` AS `genus_id`,
|
||||
`ab`.`specieFk` AS `specie_id`
|
||||
FROM `vn`.`itemBotanical` `ab`
|
|
@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|||
AS SELECT `a`.`id` AS `agency_id`,
|
||||
`a`.`name` AS `name`,
|
||||
`a`.`warehouseFk` AS `warehouse_id`,
|
||||
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
|
||||
`a`.`isOwn` AS `propios`,
|
||||
`a`.`workCenterFk` AS `workCenterFk`
|
||||
FROM `vn`.`agency` `a`
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`bionic_updating_options`
|
||||
AS SELECT `t`.`id` AS `buo_id`,
|
||||
`t`.`description` AS `description`
|
||||
FROM `vn`.`ticketUpdateAction` `t`
|
|
@ -1,6 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`businessReasonEnd`
|
||||
AS SELECT `b`.`id` AS `id`,
|
||||
`b`.`reason` AS `reason`
|
||||
FROM `vn`.`businessReasonEnd` `b`
|
|
@ -1,6 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`cl_dev`
|
||||
AS SELECT `c`.`id` AS `id`,
|
||||
`c`.`description` AS `devolucion`
|
||||
FROM `vn`.`claimRedelivery` `c`
|
|
@ -1,7 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`cl_est`
|
||||
AS SELECT `c`.`id` AS `id`,
|
||||
`c`.`description` AS `estado`,
|
||||
`c`.`roleFk` AS `roleFk`
|
||||
FROM `vn`.`claimState` `c`
|
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE vn.agency
|
||||
CHANGE warehouseAliasFk warehouseAliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@deprecated 2024-01-23 refs #5167';
|
||||
|
||||
ALTER TABLE vn.warehouse
|
||||
CHANGE aliasFk aliasFk__ SMALLINT(5) UNSIGNED DEFAULT NULL NULL COMMENT '@deprecated 2024-01-23 refs #5167';
|
||||
|
||||
RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__;
|
||||
ALTER TABLE vn.warehouseAlias__ COMMENT='@deprecated 2024-01-23 refs #5167';
|
|
@ -0,0 +1,4 @@
|
|||
-- Place your SQL code here
|
||||
UPDATE vn.supplier
|
||||
SET name = UPPER(name),
|
||||
nickname = UPPER(nickname);
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('InvoiceInCorrection', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,17 @@
|
|||
CREATE TABLE IF NOT EXISTS `vn`.`invoiceInCorrection` (
|
||||
`correctingFk` mediumint(8) UNSIGNED NOT NULL COMMENT 'Factura rectificativa',
|
||||
`correctedFk` mediumint(8) UNSIGNED NOT NULL COMMENT 'Factura rectificada',
|
||||
`cplusRectificationTypeFk` int(10) UNSIGNED NOT NULL,
|
||||
`siiTypeInvoiceOutFk` int(10) UNSIGNED NOT NULL,
|
||||
`invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3,
|
||||
PRIMARY KEY (`correctingFk`),
|
||||
KEY `invoiceInCorrection_correctedFk` (`correctedFk`),
|
||||
KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`),
|
||||
KEY `invoiceInCorrection_siiTypeInvoiceOut` (`siiTypeInvoiceOutFk`),
|
||||
KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`),
|
||||
CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_siiTypeInvoiceOut` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `siiTypeInvoiceOut` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE
|
||||
);
|
|
@ -0,0 +1 @@
|
|||
REVOKE SELECT ON TABLE vn2008.Articles_botanical FROM buyer, administrative;
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('Supplier', 'updateAllFiscalData', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
|
||||
('Supplier', 'updateFiscalData', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -0,0 +1,60 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
|
||||
vAccount VARCHAR(20)
|
||||
)
|
||||
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y genera el código IBAN correspondiente
|
||||
* a un número de cuenta bancaria español.
|
||||
*
|
||||
* @param vAccount Número de cuenta bancaria
|
||||
* @return vIban Código IBAN de 4 caracteres.
|
||||
*/
|
||||
DECLARE vIban VARCHAR(4);
|
||||
|
||||
SELECT
|
||||
CONCAT('ES',
|
||||
RIGHT(
|
||||
CONCAT(0,
|
||||
98-MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
CONCAT(
|
||||
MOD(
|
||||
SUBSTRING(vAccount, 1, 8),
|
||||
97
|
||||
),
|
||||
SUBSTRING(vAccount,9,8)
|
||||
),
|
||||
97
|
||||
),
|
||||
SUBSTRING(
|
||||
CONCAT(vAccount, 142800),
|
||||
17,
|
||||
8
|
||||
)
|
||||
),
|
||||
97
|
||||
),
|
||||
SUBSTRING(
|
||||
CONCAT(vAccount, 142800),
|
||||
25,
|
||||
2
|
||||
)
|
||||
),
|
||||
97
|
||||
)
|
||||
),
|
||||
2
|
||||
)
|
||||
) INTO vIban;
|
||||
|
||||
RETURN vIban;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
GRANT EXECUTE ON FUNCTION util.accountNumberToIban TO hr, financial;
|
|
@ -0,0 +1,38 @@
|
|||
ALTER TABLE vn.sectorType CHANGE description code varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
||||
|
||||
-- Si no pongo lo de bajo da error en la view vn.itemShelvingAvailable
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`itemShelvingStock`
|
||||
AS SELECT `ish`.`itemFk` AS `itemFk`,
|
||||
sum(`ish`.`visible`) AS `visible`,
|
||||
min(`ish`.`packing`) AS `packing`,
|
||||
min(`ish`.`grouping`) AS `grouping`,
|
||||
`s`.`description` AS `sector`,
|
||||
sum(`ish`.`visible`) AS `visibleOriginal`,
|
||||
0 AS `removed`,
|
||||
`p`.`sectorFk` AS `sectorFk`,
|
||||
`s`.`warehouseFk` AS `warehouseFk`,
|
||||
`ish`.`shelvingFk` AS `shelvingFk`,
|
||||
`p`.`code` AS `parkingCode`,
|
||||
`sh`.`parkingFk` AS `parkingFk`,
|
||||
`ish`.`id` AS `itemShelvingFk`,
|
||||
`ish`.`created` AS `created`,
|
||||
`st`.`code` = 'previousPrepared' AS `isPreviousPrepared`
|
||||
FROM (
|
||||
(
|
||||
(
|
||||
(
|
||||
`vn`.`itemShelving` `ish`
|
||||
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`sector` `s` ON(`s`.`id` = `p`.`sectorFk`)
|
||||
)
|
||||
LEFT JOIN `vn`.`sectorType` `st` ON(`st`.`id` = `s`.`typeFk`)
|
||||
)
|
||||
WHERE `ish`.`visible` <> 0
|
||||
AND `p`.`sectorFk` <> 0
|
||||
GROUP BY `ish`.`itemFk`,
|
||||
`p`.`sectorFk`;
|
|
@ -0,0 +1,34 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`(
|
||||
vSelf INT,
|
||||
vStems INT
|
||||
)
|
||||
RETURNS double
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula un valor neto estimado en función de
|
||||
* datos históricos de facturas intrastat.
|
||||
*
|
||||
* @param vSelf Id de intrastat
|
||||
* @param vStems Número de unidades
|
||||
* @return vNet
|
||||
*/
|
||||
DECLARE vNet DOUBLE;
|
||||
|
||||
SELECT ROUND(vStems / (SUM(average) / COUNT(average)), 2) INTO vNet
|
||||
FROM (
|
||||
SELECT *, stems / net average
|
||||
FROM invoiceInIntrastat
|
||||
WHERE intrastatFk = vSelf
|
||||
AND net
|
||||
AND stems > 0
|
||||
ORDER BY dated DESC
|
||||
LIMIT 20
|
||||
) sub;
|
||||
|
||||
RETURN vNet/2;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
GRANT EXECUTE ON FUNCTION vn.intrastat_estimateNet TO administrative;
|
|
@ -3,8 +3,9 @@ services:
|
|||
front:
|
||||
image: registry.verdnatura.es/salix-front:${VERSION:?}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: front/Dockerfile
|
||||
context: front
|
||||
environment:
|
||||
- TZ
|
||||
ports:
|
||||
- 80
|
||||
deploy:
|
||||
|
@ -17,12 +18,15 @@ services:
|
|||
memory: 1G
|
||||
back:
|
||||
image: registry.verdnatura.es/salix-back:${VERSION:?}
|
||||
build: .
|
||||
ports:
|
||||
- 3000
|
||||
build:
|
||||
context: .
|
||||
dockerfile: back/Dockerfile
|
||||
environment:
|
||||
- TZ
|
||||
- NODE_ENV
|
||||
- DEBUG
|
||||
ports:
|
||||
- 3000
|
||||
configs:
|
||||
- source: datasources
|
||||
target: /etc/salix/datasources.json
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* eslint-disable no-console */
|
||||
require('@babel/register')({presets: ['@babel/env']});
|
||||
require('core-js/stable');
|
||||
require('regenerator-runtime/runtime');
|
||||
require('vn-loopback/server/boot/date')();
|
||||
const getopts = require('getopts');
|
||||
|
||||
const path = require('path');
|
||||
const Myt = require('@verdnatura/myt/myt');
|
||||
|
@ -18,12 +20,16 @@ process.on('warning', warning => {
|
|||
});
|
||||
|
||||
async function test() {
|
||||
if (process.argv[2] === 'show')
|
||||
process.env.E2E_SHOW = true;
|
||||
const opts = getopts(process.argv.slice(2), {
|
||||
boolean: ['show']
|
||||
});
|
||||
process.env.E2E_SHOW = opts.show;
|
||||
|
||||
console.log('Building and running DB container.');
|
||||
const myt = new Myt();
|
||||
await myt.init({workspace: path.join(__dirname, '../..')});
|
||||
await myt.run(Run);
|
||||
await myt.deinit();
|
||||
|
||||
const Jasmine = require('jasmine');
|
||||
const jasmine = new Jasmine();
|
||||
|
@ -70,12 +76,10 @@ async function test() {
|
|||
|
||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
await jasmine.execute();
|
||||
|
||||
await myt.deinit();
|
||||
}
|
||||
|
||||
async function backendStatus() {
|
||||
log('Awaiting backend connection...');
|
||||
log('Awaiting backend connection.');
|
||||
|
||||
const milliseconds = 1000;
|
||||
const maxAttempts = 10;
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('Supplier summary & descriptor path', () => {
|
|||
it(`should confirm there's data on the summary header`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText');
|
||||
|
||||
expect(result).toContain('Plants SL - 1');
|
||||
expect(result).toContain('PLANTS SL - 1');
|
||||
});
|
||||
|
||||
it(`should confirm there's data on the summary basic data`, async() => {
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('Supplier fiscal data path', () => {
|
|||
country: null,
|
||||
postcode: null,
|
||||
city: 'Valencia',
|
||||
socialName: 'Farmer King SL',
|
||||
socialName: 'FARMER KING SL',
|
||||
taxNumber: '12345678Z',
|
||||
account: '0123456789',
|
||||
sageWithholding: 'retencion estimacion objetiva',
|
||||
|
@ -46,7 +46,7 @@ describe('Supplier fiscal data path', () => {
|
|||
country: 'España',
|
||||
postcode: '46000',
|
||||
city: 'Valencia',
|
||||
socialName: 'Farmer King SL',
|
||||
socialName: 'FARMER KING SL',
|
||||
taxNumber: '12345678Z',
|
||||
account: '0123456789',
|
||||
sageWithholding: 'RETENCION ESTIMACION OBJETIVA',
|
||||
|
|
|
@ -10,7 +10,7 @@ RUN apt-get update \
|
|||
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
||||
|
||||
WORKDIR /etc/nginx
|
||||
COPY front/nginx.conf sites-available/salix
|
||||
COPY nginx.conf sites-available/salix
|
||||
RUN rm sites-enabled/default && ln -s ../sites-available/salix sites-enabled/salix
|
||||
|
||||
COPY dist /salix/dist
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import 'angular';
|
||||
import 'angular-mocks';
|
||||
import core from './front/core/module.js';
|
||||
import './front/salix/components/app/app.js';
|
||||
import './modules/zone/front/module.js';
|
||||
import './modules/claim/front/module.js';
|
||||
import './modules/client/front/module.js';
|
||||
import './modules/invoiceOut/front/module.js';
|
||||
import './modules/invoiceIn/front/module.js';
|
||||
import './modules/item/front/module.js';
|
||||
import './modules/order/front/module.js';
|
||||
import './modules/route/front/module.js';
|
||||
import './modules/ticket/front/module.js';
|
||||
import './modules/travel/front/module.js';
|
||||
import './modules/worker/front/module.js';
|
||||
import './modules/shelving/front/module.js';
|
||||
import core from './core/module.js';
|
||||
import './salix/components/app/app.js';
|
||||
import '../modules/zone/front/module.js';
|
||||
import '../modules/claim/front/module.js';
|
||||
import '../modules/client/front/module.js';
|
||||
import '../modules/invoiceOut/front/module.js';
|
||||
import '../modules/invoiceIn/front/module.js';
|
||||
import '../modules/item/front/module.js';
|
||||
import '../modules/order/front/module.js';
|
||||
import '../modules/route/front/module.js';
|
||||
import '../modules/ticket/front/module.js';
|
||||
import '../modules/travel/front/module.js';
|
||||
import '../modules/worker/front/module.js';
|
||||
import '../modules/shelving/front/module.js';
|
||||
import 'vn-loopback/server/boot/date';
|
||||
|
||||
// Set NODE_ENV
|
50
gulpfile.js
50
gulpfile.js
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable no-console */
|
||||
require('require-yaml');
|
||||
const gulp = require('gulp');
|
||||
const PluginError = require('plugin-error');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const log = require('fancy-log');
|
||||
const Myt = require('@verdnatura/myt/myt');
|
||||
const Run = require('@verdnatura/myt/myt-run');
|
||||
|
@ -11,13 +11,10 @@ const Start = require('@verdnatura/myt/myt-start');
|
|||
|
||||
let isWindows = /^win/.test(process.platform);
|
||||
|
||||
if (argv.NODE_ENV)
|
||||
process.env.NODE_ENV = argv.NODE_ENV;
|
||||
|
||||
let langs = ['es', 'en'];
|
||||
let srcDir = './front';
|
||||
let modulesDir = './modules';
|
||||
let buildDir = 'dist';
|
||||
let buildDir = 'front/dist';
|
||||
|
||||
let backSources = [
|
||||
'!node_modules',
|
||||
|
@ -67,19 +64,40 @@ back.description = `Starts backend and database service`;
|
|||
|
||||
const defaultTask = gulp.parallel(front, back);
|
||||
defaultTask.description = `Starts all application services`;
|
||||
function install() {
|
||||
const install = require('gulp-install');
|
||||
const print = require('gulp-print');
|
||||
async function install() {
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
let npmArgs = [];
|
||||
if (argv.ci) npmArgs = ['--no-audit', '--prefer-offline'];
|
||||
console.log('-> Installing global packages...');
|
||||
await pnpmInstall();
|
||||
|
||||
let packageFiles = ['front/package.json', 'print/package.json'];
|
||||
return gulp.src(packageFiles)
|
||||
.pipe(print(filepath => {
|
||||
return `Installing packages in ${filepath}`;
|
||||
}))
|
||||
.pipe(install({npm: npmArgs}));
|
||||
const modules = ['front', 'print'];
|
||||
for (const module of modules) {
|
||||
console.log(`-> Installing '${module}' packages...`);
|
||||
await pnpmInstall(module);
|
||||
}
|
||||
|
||||
async function pnpmInstall(prefix) {
|
||||
let args = ['install', '--prefer-offline'];
|
||||
if (prefix) args = args.concat(['--prefix', prefix]);
|
||||
|
||||
const options = {
|
||||
stdio: [
|
||||
process.stdin,
|
||||
process.stdout,
|
||||
process.stderr
|
||||
]
|
||||
};
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const child = spawn('pnpm', args, options);
|
||||
child.on('exit', code => {
|
||||
if (code !== 0)
|
||||
reject(new Error(`pnpm exit code ${code}`));
|
||||
else
|
||||
resolve(code);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
install.description = `Installs node dependencies in all directories`;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
|||
},
|
||||
testEnvironment: 'jsdom',
|
||||
setupFilesAfterEnv: [
|
||||
'./jest-front.js'
|
||||
'./front/jest-setup.js'
|
||||
],
|
||||
testMatch: [
|
||||
'**/front/**/*.spec.js',
|
||||
|
@ -37,7 +37,7 @@ module.exports = {
|
|||
],
|
||||
moduleNameMapper: {
|
||||
'\\.(css|scss)$': 'identity-obj-proxy',
|
||||
'\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/fileMock.js',
|
||||
'\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/front/jest-mock.js',
|
||||
},
|
||||
testURL: 'http://localhost',
|
||||
verbose: false,
|
||||
|
|
|
@ -198,12 +198,13 @@
|
|||
"Booking completed": "Booking complete",
|
||||
"The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation",
|
||||
"You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets",
|
||||
"Bank entity must be specified": "Bank entity must be specified",
|
||||
"Try again": "Try again",
|
||||
"keepPrice": "keepPrice",
|
||||
"Cannot past travels with entries": "Cannot past travels with entries",
|
||||
"It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}",
|
||||
"Incorrect pin": "Incorrect pin.",
|
||||
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
|
||||
"Fecha fuera de rango": "Fecha fuera de rango",
|
||||
"There is no zone for these parameters 34": "There is no zone for these parameters 34"
|
||||
"Name should be uppercase": "Name should be uppercase",
|
||||
"You cannot update these fields": "You cannot update these fields"
|
||||
}
|
|
@ -337,5 +337,8 @@
|
|||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
||||
"No tickets to invoice": "No hay tickets para facturar",
|
||||
"An email is necessary": "Es necesario un email"
|
||||
"Name should be uppercase": "El nombre debe ir en mayúscula",
|
||||
"Bank entity must be specified": "La entidad bancaria es obligatoria",
|
||||
"An email is necessary": "Es necesario un email",
|
||||
"You cannot update these fields": "No puedes actualizar estos campos"
|
||||
}
|
|
@ -2,13 +2,17 @@ module.exports = Self => {
|
|||
Self.remoteMethodCtx('clone', {
|
||||
description: 'Clone the invoiceIn and as many invoiceInTax and invoiceInDueDay referencing it',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The invoiceIn id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
}, {
|
||||
arg: 'isRectification',
|
||||
type: 'boolean',
|
||||
description: 'Clone quantities in negative and clone Intrastat'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
|
@ -19,7 +23,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.clone = async(ctx, id, options) => {
|
||||
Self.clone = async(ctx, id, isRectification, options) => {
|
||||
const models = Self.app.models;
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
@ -45,14 +49,28 @@ module.exports = Self => {
|
|||
'isVatDeductible',
|
||||
'withholdingSageFk',
|
||||
'deductibleExpenseFk',
|
||||
]
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'invoiceInTax',
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInDueDay',
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInIntrastat'
|
||||
}
|
||||
],
|
||||
}, myOptions);
|
||||
const sourceInvoiceInTax = await models.InvoiceInTax.find({where: {invoiceInFk: id}}, myOptions);
|
||||
const sourceInvoiceInDueDay = await models.InvoiceInDueDay.find({where: {invoiceInFk: id}}, myOptions);
|
||||
const invoiceInTax = sourceInvoiceIn.invoiceInTax();
|
||||
const invoiceInDueDay = sourceInvoiceIn.invoiceInDueDay();
|
||||
const invoiceInIntrastat = sourceInvoiceIn.invoiceInIntrastat();
|
||||
|
||||
const issued = new Date(sourceInvoiceIn.issued);
|
||||
issued.setMonth(issued.getMonth() + 1);
|
||||
const clonedRef = sourceInvoiceIn.supplierRef + '(2)';
|
||||
const totalCorrections = await models.InvoiceInCorrection.count({correctedFk: id}, myOptions);
|
||||
|
||||
const clonedRef = sourceInvoiceIn.supplierRef + `(${totalCorrections + 2})`;
|
||||
|
||||
const clone = await models.InvoiceIn.create({
|
||||
serial: sourceInvoiceIn.serial,
|
||||
|
@ -68,30 +86,44 @@ module.exports = Self => {
|
|||
|
||||
const promises = [];
|
||||
|
||||
for (let tax of sourceInvoiceInTax) {
|
||||
for (let tax of invoiceInTax) {
|
||||
promises.push(models.InvoiceInTax.create({
|
||||
invoiceInFk: clone.id,
|
||||
taxableBase: tax.taxableBase,
|
||||
taxableBase: isRectification ? -tax.taxableBase : tax.taxableBase,
|
||||
expenseFk: tax.expenseFk,
|
||||
foreignValue: tax.foreignValue,
|
||||
foreignValue: isRectification ? -tax.foreignValue : tax.foreignValue,
|
||||
taxTypeSageFk: tax.taxTypeSageFk,
|
||||
transactionTypeSageFk: tax.transactionTypeSageFk
|
||||
}, myOptions));
|
||||
}
|
||||
|
||||
for (let dueDay of sourceInvoiceInDueDay) {
|
||||
const dueDated = dueDay.dueDated;
|
||||
dueDated.setMonth(dueDated.getMonth() + 1);
|
||||
if (!isRectification) {
|
||||
for (let dueDay of invoiceInDueDay) {
|
||||
const dueDated = dueDay.dueDated;
|
||||
dueDated.setMonth(dueDated.getMonth() + 1);
|
||||
|
||||
promises.push(models.InvoiceInDueDay.create({
|
||||
invoiceInFk: clone.id,
|
||||
dueDated: dueDated,
|
||||
bankFk: dueDay.bankFk,
|
||||
amount: dueDay.amount,
|
||||
foreignValue: dueDated.foreignValue,
|
||||
}, myOptions));
|
||||
promises.push(models.InvoiceInDueDay.create({
|
||||
invoiceInFk: clone.id,
|
||||
dueDated: dueDated,
|
||||
bankFk: dueDay.bankFk,
|
||||
amount: dueDay.amount,
|
||||
foreignValue: dueDated.foreignValue,
|
||||
}, myOptions));
|
||||
}
|
||||
} else {
|
||||
for (let intrastat of invoiceInIntrastat) {
|
||||
promises.push(models.InvoiceInIntrastat.create({
|
||||
invoiceInFk: clone.id,
|
||||
net: -intrastat.net,
|
||||
intrastatFk: intrastat.intrastatFk,
|
||||
amount: -intrastat.amount,
|
||||
stems: -intrastat.stems,
|
||||
country: intrastat.countryFk,
|
||||
dated: Date.vnNew(),
|
||||
statisticalValue: intrastat.statisticalValue
|
||||
}, myOptions));
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('corrective', {
|
||||
description: 'Creates a rectificated invoice in',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number'
|
||||
}, {
|
||||
arg: 'invoiceReason',
|
||||
type: 'number',
|
||||
}, {
|
||||
arg: 'invoiceType',
|
||||
type: 'number',
|
||||
}, {
|
||||
arg: 'invoiceClass',
|
||||
type: 'number'
|
||||
}],
|
||||
returns: {
|
||||
type: 'number',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/corrective',
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.corrective = async(ctx, id, invoiceReason, invoiceType, invoiceClass, 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 clone = await Self.clone(ctx, id, true, myOptions);
|
||||
await models.InvoiceInCorrection.create({
|
||||
correctingFk: clone.id,
|
||||
correctedFk: id,
|
||||
cplusRectificationTypeFk: invoiceType,
|
||||
siiTypeInvoiceOutFk: invoiceClass,
|
||||
invoiceCorrectionTypeFk: invoiceReason
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
return clone.id;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
@ -80,6 +79,11 @@ module.exports = Self => {
|
|||
type: 'boolean',
|
||||
description: 'Whether the invoice is booked or not',
|
||||
},
|
||||
{
|
||||
arg: 'correctedFk',
|
||||
type: 'number',
|
||||
description: 'The corrected invoice',
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
|
@ -93,6 +97,7 @@ module.exports = Self => {
|
|||
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
|
||||
const myOptions = {};
|
||||
|
@ -105,6 +110,14 @@ module.exports = Self => {
|
|||
dateTo.setHours(23, 59, 0, 0);
|
||||
}
|
||||
|
||||
let correctings;
|
||||
if (args.correctedFk) {
|
||||
correctings = await models.InvoiceInCorrection.find({
|
||||
fields: ['correctingFk'],
|
||||
where: {correctedFk: args.correctedFk}
|
||||
});
|
||||
}
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
|
@ -128,6 +141,8 @@ module.exports = Self => {
|
|||
return {[`ii.${param}`]: value};
|
||||
case 'awbCode':
|
||||
return {'sub.code': value};
|
||||
case 'correctedFk':
|
||||
return {'ii.id': {inq: correctings.map(x => x.correctingFk)}};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,50 +2,75 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('invoiceIn clone()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should return the cloned invoiceIn and also clone invoiceInDueDays and invoiceInTaxes if there are any referencing the invoiceIn', async() => {
|
||||
const userId = 1;
|
||||
const ctx = {
|
||||
req: {
|
||||
const clone = await models.InvoiceIn.clone(ctx, 1, false, options);
|
||||
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
expect(clone.supplierRef).toEqual('1234(2)');
|
||||
const invoiceIn = await models.InvoiceIn.findOne({
|
||||
include: [
|
||||
{
|
||||
relation: 'invoiceInTax',
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInDueDay',
|
||||
}
|
||||
], where: {
|
||||
id: clone.id
|
||||
}
|
||||
};
|
||||
}, options);
|
||||
const invoiceInTax = invoiceIn.invoiceInTax();
|
||||
const invoiceInDueDay = invoiceIn.invoiceInDueDay();
|
||||
|
||||
const tx = await models.InvoiceIn.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
expect(invoiceInTax.length).toEqual(2);
|
||||
expect(invoiceInDueDay.length).toEqual(2);
|
||||
});
|
||||
|
||||
try {
|
||||
const clone = await models.InvoiceIn.clone(ctx, 1, options);
|
||||
it('should return the cloned invoiceIn and also clone invoiceInIntrastat and invoiceInTaxes if it is rectificative', async() => {
|
||||
const clone = await models.InvoiceIn.clone(ctx, 1, true, options);
|
||||
|
||||
expect(clone.supplierRef).toEqual('1234(2)');
|
||||
expect(clone.supplierRef).toEqual('1234(2)');
|
||||
const invoiceIn = await models.InvoiceIn.findOne({
|
||||
include: [
|
||||
{
|
||||
relation: 'invoiceInTax',
|
||||
},
|
||||
{
|
||||
relation: 'invoiceInIntrastat',
|
||||
}
|
||||
], where: {
|
||||
id: clone.id
|
||||
}
|
||||
}, options);
|
||||
const invoiceInTax = invoiceIn.invoiceInTax();
|
||||
const invoiceInIntrastat = invoiceIn.invoiceInIntrastat();
|
||||
|
||||
const invoiceInTaxes = await models.InvoiceInTax.find({where: {invoiceInFk: clone.id}}, options);
|
||||
|
||||
expect(invoiceInTaxes.length).toEqual(2);
|
||||
|
||||
const invoiceInDueDays = await models.InvoiceInDueDay.find({where: {invoiceInFk: clone.id}}, options);
|
||||
|
||||
expect(invoiceInDueDays.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(invoiceInTax.length).toEqual(2);
|
||||
expect(invoiceInIntrastat.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('invoiceIn corrective()', () => {
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('La función corrective debería devolver un id cuando se ejecuta correctamente', async() => {
|
||||
const originalId = 1;
|
||||
const invoiceReason = 3;
|
||||
const invoiceType = 2;
|
||||
const invoiceClass = 1;
|
||||
const cloneId = await models.InvoiceIn.corrective(ctx,
|
||||
originalId, invoiceReason, invoiceType, invoiceClass, options);
|
||||
|
||||
expect(cloneId).toBeDefined();
|
||||
|
||||
const correction = await models.InvoiceInCorrection.findOne({
|
||||
where: {correctedFk: originalId, correctingFk: cloneId}
|
||||
}, options);
|
||||
|
||||
expect(correction.cplusRectificationTypeFk).toEqual(invoiceType);
|
||||
expect(correction.siiTypeInvoiceOutFk).toEqual(invoiceClass);
|
||||
expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason);
|
||||
});
|
||||
});
|
|
@ -8,14 +8,14 @@ describe('InvoiceIn filter()', () => {
|
|||
try {
|
||||
const ctx = {
|
||||
args: {
|
||||
search: 'Plants SL',
|
||||
search: 'PLANTS SL',
|
||||
}
|
||||
};
|
||||
|
||||
const result = await models.InvoiceIn.filter(ctx, {}, options);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
expect(result[0].supplierName).toEqual('Plants SL');
|
||||
expect(result[0].supplierName).toEqual('PLANTS SL');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
"InvoiceInConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"InvoiceInCorrection": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"InvoiceInDueDay": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "InvoiceInCorrection",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "invoiceInCorrection"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"correctingFk": {
|
||||
"id": true,
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"invoiceIn": {
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceIn",
|
||||
"foreignKey": "correctedFk"
|
||||
},
|
||||
"cplusRectificationType": {
|
||||
"type": "belongsTo",
|
||||
"model": "CplusRectificationType",
|
||||
"foreignKey": "cplusRectificationTypeFk"
|
||||
},
|
||||
"invoiceCorrectionType": {
|
||||
"type": "belongsTo",
|
||||
"model": "InvoiceCorrectionType",
|
||||
"foreignKey": "invoiceCorrectionTypeFk"
|
||||
},
|
||||
"siiTypeInvoiceOut": {
|
||||
"type": "belongsTo",
|
||||
"model": "SiiTypeInvoiceOut",
|
||||
"foreignKey": "siiTypeInvoiceOutFk"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ module.exports = Self => {
|
|||
require('../methods/invoice-in/invoiceInPdf')(Self);
|
||||
require('../methods/invoice-in/invoiceInEmail')(Self);
|
||||
require('../methods/invoice-in/getSerial')(Self);
|
||||
require('../methods/invoice-in/corrective')(Self);
|
||||
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn'))
|
||||
return new UserError(`This invoice has a linked vehicle.`);
|
||||
|
|
|
@ -103,6 +103,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Dms",
|
||||
"foreignKey": "dmsFk"
|
||||
},
|
||||
"invoiceInCorrection": {
|
||||
"type": "hasOne",
|
||||
"model": "InvoiceInCorrection",
|
||||
"foreignKey": "correctedFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ module.exports = Self => {
|
|||
cou.country,
|
||||
c.id clientId,
|
||||
c.socialName clientSocialName,
|
||||
u.nickname workerSocialName,
|
||||
SUM(s.quantity * s.price * ( 100 - s.discount ) / 100) amount,
|
||||
negativeBase.taxableBase,
|
||||
negativeBase.ticketFk,
|
||||
|
@ -80,6 +81,7 @@ module.exports = Self => {
|
|||
JOIN vn.client c ON c.id = t.clientFk
|
||||
JOIN vn.country cou ON cou.id = c.countryFk
|
||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||
JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN (
|
||||
SELECT ticketFk, taxableBase
|
||||
FROM tmp.ticketAmount
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class Controller extends Section {
|
|||
this.filter = {
|
||||
where: {
|
||||
itemFk: this.$params.id,
|
||||
shipped: {
|
||||
landed: {
|
||||
between: [from, to]
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class Controller extends Section {
|
|||
const to = new Date(this._dateTo);
|
||||
to.setHours(23, 59, 59, 59);
|
||||
|
||||
this.filter.where.shipped = {
|
||||
this.filter.where.landed = {
|
||||
between: [from, to]
|
||||
};
|
||||
this.$.model.refresh();
|
||||
|
@ -53,7 +53,7 @@ class Controller extends Section {
|
|||
const to = new Date(value);
|
||||
to.setHours(23, 59, 59, 59);
|
||||
|
||||
this.filter.where.shipped = {
|
||||
this.filter.where.landed = {
|
||||
between: [from, to]
|
||||
};
|
||||
this.$.model.refresh();
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('Supplier getSummary()', () => {
|
|||
const supplier = await app.models.Supplier.getSummary(1);
|
||||
|
||||
expect(supplier.id).toEqual(1);
|
||||
expect(supplier.name).toEqual('Plants SL');
|
||||
expect(supplier.name).toEqual('PLANTS SL');
|
||||
expect(supplier.nif).toEqual('06089160W');
|
||||
expect(supplier.account).toEqual('4100000001');
|
||||
expect(supplier.payDay).toEqual(15);
|
||||
|
|
|
@ -25,13 +25,13 @@ describe('Supplier newSupplier()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.args = {
|
||||
name: 'newSupplier',
|
||||
name: 'NEWSUPPLIER',
|
||||
nif: '12345678Z'
|
||||
};
|
||||
|
||||
const result = await models.Supplier.newSupplier(ctx, options);
|
||||
|
||||
expect(result.name).toEqual('newSupplier');
|
||||
expect(result.name).toEqual('NEWSUPPLIER');
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,92 +1,142 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Supplier updateFiscalData', () => {
|
||||
describe('Supplier updateFiscalData()', () => {
|
||||
const supplierId = 1;
|
||||
const administrativeId = 5;
|
||||
const employeeId = 1;
|
||||
const defaultData = {
|
||||
name: 'Plants SL',
|
||||
nif: '06089160W',
|
||||
account: '4100000001',
|
||||
sageTaxTypeFk: 4,
|
||||
sageWithholdingFk: 1,
|
||||
sageTransactionTypeFk: 1,
|
||||
postCode: '15214',
|
||||
city: 'PONTEVEDRA',
|
||||
provinceFk: 1,
|
||||
countryFk: 1,
|
||||
};
|
||||
const buyerId = 35;
|
||||
|
||||
it('should return an error if the user is not administrative', async() => {
|
||||
const ctx = {req: {accessToken: {userId: employeeId}}};
|
||||
ctx.args = {};
|
||||
const name = 'NEW PLANTS';
|
||||
const city = 'PONTEVEDRA';
|
||||
const nif = 'A68446004';
|
||||
const account = '4000000005';
|
||||
const sageTaxTypeFk = 5;
|
||||
const sageWithholdingFk = 2;
|
||||
const sageTransactionTypeFk = 2;
|
||||
const postCode = '46460';
|
||||
const phone = 456129367;
|
||||
const street = ' Fake address 12 3 flat';
|
||||
const provinceFk = 2;
|
||||
const countryFk = 1;
|
||||
const supplierActivityFk = 'animals';
|
||||
const healthRegister = '400664487H';
|
||||
|
||||
let error;
|
||||
await app.models.Supplier.updateFiscalData(ctx, supplierId)
|
||||
.catch(e => {
|
||||
error = e;
|
||||
});
|
||||
let ctx;
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
expect(error.message).toBeDefined();
|
||||
});
|
||||
|
||||
it('should check that the supplier fiscal data is untainted', async() => {
|
||||
const supplier = await app.models.Supplier.findById(supplierId);
|
||||
|
||||
expect(supplier.name).toEqual(defaultData.name);
|
||||
expect(supplier.nif).toEqual(defaultData.nif);
|
||||
expect(supplier.account).toEqual(defaultData.account);
|
||||
expect(supplier.sageTaxTypeFk).toEqual(defaultData.sageTaxTypeFk);
|
||||
expect(supplier.sageWithholdingFk).toEqual(defaultData.sageWithholdingFk);
|
||||
expect(supplier.sageTransactionTypeFk).toEqual(defaultData.sageTransactionTypeFk);
|
||||
expect(supplier.postCode).toEqual(defaultData.postCode);
|
||||
expect(supplier.city).toEqual(defaultData.city);
|
||||
expect(supplier.provinceFk).toEqual(defaultData.provinceFk);
|
||||
expect(supplier.countryFk).toEqual(defaultData.countryFk);
|
||||
});
|
||||
|
||||
it('should update the supplier fiscal data and return the count if changes made', async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: administrativeId},
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: buyerId},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
ctx.args = {
|
||||
name: 'Weapon Dealer',
|
||||
nif: 'A68446004',
|
||||
account: '4000000005',
|
||||
sageTaxTypeFk: 5,
|
||||
sageWithholdingFk: 2,
|
||||
sageTransactionTypeFk: 2,
|
||||
postCode: '46460',
|
||||
city: 'VALENCIA',
|
||||
provinceFk: 2,
|
||||
countryFk: 1,
|
||||
supplierActivityFk: 'animals',
|
||||
healthRegister: '400664487H'
|
||||
};
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
const result = await app.models.Supplier.updateFiscalData(ctx, supplierId);
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
expect(result.name).toEqual('Weapon Dealer');
|
||||
expect(result.nif).toEqual('A68446004');
|
||||
expect(result.account).toEqual('4000000005');
|
||||
expect(result.sageTaxTypeFk).toEqual(5);
|
||||
expect(result.sageWithholdingFk).toEqual(2);
|
||||
expect(result.sageTransactionTypeFk).toEqual(2);
|
||||
expect(result.postCode).toEqual('46460');
|
||||
expect(result.city).toEqual('VALENCIA');
|
||||
expect(result.provinceFk).toEqual(2);
|
||||
expect(result.countryFk).toEqual(1);
|
||||
expect(result.supplierActivityFk).toEqual('animals');
|
||||
expect(result.healthRegister).toEqual('400664487H');
|
||||
it('should throw an error if it is a buyer and tries to update forbidden fiscal data', async() => {
|
||||
try {
|
||||
await models.Supplier.updateFiscalData(ctx,
|
||||
supplierId,
|
||||
name,
|
||||
nif,
|
||||
account,
|
||||
undefined,
|
||||
sageTaxTypeFk,
|
||||
undefined,
|
||||
sageTransactionTypeFk,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
provinceFk,
|
||||
countryFk,
|
||||
supplierActivityFk,
|
||||
healthRegister,
|
||||
undefined,
|
||||
undefined,
|
||||
options);
|
||||
} catch (e) {
|
||||
expect(e.message).toEqual('You cannot update these fields');
|
||||
}
|
||||
});
|
||||
|
||||
// Restores
|
||||
ctx.args = defaultData;
|
||||
await app.models.Supplier.updateFiscalData(ctx, supplierId);
|
||||
it('should update the granted fiscal data if it is a buyer', async() => {
|
||||
const supplier = await models.Supplier.updateFiscalData(ctx,
|
||||
supplierId,
|
||||
undefined,
|
||||
undefined,
|
||||
account,
|
||||
phone,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
postCode,
|
||||
street,
|
||||
city,
|
||||
provinceFk,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
options);
|
||||
|
||||
expect(supplier.account).toEqual(account);
|
||||
expect(supplier.phone).toEqual(phone);
|
||||
expect(supplier.postCode).toEqual(postCode);
|
||||
expect(supplier.account).toEqual(account);
|
||||
expect(supplier.city).toEqual(city);
|
||||
expect(supplier.provinceFk).toEqual(provinceFk);
|
||||
});
|
||||
|
||||
it('should update all fiscalData if it is an administative', async() => {
|
||||
const supplier = await models.Supplier.updateFiscalData(ctx,
|
||||
supplierId,
|
||||
name,
|
||||
nif,
|
||||
account,
|
||||
phone,
|
||||
sageTaxTypeFk,
|
||||
sageWithholdingFk,
|
||||
sageTransactionTypeFk,
|
||||
postCode,
|
||||
street,
|
||||
city,
|
||||
provinceFk,
|
||||
countryFk,
|
||||
supplierActivityFk,
|
||||
healthRegister,
|
||||
undefined,
|
||||
undefined,
|
||||
options);
|
||||
|
||||
expect(supplier.name).toEqual(name);
|
||||
expect(supplier.nif).toEqual(nif);
|
||||
expect(supplier.account).toEqual(account);
|
||||
expect(supplier.phone).toEqual(phone);
|
||||
expect(supplier.sageTaxTypeFk).toEqual(sageTaxTypeFk);
|
||||
expect(supplier.sageWithholdingFk).toEqual(sageWithholdingFk);
|
||||
expect(supplier.sageTransactionTypeFk).toEqual(sageTransactionTypeFk);
|
||||
expect(supplier.postCode).toEqual(postCode);
|
||||
expect(supplier.street).toEqual(street);
|
||||
expect(supplier.city).toEqual(city);
|
||||
expect(supplier.provinceFk).toEqual(provinceFk);
|
||||
expect(supplier.countryFk).toEqual(countryFk);
|
||||
expect(supplier.supplierActivityFk).toEqual(supplierActivityFk);
|
||||
expect(supplier.healthRegister).toEqual(healthRegister);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,75 +1,59 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('updateFiscalData', {
|
||||
Self.remoteMethodCtx('updateFiscalData', {
|
||||
description: 'Updates fiscal data of a supplier',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'ctx',
|
||||
type: 'Object',
|
||||
http: {source: 'context'}
|
||||
},
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
description: 'The supplier id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'name',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'nif',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'account',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'phone',
|
||||
type: 'string'
|
||||
}, {
|
||||
arg: 'sageTaxTypeFk',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'sageWithholdingFk',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'sageTransactionTypeFk',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'postCode',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'street',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'city',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'provinceFk',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'countryFk',
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'supplierActivityFk',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'healthRegister',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'isVies',
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
}, {
|
||||
arg: 'isTrucker',
|
||||
type: 'boolean'
|
||||
}],
|
||||
|
@ -84,15 +68,42 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.updateFiscalData = async(ctx, supplierId) => {
|
||||
Self.updateFiscalData = async(ctx, supplierId, name, nif, account, phone, sageTaxTypeFk, sageWithholdingFk, sageTransactionTypeFk, postCode, street, city, provinceFk, countryFk, supplierActivityFk, healthRegister, isVies, isTrucker, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const {args} = ctx;
|
||||
const myOptions = {};
|
||||
const supplier = await models.Supplier.findById(supplierId);
|
||||
|
||||
// Remove unwanted properties
|
||||
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||
|
||||
delete args.ctx;
|
||||
delete args.id;
|
||||
|
||||
return supplier.updateAttributes(args);
|
||||
const updateAllFiscalData = await models.ACL.checkAccessAcl(ctx, 'Supplier', 'updateAllFiscalData', 'WRITE');
|
||||
if (!updateAllFiscalData) {
|
||||
for (const arg in args) {
|
||||
if (args[arg] && !['street', 'postCode', 'city', 'provinceFk', 'phone'].includes(arg))
|
||||
throw new UserError('You cannot update these fields');
|
||||
}
|
||||
}
|
||||
|
||||
return supplier.updateAttributes({
|
||||
name,
|
||||
nif,
|
||||
account,
|
||||
phone,
|
||||
sageTaxTypeFk,
|
||||
sageWithholdingFk,
|
||||
sageTransactionTypeFk,
|
||||
postCode,
|
||||
street,
|
||||
city,
|
||||
provinceFk,
|
||||
countryFk,
|
||||
supplierActivityFk,
|
||||
healthRegister,
|
||||
isVies,
|
||||
isTrucker
|
||||
}, myOptions);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ describe('loopback model Supplier', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const newSupplier = await models.Supplier.create({name: 'Alfred Pennyworth'}, options);
|
||||
const newSupplier = await models.Supplier.create({name: 'ALFRED PENNYWORTH'}, options);
|
||||
const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options);
|
||||
|
||||
expect(Number(fetchedSupplier.account)).toEqual(4100000000 + newSupplier.id);
|
||||
|
|
|
@ -46,6 +46,12 @@ module.exports = Self => {
|
|||
Self.validateAsync('postCode', hasValidPostcode, {
|
||||
message: `The postcode doesn't exist. Please enter a correct one`
|
||||
});
|
||||
Self.validatesFormatOf('name', {
|
||||
message: 'Name should be uppercase',
|
||||
allowNull: false,
|
||||
allowBlank: false,
|
||||
with: /^[^a-z]*$/
|
||||
});
|
||||
|
||||
async function hasValidPostcode(err, done) {
|
||||
if (!this.postcode)
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
<vn-textfield
|
||||
label="Supplier name"
|
||||
ng-model="$ctrl.supplier.name"
|
||||
vn-focus>
|
||||
vn-focus
|
||||
ng-keyup="$ctrl.supplier.name = $ctrl.supplier.name.toUpperCase()">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
</vn-card>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
||||
"@babel/preset-env": "^7.11.0",
|
||||
"@babel/register": "^7.7.7",
|
||||
"@verdnatura/myt": "^1.6.3",
|
||||
"@verdnatura/myt": "^1.6.6",
|
||||
"angular-mocks": "^1.7.9",
|
||||
"babel-jest": "^26.0.1",
|
||||
"babel-loader": "^8.2.4",
|
||||
|
@ -67,6 +67,7 @@
|
|||
"eslint-plugin-jasmine": "^2.10.1",
|
||||
"fancy-log": "^1.3.2",
|
||||
"file-loader": "^6.2.0",
|
||||
"getopts": "^2.3.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-env": "^0.4.0",
|
||||
|
@ -89,7 +90,6 @@
|
|||
"js-yaml": "^4.1.0",
|
||||
"json-loader": "^0.5.7",
|
||||
"merge-stream": "^1.0.1",
|
||||
"minimist": "^1.2.5",
|
||||
"node-sass": "^9.0.0",
|
||||
"nodemon": "^2.0.16",
|
||||
"plugin-error": "^1.0.1",
|
||||
|
@ -107,7 +107,7 @@
|
|||
"scripts": {
|
||||
"dbtest": "nodemon -q db/tests.js -w db/tests",
|
||||
"test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json",
|
||||
"test:back:ci": "node back/tests.js ci",
|
||||
"test:back:ci": "node back/tests.js --ci --junit --network jenkins",
|
||||
"test:e2e": "node e2e/helpers/tests.js",
|
||||
"test:front": "jest --watch",
|
||||
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
||||
|
|
|
@ -128,8 +128,8 @@ devDependencies:
|
|||
specifier: ^7.7.7
|
||||
version: 7.23.7(@babel/core@7.23.9)
|
||||
'@verdnatura/myt':
|
||||
specifier: ^1.6.3
|
||||
version: 1.6.3
|
||||
specifier: ^1.6.6
|
||||
version: 1.6.6
|
||||
angular-mocks:
|
||||
specifier: ^1.7.9
|
||||
version: 1.8.3
|
||||
|
@ -163,6 +163,9 @@ devDependencies:
|
|||
file-loader:
|
||||
specifier: ^6.2.0
|
||||
version: 6.2.0(webpack@5.90.1)
|
||||
getopts:
|
||||
specifier: ^2.3.0
|
||||
version: 2.3.0
|
||||
gulp:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.2
|
||||
|
@ -229,9 +232,6 @@ devDependencies:
|
|||
merge-stream:
|
||||
specifier: ^1.0.1
|
||||
version: 1.0.1
|
||||
minimist:
|
||||
specifier: ^1.2.5
|
||||
version: 1.2.8
|
||||
node-sass:
|
||||
specifier: ^9.0.0
|
||||
version: 9.0.0
|
||||
|
@ -2630,8 +2630,8 @@ packages:
|
|||
dev: false
|
||||
optional: true
|
||||
|
||||
/@verdnatura/myt@1.6.3:
|
||||
resolution: {integrity: sha512-VRoTB5sEPL8a7VaX9l2afpaPNT6pBa+If1tP9tpaJ4enFQbNITlApcC0GK6XYmWMkJQjl2lgdN4/u0UCiNb2MQ==}
|
||||
/@verdnatura/myt@1.6.6:
|
||||
resolution: {integrity: sha512-5KHi9w1baEQ6Oe/pAR8pl0oD5yyJJuPirE+ZhygreUGGURfig4VekjhlGE3WEbWquDiIAMi89J1VQ+1Ba0+jQw==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@sqltools/formatter': 1.2.5
|
||||
|
|
|
@ -11,7 +11,7 @@ let baseConfig = {
|
|||
entry: {salix: 'salix'},
|
||||
mode,
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist'),
|
||||
path: path.join(__dirname, 'front/dist'),
|
||||
publicPath: '/'
|
||||
},
|
||||
module: {
|
||||
|
@ -139,7 +139,7 @@ let devConfig = {
|
|||
host: '0.0.0.0',
|
||||
port: 5000,
|
||||
publicPath: '/',
|
||||
contentBase: 'dist',
|
||||
contentBase: 'front/dist',
|
||||
quiet: false,
|
||||
noInfo: false,
|
||||
hot: true,
|
||||
|
|
Loading…
Reference in New Issue