Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
2e09456bfa
|
@ -7,7 +7,7 @@ RUN apt-get update \
|
|||
curl \
|
||||
ca-certificates \
|
||||
gnupg2 \
|
||||
libfontconfig \
|
||||
libfontconfig lftp \
|
||||
&& apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
|
||||
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
|
||||
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
|
||||
|
|
|
@ -13,10 +13,9 @@ describe('Chat notifyIssue()', () => {
|
|||
spyOn(chatModel, 'send').and.callThrough();
|
||||
spyOn(osTicketModel, 'rawSql').and.returnValue([]);
|
||||
|
||||
const response = await chatModel.notifyIssues(ctx);
|
||||
await chatModel.notifyIssues(ctx);
|
||||
|
||||
expect(chatModel.send).not.toHaveBeenCalled();
|
||||
expect(response).toBeUndefined();
|
||||
});
|
||||
|
||||
it(`should return a response calling the send() method`, async() => {
|
||||
|
@ -27,16 +26,15 @@ describe('Chat notifyIssue()', () => {
|
|||
username: 'batman',
|
||||
subject: 'Issue title'}
|
||||
]);
|
||||
// eslint-disable-next-line max-len
|
||||
const expectedMessage = `@all ➔ There's a new urgent ticket:\r\n[ID: *00001* - Issue title (@batman)](https://cau.verdnatura.es/scp/tickets.php?id=1)`;
|
||||
|
||||
const department = await app.models.Department.findById(departmentId);
|
||||
let orgChatName = department.chatName;
|
||||
await department.updateAttribute('chatName', 'IT');
|
||||
|
||||
const response = await chatModel.notifyIssues(ctx);
|
||||
await chatModel.notifyIssues(ctx);
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#IT', expectedMessage);
|
||||
|
||||
// restores
|
||||
|
|
|
@ -5,14 +5,13 @@ describe('Chat send()', () => {
|
|||
let ctx = {req: {accessToken: {userId: 1}}};
|
||||
let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(response).toEqual(true);
|
||||
});
|
||||
|
||||
it('should retrun false as response', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 18}}};
|
||||
let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something');
|
||||
|
||||
expect(response).toBeFalsy();
|
||||
expect(response).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,10 +20,8 @@ describe('Chat sendCheckingPresence()', () => {
|
|||
})
|
||||
);
|
||||
|
||||
const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', 'I changed something');
|
||||
});
|
||||
|
||||
|
@ -47,10 +45,8 @@ describe('Chat sendCheckingPresence()', () => {
|
|||
const department = await models.Department.findById(departmentId, null, options);
|
||||
await department.updateAttribute('chatName', 'cooler');
|
||||
|
||||
const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym ➔ I changed something');
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE bucket
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12)
|
||||
SET
|
||||
bucket_id = @col2,
|
||||
bucket_type_id = @col4,
|
||||
description = @col5,
|
||||
x_size = @col6,
|
||||
y_size = @col7,
|
||||
z_size = @col8,
|
||||
entry_date = STR_TO_DATE(@col10, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col11, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col12, '%Y%m%d%H%i')
|
|
@ -0,0 +1,10 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE bucket_type
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
|
||||
SET
|
||||
bucket_type_id = @col2,
|
||||
description = @col3,
|
||||
entry_date = STR_TO_DATE(@col4, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE `feature`
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
|
||||
SET
|
||||
item_id = @col2,
|
||||
feature_type_id = @col3,
|
||||
feature_value = @col4,
|
||||
entry_date = STR_TO_DATE(@col5, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i')
|
|
@ -0,0 +1,10 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE genus
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
|
||||
SET
|
||||
genus_id = @col2,
|
||||
latin_genus_name = @col3,
|
||||
entry_date = STR_TO_DATE(@col4, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i')
|
|
@ -0,0 +1,13 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE item
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12)
|
||||
SET
|
||||
id = @col2,
|
||||
product_name = @col4,
|
||||
name = @col5,
|
||||
plant_id = @col7,
|
||||
group_id = @col9,
|
||||
entry_date = STR_TO_DATE(@col10, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col11, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col12, '%Y%m%d%H%i')
|
|
@ -0,0 +1,12 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE `item_feature`
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8)
|
||||
SET
|
||||
item_id = @col2,
|
||||
feature = @col3,
|
||||
regulation_type = @col4,
|
||||
presentation_order = @col5,
|
||||
entry_date = STR_TO_DATE(@col6, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col7, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col8, '%Y%m%d%H%i')
|
|
@ -0,0 +1,10 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE item_group
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6)
|
||||
SET
|
||||
group_code = @col2,
|
||||
dutch_group_description = @col3,
|
||||
entry_date = STR_TO_DATE(@col4, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE plant
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9)
|
||||
SET
|
||||
plant_id = @col3,
|
||||
genus_id = @col4,
|
||||
specie_id = @col5,
|
||||
entry_date = STR_TO_DATE(@col7, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col8, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col9, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE specie
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
|
||||
SET
|
||||
specie_id = @col2,
|
||||
genus_id = @col3,
|
||||
latin_species_name = @col4,
|
||||
entry_date = STR_TO_DATE(@col5, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE edi.supplier
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12, @col13, @col14, @col15, @col16, @col17, @col18, @col19, @col20)
|
||||
SET
|
||||
GLNAddressCode = @col2,
|
||||
supplier_id = @col4,
|
||||
company_name = @col3,
|
||||
entry_date = STR_TO_DATE(@col9, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col10, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col11, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE `type`
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
|
||||
SET
|
||||
type_id = @col2,
|
||||
type_group_id = @col3,
|
||||
description = @col4,
|
||||
entry_date = STR_TO_DATE(@col5, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i')
|
|
@ -0,0 +1,11 @@
|
|||
LOAD DATA LOCAL INFILE ?
|
||||
INTO TABLE `value`
|
||||
FIELDS TERMINATED BY ';'
|
||||
LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7)
|
||||
SET
|
||||
type_id = @col2,
|
||||
type_value = @col3,
|
||||
type_description = @col4,
|
||||
entry_date = STR_TO_DATE(@col5, '%Y%m%d'),
|
||||
expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')),
|
||||
change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i')
|
|
@ -0,0 +1,155 @@
|
|||
/* eslint no-console: "off" */
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateData', {
|
||||
description: 'Updates schema data from external provider',
|
||||
accessType: 'WRITE',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/updateData`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateData = async() => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const container = await models.TempContainer.container('edi');
|
||||
const tempPath = path.join(container.client.root, container.name);
|
||||
|
||||
const [ftpConfig] = await Self.rawSql('SELECT host, user, password FROM edi.ftpConfig');
|
||||
console.debug(`Openning FTP connection to ${ftpConfig.host}...\n`);
|
||||
|
||||
const FtpClient = require('ftps');
|
||||
const ftpClient = new FtpClient({
|
||||
host: ftpConfig.host,
|
||||
username: ftpConfig.user,
|
||||
password: ftpConfig.password,
|
||||
procotol: 'ftp'
|
||||
});
|
||||
|
||||
const files = await Self.rawSql('SELECT fileName, toTable, file, updated FROM edi.fileConfig');
|
||||
|
||||
let remoteFile;
|
||||
let tempDir;
|
||||
let tempFile;
|
||||
for (const file of files) {
|
||||
try {
|
||||
const fileName = file.file;
|
||||
|
||||
console.debug(`Downloading file ${fileName}...`);
|
||||
|
||||
remoteFile = `codes/${fileName}.ZIP`;
|
||||
tempDir = `${tempPath}/${fileName}`;
|
||||
tempFile = `${tempPath}/${fileName}.zip`;
|
||||
|
||||
await extractFile({
|
||||
ftpClient: ftpClient,
|
||||
file: file,
|
||||
paths: {
|
||||
remoteFile: remoteFile,
|
||||
tempDir: tempDir,
|
||||
tempFile: tempFile
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (fs.existsSync(tempFile))
|
||||
await fs.unlink(tempFile);
|
||||
|
||||
await fs.rmdir(tempDir, {recursive: true});
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
async function extractFile({ftpClient, file, paths}) {
|
||||
// Download the zip file
|
||||
ftpClient.get(paths.remoteFile, paths.tempFile);
|
||||
|
||||
// Execute download command
|
||||
ftpClient.exec(async(err, response) => {
|
||||
if (response.error) {
|
||||
console.debug(`Error downloading file... ${response.error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const AdmZip = require('adm-zip');
|
||||
const zip = new AdmZip(paths.tempFile);
|
||||
const entries = zip.getEntries();
|
||||
|
||||
zip.extractAllTo(paths.tempDir, false);
|
||||
|
||||
if (fs.existsSync(paths.tempFile))
|
||||
await fs.unlink(paths.tempFile);
|
||||
|
||||
await dumpData({file, entries, paths});
|
||||
|
||||
await fs.rmdir(paths.tempDir, {recursive: true});
|
||||
});
|
||||
}
|
||||
|
||||
async function dumpData({file, entries, paths}) {
|
||||
const toTable = file.toTable;
|
||||
const baseName = file.fileName;
|
||||
|
||||
for (const zipEntry of entries) {
|
||||
const entryName = zipEntry.entryName;
|
||||
console.log(`Reading file ${entryName}...`);
|
||||
|
||||
const startIndex = (entryName.length - 10);
|
||||
const endIndex = (entryName.length - 4);
|
||||
const dateString = entryName.substring(startIndex, endIndex);
|
||||
const lastUpdated = new Date();
|
||||
|
||||
// Format string date to a date object
|
||||
let updated = null;
|
||||
if (file.updated) {
|
||||
updated = new Date(file.updated);
|
||||
updated.setHours(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
lastUpdated.setFullYear(`20${dateString.substring(4, 6)}`);
|
||||
lastUpdated.setMonth(parseInt(dateString.substring(2, 4)) - 1);
|
||||
lastUpdated.setDate(dateString.substring(0, 2));
|
||||
lastUpdated.setHours(0, 0, 0, 0);
|
||||
|
||||
if (updated && lastUpdated <= updated) {
|
||||
console.debug(`Table ${toTable} already updated, skipping...`);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log('Dumping data...');
|
||||
const templatePath = path.join(__dirname, `./sql/${toTable}.sql`);
|
||||
const sqlTemplate = fs.readFileSync(templatePath, 'utf8');
|
||||
|
||||
const rawPath = path.join(paths.tempDir, entryName);
|
||||
|
||||
try {
|
||||
const tx = await Self.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
await Self.rawSql(`DELETE FROM edi.${toTable}`, null, options);
|
||||
await Self.rawSql(sqlTemplate, [rawPath], options);
|
||||
await Self.rawSql(`
|
||||
UPDATE edi.fileConfig
|
||||
SET updated = ?
|
||||
WHERE fileName = ?
|
||||
`, [lastUpdated, baseName], options);
|
||||
|
||||
tx.commit();
|
||||
} catch (error) {
|
||||
tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(`Updated table ${toTable}\n`);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -109,6 +109,9 @@
|
|||
},
|
||||
"OsTicket": {
|
||||
"dataSource": "osticket"
|
||||
},
|
||||
"Edi": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/edi/updateData')(Self);
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "Edi",
|
||||
"base": "VnModel"
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
UPDATE vn.absenceType
|
||||
SET code='halfPaidLeave'
|
||||
WHERE id=15 AND name='Permiso retribuido 1/2 día' AND rgb='#5151c0' AND code IS NULL AND permissionRate=NULL AND holidayEntitlementRate=0.50 AND discountRate=0.00;
|
|
@ -1,27 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('EntryObservation', '*', '*', 'ALLOW', 'ROLE', 'buyer'),
|
||||
('LdapConfig', '*', '*', 'ALLOW', 'ROLE', 'sysadmin'),
|
||||
('SambaConfig', '*', '*', 'ALLOW', 'ROLE', 'sysadmin'),
|
||||
('ACL', '*', '*', 'ALLOW', 'ROLE', 'developer'),
|
||||
('AccessToken', '*', '*', 'ALLOW', 'ROLE', 'developer'),
|
||||
('MailAliasAccount', '*', '*', 'ALLOW', 'ROLE', 'marketing'),
|
||||
('MailAliasAccount', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('MailAlias', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('MailForward', '*', '*', 'ALLOW', 'ROLE', 'marketing'),
|
||||
('MailForward', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('RoleInherit', '*', '*', 'ALLOW', 'ROLE', 'it'),
|
||||
('RoleRole', '*', '*', 'ALLOW', 'ROLE', 'it'),
|
||||
('AccountConfig', '*', '*', 'ALLOW', 'ROLE', 'sysadmin');
|
||||
|
||||
UPDATE `salix`.`ACL`
|
||||
SET accessType='*', principalId='it'
|
||||
WHERE model = 'Role';
|
||||
|
||||
DELETE FROM `salix`.`ACL`
|
||||
WHERE id IN (280, 281);
|
||||
|
||||
UPDATE `salix`.`ACL`
|
||||
SET accessType='*', principalId='marketing'
|
||||
WHERE id=279;
|
|
@ -1,5 +0,0 @@
|
|||
UPDATE `salix`.`defaultViewConfig`
|
||||
SET `columns` = '{"intrastat":false,"description":false,"density":false,"isActive":false,
|
||||
"freightValue":false,"packageValue":false,"isIgnored":false,"price2":false,"ektFk":false,"weight":false,
|
||||
"size":false,"comissionValue":false,"landing":false}'
|
||||
WHERE tableCode = 'latestBuys'
|
|
@ -1,33 +0,0 @@
|
|||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=96;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=95;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=115;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=123;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=94;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=101;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=80;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=125;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=98;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail='direccioncomercial@verdnatura.es'
|
||||
WHERE id=92;
|
||||
UPDATE vn.department
|
||||
SET notificationEmail=''
|
||||
WHERE id=43;
|
|
@ -1,142 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`item_getBalance`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`item_getBalance`(IN vItemId int, IN vWarehouse int)
|
||||
BEGIN
|
||||
DECLARE vDateInventory DATETIME;
|
||||
DECLARE vCurdate DATE DEFAULT CURDATE();
|
||||
DECLARE vDayEnd DATETIME DEFAULT util.dayEnd(vCurdate);
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
SET @a = 0;
|
||||
SET @currentLineFk = 0;
|
||||
SET @shipped = '';
|
||||
|
||||
SELECT DATE(@shipped:= shipped) shipped,
|
||||
alertLevel,
|
||||
stateName,
|
||||
origin,
|
||||
reference,
|
||||
clientFk,
|
||||
name,
|
||||
`in` AS invalue,
|
||||
`out`,
|
||||
@a := @a + IFNULL(`in`,0) - IFNULL(`out`,0) as balance,
|
||||
@currentLineFk := IF (@shipped < CURDATE()
|
||||
OR (@shipped = CURDATE() AND (isPicked OR alertLevel >= 2)),
|
||||
lineFk,@currentLineFk) lastPreparedLineFk,
|
||||
isTicket,
|
||||
lineFk,
|
||||
isPicked,
|
||||
clientType,
|
||||
claimFk
|
||||
FROM
|
||||
( SELECT tr.landed AS shipped,
|
||||
b.quantity AS `in`,
|
||||
NULL AS `out`,
|
||||
al.id AS alertLevel,
|
||||
st.name AS stateName,
|
||||
s.name AS name,
|
||||
e.ref AS reference,
|
||||
e.id AS origin,
|
||||
s.id AS clientFk,
|
||||
IF(al.id = 3, TRUE, FALSE) isPicked,
|
||||
FALSE AS isTicket,
|
||||
b.id lineFk,
|
||||
NULL `order`,
|
||||
NULL AS clientType,
|
||||
NULL AS claimFk
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN alertLevel al ON al.id =
|
||||
CASE
|
||||
WHEN tr.shipped < CURDATE() THEN 3
|
||||
WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3
|
||||
ELSE 0
|
||||
END
|
||||
JOIN state st ON st.code = al.code
|
||||
WHERE tr.landed >= vDateInventory
|
||||
AND vWarehouse = tr.warehouseInFk
|
||||
AND b.itemFk = vItemId
|
||||
AND e.isInventory = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
al.id,
|
||||
st.name,
|
||||
s.name,
|
||||
e.ref,
|
||||
e.id,
|
||||
s.id,
|
||||
IF(al.id = 3, TRUE, FALSE),
|
||||
FALSE,
|
||||
b.id,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN warehouse w ON w.id = tr.warehouseOutFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
JOIN alertLevel al ON al.id =
|
||||
CASE
|
||||
WHEN tr.shipped < CURDATE() THEN 3
|
||||
WHEN tr.shipped = CURDATE() AND tr.isReceived = TRUE THEN 3
|
||||
ELSE 0
|
||||
END
|
||||
JOIN state st ON st.code = al.code
|
||||
WHERE tr.shipped >= vDateInventory
|
||||
AND vWarehouse =tr.warehouseOutFk
|
||||
AND s.id <> 4
|
||||
AND b.itemFk = vItemId
|
||||
AND e.isInventory = FALSE
|
||||
AND w.isFeedStock = FALSE
|
||||
AND e.isRaid = FALSE
|
||||
UNION ALL
|
||||
|
||||
SELECT DATE(t.shipped),
|
||||
NULL,
|
||||
s.quantity,
|
||||
al.id,
|
||||
st.name,
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id,
|
||||
t.clientFk,
|
||||
stk.id,
|
||||
TRUE,
|
||||
s.id,
|
||||
st.`order`,
|
||||
ct.code,
|
||||
cb.claimFk
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
LEFT JOIN ticketState ts ON ts.ticket = t.id
|
||||
LEFT JOIN state st ON st.code = ts.code
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN clientType ct ON ct.id = c.clientTypeFk
|
||||
JOIN alertLevel al ON al.id =
|
||||
CASE
|
||||
WHEN t.shipped < curdate() THEN 3
|
||||
WHEN t.shipped > util.dayEnd(curdate()) THEN 0
|
||||
ELSE IFNULL(ts.alertLevel, 0)
|
||||
END
|
||||
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
||||
LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
|
||||
LEFT JOIN claimBeginning cb ON s.id = cb.saleFk
|
||||
WHERE t.shipped >= vDateInventory
|
||||
AND s.itemFk = vItemId
|
||||
AND vWarehouse =t.warehouseFk
|
||||
ORDER BY shipped, alertLevel DESC, isTicket, `order` DESC, isPicked DESC, `in` DESC, `out` DESC
|
||||
) AS itemDiary;
|
||||
|
||||
END;
|
||||
$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE vn.payMethod CHANGE ibanRequiredForClients isIbanRequiredForClients tinyint(3) DEFAULT 0 NULL;
|
||||
ALTER TABLE vn.payMethod CHANGE ibanRequiredForSuppliers isIbanRequiredForSuppliers tinyint(3) DEFAULT 0 NULL;
|
|
@ -1,120 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`sale_recalcComponent`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_recalcComponent`(vOption INT)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Actualiza los componentes
|
||||
*
|
||||
* @table tmp.recalculateSales
|
||||
*/
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vWarehouseFk SMALLINT;
|
||||
DECLARE vAgencyModeFk INT;
|
||||
DECLARE vAddressFk INT;
|
||||
DECLARE vTicketFk BIGINT;
|
||||
DECLARE vItemFk BIGINT;
|
||||
DECLARE vLanded DATE;
|
||||
DECLARE vIsEditable BOOLEAN;
|
||||
DECLARE vZoneFk INTEGER;
|
||||
DECLARE vOption INTEGER;
|
||||
|
||||
DECLARE vSale INTEGER;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vCur CURSOR FOR
|
||||
SELECT id from tmp.recalculateSales;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vCur;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vCur INTO vSale;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SELECT t.refFk IS NULL AND (IFNULL(ts.alertLevel, 0) = 0 OR s.price = 0),
|
||||
s.ticketFk,
|
||||
s.itemFk ,
|
||||
t.zoneFk,
|
||||
t.warehouseFk,
|
||||
t.shipped,
|
||||
t.addressFk,
|
||||
t.agencyModeFk,
|
||||
t.landed
|
||||
INTO vIsEditable,
|
||||
vTicketFk,
|
||||
vItemFk,
|
||||
vZoneFk,
|
||||
vWarehouseFk,
|
||||
vShipped,
|
||||
vAddressFk,
|
||||
vAgencyModeFk,
|
||||
vLanded
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
WHERE s.id = vSale;
|
||||
|
||||
CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk, TRUE);
|
||||
|
||||
IF (SELECT COUNT(*) FROM tmp.zoneGetLanded LIMIT 1) = 0 THEN
|
||||
CALL util.throw('There is no zone for these parameters');
|
||||
END IF;
|
||||
|
||||
IF vLanded IS NULL OR vZoneFk IS NULL THEN
|
||||
|
||||
UPDATE ticket t
|
||||
SET t.landed = (SELECT landed FROM tmp.zoneGetLanded LIMIT 1)
|
||||
WHERE t.id = vTicketFk AND t.landed IS NULL;
|
||||
|
||||
IF vZoneFk IS NULL THEN
|
||||
SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetLanded LIMIT 1;
|
||||
UPDATE ticket t
|
||||
SET t.zoneFk = vZoneFk
|
||||
WHERE t.id = vTicketFk AND t.zoneFk IS NULL;
|
||||
END IF;
|
||||
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.zoneGetLanded;
|
||||
|
||||
-- rellena la tabla buyUltimate con la ultima compra
|
||||
CALL buyUltimate (vWarehouseFk, vShipped);
|
||||
|
||||
DELETE FROM tmp.buyUltimate WHERE itemFk != vItemFk;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
|
||||
CREATE TEMPORARY TABLE tmp.ticketLot
|
||||
SELECT vWarehouseFk warehouseFk, NULL available, vItemFk itemFk, buyFk, vZoneFk zoneFk
|
||||
FROM tmp.buyUltimate
|
||||
WHERE itemFk = vItemFk;
|
||||
|
||||
CALL catalog_componentPrepare();
|
||||
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
||||
CREATE TEMPORARY TABLE tmp.sale
|
||||
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
|
||||
SELECT vSale saleFk,vWarehouseFk warehouseFk;
|
||||
|
||||
IF vOption IS NULL THEN
|
||||
SET vOption = IF(vIsEditable, 1, 6);
|
||||
END IF;
|
||||
|
||||
CALL ticketComponentUpdateSale(vOption);
|
||||
CALL catalog_componentPurge();
|
||||
|
||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||
DROP TEMPORARY TABLE tmp.sale;
|
||||
|
||||
END LOOP;
|
||||
CLOSE vCur;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,23 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`sale_calculateComponent`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_calculateComponent`(vSale INT, vOption INT)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes
|
||||
*
|
||||
* @param vSale Id de la venta
|
||||
* @param vOption indica en que componente pone el descuadre, NULL en casos habituales
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales;
|
||||
CREATE TEMPORARY TABLE tmp.recalculateSales
|
||||
SELECT s.id
|
||||
FROM sale s
|
||||
WHERE s.id = vSale;
|
||||
|
||||
CALL vn.sale_recalcComponent(vOption);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.recalculateSales;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Sale','payBack','WRITE','ALLOW','ROLE','employee');
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `vn`.`payMethod` ADD hasVerified TINYINT(1) DEFAULT 0 NULL;
|
|
@ -1,3 +0,0 @@
|
|||
UPDATE `vn`.`department`
|
||||
SET `notificationEmail` = 'finanzas@verdnatura.es'
|
||||
WHERE `name` = 'FINANZAS';
|
|
@ -1,2 +0,0 @@
|
|||
UPDATE `vn`.`supplier`
|
||||
SET isPayMethodChecked = TRUE;
|
|
@ -1,33 +0,0 @@
|
|||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn`.`payment_afterInsert` AFTER INSERT ON `payment` FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vIsPayMethodChecked BOOLEAN;
|
||||
DECLARE vEmail VARCHAR(150);
|
||||
|
||||
SELECT isPayMethodChecked INTO vIsPayMethodChecked
|
||||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
|
||||
|
||||
IF vIsPayMethodChecked = FALSE THEN
|
||||
|
||||
SELECT notificationEmail INTO vEmail
|
||||
FROM department
|
||||
WHERE name = 'FINANZAS';
|
||||
|
||||
CALL mail_insert(
|
||||
vEmail,
|
||||
NULL,
|
||||
'Pago con método sin verificar',
|
||||
CONCAT(
|
||||
'Se ha realizado el pago ',
|
||||
NEW.id,
|
||||
' al proveedor ',
|
||||
NEW.supplierFk,
|
||||
' con el método de pago sin verificar.'
|
||||
)
|
||||
);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,26 +0,0 @@
|
|||
DROP TRIGGER IF EXISTS `vn`.`supplier_beforeUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn`.`supplier_beforeUpdate`
|
||||
BEFORE UPDATE ON `vn`.`supplier` FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vHasChange BOOL DEFAULT FALSE;
|
||||
DECLARE vPayMethodHasVerified BOOL;
|
||||
|
||||
SELECT hasVerified INTO vPayMethodHasVerified
|
||||
FROM payMethod
|
||||
WHERE id = NEW.payMethodFk;
|
||||
|
||||
SET vHasChange = (NEW.payDemFk <> OLD.payDemFk) OR (NEW.payDay <> OLD.payDay);
|
||||
|
||||
IF vPayMethodHasVerified AND !vHasChange THEN
|
||||
SET vHasChange = (NEW.payMethodFk <> OLD.payMethodFk);
|
||||
END IF;
|
||||
|
||||
IF vHasChange THEN
|
||||
SET NEW.isPayMethodChecked = FALSE;
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,2 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId)
|
||||
VALUES(301, 'Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES ('Edi', 'updateData', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES(304, 'Agency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('EducationLevel', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL`
|
||||
(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES('InvoiceInIntrastat', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('SupplierAgencyTerm', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,8 @@
|
|||
CREATE TABLE `vn`.`claimConfig` (
|
||||
`id` int(11) NOT NULL,
|
||||
`pickupContact` varchar(250),
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
INSERT INTO vn.claimConfig (id, pickupContact)
|
||||
VALUES(1, 'Email: cmorenoa@logista.com Telf: 961594250 Extensión: 206');
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `vn`.`claimState` ADD `hasToNotify` TINYINT DEFAULT 0 NULL;
|
||||
UPDATE `vn`.`claimState` SET `hasToNotify` = 1 WHERE `code` IN ('canceled', 'incomplete');
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `vn`.`claim` ADD packages smallint(10) unsigned DEFAULT 0 NULL COMMENT 'packages received by the client';
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `vn`.`component` (`name`,`typeFk`,`classRate`,`isRenewable`,`code`,`isRequired`)
|
||||
VALUES ('maná reclamacion',7,4,0,'manaClaim',0);
|
|
@ -0,0 +1,90 @@
|
|||
ALTER TABLE `vn`.`country` ADD `a3Code` INT NULL COMMENT 'Código país para a3';
|
||||
|
||||
UPDATE `vn`.`country` c
|
||||
JOIN `vn2008`.`payroll_pais` `p` ON `p`.`pais` = `c`.`country`
|
||||
SET `c`.`a3Code` = `p`.`codpais`;
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 710
|
||||
WHERE `country` = 'Sud-Africa'; -- ÁFRICA DEL SUR
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 643
|
||||
WHERE `country` = 'Rusia'; -- FEDERACIÓN DE RUSIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 28
|
||||
WHERE `country` = 'Antigua'; -- ANTIGUA Y BARBUDA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 840
|
||||
WHERE `country` = 'USA'; -- ESTADOS UNIDOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 404
|
||||
WHERE `country` = 'Kenya'; -- KENIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 498
|
||||
WHERE `country` = 'Moldavia'; -- REPÚBLICA DE MOLDAVIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 826
|
||||
WHERE `country` = 'Gran Bretaña'; -- REINO UNIDO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 484
|
||||
WHERE `country` = 'Mexico'; -- MÉJICO
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 716
|
||||
WHERE `country` = 'Zimbawe'; -- ZINBABWE
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 203
|
||||
WHERE `country` = 'Chequia'; -- REPÚBLICA CHECA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 764
|
||||
WHERE `country` = 'Thailandia'; -- TAILANDIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 276
|
||||
WHERE `country` = 'Alemania'; -- REPÚBLICA FEDERAL DE ALEMANIA
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 112
|
||||
WHERE `country` = 'Bielorrusia'; -- BELARUS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 528
|
||||
WHERE `country` = 'Holanda'; -- PAÍSES BAJOS
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 410
|
||||
WHERE `country` = 'Corea del Sur'; -- COREA (REPÚBLICA)
|
||||
|
||||
UPDATE `vn`.`country`
|
||||
SET `a3Code` = 724
|
||||
WHERE `country` = 'España exento'; -- ESPAÑA
|
||||
|
||||
-- Borrar registro USA de country:
|
||||
UPDATE `vn`.`supplier` `s`
|
||||
SET `s`.`countryFk` = 62
|
||||
WHERE `s`.`countryFk` = 12;
|
||||
|
||||
UPDATE `vn`.`bankEntity`
|
||||
SET `countryFk` = 62
|
||||
WHERE `countryFk` = 12;
|
||||
|
||||
DELETE FROM `vn`.`country`
|
||||
WHERE `id`= 12;
|
||||
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA NORTE (REPÚBLICA DEM. POPULAR)'
|
||||
WHERE `codpais`=408;
|
||||
UPDATE `vn2008`.`payroll_pais`
|
||||
SET `pais`='COREA SUR (REPÚBLICA) '
|
||||
WHERE `codpais`=410;
|
||||
|
||||
RENAME TABLE `vn2008`.`payroll_pais` TO `vn2008`.`payroll_pais__`;
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`)
|
||||
VALUES ('InvoiceInIntrastat','*','*','ALLOW','ROLE','employee');
|
|
@ -0,0 +1,106 @@
|
|||
DROP PROCEDURE IF EXISTS `bs`.`manaCustomerUpdate`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `bs`.`manaCustomerUpdate`()
|
||||
BEGIN
|
||||
DECLARE vToDated DATE;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vForDeleteDated DATE;
|
||||
DECLARE vManaId INT;
|
||||
DECLARE vManaAutoId INT;
|
||||
DECLARE vClaimManaId INT;
|
||||
DECLARE vManaBankId INT;
|
||||
DECLARE vManaGreugeTypeId INT;
|
||||
|
||||
SELECT id INTO vManaId
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaAutoId
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimManaId
|
||||
FROM `component` WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBankId
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeTypeId
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
DELETE
|
||||
FROM bs.manaCustomer
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT IFNULL(max(dated), '2016-01-01')
|
||||
INTO vFromDated
|
||||
FROM bs.manaCustomer;
|
||||
|
||||
WHILE timestampadd(DAY,30,vFromDated) < CURDATE() DO
|
||||
|
||||
SELECT
|
||||
timestampadd(DAY,30,vFromDated),
|
||||
timestampadd(DAY,-90,vFromDated)
|
||||
INTO
|
||||
vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM bs.manaCustomer
|
||||
WHERE dated <= vForDeleteDated;
|
||||
|
||||
|
||||
INSERT INTO bs.manaCustomer(Id_Cliente, Mana, dated)
|
||||
|
||||
SELECT
|
||||
Id_Cliente,
|
||||
cast(sum(mana) as decimal(10,2)) as mana,
|
||||
vToDated as dated
|
||||
FROM
|
||||
|
||||
(
|
||||
SELECT cs.Id_Cliente, Cantidad * Valor as mana
|
||||
FROM vn2008.Tickets t
|
||||
JOIN vn2008.Consignatarios cs using(Id_Consigna)
|
||||
JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket
|
||||
JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento
|
||||
WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId)
|
||||
AND t.Fecha > vFromDated
|
||||
AND date(t.Fecha) <= vToDated
|
||||
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT r.Id_Cliente, - Entregado
|
||||
FROM vn2008.Recibos r
|
||||
WHERE Id_Banco = vManaBankId
|
||||
AND Fechacobro > vFromDated
|
||||
AND Fechacobro <= vToDated
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT g.Id_Cliente, g.Importe
|
||||
FROM vn2008.Greuges g
|
||||
WHERE Greuges_type_id = vManaGreugeTypeId
|
||||
AND Fecha > vFromDated
|
||||
AND Fecha <= vToDated
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Id_Cliente, mana
|
||||
FROM bs.manaCustomer
|
||||
WHERE dated = vFromDated
|
||||
) sub
|
||||
|
||||
GROUP BY Id_Cliente
|
||||
HAVING Id_Cliente;
|
||||
|
||||
SET vFromDated = vToDated;
|
||||
|
||||
END WHILE;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,75 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`manaSpellersRequery`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula el mana consumido por un trabajador
|
||||
*
|
||||
* @param vWorkerFk Id Trabajador
|
||||
*/
|
||||
DECLARE vWorkerIsExcluded BOOLEAN;
|
||||
DECLARE vFromDated DATE;
|
||||
DECLARE vToDated DATE DEFAULT TIMESTAMPADD(DAY,1,CURDATE());
|
||||
DECLARE vMana INT;
|
||||
DECLARE vAutoMana INT;
|
||||
DECLARE vClaimMana INT;
|
||||
DECLARE vManaBank INT;
|
||||
DECLARE vManaGreugeType INT;
|
||||
|
||||
SELECT COUNT(*) INTO vWorkerIsExcluded
|
||||
FROM workerManaExcluded
|
||||
WHERE workerFk = vWorkerFk;
|
||||
|
||||
IF NOT vWorkerIsExcluded THEN
|
||||
SELECT id INTO vMana
|
||||
FROM `component` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vAutoMana
|
||||
FROM `component` WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimMana
|
||||
FROM `component` WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBank
|
||||
FROM `bank` WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeType
|
||||
FROM `greugeType` WHERE code = 'mana';
|
||||
|
||||
SELECT max(dated) INTO vFromDated
|
||||
FROM clientManaCache;
|
||||
|
||||
REPLACE workerMana (workerFk, amount)
|
||||
SELECT vWorkerFk, sum(mana) FROM
|
||||
(
|
||||
SELECT s.quantity * sc.value as mana
|
||||
FROM ticket t
|
||||
JOIN address a ON a.id = t.addressFk
|
||||
JOIN client c ON c.id = a.clientFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE c.salesPersonFk = vWorkerFk AND sc.componentFk IN (vMana, vAutoMana, vClaimMana)
|
||||
AND t.shipped > vFromDated AND t.shipped < vToDated
|
||||
UNION ALL
|
||||
SELECT - r.amountPaid
|
||||
FROM receipt r
|
||||
JOIN client c ON c.id = r.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND bankFk = vManaBank
|
||||
AND payed > vFromDated
|
||||
UNION ALL
|
||||
SELECT g.amount
|
||||
FROM greuge g
|
||||
JOIN client c ON c.id = g.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND g.greugeTypeFk = vManaGreugeType
|
||||
AND g.shipped > vFromDated and g.shipped < CURDATE()
|
||||
UNION ALL
|
||||
SELECT cc.mana
|
||||
FROM clientManaCache cc
|
||||
JOIN client c ON c.id = cc.clientFk
|
||||
WHERE c.salesPersonFk = vWorkerFk AND cc.dated = vFromDated
|
||||
) sub;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,48 @@
|
|||
ALTER TABLE `vn`.`agencyTerm` ADD `supplierFk` INT NULL;
|
||||
ALTER TABLE `vn`.`agencyTerm` CHANGE `supplierFk` `supplierFk` INT NULL AFTER `agencyFk`;
|
||||
|
||||
UPDATE `vn`.`agencyTerm` `at`
|
||||
JOIN `vn`.`agency` `a` ON `a`.`id` = `at`.`agencyFk`
|
||||
SET `at`.`supplierFk` = `a`.`supplierFk`;
|
||||
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK` FOREIGN KEY (`agencyFk`) REFERENCES `vn`.`agency`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`agencyTerm` ADD CONSTRAINT `agencyTerm_FK_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
RENAME TABLE `vn`.`agencyTerm` TO `vn`.`supplierAgencyTerm`;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn`.`agencyTerm` AS
|
||||
SELECT
|
||||
`sat`.`agencyFk` AS `agencyFk`,
|
||||
`sat`.`minimumPackages` AS `minimumPackages`,
|
||||
`sat`.`kmPrice` AS `kmPrice`,
|
||||
`sat`.`packagePrice` AS `packagePrice`,
|
||||
`sat`.`routePrice` AS `routePrice`,
|
||||
`sat`.`minimumKm` AS `minimumKm`,
|
||||
`sat`.`minimumM3` AS `minimumM3`,
|
||||
`sat`.`m3Price` AS `m3Price`
|
||||
FROM
|
||||
`vn`.`supplierAgencyTerm` `sat`;
|
||||
|
||||
ALTER TABLE `vn`.`agency` DROP FOREIGN KEY `agency_ibfk_4`;
|
||||
ALTER TABLE `vn`.`agency` CHANGE `supplierFk` `supplierFk__` int(11) DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER=`root`@`localhost`
|
||||
VIEW `vn2008`.`agency` AS
|
||||
SELECT
|
||||
`a`.`id` AS `agency_id`,
|
||||
`a`.`name` AS `name`,
|
||||
`a`.`warehouseFk` AS `warehouse_id`,
|
||||
`a`.`isVolumetric` AS `por_volumen`,
|
||||
`a`.`bankFk` AS `Id_Banco`,
|
||||
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
|
||||
`a`.`isOwn` AS `propios`,
|
||||
`a`.`labelZone` AS `zone_label`,
|
||||
`a`.`workCenterFk` AS `workCenterFk`,
|
||||
`a`.`supplierFk__` AS `supplierFk__`
|
||||
FROM
|
||||
`vn`.`agency` `a`;
|
|
@ -83,8 +83,67 @@ BEGIN
|
|||
FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount;
|
||||
|
||||
END WHILE;
|
||||
CLOSE vRsMainTicket;
|
||||
CLOSE vRsMainTicket;
|
||||
|
||||
END;
|
||||
INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk)
|
||||
VALUES(vNewTicket, vOriginTicket);
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE `vn`.`ticketRefund` (
|
||||
`id` INT auto_increment NULL,
|
||||
`refundTicketFk` INT NOT NULL,
|
||||
`originalTicketFk` INT NOT NULL,
|
||||
CONSTRAINT `ticketRefund_PK` PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci;
|
||||
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK` FOREIGN KEY (`refundTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`ticketRefund` ADD CONSTRAINT `ticketRefund_FK_1` FOREIGN KEY (`originalTicketFk`) REFERENCES `vn`.`ticket`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
DELIMITER ;
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert`
|
||||
BEFORE INSERT ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate`
|
||||
BEFORE UPDATE ON `ticketRefund`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
IF NEW.refundTicketFk = NEW.originalTicketFk THEN
|
||||
CALL util.throw('Original ticket and refund ticket has same id');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM ticketRefund
|
||||
WHERE refundTicketFk = NEW.originalTicketFk;
|
||||
|
||||
IF vAlreadyExists > 0 THEN
|
||||
CALL util.throw('This ticket is already a refund');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,16 @@
|
|||
DROP TRIGGER `vn`.`travelThermograph_beforeInsert`;
|
||||
|
||||
ALTER TABLE `vn`.`travelThermograph` CHANGE `temperature` `temperature__` enum('COOL','WARM','DRY') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL NULL;
|
||||
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED VIEW `vn2008`.`travel_thermograph` AS
|
||||
select
|
||||
`tt`.`thermographFk` AS `thermograph_id`,
|
||||
`tt`.`created` AS `odbc_date`,
|
||||
`tt`.`warehouseFk` AS `warehouse_id`,
|
||||
`tt`.`travelFk` AS `travel_id`,
|
||||
`tt`.`temperatureFk` AS `temperature`,
|
||||
`tt`.`result` AS `result`,
|
||||
`tt`.`dmsFk` AS `gestdoc_id`
|
||||
from
|
||||
`vn`.`travelThermograph` `tt`;
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus__` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `w`.`maritalStatus__` = NULL;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`maritalStatus__` = `pl`.`estadocivil`;
|
||||
|
||||
ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen';
|
||||
ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL;
|
||||
ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
INSERT INTO `vn`.`country` (`country`, `CEE`, `code`, `politicalCountryFk`, `isUeeMember`, `a3Code`)
|
||||
VALUES
|
||||
('Argentina',2,'AR',80,0,32),
|
||||
('Cuba',2,'CU',81,0,192),
|
||||
('Guinea Ecuatorial',2,'GQ',82,0,226),
|
||||
('Guinea',2,'GN',83,0,324),
|
||||
('Honduras',2,'HN',84,0,340),
|
||||
('Mali',2,'ML',85,0,466),
|
||||
('Nicaragua',2,'NI',86,0,558),
|
||||
('Pakistán',2,'PK',87,0,586),
|
||||
('Paraguay',2,'PY',88,0,600),
|
||||
('Senegal',2,'SN',89,0,686),
|
||||
('Uruguay',2,'UY',90,0,858),
|
||||
('Venezuela',2,'VE',91,0,862),
|
||||
('Bulgaria',2,'BG',92,1,100),
|
||||
('Georgia',2,'GE',93,0,268);
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` `pl` ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
JOIN `vn`.`country` `co` ON `co`.`a3Code` = `pl`.`codpais`
|
||||
SET `w`.`originCountryFk` = `co`.`id`;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
JOIN `vn`.`person` `p` ON `p`.`workerFk` = `w`.`id`
|
||||
JOIN `postgresql`.`profile` `pr` ON `pr`.`person_id` = `p`.`id`
|
||||
JOIN `vn2008`.`profile_labour_payroll` pl ON `pl`.`profile_id` = `pr`.`profile_id`
|
||||
SET `w`.`SSN` = CONCAT(`pl`.`NSSProvincia`, `pl`.`NssNumero`, `pl`.`NssDC`);
|
||||
|
||||
RENAME TABLE `vn2008`.`profile_labour_payroll` TO `vn2008`.`profile_labour_payroll__`;
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_contrato`;
|
||||
ALTER TABLE `vn`.`workerBusinessType` MODIFY COLUMN `id` int(11) NOT NULL;
|
||||
ALTER TABLE `postgresql`.`business_labour_payroll` ADD CONSTRAINT `business_labour_payroll_FK` FOREIGN KEY (cod_contrato) REFERENCES `vn`.`workerBusinessType`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,73 @@
|
|||
DROP PROCEDURE IF EXISTS vn.timeControl_getError;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||
BEGIN
|
||||
/*
|
||||
* @param vDatedFrom
|
||||
* @param vDatedTo
|
||||
* @table tmp.`user`(userFk)
|
||||
* Fichadas incorrectas de las cuales no se puede calcular horas trabajadas
|
||||
* @return tmp.timeControlError (id)
|
||||
*/
|
||||
DECLARE vDayMaxTime INTEGER;
|
||||
|
||||
SET @journeyCounter := 0;
|
||||
SET @lastUserFk := NULL;
|
||||
|
||||
SELECT dayMaxTime INTO vDayMaxTime
|
||||
FROM workerTimeControlConfig LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
|
||||
CREATE TEMPORARY TABLE tmp.timeControl
|
||||
(INDEX(id), INDEX(journeyCounter))
|
||||
ENGINE = MEMORY
|
||||
SELECT sub.id,
|
||||
sub.direction,
|
||||
sub.timed,
|
||||
IF(sub.direction = 'in' OR @hasOut OR sub.userFk <> @lastUserFk, @journeyCounter := @journeyCounter + 1, @journeyCounter) journeyCounter,
|
||||
@lastUserFk := sub.userFk workerFk,
|
||||
IF(sub.direction = 'out', @hasOut:= TRUE, @hasOut:= FALSE)
|
||||
FROM (
|
||||
SELECT DISTINCT wtc.id,
|
||||
wtc.direction,
|
||||
wtc.timed,
|
||||
wtc.userFk
|
||||
FROM workerTimeControl wtc
|
||||
JOIN tmp.`user` w ON w.userFk = wtc.userFk
|
||||
WHERE wtc.timed BETWEEN DATE_SUB(vDatedFrom, INTERVAL 1 DAY) AND DATE_ADD(vDatedTo, INTERVAL 1 DAY)
|
||||
ORDER BY wtc.userFk, wtc.timed
|
||||
) sub;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
|
||||
CREATE TEMPORARY TABLE tmp.timeControlAux
|
||||
(INDEX(id), INDEX(journeyCounter))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM tmp.timeControl;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlError;
|
||||
CREATE TEMPORARY TABLE tmp.timeControlError
|
||||
(INDEX(id))
|
||||
ENGINE = MEMORY
|
||||
SELECT id
|
||||
FROM tmp.timeControlAux tca
|
||||
JOIN (SELECT journeyCounter,
|
||||
UNIX_TIMESTAMP(MAX(timed)) - UNIX_TIMESTAMP(MIN(timed)) timeWork,
|
||||
SUM(direction = 'in') totalIn,
|
||||
SUM(direction = 'out') totalOut,
|
||||
timed
|
||||
FROM tmp.timeControl
|
||||
GROUP BY journeyCounter
|
||||
HAVING COUNT(*) MOD 2 = 1
|
||||
OR totalIn <> 1
|
||||
OR totalOut <> 1
|
||||
OR timeWork >= vDayMaxTime
|
||||
)sub ON sub.journeyCounter = tca.journeyCounter
|
||||
WHERE sub.timed BETWEEN vDatedFrom AND vDatedTo;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControl;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.timeControlAux;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
File diff suppressed because one or more lines are too long
|
@ -32,6 +32,11 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`)
|
|||
('10');
|
||||
|
||||
UPDATE `account`.`role` SET id = 100 WHERE id = 0;
|
||||
|
||||
INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPrefix`, `userHost`, `tplUser`)
|
||||
VALUES
|
||||
(1, 'mysqlPassword', '$', '!', '%', 'any');
|
||||
|
||||
CALL `account`.`role_sync`;
|
||||
|
||||
INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`)
|
||||
|
@ -42,10 +47,36 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`
|
|||
INSERT INTO `account`.`account`(`id`)
|
||||
SELECT id FROM `account`.`user`;
|
||||
|
||||
INSERT INTO `vn`.`educationLevel` (`id`, `name`)
|
||||
VALUES
|
||||
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
|
||||
(2, 'ENSEÑANZAS DE BACHILLERATO');
|
||||
|
||||
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
|
||||
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
|
||||
FROM `vn`.`user`;
|
||||
|
||||
ALTER TABLE `vn`.`worker` ADD `originCountryFk` mediumint(8) unsigned NULL COMMENT 'País de origen';
|
||||
ALTER TABLE `vn`.`worker` ADD `educationLevelFk` SMALLINT NULL;
|
||||
ALTER TABLE `vn`.`worker` ADD `SSN` varchar(15) NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus__` `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` MODIFY COLUMN `maritalStatus` enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
|
||||
ALTER TABLE `vn`.`worker` CHANGE `maritalStatus` maritalStatus enum('S','M') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER sectorFk;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_2` FOREIGN KEY (`educationLevelFk`) REFERENCES `vn`.`educationLevel`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `vn`.`worker` ADD CONSTRAINT `worker_FK_1` FOREIGN KEY (`originCountryFk`) REFERENCES `vn`.`country`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `maritalStatus` = 'S';
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `originCountryFk` = '1';
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `educationLevelFk` = '2';
|
||||
|
||||
UPDATE `vn`.`worker` `w`
|
||||
SET `SSN` = '123456789123';
|
||||
|
||||
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
|
||||
UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9;
|
||||
UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18;
|
||||
|
@ -287,10 +318,10 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
|
|||
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`)
|
||||
VALUES
|
||||
(1101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street, Queens, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street, Apartament 3-D', 'Silla', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point, 90265', 'Silla', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist'),
|
||||
(1106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'City of New York, New York, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
|
||||
(1107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill, San Francisco, California', 'Silla', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist'),
|
||||
(1108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist'),
|
||||
|
@ -807,25 +838,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
|
|||
('VT', 'Sales');
|
||||
|
||||
INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`,
|
||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`)
|
||||
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`)
|
||||
VALUES
|
||||
(1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V'),
|
||||
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H'),
|
||||
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL),
|
||||
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
||||
(5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
||||
(6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
||||
(7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
||||
(8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL),
|
||||
(9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL),
|
||||
(10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
||||
(11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL),
|
||||
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL),
|
||||
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 0, 2, 'VT', 1, NULL, NULL),
|
||||
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL),
|
||||
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL),
|
||||
(16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL),
|
||||
(71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL);
|
||||
(1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0),
|
||||
(2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0),
|
||||
(3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
|
||||
(4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||
(5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||
(6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||
(7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||
(8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0),
|
||||
(9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
|
||||
(10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||
(11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0),
|
||||
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0),
|
||||
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1),
|
||||
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0),
|
||||
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
|
||||
(16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0),
|
||||
(71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0);
|
||||
|
||||
-- Update the taxClass after insert of the items
|
||||
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
|
||||
|
@ -835,7 +866,7 @@ INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`
|
|||
VALUES
|
||||
(1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
||||
(2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
|
||||
(3, 5, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
|
||||
(3, 13, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`)
|
||||
VALUES
|
||||
|
@ -1695,22 +1726,22 @@ INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk
|
|||
(4, 1102, 2, CURDATE(), 18, 18, 567),
|
||||
(5, 1102, 3, CURDATE(), 19, 19, 567);
|
||||
|
||||
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`)
|
||||
INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, `hasToNotify`)
|
||||
VALUES
|
||||
( 1, 'pending', 'Pendiente', 1, 1),
|
||||
( 2, 'managed', 'Gestionado', 1, 5),
|
||||
( 3, 'resolved', 'Resuelto', 72, 7),
|
||||
( 4, 'canceled', 'Anulado', 72, 6),
|
||||
( 5, 'incomplete', 'Incompleta', 72, 3),
|
||||
( 6, 'mana', 'Mana', 1, 4),
|
||||
( 7, 'lack', 'Faltas', 1, 2);
|
||||
( 1, 'pending', 'Pendiente', 1, 1, 0),
|
||||
( 2, 'managed', 'Gestionado', 1, 5, 0),
|
||||
( 3, 'resolved', 'Resuelto', 72, 7, 0),
|
||||
( 4, 'canceled', 'Anulado', 72, 6, 1),
|
||||
( 5, 'incomplete', 'Incompleta', 72, 3, 1),
|
||||
( 6, 'mana', 'Mana', 1, 4, 0),
|
||||
( 7, 'lack', 'Faltas', 1, 2, 0);
|
||||
|
||||
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created` )
|
||||
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`)
|
||||
VALUES
|
||||
(1, CURDATE(), 1, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', 1101, 18, 3, 0, CURDATE()),
|
||||
(2, CURDATE(), 2, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', 1101, 18, 3, 0, CURDATE()),
|
||||
(3, CURDATE(), 3, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', 1101, 18, 1, 1, CURDATE()),
|
||||
(4, CURDATE(), 3, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', 1104, 18, 5, 0, CURDATE());
|
||||
(1, CURDATE(), 1, 'Cu nam labores lobortis definiebas, ei aliquyam salutatus persequeris quo, cum eu nemore fierent dissentiunt. Per vero dolor id, vide democritum scribentur eu vim, pri erroribus temporibus ex.', 1101, 18, 3, 0, CURDATE(), 0),
|
||||
(2, CURDATE(), 2, 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.', 1101, 18, 3, 0, CURDATE(), 1),
|
||||
(3, CURDATE(), 3, 'An vim commodo dolorem volutpat, cu expetendis voluptatum usu, et mutat consul adversarium his. His natum numquam legimus an, diam fabulas mei ut. Melius fabellas sadipscing vel id. Partem diceret mandamus mea ne, has te tempor nostrud. Aeque nostro eum no.', 1101, 18, 1, 1, CURDATE(), 5),
|
||||
(4, CURDATE(), 3, 'Wisi forensibus mnesarchum in cum. Per id impetus abhorreant, his no magna definiebas, inani rationibus in quo. Ut vidisse dolores est, ut quis nominavi mel. Ad pri quod apeirian concludaturque.', 1104, 18, 5, 0, CURDATE(), 10);
|
||||
|
||||
INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`)
|
||||
VALUES
|
||||
|
@ -1897,14 +1928,29 @@ INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`)
|
|||
('1', '24.5', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))),
|
||||
('5', '23', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)));
|
||||
|
||||
INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`, `code`, `holidayEntitlementRate`)
|
||||
INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`)
|
||||
VALUES
|
||||
(1, 'Holidays', '#FF4444', 'holiday', 0),
|
||||
(2, 'Leave of absence', '#C71585', 'absence', 0),
|
||||
(6, 'Half holiday', '#E65F00', 'halfHoliday', 0),
|
||||
(15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0),
|
||||
(20, 'Furlough', '#97B92F', 'furlough', 1),
|
||||
(21, 'Furlough half day', '#778899', 'halfFurlough', 0.5);
|
||||
(1, 'Holidays', '#FF4444', 'holiday', 0, 0),
|
||||
(2, 'Leave of absence', '#C71585', 'absence', 0, 1),
|
||||
(6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5),
|
||||
(15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1),
|
||||
(20, 'Furlough', '#97B92F', 'furlough', 1, 1),
|
||||
(21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1);
|
||||
|
||||
ALTER TABLE `postgresql`.`business_labour_payroll` DROP FOREIGN KEY `business_labour_payroll_cod_categoria`;
|
||||
|
||||
INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent`, `hasHolidayEntitlement`)
|
||||
VALUES
|
||||
(1, 'CONTRATO HOLANDA', 1, 0, 1),
|
||||
(100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1),
|
||||
(109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1);
|
||||
|
||||
INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, `cod_categoria`, `cod_contrato`, `importepactado`)
|
||||
VALUES
|
||||
(1, 7, 12, 100, 900.50),
|
||||
(1106, 7, 12, 100, 1263.03),
|
||||
(1107, 7, 12, 100, 2000),
|
||||
(1108, 7, 12, 100, 1500);
|
||||
|
||||
INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`)
|
||||
VALUES
|
||||
|
@ -2408,6 +2454,13 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for
|
|||
(6, 29.95, '7001000000', NULL, 7, 20),
|
||||
(7, 58.64, '6210000567', NULL, 8, 20);
|
||||
|
||||
INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amount`, `stems`, `countryFk`)
|
||||
VALUES
|
||||
(1, 30.50, 5080000, 10.00, 162, 5),
|
||||
(1, 10, 6021010, 20.00, 205, 5),
|
||||
(2, 13.20, 5080000, 15.00, 580, 5),
|
||||
(2, 16.10, 6021010, 25.00, 80, 5);
|
||||
|
||||
INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
|
||||
SELECT `id`
|
||||
FROM `vn`.`ticket` t
|
||||
|
@ -2457,28 +2510,13 @@ INSERT INTO `bs`.`defaulter` (`clientFk`, `amount`, `created`, `defaulterSinced`
|
|||
(1107, 500, CURDATE(), CURDATE()),
|
||||
(1109, 500, CURDATE(), CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`agencyTerm` (`agencyFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
|
||||
VALUES
|
||||
(1, 0, 0.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(3, 0, 0.00, 3.05, NULL, 0, 0.00, 0),
|
||||
(2, 60, 0.00, 0.00, NULL, 0, 5.00, 33);
|
||||
|
||||
UPDATE `vn`.`agency`
|
||||
SET `supplierFk`=1
|
||||
WHERE `id`=1;
|
||||
UPDATE `vn`.`agency`
|
||||
SET `supplierFk`=1
|
||||
WHERE `id`=2;
|
||||
UPDATE `vn`.`agency`
|
||||
SET `supplierFk`=2
|
||||
WHERE `id`=3;
|
||||
UPDATE `vn`.`route`
|
||||
SET `invoiceInFk`=1
|
||||
WHERE `id`=1;
|
||||
|
||||
UPDATE `vn`.`route`
|
||||
SET `invoiceInFk`=1
|
||||
WHERE `id`=1;
|
||||
UPDATE `vn`.`route`
|
||||
SET `invoiceInFk`=2
|
||||
WHERE `id`=2;
|
||||
SET `invoiceInFk`=2
|
||||
WHERE `id`=2;
|
||||
INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`)
|
||||
VALUES
|
||||
(18, YEAR(CURDATE()), MONTH(CURDATE()), 807.23),
|
||||
|
@ -2491,6 +2529,7 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`)
|
|||
(3, 200.78, CURDATE(), 2, 1101),
|
||||
(4, 33.8, CURDATE(), 1, 1101),
|
||||
(30, 34.4, CURDATE(), 1, 1108);
|
||||
|
||||
INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
|
||||
VALUES
|
||||
('deliveryClientTest', 'deliveryClientTest', 'findTest', 'word');
|
||||
|
@ -2498,3 +2537,23 @@ INSERT INTO `vn`.`docuware` (`code`, `fileCabinetName`, `dialogName` , `find`)
|
|||
INSERT INTO `vn`.`docuwareConfig` (`url`)
|
||||
VALUES
|
||||
('https://verdnatura.docuware.cloud/docuware/platform');
|
||||
|
||||
INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`)
|
||||
VALUES
|
||||
(1, 'dayOfIT');
|
||||
|
||||
INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`)
|
||||
VALUES
|
||||
(1, 'National', '#4169E1');
|
||||
|
||||
INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`)
|
||||
VALUES
|
||||
(1, 1, CONCAT(YEAR(CURDATE()), '-12-09'), 1, 1);
|
||||
|
||||
INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`)
|
||||
VALUES
|
||||
(1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23),
|
||||
(2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33),
|
||||
(3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0),
|
||||
(5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0);
|
||||
|
|
39448
db/dump/structure.sql
39448
db/dump/structure.sql
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,6 @@ IGNORETABLES=(
|
|||
--ignore-table=bs.productionIndicators
|
||||
--ignore-table=bs.VentasPorCliente
|
||||
--ignore-table=bs.v_ventas
|
||||
--ignore-table=edi.supplyOffer
|
||||
--ignore-table=postgresql.currentWorkersStats
|
||||
--ignore-table=vn.accounting__
|
||||
--ignore-table=vn.agencyModeZone
|
||||
|
|
|
@ -346,16 +346,17 @@ export default {
|
|||
saveFieldsButton: '.vn-popover.shown vn-button[label="Save"] > button'
|
||||
},
|
||||
itemFixedPrice: {
|
||||
add: 'vn-fixed-price vn-icon[icon="add_circle"]',
|
||||
fourthFixedPrice: 'vn-fixed-price vn-tr:nth-child(4)',
|
||||
fourthItemID: 'vn-fixed-price vn-tr:nth-child(4) vn-autocomplete[ng-model="price.itemFk"]',
|
||||
fourthWarehouse: 'vn-fixed-price vn-tr:nth-child(4) vn-autocomplete[ng-model="price.warehouseFk"]',
|
||||
fourthPPU: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(4)',
|
||||
fourthPPP: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(5)',
|
||||
fourthMinPrice: 'vn-fixed-price vn-tr:nth-child(4) > vn-td-editable:nth-child(6)',
|
||||
fourthStarted: 'vn-fixed-price vn-tr:nth-child(4) vn-date-picker[ng-model="price.started"]',
|
||||
fourthEnded: 'vn-fixed-price vn-tr:nth-child(4) vn-date-picker[ng-model="price.ended"]',
|
||||
fourthDeleteIcon: 'vn-fixed-price vn-tr:nth-child(4) > vn-td:nth-child(9) > vn-icon-button[icon="delete"]'
|
||||
add: 'vn-fixed-price vn-icon-button[icon="add_circle"]',
|
||||
fourthFixedPrice: 'vn-fixed-price tr:nth-child(5)',
|
||||
fourthItemID: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.itemFk"]',
|
||||
fourthWarehouse: 'vn-fixed-price tr:nth-child(5) vn-autocomplete[ng-model="price.warehouseFk"]',
|
||||
fourthPPU: 'vn-fixed-price tr:nth-child(5) > td:nth-child(4)',
|
||||
fourthPPP: 'vn-fixed-price tr:nth-child(5) > td:nth-child(5)',
|
||||
fourthHasMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-check[ng-model="price.hasMinPrice"]',
|
||||
fourthMinPrice: 'vn-fixed-price tr:nth-child(5) > td:nth-child(6) > vn-input-number[ng-model="price.minPrice"]',
|
||||
fourthStarted: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.started"]',
|
||||
fourthEnded: 'vn-fixed-price tr:nth-child(5) vn-date-picker[ng-model="price.ended"]',
|
||||
fourthDeleteIcon: 'vn-fixed-price tr:nth-child(5) > td:nth-child(9) > vn-icon-button[icon="delete"]'
|
||||
},
|
||||
itemCreateView: {
|
||||
temporalName: 'vn-item-create vn-textfield[ng-model="$ctrl.item.provisionalName"]',
|
||||
|
@ -391,7 +392,6 @@ export default {
|
|||
name: 'vn-item-basic-data vn-textfield[ng-model="$ctrl.item.name"]',
|
||||
relevancy: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.relevancy"]',
|
||||
origin: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]',
|
||||
compression: 'vn-item-basic-data vn-input-number[ng-model="$ctrl.item.compression"]',
|
||||
generic: 'vn-autocomplete[ng-model="$ctrl.item.genericFk"]',
|
||||
isFragile: 'vn-check[ng-model="$ctrl.item.isFragile"]',
|
||||
longName: 'vn-textfield[ng-model="$ctrl.item.longName"]',
|
||||
|
@ -585,6 +585,7 @@ export default {
|
|||
firstSalePriceInput: '.vn-popover.shown input[ng-model="$ctrl.field"]',
|
||||
firstSaleDiscount: 'vn-ticket-sale vn-table vn-tr:nth-child(1) > vn-td:nth-child(10) > span',
|
||||
firstSaleDiscountInput: '.vn-popover.shown [ng-model="$ctrl.field"]',
|
||||
saveSaleDiscountButton: '.vn-popover.shown vn-button[label="Save"]',
|
||||
firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(11)',
|
||||
firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)',
|
||||
firstSaleColour: 'vn-ticket-sale vn-tr:nth-child(1) vn-fetched-tags section',
|
||||
|
@ -692,6 +693,7 @@ export default {
|
|||
claimBasicData: {
|
||||
claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]',
|
||||
observation: 'vn-textarea[ng-model="$ctrl.claim.observation"]',
|
||||
packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]',
|
||||
hasToPickUpCheckbox: 'vn-claim-basic-data vn-check[ng-model="$ctrl.claim.hasToPickUp"]',
|
||||
saveButton: `button[type=submit]`
|
||||
},
|
||||
|
@ -898,6 +900,7 @@ export default {
|
|||
sundayWorkedHours: 'vn-worker-time-control vn-table > div > vn-tfoot > vn-tr:nth-child(1) > vn-td:nth-child(7)',
|
||||
weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span',
|
||||
nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]',
|
||||
previousMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_left]',
|
||||
secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number',
|
||||
navigateBackToIndex: 'vn-worker-descriptor [name="goToModuleIndex"]'
|
||||
},
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('Client defaulter path', () => {
|
|||
const salesPersonName =
|
||||
await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText');
|
||||
|
||||
expect(clientName).toEqual('Batman');
|
||||
expect(clientName).toEqual('Ororo Munroe');
|
||||
expect(salesPersonName).toEqual('salesPersonNick');
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ describe('Worker time control path', () => {
|
|||
await page.loginAndModule('salesBoss', 'worker');
|
||||
await page.accessToSearchResult('HankPym');
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
|
@ -98,8 +100,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 7 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '07:00 h.');
|
||||
it(`should check Hank Pym worked 6:40 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '06:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -152,8 +154,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 happy hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -206,8 +208,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 cheerfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 cheerfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -257,8 +259,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 joyfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 joyfull hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -307,8 +309,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 hours with a smile on his face`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 hours with a smile on his face`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -327,6 +329,8 @@ describe('Worker time control path', () => {
|
|||
it('should access to the time control section', async() => {
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitForState('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
it('should lovingly scan in Hank Pym', async() => {
|
||||
|
@ -352,8 +356,8 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 hours with all his will`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 hours with all his will`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '07:40 h.');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -380,11 +384,11 @@ describe('Worker time control path', () => {
|
|||
expect(result).toEqual(scanTime);
|
||||
});
|
||||
|
||||
it(`should check Hank Pym worked 8 glad hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '08:00 h.');
|
||||
it(`should check Hank Pym worked 7:40 glad hours`, async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '07:40 h.');
|
||||
});
|
||||
|
||||
it(`should check Hank Pym doesn't have hours set on the next months first week`, async() => {
|
||||
it(`should check Hank Pym doesn't have hours set on the next months second week`, async() => {
|
||||
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.');
|
||||
|
@ -408,10 +412,12 @@ describe('Worker time control path', () => {
|
|||
await page.loginAndModule('HankPym', 'worker');
|
||||
await page.accessToSearchResult('HankPym');
|
||||
await page.accessToSection('worker.card.timeControl');
|
||||
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
|
||||
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
|
||||
});
|
||||
|
||||
it('should check his weekly hours are alright', async() => {
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '55:00 h.');
|
||||
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '52:40 h.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -30,8 +30,6 @@ describe('Item Edit basic data path', () => {
|
|||
await page.autocompleteSearch(selectors.itemBasicData.origin, 'Spain');
|
||||
await page.clearInput(selectors.itemBasicData.relevancy);
|
||||
await page.write(selectors.itemBasicData.relevancy, '1');
|
||||
await page.clearInput(selectors.itemBasicData.compression);
|
||||
await page.write(selectors.itemBasicData.compression, '2');
|
||||
await page.clearInput(selectors.itemBasicData.generic);
|
||||
await page.autocompleteSearch(selectors.itemBasicData.generic, '16');
|
||||
await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
|
||||
|
@ -96,13 +94,6 @@ describe('Item Edit basic data path', () => {
|
|||
expect(result).toEqual('Spain');
|
||||
});
|
||||
|
||||
it(`should confirm the item compression was edited`, async() => {
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.itemBasicData.compression, 'value');
|
||||
|
||||
expect(result).toEqual('2');
|
||||
});
|
||||
|
||||
it(`should confirm the item generic was edited`, async() => {
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.itemBasicData.generic, 'value');
|
||||
|
|
|
@ -16,33 +16,17 @@ describe('Item fixed prices path', () => {
|
|||
});
|
||||
|
||||
it('should click on the add new foxed price button', async() => {
|
||||
await page.doSearch();
|
||||
await page.waitToClick(selectors.itemFixedPrice.add);
|
||||
await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice);
|
||||
});
|
||||
|
||||
it('should fill the fixed price data', async() => {
|
||||
const now = new Date();
|
||||
const searchValue = 'Chest ammo box';
|
||||
await page.waitToClick(selectors.itemFixedPrice.fourthItemID);
|
||||
await page.write('body > div > div > div.content > div.filter.ng-scope > vn-textfield', searchValue);
|
||||
try {
|
||||
await page.waitForFunction(searchValue => {
|
||||
const element = document.querySelector('li.active');
|
||||
if (element)
|
||||
return element.innerText.toLowerCase().includes(searchValue.toLowerCase());
|
||||
}, {}, searchValue);
|
||||
} catch (error) {
|
||||
const builtSelector = await page.selectorFormater(selectors.ticketSales.moreMenuState);
|
||||
const inputValue = await page.evaluate(() => {
|
||||
return document.querySelector('.vn-drop-down.shown vn-textfield input').value;
|
||||
});
|
||||
throw new Error(`${builtSelector} value is ${inputValue}! ${error}`);
|
||||
}
|
||||
await page.keyboard.press('Enter');
|
||||
await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one');
|
||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPU, '20');
|
||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPP, '10');
|
||||
await page.writeOnEditableTD(selectors.itemFixedPrice.fourthMinPrice, '5');
|
||||
await page.write(selectors.itemFixedPrice.fourthPPU, '1');
|
||||
await page.write(selectors.itemFixedPrice.fourthPPP, '1');
|
||||
await page.write(selectors.itemFixedPrice.fourthMinPrice, '1');
|
||||
await page.pickDate(selectors.itemFixedPrice.fourthStarted, now);
|
||||
await page.pickDate(selectors.itemFixedPrice.fourthEnded, now);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
@ -53,7 +37,9 @@ describe('Item fixed prices path', () => {
|
|||
it('should reload the section and check the created price has the expected ID', async() => {
|
||||
await page.accessToSection('item.index');
|
||||
await page.accessToSection('item.fixedPrice');
|
||||
const result = await page.getProperty('vn-fixed-price > div > vn-card > vn-table > div > vn-tbody > vn-tr:nth-child(4) > vn-td:nth-child(1) > span', 'innerText');
|
||||
await page.doSearch();
|
||||
|
||||
const result = await page.waitToGetProperty(selectors.itemFixedPrice.fourthItemID, 'value');
|
||||
|
||||
expect(result).toContain('13');
|
||||
});
|
||||
|
|
|
@ -175,7 +175,8 @@ describe('Ticket Edit sale path', () => {
|
|||
it('should update the discount', async() => {
|
||||
await page.waitToClick(selectors.ticketSales.firstSaleDiscount);
|
||||
await page.waitForSelector(selectors.ticketSales.firstSaleDiscountInput);
|
||||
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d');
|
||||
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50');
|
||||
await page.waitToClick(selectors.ticketSales.saveSaleDiscountButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('Ticket Create new tracking state path', () => {
|
|||
});
|
||||
|
||||
it(`should create a new state`, async() => {
|
||||
await page.autocompleteSearch(selectors.createStateView.state, '¿Fecha?');
|
||||
await page.autocompleteSearch(selectors.createStateView.state, 'OK');
|
||||
await page.waitToClick(selectors.createStateView.saveStateButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ describe('Claim edit basic data path', () => {
|
|||
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado');
|
||||
await page.clearTextarea(selectors.claimBasicData.observation);
|
||||
await page.write(selectors.claimBasicData.observation, 'edited observation');
|
||||
await page.clearInput(selectors.claimBasicData.packages);
|
||||
await page.write(selectors.claimBasicData.packages, '2');
|
||||
await page.waitToClick(selectors.claimBasicData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
@ -64,10 +66,19 @@ describe('Claim edit basic data path', () => {
|
|||
expect(result).toEqual('edited observation');
|
||||
});
|
||||
|
||||
it('should confirm the claim packages was edited', async() => {
|
||||
const result = await page
|
||||
.waitToGetProperty(selectors.claimBasicData.packages, 'value');
|
||||
|
||||
expect(result).toEqual('2');
|
||||
});
|
||||
|
||||
it(`should edit the claim to leave it untainted`, async() => {
|
||||
await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente');
|
||||
await page.clearTextarea(selectors.claimBasicData.observation);
|
||||
await page.write(selectors.claimBasicData.observation, 'Observation one');
|
||||
await page.clearInput(selectors.claimBasicData.packages);
|
||||
await page.write(selectors.claimBasicData.packages, '0');
|
||||
await page.waitToClick(selectors.claimBasicData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ describe('Claim development', () => {
|
|||
.waitToGetProperty(selectors.claimDevelopment.firstClaimRedelivery, 'value');
|
||||
|
||||
expect(reason).toEqual('Calor');
|
||||
expect(result).toEqual('Cocido');
|
||||
expect(result).toEqual('Baboso/Cocido');
|
||||
expect(responsible).toEqual('Calidad general');
|
||||
expect(worker).toEqual('adminAssistantNick');
|
||||
expect(redelivery).toEqual('Cliente');
|
||||
|
|
|
@ -50,7 +50,7 @@ describe('InvoiceOut manual invoice path', () => {
|
|||
});
|
||||
|
||||
it('should create an invoice from a client', async() => {
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Charles Xavier');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Max Eisenhardt');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional');
|
||||
await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national');
|
||||
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
|
||||
|
|
|
@ -80,7 +80,7 @@ describe('Account create and basic data path', () => {
|
|||
await page.reloadSection('account.card.roles');
|
||||
const rolesCount = await page.countElement(selectors.accountRoles.anyResult);
|
||||
|
||||
expect(rolesCount).toEqual(35);
|
||||
expect(rolesCount).toEqual(61);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ export default class SmartTable extends Component {
|
|||
this._options = options;
|
||||
if (!options) return;
|
||||
|
||||
if (options.defaultSearch)
|
||||
this.displaySearch();
|
||||
|
||||
const activeButtons = options.activeButtons;
|
||||
const missingId = activeButtons && activeButtons.shownColumns && !this.viewConfigId;
|
||||
if (missingId)
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked",
|
||||
"Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*",
|
||||
"Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*",
|
||||
"This ticket is not an stowaway anymore": "The ticket id [{{ticketId}}]({{{ticketUrl}}}) is not an stowaway anymore",
|
||||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||
|
@ -121,5 +122,6 @@
|
|||
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
||||
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
||||
"The worker has hours recorded that day": "The worker has hours recorded that day",
|
||||
"isWithoutNegatives": "isWithoutNegatives"
|
||||
"isWithoutNegatives": "isWithoutNegatives",
|
||||
"routeFk": "routeFk"
|
||||
}
|
|
@ -137,6 +137,7 @@
|
|||
"Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*",
|
||||
"Claim state has changed to incomplete": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *incompleta*",
|
||||
"Claim state has changed to canceled": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *anulado*",
|
||||
"This ticket is not an stowaway anymore": "El ticket id [{{ticketId}}]({{{ticketUrl}}}) ha dejado de ser un polizón",
|
||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||
|
@ -220,5 +221,8 @@
|
|||
"Can't transfer claimed sales": "No puedes transferir lineas reclamadas",
|
||||
"You don't have privileges to create pay back": "No tienes permisos para crear un abono",
|
||||
"The item is required": "El artículo es requerido",
|
||||
"reference duplicated": "Referencia duplicada"
|
||||
"The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo",
|
||||
"date in the future": "Fecha en el futuro",
|
||||
"reference duplicated": "Referencia duplicada",
|
||||
"This ticket is already a refund": "Este ticket ya es un abono"
|
||||
}
|
|
@ -15,7 +15,8 @@
|
|||
"legacyUtcDateProcessing": false,
|
||||
"timezone": "local",
|
||||
"connectTimeout": 40000,
|
||||
"acquireTimeout": 20000
|
||||
"acquireTimeout": 20000,
|
||||
"waitForConnections": true
|
||||
},
|
||||
"osticket": {
|
||||
"connector": "memory",
|
||||
|
|
|
@ -26,7 +26,6 @@ module.exports = Self => {
|
|||
|
||||
Self.sync = async function(userName, password, force) {
|
||||
let $ = Self.app.models;
|
||||
|
||||
let user = await $.Account.findOne({
|
||||
fields: ['id'],
|
||||
where: {name: userName}
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = Self => {
|
|||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'client',
|
||||
arg: 'clientName',
|
||||
type: 'string',
|
||||
description: 'The worker name',
|
||||
http: {source: 'query'}
|
||||
|
@ -94,11 +94,11 @@ module.exports = Self => {
|
|||
? {'cl.id': value}
|
||||
: {
|
||||
or: [
|
||||
{'cl.socialName': {like: `%${value}%`}}
|
||||
{'cl.clientName': {like: `%${value}%`}}
|
||||
]
|
||||
};
|
||||
case 'client':
|
||||
return {'cl.socialName': {like: `%${value}%`}};
|
||||
case 'clientName':
|
||||
return {'cl.clientName': {like: `%${value}%`}};
|
||||
case 'clientFk':
|
||||
return {'cl.clientFk': value};
|
||||
case 'id':
|
||||
|
@ -128,7 +128,7 @@ module.exports = Self => {
|
|||
SELECT
|
||||
cl.id,
|
||||
cl.clientFk,
|
||||
c.socialName,
|
||||
c.name AS clientName,
|
||||
cl.workerFk,
|
||||
u.name AS workerName,
|
||||
cs.description,
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('claim filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await app.models.Claim.filter({args: {filter: {}, search: 'Iron man'}}, null, options);
|
||||
const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result[0].id).toEqual(4);
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('Update Claim', () => {
|
|||
expect(error.message).toEqual(`You don't have enough privileges to change that field`);
|
||||
});
|
||||
|
||||
it(`should success to update the claim within privileges `, async() => {
|
||||
it(`should success to update the claimState to 'canceled' and send a rocket message`, async() => {
|
||||
const tx = await app.models.Claim.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -55,13 +55,15 @@ describe('Update Claim', () => {
|
|||
|
||||
const newClaim = await app.models.Claim.create(originalData, options);
|
||||
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||
|
||||
const canceledState = 4;
|
||||
const claimManagerId = 72;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {
|
||||
userId: claimManagerId
|
||||
}
|
||||
accessToken: {userId: claimManagerId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {
|
||||
observation: 'valid observation',
|
||||
|
@ -69,11 +71,56 @@ describe('Update Claim', () => {
|
|||
hasToPickUp: false
|
||||
}
|
||||
};
|
||||
ctx.req.__ = (value, params) => {
|
||||
return params.nickname;
|
||||
};
|
||||
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||
|
||||
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||
|
||||
expect(updatedClaim.observation).toEqual(ctx.args.observation);
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it(`should success to update the claimState to 'incomplete' and send a rocket message`, async() => {
|
||||
const tx = await app.models.Claim.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const newClaim = await app.models.Claim.create(originalData, options);
|
||||
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||
|
||||
const incompleteState = 5;
|
||||
const claimManagerId = 72;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: claimManagerId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {
|
||||
observation: 'valid observation',
|
||||
claimStateFk: incompleteState,
|
||||
hasToPickUp: false
|
||||
}
|
||||
};
|
||||
ctx.req.__ = (value, params) => {
|
||||
return params.nickname;
|
||||
};
|
||||
await app.models.Claim.updateClaim(ctx, newClaim.id, options);
|
||||
|
||||
let updatedClaim = await app.models.Claim.findById(newClaim.id, null, options);
|
||||
|
||||
expect(updatedClaim.observation).toEqual(ctx.args.observation);
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -28,6 +28,10 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'hasToPickUp',
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
arg: 'packages',
|
||||
type: 'number'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
|
@ -92,9 +96,12 @@ module.exports = Self => {
|
|||
// When claimState has been changed
|
||||
if (args.claimStateFk) {
|
||||
const newState = await models.ClaimState.findById(args.claimStateFk, null, options);
|
||||
|
||||
if (newState.code == 'incomplete')
|
||||
notifyStateChange(ctx, salesPerson.id, claim);
|
||||
if (newState.hasToNotify) {
|
||||
if (newState.code == 'incomplete')
|
||||
notifyStateChange(ctx, salesPerson.id, claim, newState.code);
|
||||
if (newState.code == 'canceled')
|
||||
notifyStateChange(ctx, claim.workerFk, claim, newState.code);
|
||||
}
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
@ -121,11 +128,12 @@ module.exports = Self => {
|
|||
return canUpdate;
|
||||
}
|
||||
|
||||
async function notifyStateChange(ctx, workerId, claim) {
|
||||
const origin = ctx.req.headers.origin;
|
||||
async function notifyStateChange(ctx, workerId, claim, state) {
|
||||
const models = Self.app.models;
|
||||
const origin = ctx.req.headers.origin;
|
||||
const $t = ctx.req.__; // $translate
|
||||
const message = $t('Claim state has changed to incomplete', {
|
||||
|
||||
const message = $t(`Claim state has changed to ${state}`, {
|
||||
claimId: claim.id,
|
||||
clientName: claim.client().name,
|
||||
claimUrl: `${origin}/#!/claim/${claim.id}/summary`
|
||||
|
|
|
@ -13,20 +13,24 @@
|
|||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
"type": "String",
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"description": {
|
||||
"type": "String",
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"priority": {
|
||||
"type": "Number",
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"hasToNotify": {
|
||||
"type": "boolean",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
},
|
||||
"workerFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"packages": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -43,7 +43,14 @@
|
|||
order="priority ASC"
|
||||
vn-focus>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-input-number vn-one
|
||||
min="0"
|
||||
type="number"
|
||||
label="Packages received"
|
||||
ng-model="$ctrl.claim.packages">
|
||||
</vn-input-number>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textarea
|
||||
|
|
|
@ -5,4 +5,5 @@ Responsability: Responsabilidad
|
|||
Company: Empresa
|
||||
Sales/Client: Comercial/Cliente
|
||||
Pick up: Recoger
|
||||
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial
|
||||
Packages received: Bultos recibidos
|
|
@ -78,6 +78,11 @@
|
|||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-button
|
||||
label="Next"
|
||||
class="next"
|
||||
ui-sref="claim.card.photos">
|
||||
</vn-button>
|
||||
<vn-float-button
|
||||
icon="add"
|
||||
ng-if="$ctrl.isRewritable"
|
||||
|
|
|
@ -25,3 +25,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.next{
|
||||
float: right;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="id" shrink>
|
||||
<th field="clientFk" shrink>
|
||||
<span translate>Id</span>
|
||||
</th>
|
||||
<th field="clientFk">
|
||||
<th field="clientName">
|
||||
<span translate>Client</span>
|
||||
</th>
|
||||
<th field="created" center shrink-date>
|
||||
<span translate>Created</span>
|
||||
</th>
|
||||
<th field="salesPersonFk">
|
||||
<th field="workerFk">
|
||||
<span translate>Worker</span>
|
||||
</th>
|
||||
<th field="claimStateFk">
|
||||
|
@ -40,7 +40,7 @@
|
|||
<span
|
||||
vn-click-stop="clientDescriptor.show($event, claim.clientFk)"
|
||||
class="link">
|
||||
{{::claim.socialName}}
|
||||
{{::claim.clientName}}
|
||||
</span>
|
||||
</td>
|
||||
<td center shrink-date>{{::claim.created | date:'dd/MM/yyyy'}}</td>
|
||||
|
|
|
@ -11,11 +11,11 @@ class Controller extends Section {
|
|||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'clientFk',
|
||||
field: 'clientName',
|
||||
autocomplete: {
|
||||
url: 'Clients',
|
||||
showField: 'socialName',
|
||||
valueField: 'socialName'
|
||||
showField: 'name',
|
||||
valueField: 'name'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -46,21 +46,12 @@ class Controller extends Section {
|
|||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'clientName':
|
||||
return {'cl.clientName': {like: `%${value}%`}};
|
||||
case 'clientFk':
|
||||
return {['cl.socialName']: value};
|
||||
case 'id':
|
||||
case 'claimStateFk':
|
||||
case 'priority':
|
||||
case 'workerFk':
|
||||
return {[`cl.${param}`]: value};
|
||||
case 'salesPersonFk':
|
||||
case 'attenderFk':
|
||||
return {'cl.workerFk': value};
|
||||
case 'created':
|
||||
value.setHours(0, 0, 0, 0);
|
||||
to = new Date(value);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
return {'cl.created': {between: [value, to]}};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<vn-textfield
|
||||
vn-one
|
||||
label="Client"
|
||||
ng-model="filter.client">
|
||||
ng-model="filter.clientName">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('checkDuplicatedData', {
|
||||
description: 'Checks if a client has same email, mobile or phone than other client and send an email',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The client id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
verb: 'GET',
|
||||
path: '/:id/checkDuplicatedData'
|
||||
}
|
||||
});
|
||||
|
||||
Self.checkDuplicatedData = async function(id, options) {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const client = await Self.app.models.Client.findById(id, myOptions);
|
||||
|
||||
const emails = client.email ? client.email.split(',') : null;
|
||||
|
||||
const findParams = [];
|
||||
if (emails.length) {
|
||||
for (let email of emails)
|
||||
findParams.push({email: email});
|
||||
}
|
||||
|
||||
if (client.phone)
|
||||
findParams.push({phone: client.phone});
|
||||
|
||||
if (client.mobile)
|
||||
findParams.push({mobile: client.mobile});
|
||||
|
||||
const filterObj = {
|
||||
where: {
|
||||
and: [
|
||||
{or: findParams},
|
||||
{id: {neq: client.id}}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const clientSameData = await Self.findOne(filterObj, myOptions);
|
||||
|
||||
if (clientSameData) {
|
||||
await Self.app.models.Mail.create({
|
||||
receiver: 'direccioncomercial@verdnatura.es',
|
||||
subject: `Cliente con email/teléfono/móvil duplicados`,
|
||||
body: 'El cliente ' + client.id + ' comparte alguno de estos datos con el cliente ' + clientSameData.id +
|
||||
'\n- Email: ' + client.email +
|
||||
'\n- Teléfono: ' + client.phone +
|
||||
'\n- Móvil: ' + client.mobile
|
||||
}, myOptions);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client checkDuplicated()', () => {
|
||||
it('should send an mail if mobile/phone/email is duplicated', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const id = 1110;
|
||||
const mailModel = models.Mail;
|
||||
spyOn(mailModel, 'create');
|
||||
|
||||
await models.Client.checkDuplicatedData(id, options);
|
||||
|
||||
expect(mailModel.create).toHaveBeenCalled();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,7 +1,6 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
// #3673 sendSms tests excluded
|
||||
xdescribe('client sendSms()', () => {
|
||||
describe('client sendSms()', () => {
|
||||
it('should now send a message and log it', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
|
|
|
@ -6,6 +6,12 @@ describe('Address updateAddress', () => {
|
|||
const provinceId = 5;
|
||||
const incotermsId = 'FAS';
|
||||
const customAgentOneId = 1;
|
||||
const employeeId = 1;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: employeeId}
|
||||
}
|
||||
};
|
||||
|
||||
it('should throw the non uee member error if no incoterms is defined', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
@ -14,11 +20,9 @@ describe('Address updateAddress', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {
|
||||
args: {
|
||||
provinceFk: provinceId,
|
||||
customsAgentFk: customAgentOneId
|
||||
}
|
||||
ctx.args = {
|
||||
provinceFk: provinceId,
|
||||
customsAgentFk: customAgentOneId
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
|
@ -40,11 +44,9 @@ describe('Address updateAddress', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {
|
||||
args: {
|
||||
provinceFk: provinceId,
|
||||
incotermsFk: incotermsId
|
||||
}
|
||||
ctx.args = {
|
||||
provinceFk: provinceId,
|
||||
incotermsFk: incotermsId
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
|
@ -66,13 +68,11 @@ describe('Address updateAddress', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 'My edited address';
|
||||
const ctx = {
|
||||
args: {
|
||||
provinceFk: provinceId,
|
||||
nickname: expectedResult,
|
||||
incotermsFk: incotermsId,
|
||||
customsAgentFk: customAgentOneId
|
||||
}
|
||||
ctx.args = {
|
||||
provinceFk: provinceId,
|
||||
nickname: expectedResult,
|
||||
incotermsFk: incotermsId,
|
||||
customsAgentFk: customAgentOneId
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
|
@ -88,6 +88,48 @@ describe('Address updateAddress', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should return an error for a user without enough privileges', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.args = {
|
||||
isLogifloraAllowed: true
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(`You don't have enough privileges`);
|
||||
});
|
||||
|
||||
it('should update isLogifloraAllowed', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
const salesAssistantId = 21;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.req.accessToken.userId = salesAssistantId;
|
||||
ctx.args = {
|
||||
isLogifloraAllowed: true
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
const address = await models.Address.findById(addressId, null, options);
|
||||
|
||||
expect(address.isLogifloraAllowed).toEqual(true);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should update the address', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
|
@ -95,10 +137,8 @@ describe('Address updateAddress', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 'My second time edited address';
|
||||
const ctx = {
|
||||
args: {
|
||||
nickname: expectedResult
|
||||
}
|
||||
ctx.args = {
|
||||
nickname: expectedResult
|
||||
};
|
||||
|
||||
await models.Client.updateAddress(ctx, clientId, addressId, options);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
xdescribe('Client updatePortfolio', () => {
|
||||
const salesPersonId = 18;
|
||||
describe('Client updatePortfolio', () => {
|
||||
const clientId = 1108;
|
||||
it('should update the portfolioWeight', async() => {
|
||||
it('should update the portfolioWeight when the salesPerson of a client changes', async() => {
|
||||
const salesPersonId = 18;
|
||||
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -15,9 +16,33 @@ xdescribe('Client updatePortfolio', () => {
|
|||
|
||||
await models.Client.updatePortfolio();
|
||||
|
||||
let [vendedores] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.vendedores WHERE Id_Trabajador = ${salesPersonId}; `, null, options);
|
||||
let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
|
||||
|
||||
expect(vendedores.portfolioWeight).toEqual(expectedResult);
|
||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
// task 3817
|
||||
xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => {
|
||||
const salesPersonId = 19;
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const expectedResult = 34.40;
|
||||
|
||||
await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = NULL WHERE id = ${clientId}; `);
|
||||
|
||||
await models.Client.updatePortfolio();
|
||||
|
||||
let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options);
|
||||
|
||||
expect(salesPerson.portfolioWeight).toEqual(expectedResult);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -68,6 +68,10 @@ module.exports = function(Self) {
|
|||
{
|
||||
arg: 'isEqualizated',
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
arg: 'isLogifloraAllowed',
|
||||
type: 'boolean'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -83,11 +87,16 @@ module.exports = function(Self) {
|
|||
Self.updateAddress = async(ctx, clientId, addressId, options) => {
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
const isSalesAssistant = await models.Account.hasRole(userId, 'salesAssistant', myOptions);
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (args.isLogifloraAllowed && !isSalesAssistant)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
const address = await models.Address.findOne({
|
||||
where: {
|
||||
id: addressId,
|
||||
|
|
|
@ -56,7 +56,7 @@ module.exports = Self => {
|
|||
FROM (
|
||||
SELECT
|
||||
DISTINCT c.id clientFk,
|
||||
c.socialName clientName,
|
||||
c.name clientName,
|
||||
c.salesPersonFk,
|
||||
u.nickname salesPersonName,
|
||||
d.amount,
|
||||
|
|
|
@ -47,12 +47,12 @@ describe('defaulter filter()', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'spider'}};
|
||||
const ctx = {req: {accessToken: {userId: authUserId}}, args: {search: 'Petter Parker'}};
|
||||
|
||||
const result = await models.Defaulter.filter(ctx, null, options);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(firstRow.clientName).toEqual('Spider man');
|
||||
expect(firstRow.clientName).toEqual('Petter Parker');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
// #3673 sendSms tests excluded
|
||||
xdescribe('sms send()', () => {
|
||||
describe('sms send()', () => {
|
||||
it('should not return status error', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1}}};
|
||||
const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body');
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
},
|
||||
"isEqualizated": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isLogifloraAllowed": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"validations": [],
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports = Self => {
|
|||
require('../methods/client/consumption')(Self);
|
||||
require('../methods/client/createReceipt')(Self);
|
||||
require('../methods/client/updatePortfolio')(Self);
|
||||
require('../methods/client/checkDuplicated')(Self);
|
||||
|
||||
// Validations
|
||||
|
||||
|
|
|
@ -38,7 +38,13 @@
|
|||
label="Is equalizated"
|
||||
ng-model="$ctrl.address.isEqualizated"
|
||||
vn-acl="administrative, salesAssistant">
|
||||
</vn-check>
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
label="Is Logiflora allowed"
|
||||
ng-model="$ctrl.address.isLogifloraAllowed"
|
||||
vn-acl="salesAssistant">
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue