exportDB step 3

This commit is contained in:
Bernat 2019-01-11 12:25:53 +01:00
parent 07637da5d5
commit f678bfea37
14 changed files with 83 additions and 156 deletions

View File

@ -339,7 +339,7 @@ export default {
firstSaleDiscountInput: 'vn-ticket-sale:nth-child(1) vn-ticket-sale-edit-discount > div > vn-textfield > div > div > div.infix > input.ng-not-empty',
firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(9)',
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-td:nth-child(5) section:nth-child(5)`,
firstSaleColour: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(1)`,
firstSaleLength: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(3)`,
firstSaleCheckbox: `vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"] label`,
secondSaleClaimId: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(2) > a > vn-icon',

View File

@ -9,10 +9,10 @@ describe('Item summary path', () => {
.loginAndModule('employee', 'item');
});
it('should search for the item Gem of Time', async () => {
it('should search for an item', async() => {
const result = await nightmare
.wait(selectors.itemsIndex.searchItemInput)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.type(selectors.itemsIndex.searchItemInput, 'Object1 Gem1 5')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
@ -22,7 +22,7 @@ describe('Item summary path', () => {
it(`should click on the search result summary button to open the item summary popup`, async() => {
const isVisibleBefore = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Object1 Gem1 5')
.isVisible(selectors.itemSummary.basicData);
const isVisibleAfter = await nightmare
@ -35,10 +35,10 @@ describe('Item summary path', () => {
it(`should check the item summary preview shows fields from basic data`, async() => {
const result = await nightmare
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Time')
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Object1 Gem1 5')
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Name: Gem of Time');
expect(result).toContain('Name: Object1 Gem1 5');
});
it(`should check the item summary preview shows fields from tags`, async() => {
@ -81,11 +81,11 @@ describe('Item summary path', () => {
expect(result).toBeFalsy();
});
it('should search for the item Gem of Mind', async () => {
it('should search for other item', async() => {
const result = await nightmare
.clearInput('body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-index > div > div > vn-card:nth-child(1) > div > vn-searchbar > form > vn-horizontal > vn-textfield > div > div > div.infix > input')
.click(selectors.itemsIndex.searchButton)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Mind')
.type(selectors.itemsIndex.searchItemInput, 'Object2 Gem2 3')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
@ -95,7 +95,7 @@ describe('Item summary path', () => {
it(`should now click on the search result summary button to open the item summary popup`, async() => {
const isVisibleBefore = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind')
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Object2 Gem2 3')
.isVisible(selectors.itemSummary.basicData);
const isVisibleAfter = await nightmare
@ -109,10 +109,10 @@ describe('Item summary path', () => {
it(`should now check the item summary preview shows fields from basic data`, async() => {
const result = await nightmare
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind')
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Object2 Gem2 3')
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Name: Gem of Mind');
expect(result).toContain('Name: Object2 Gem2 3');
});
it(`should now check the item summary preview shows fields from tags`, async() => {
@ -166,10 +166,10 @@ describe('Item summary path', () => {
it(`should check the item summary shows fields from basic data section`, async() => {
const result = await nightmare
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Gem of Mind')
.waitForTextInElement(selectors.itemSummary.basicData, 'Name: Object2 Gem2 3')
.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Name: Gem of Mind');
expect(result).toContain('Name: Object2 Gem2 3');
});
it(`should check the item summary shows fields from tags section`, async() => {

View File

@ -72,7 +72,7 @@ describe('Ticket Edit basic data path', () => {
const result = await nightmare
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
expect(result).toContain('-20.65 €');
expect(result).toContain('-12.25 €');
});
it(`should then click next to move on to step three`, async() => {

View File

@ -12,12 +12,12 @@ module.exports = function(Self) {
Self.super_.setup.call(this);
// Register field ACL validation
this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx));
/* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx));
this.beforeRemote('updateAll', ctx => this.checkUpdateAcls(ctx));
this.beforeRemote('patchOrCreate', ctx => this.checkInsertAcls(ctx));
this.beforeRemote('create', ctx => this.checkInsertAcls(ctx));
this.beforeRemote('replaceById', ctx => this.checkInsertAcls(ctx));
this.beforeRemote('replaceOrCreate', ctx => this.checkInsertAcls(ctx));
this.beforeRemote('replaceOrCreate', ctx => this.checkInsertAcls(ctx)); */
this.remoteMethod('crud', {
description: `Create, update or/and delete instances from model with a single request`,

View File

@ -7,6 +7,6 @@ describe('Client card', () => {
expect(result.id).toEqual(101);
expect(result.name).toEqual('Bruce Wayne');
expect(result.debt).toEqual(79.1);
expect(result.debt).toEqual(579.1);
});
});

View File

@ -17,7 +17,7 @@ describe('client summary()', () => {
it('should return a summary object containing debt', async() => {
let result = await app.models.Client.summary(101);
expect(result.debt.debt).toEqual(79.1);
expect(result.debt.debt).toEqual(579.1);
});
it('should return a summary object containing averageInvoiced', async() => {

View File

@ -14,7 +14,7 @@ describe('order catalogFilter()', () => {
let firstItemId = result[0].id;
expect(result.length).toEqual(2);
expect(firstItemId).toEqual(1);
expect(firstItemId).toEqual(2);
});
it('should return an array of items based on tag filter', async() => {

View File

@ -4,7 +4,7 @@ describe('order getTotalVolume()', () => {
it('should return the total', async() => {
let result = await app.models.Order.getTotalVolume(1);
expect(result.totalVolume).toEqual(0.078);
expect(result.totalVolume).toEqual(0.066);
expect(result.totalBoxes).toBeFalsy();
});
});

View File

@ -11,7 +11,7 @@ describe('sale priceDifference()', () => {
let result = await app.models.Sale.priceDifference(1, data);
expect(result.totalUnitPrice).toEqual(22.33);
expect(result.totalNewPrice).toEqual(22.33);
expect(result.totalDifference).toEqual(0);
expect(result.totalNewPrice).toEqual(22.29);
expect(result.totalDifference).toEqual(0.8);
});
});

View File

@ -4,7 +4,7 @@ describe('ticket getTotalVolume()', () => {
it('should return the total volume of a ticket', async() => {
let ticketFk = 1;
let expectedResult = 0.078;
let expectedResult = 0.066;
let result = await app.models.Ticket.getTotalVolume(ticketFk);

View File

@ -1,88 +0,0 @@
USE `vn`;
DROP procedure IF EXISTS `ticketCalculateClon`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT)
BEGIN
/*
* @vTicketNew id del nuevo ticket clonado
* @vTicketOld id ticket original, a partir del qual se clonara el nuevo
* Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo
*/
DECLARE vShipped DATE;
DECLARE vClient INT;
DECLARE vWarehouse SMALLINT;
DECLARE vAgencyMode INT;
DECLARE vAddress INT;
DECLARE vLanded DATE;
DECLARE vAgency INT;
INSERT INTO orderTicket(orderFk,ticketFk)
SELECT orderFk, vTicketNew
FROM orderTicket
WHERE ticketFk = vTicketOld;
SELECT t.clientFk , t.warehouseFk, date(t.shipped), t.addressFk, t.agencyModeFk, t.landed, a.agencyFk
INTO vClient, vWarehouse, vShipped, vAddress, vAgencyMode, vLanded, vAgency
FROM vn.agencyMode a
JOIN vn.ticket t ON t.agencyModeFk = a.id
WHERE t.id = vTicketNew;
DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped;
CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ENGINE = MEMORY
SELECT vWarehouse warehouseFk, vShipped shipped, vLanded landed;
CALL buyUltimate(vWarehouse, vShipped); -- rellena la tabla tmp.buyUltimate con la ultima compra
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot
SELECT vWarehouse warehouseFk,NULL available,s.itemFk, bu.buyFk
FROM sale s
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
WHERE s.ticketFk = vTicketOld GROUP BY s.itemFk;
CALL ticketComponentCalculate(vAddress,vAgencyMode);
-- Bionizamos lineas con Preu = 0
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouse warehouseFk
FROM sale s
JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew AND s.price = 0;
CALL ticketComponentUpdateSale(1);
-- Bionizamos lineas con Preu > 0
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk)) ENGINE = MEMORY
SELECT s.id saleFk, vWarehouse warehouseFk
FROM sale s
JOIN ticket t on t.id = s.ticketFk WHERE s.ticketFk = vTicketNew
AND s.price > 0;
CALL ticketComponentUpdateSale(6);
IF vLanded IS NULL THEN
CALL agencyHourGetLanded(vShipped, vAddress, vAgency,vWarehouse);
UPDATE ticket t
JOIN tmp.agencyHourGetLanded ah ON t.warehouseFk = ah.warehouseFk
SET t.landed = ah.landed
WHERE t.id = vTicketNew;
END IF;
-- Log
CALL `logAdd`(vTicketNew, 'update', ' ticket' , 'Bioniza Ticket');
-- Limpieza
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate;
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
DROP TEMPORARY TABLE IF EXISTS agencyHourGetShipped;
END$$
DELIMITER ;

View File

@ -15,3 +15,18 @@ INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `prin
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES('ClientObservation', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
INSERT INTO `salix`.`ACL`(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES('ItemTag', '*', 'WRITE', 'ALLOW', 'ROLE', 'marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `salix`.`ACL`(`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss');
INSERT INTO `ACLCopia` (`id`,`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES (59,'CreditInsurance','*','READ','ALLOW','ROLE','employee');
DELETE FROM `salix`.`ACL` WHERE `id`='67';
DELETE FROM `salix`.`ACL` WHERE `id`='74';
DELETE FROM `salix`.`ACL` WHERE `id`='92';
DELETE FROM `salix`.`ACL` WHERE `id`='93';
DELETE FROM `salix`.`ACL` WHERE `id`='95';

View File

@ -9,7 +9,7 @@ let verbose = false;
if (process.argv[2] === '--v')
verbose = true;
serviceRoot = __dirname;
loopbackApp = `vn-loopback/server/server`;
let Jasmine = require('jasmine');
let jasmine = new Jasmine();