7299_testToMaster #2411
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
||||||
path: `/:id/downloadFile`,
|
path: `/:id/downloadFile`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadFile = async function(ctx, id) {
|
Self.downloadFile = async function(ctx, id) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
||||||
path: `/:id/download`,
|
path: `/:id/download`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.download = async function(id, fileCabinet, filter) {
|
Self.download = async function(id, fileCabinet, filter) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
||||||
path: `/:collection/:size/:id/download`,
|
path: `/:collection/:size/:id/download`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.download = async function(ctx, collection, size, id) {
|
Self.download = async function(ctx, collection, size, id) {
|
||||||
|
|
|
@ -33,16 +33,23 @@ module.exports = Self => {
|
||||||
// Schedule to remove current token
|
// Schedule to remove current token
|
||||||
setTimeout(async() => {
|
setTimeout(async() => {
|
||||||
try {
|
try {
|
||||||
await Self.logout(token.id);
|
const exists = await models.AccessToken.findById(token.id);
|
||||||
|
exists && await Self.logout(token.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}, courtesyTime * 1000);
|
}, courtesyTime * 1000);
|
||||||
|
|
||||||
|
// Get scopes
|
||||||
|
|
||||||
|
let createTokenOptions = {};
|
||||||
|
const {scopes} = token;
|
||||||
|
if (scopes)
|
||||||
|
createTokenOptions = {scopes: [scopes[0]]};
|
||||||
// Create new accessToken
|
// Create new accessToken
|
||||||
const user = await Self.findById(token.userId);
|
const user = await Self.findById(token.userId);
|
||||||
const accessToken = await user.createAccessToken();
|
const accessToken = await user.accessTokens.create(createTokenOptions);
|
||||||
|
|
||||||
return {id: accessToken.id, ttl: accessToken.ttl};
|
return {id: accessToken.id, ttl: accessToken.ttl};
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,17 @@ describe('Renew Token', () => {
|
||||||
const {id} = await models.VnUser.renewToken(ctx);
|
const {id} = await models.VnUser.renewToken(ctx);
|
||||||
|
|
||||||
expect(id).not.toEqual(ctx.req.accessToken.id);
|
expect(id).not.toEqual(ctx.req.accessToken.id);
|
||||||
|
|
||||||
|
await models.VnUser.logout(ctx.req.accessToken.id);
|
||||||
|
jasmine.clock().tick(70 * 1000);
|
||||||
|
let tokenNotExists;
|
||||||
|
try {
|
||||||
|
tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id);
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(tokenNotExists).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('NOT should renew', async() => {
|
it('NOT should renew', async() => {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
const TOKEN_MULTIMEDIA = 'read:multimedia';
|
||||||
describe('Share Token', () => {
|
describe('Share Token', () => {
|
||||||
let ctx = null;
|
let ctx = null;
|
||||||
|
const startingTime = Date.now();
|
||||||
|
let multimediaToken = null;
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
const unAuthCtx = {
|
const unAuthCtx = {
|
||||||
req: {
|
req: {
|
||||||
|
@ -17,11 +20,45 @@ describe('Share Token', () => {
|
||||||
ctx = {req: {accessToken: accessToken}};
|
ctx = {req: {accessToken: accessToken}};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should renew token', async() => {
|
beforeEach(async() => {
|
||||||
const multimediaToken = await models.VnUser.shareToken(ctx);
|
multimediaToken = await models.VnUser.shareToken(ctx);
|
||||||
|
jasmine.clock().install();
|
||||||
|
jasmine.clock().mockDate(new Date(startingTime));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.clock().uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should generate token', async() => {
|
||||||
expect(Object.keys(multimediaToken).length).toEqual(1);
|
expect(Object.keys(multimediaToken).length).toEqual(1);
|
||||||
expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId);
|
expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId);
|
||||||
expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia');
|
expect(multimediaToken.multimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('NOT should renew', async() => {
|
||||||
|
let error;
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
response = await models.VnUser.renewToken(ctx);
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toBeUndefined();
|
||||||
|
expect(response.id).toEqual(ctx.req.accessToken.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should renew token', async() => {
|
||||||
|
const mockDate = new Date(startingTime + 26600000);
|
||||||
|
jasmine.clock().mockDate(mockDate);
|
||||||
|
|
||||||
|
const newShareToken = await models.VnUser.renewToken({req: {accessToken: multimediaToken.multimediaToken}});
|
||||||
|
const {id} = newShareToken;
|
||||||
|
|
||||||
|
expect(id).not.toEqual(ctx.req.accessToken.id);
|
||||||
|
const newMultimediaToken = await models.AccessToken.findById(id);
|
||||||
|
|
||||||
|
expect(newMultimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1492,21 +1492,21 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF
|
||||||
|
|
||||||
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
||||||
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
||||||
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
|
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()),
|
||||||
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
(8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()),
|
||||||
(9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
(9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
|
(10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
(11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
|
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
|
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()),
|
||||||
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
|
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE());
|
||||||
|
|
||||||
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
|
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2551,15 +2551,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
|
||||||
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
||||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1),
|
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1),
|
||||||
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
|
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
|
||||||
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
|
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
|
||||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1),
|
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1),
|
||||||
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
|
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
|
||||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
|
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1),
|
||||||
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
|
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1),
|
||||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
|
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
|
||||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
|
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
|
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2614,6 +2614,10 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo
|
||||||
(2, 13.20, 5080000, 15.00, 580, 5),
|
(2, 13.20, 5080000, 15.00, 580, 5),
|
||||||
(2, 16.10, 6021010, 25.00, 80, 5);
|
(2, 16.10, 6021010, 25.00, 80, 5);
|
||||||
|
|
||||||
|
UPDATE `vn`.`invoiceIn`
|
||||||
|
SET isBooked = TRUE
|
||||||
|
WHERE id IN (2, 5, 7, 8, 9, 10);
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE `tmp`.`ticket_recalc`()
|
CREATE PROCEDURE `tmp`.`ticket_recalc`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -3251,7 +3255,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 20,
|
packing = 20,
|
||||||
`grouping` = 1,
|
`grouping` = 1,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3289,7 +3293,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 40,
|
packing = 40,
|
||||||
`grouping` = 5,
|
`grouping` = 5,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3327,7 +3331,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 2,
|
stickers = 2,
|
||||||
packing = 10,
|
packing = 10,
|
||||||
`grouping` = 5,
|
`grouping` = 5,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3373,7 +3377,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 20,
|
packing = 20,
|
||||||
`grouping` = 4,
|
`grouping` = 4,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3411,7 +3415,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 20,
|
packing = 20,
|
||||||
`grouping` = 1,
|
`grouping` = 1,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3450,7 +3454,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 200,
|
packing = 200,
|
||||||
`grouping` = 30,
|
`grouping` = 30,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3489,7 +3493,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 500,
|
packing = 500,
|
||||||
`grouping` = 10,
|
`grouping` = 10,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3528,7 +3532,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 2,
|
stickers = 2,
|
||||||
packing = 300,
|
packing = 300,
|
||||||
`grouping` = 50,
|
`grouping` = 50,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3567,7 +3571,7 @@ INSERT INTO vn.buy
|
||||||
stickers = 2,
|
stickers = 2,
|
||||||
packing = 50,
|
packing = 50,
|
||||||
`grouping` = 5,
|
`grouping` = 5,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 1,
|
price1 = 1,
|
||||||
price2 = 1,
|
price2 = 1,
|
||||||
price3 = 1,
|
price3 = 1,
|
||||||
|
@ -3607,7 +3611,7 @@ INSERT vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 5,
|
packing = 5,
|
||||||
`grouping` = 2,
|
`grouping` = 2,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 7,
|
price1 = 7,
|
||||||
price2 = 7,
|
price2 = 7,
|
||||||
price3 = 7,
|
price3 = 7,
|
||||||
|
@ -3646,7 +3650,7 @@ INSERT vn.buy
|
||||||
stickers = 1,
|
stickers = 1,
|
||||||
packing = 100,
|
packing = 100,
|
||||||
`grouping` = 5,
|
`grouping` = 5,
|
||||||
groupingMode = 1,
|
groupingMode = 'packing',
|
||||||
price1 = 7,
|
price1 = 7,
|
||||||
price2 = 7,
|
price2 = 7,
|
||||||
price3 = 7,
|
price3 = 7,
|
||||||
|
|
|
@ -14,7 +14,6 @@ proc:BEGIN
|
||||||
DECLARE vPackage INT;
|
DECLARE vPackage INT;
|
||||||
DECLARE vPutOrderFk INT;
|
DECLARE vPutOrderFk INT;
|
||||||
DECLARE vIsLot BOOLEAN;
|
DECLARE vIsLot BOOLEAN;
|
||||||
DECLARE vForceToPacking INT DEFAULT 2;
|
|
||||||
DECLARE vEntryFk INT;
|
DECLARE vEntryFk INT;
|
||||||
DECLARE vHasToChangePackagingFk BOOLEAN;
|
DECLARE vHasToChangePackagingFk BOOLEAN;
|
||||||
DECLARE vIsFloramondoDirect BOOLEAN;
|
DECLARE vIsFloramondoDirect BOOLEAN;
|
||||||
|
@ -147,10 +146,10 @@ proc:BEGIN
|
||||||
(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue,
|
(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue,
|
||||||
IFNULL(vItem, vDefaultEntry) itemFk,
|
IFNULL(vItem, vDefaultEntry) itemFk,
|
||||||
e.qty stickers,
|
e.qty stickers,
|
||||||
@pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing,
|
@pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing,
|
||||||
IFNULL(b.`grouping`, e.pac),
|
IFNULL(b.`grouping`, e.pac),
|
||||||
@pac * e.qty,
|
@pac * e.qty,
|
||||||
vForceToPacking,
|
'packing',
|
||||||
IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk),
|
IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk),
|
||||||
(IFNULL(i.weightByPiece, 0) * @pac) / 1000
|
(IFNULL(i.weightByPiece, 0) * @pac) / 1000
|
||||||
FROM ekt e
|
FROM ekt e
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`()
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
DECLARE vLanded DATETIME;
|
DECLARE vLanded DATETIME;
|
||||||
DECLARE vDone INT DEFAULT FALSE;
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
|
@ -417,7 +417,7 @@ proc: BEGIN
|
||||||
o.NumberOfUnits etiquetas,
|
o.NumberOfUnits etiquetas,
|
||||||
o.NumberOfItemsPerCask packing,
|
o.NumberOfItemsPerCask packing,
|
||||||
GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`,
|
GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`,
|
||||||
2, -- Obliga al Packing
|
'packing',
|
||||||
o.embalageCode,
|
o.embalageCode,
|
||||||
o.diId
|
o.diId
|
||||||
FROM edi.offer o
|
FROM edi.offer o
|
||||||
|
@ -518,5 +518,5 @@ proc: BEGIN
|
||||||
fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime);
|
fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime);
|
||||||
|
|
||||||
DO RELEASE_LOCK('edi.floramondo_offerRefresh');
|
DO RELEASE_LOCK('edi.floramondo_offerRefresh');
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Returns one recordset from catalogue
|
||||||
|
*
|
||||||
|
* @param vCatalogueFk Identifier de floranet.catalogue
|
||||||
|
*/
|
||||||
|
SELECT * FROM catalogue WHERE id = vSelf;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,41 +1,21 @@
|
||||||
DROP PROCEDURE IF EXISTS floranet.order_put;
|
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON)
|
||||||
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON)
|
|
||||||
READS SQL DATA
|
READS SQL DATA
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Get and process an order.
|
* Get and process an order.
|
||||||
*
|
*
|
||||||
* @param vOrder Data of the order
|
* @param vJsonData The order data in json format
|
||||||
*
|
|
||||||
* Customer data: <customerName>, <email>, <customerPhone>
|
|
||||||
*
|
|
||||||
* Item data: <catalogueFk>, <message>
|
|
||||||
*
|
|
||||||
* Delivery data: <deliveryName>, <address>, <deliveryPhone>
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
INSERT IGNORE INTO `order`(
|
INSERT INTO `order`
|
||||||
catalogueFk,
|
SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')),
|
||||||
customerName,
|
customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')),
|
||||||
email,
|
email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')),
|
||||||
customerPhone,
|
customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')),
|
||||||
message,
|
message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')),
|
||||||
deliveryName,
|
deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')),
|
||||||
address,
|
address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')),
|
||||||
deliveryPhone
|
deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone'));
|
||||||
)
|
|
||||||
VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')),
|
|
||||||
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone'))
|
|
||||||
);
|
|
||||||
|
|
||||||
SELECT LAST_INSERT_ID() orderFk;
|
SELECT LAST_INSERT_ID() orderFk;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -6,16 +6,24 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
|
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
|
||||||
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
|
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
|
||||||
|
DECLARE vLogExists BOOL;
|
||||||
|
|
||||||
SET sql_log_bin = OFF;
|
SET sql_log_bin = OFF;
|
||||||
SET GLOBAL slow_query_log = OFF;
|
SET GLOBAL slow_query_log = OFF;
|
||||||
|
|
||||||
RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
|
SELECT COUNT(*) > 0 INTO vLogExists
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log';
|
||||||
|
|
||||||
DELETE FROM `mysql`.`slow_log_temp`
|
IF vLogExists THEN
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp;
|
||||||
|
RENAME TABLE mysql.slow_log TO mysql.slow_log_temp;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DELETE FROM mysql.slow_log_temp
|
||||||
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
|
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
|
||||||
|
|
||||||
RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`;
|
RENAME TABLE mysql.slow_log_temp TO mysql.slow_log;
|
||||||
|
|
||||||
SET GLOBAL slow_query_log = vSlowQueryLog;
|
SET GLOBAL slow_query_log = vSlowQueryLog;
|
||||||
SET sql_log_bin = vSqlLogBin;
|
SET sql_log_bin = vSqlLogBin;
|
||||||
|
|
|
@ -48,7 +48,7 @@ BEGIN
|
||||||
IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3,
|
IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3,
|
||||||
IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
|
IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing,
|
||||||
IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
|
IFNULL(pf.`grouping`, b.`grouping`) `grouping`,
|
||||||
ABS(IFNULL(pf.box, b.groupingMode)) groupingMode,
|
b.groupingMode groupingMode,
|
||||||
tl.buyFk,
|
tl.buyFk,
|
||||||
i.typeFk,
|
i.typeFk,
|
||||||
IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
|
IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping
|
||||||
|
@ -252,14 +252,15 @@ BEGIN
|
||||||
SELECT tcc.warehouseFk,
|
SELECT tcc.warehouseFk,
|
||||||
tcc.itemFk,
|
tcc.itemFk,
|
||||||
1 rate,
|
1 rate,
|
||||||
IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`,
|
IF(tcc.groupingMode = 'grouping', tcc.`grouping`, 1) `grouping`,
|
||||||
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price,
|
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price,
|
||||||
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg
|
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg
|
||||||
FROM tmp.ticketComponentCalculate tcc
|
FROM tmp.ticketComponentCalculate tcc
|
||||||
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
|
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
|
||||||
AND tcs.warehouseFk = tcc.warehouseFk
|
AND tcs.warehouseFk = tcc.warehouseFk
|
||||||
WHERE IFNULL(tcs.classRate, 1) = 1
|
WHERE IFNULL(tcs.classRate, 1) = 1
|
||||||
AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0)
|
AND NOT tcc.groupingMode = 'packing'
|
||||||
|
AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL)
|
||||||
GROUP BY tcs.warehouseFk, tcs.itemFk;
|
GROUP BY tcs.warehouseFk, tcs.itemFk;
|
||||||
|
|
||||||
INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
|
INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
|
||||||
|
|
|
@ -40,8 +40,8 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT b.itemFk,
|
SELECT b.itemFk,
|
||||||
CASE b.groupingMode
|
CASE b.groupingMode
|
||||||
WHEN 0 THEN 1
|
WHEN NULL THEN 1
|
||||||
WHEN 2 THEN b.packing
|
WHEN 'packing' THEN b.packing
|
||||||
ELSE b.`grouping`
|
ELSE b.`grouping`
|
||||||
END `grouping`
|
END `grouping`
|
||||||
FROM buy b
|
FROM buy b
|
||||||
|
|
|
@ -7,195 +7,195 @@ BEGIN
|
||||||
* @param vSelf company id
|
* @param vSelf company id
|
||||||
* @param vMonthAgo time interval to be consulted
|
* @param vMonthAgo time interval to be consulted
|
||||||
*/
|
*/
|
||||||
DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE());
|
DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE());
|
||||||
DECLARE vCurrencyEuroFk INT;
|
DECLARE vCurrencyEuroFk INT;
|
||||||
DECLARE vStartDate DATE;
|
DECLARE vStartDate DATE;
|
||||||
DECLARE vInvalidBalances DOUBLE;
|
DECLARE vInvalidBalances DOUBLE;
|
||||||
|
|
||||||
SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig;
|
SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig;
|
||||||
SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR';
|
SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR';
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tOpeningBalances;
|
DROP TEMPORARY TABLE IF EXISTS tOpeningBalances;
|
||||||
CREATE TEMPORARY TABLE tOpeningBalances (
|
CREATE TEMPORARY TABLE tOpeningBalances (
|
||||||
supplierFk INT NOT NULL,
|
supplierFk INT NOT NULL,
|
||||||
companyFk INT NOT NULL,
|
companyFk INT NOT NULL,
|
||||||
openingBalances DOUBLE NOT NULL,
|
openingBalances DOUBLE NOT NULL,
|
||||||
closingBalances DOUBLE NOT NULL,
|
closingBalances DOUBLE NOT NULL,
|
||||||
currencyFk INT NOT NULL,
|
currencyFk INT NOT NULL,
|
||||||
PRIMARY KEY (supplierFk, companyFk, currencyFk)
|
PRIMARY KEY (supplierFk, companyFk, currencyFk)
|
||||||
) ENGINE = MEMORY;
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
-- Calculates the opening and closing balance for each supplier
|
-- Calculates the opening and closing balance for each supplier
|
||||||
INSERT INTO tOpeningBalances
|
INSERT INTO tOpeningBalances
|
||||||
SELECT supplierFk,
|
SELECT supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
SUM(amount * isBeforeStarting) AS openingBalances,
|
SUM(amount * isBeforeStarting) AS openingBalances,
|
||||||
SUM(amount) closingBalances,
|
SUM(amount) closingBalances,
|
||||||
currencyFk
|
currencyFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT p.supplierFk,
|
SELECT p.supplierFk,
|
||||||
p.companyFk,
|
p.companyFk,
|
||||||
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
|
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
|
||||||
p.dueDated < vStartingDate isBeforeStarting,
|
p.dueDated < vStartingDate isBeforeStarting,
|
||||||
p.currencyFk
|
p.currencyFk
|
||||||
FROM payment p
|
FROM payment p
|
||||||
WHERE p.received > vStartDate
|
WHERE p.received > vStartDate
|
||||||
AND p.companyFk = vSelf
|
AND p.companyFk = vSelf
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.supplierFk,
|
SELECT r.supplierFk,
|
||||||
r.companyFk,
|
r.companyFk,
|
||||||
- IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
|
- IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
|
||||||
rv.dueDated < vStartingDate isBeforeStarting,
|
rv.dueDated < vStartingDate isBeforeStarting,
|
||||||
r.currencyFk
|
r.currencyFk
|
||||||
FROM invoiceIn r
|
FROM invoiceIn r
|
||||||
INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
||||||
WHERE r.issued > vStartDate
|
WHERE r.issued > vStartDate
|
||||||
AND r.isBooked
|
AND r.isBooked
|
||||||
AND r.companyFk = vSelf
|
AND r.companyFk = vSelf
|
||||||
) sub GROUP BY companyFk, supplierFk, currencyFk;
|
) sub GROUP BY companyFk, supplierFk, currencyFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
|
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
|
||||||
CREATE TEMPORARY TABLE tPendingDuedates (
|
CREATE TEMPORARY TABLE tPendingDuedates (
|
||||||
id INT auto_increment,
|
id INT auto_increment,
|
||||||
expirationId INT,
|
expirationId INT,
|
||||||
dated DATE,
|
dated DATE,
|
||||||
supplierFk INT NOT NULL,
|
supplierFk INT NOT NULL,
|
||||||
companyFk INT NOT NULL,
|
companyFk INT NOT NULL,
|
||||||
amount DECIMAL(10, 2) NOT NULL,
|
amount DECIMAL(10, 2) NOT NULL,
|
||||||
currencyFk INT NOT NULL,
|
currencyFk INT NOT NULL,
|
||||||
pending DECIMAL(10, 2) DEFAULT 0,
|
pending DECIMAL(10, 2) DEFAULT 0,
|
||||||
balance DECIMAL(10, 2) DEFAULT 0,
|
balance DECIMAL(10, 2) DEFAULT 0,
|
||||||
endingBalance DECIMAL(10, 2) DEFAULT 0,
|
endingBalance DECIMAL(10, 2) DEFAULT 0,
|
||||||
isPayment BOOLEAN,
|
isPayment BOOLEAN,
|
||||||
isReconciled BOOLEAN,
|
isReconciled BOOLEAN,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
INDEX (supplierFk, companyFk, currencyFk)
|
INDEX (supplierFk, companyFk, currencyFk)
|
||||||
) ENGINE = MEMORY;
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
INSERT INTO tPendingDuedates (
|
INSERT INTO tPendingDuedates (
|
||||||
expirationId,
|
expirationId,
|
||||||
dated,
|
dated,
|
||||||
supplierFk,
|
supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
amount,
|
amount,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
isPayment,
|
isPayment,
|
||||||
isReconciled
|
isReconciled
|
||||||
)SELECT p.id,
|
)SELECT p.id,
|
||||||
p.dueDated,
|
p.dueDated,
|
||||||
p.supplierFk,
|
p.supplierFk,
|
||||||
p.companyFk,
|
p.companyFk,
|
||||||
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
|
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa),
|
||||||
p.currencyFk,
|
p.currencyFk,
|
||||||
TRUE isPayment,
|
TRUE isPayment,
|
||||||
p.isConciliated
|
p.isConciliated
|
||||||
FROM payment p
|
FROM payment p
|
||||||
WHERE p.dueDated >= vStartingDate
|
WHERE p.dueDated >= vStartingDate
|
||||||
AND p.companyFk = vSelf
|
AND p.companyFk = vSelf
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.id,
|
SELECT r.id,
|
||||||
rv.dueDated,
|
rv.dueDated,
|
||||||
r.supplierFk,
|
r.supplierFk,
|
||||||
r.companyFk,
|
r.companyFk,
|
||||||
-IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
|
-IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue),
|
||||||
r.currencyFk,
|
r.currencyFk,
|
||||||
FALSE isPayment,
|
FALSE isPayment,
|
||||||
TRUE
|
TRUE
|
||||||
FROM invoiceIn r
|
FROM invoiceIn r
|
||||||
LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
|
LEFT JOIN tOpeningBalances si ON r.companyFk = si.companyFk
|
||||||
AND r.supplierFk = si.supplierFk
|
AND r.supplierFk = si.supplierFk
|
||||||
AND r.currencyFk = si.currencyFk
|
AND r.currencyFk = si.currencyFk
|
||||||
JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
||||||
WHERE rv.dueDated >= vStartingDate
|
WHERE rv.dueDated >= vStartingDate
|
||||||
AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
|
AND (si.closingBalances IS NULL OR si.closingBalances <> 0)
|
||||||
AND r.isBooked
|
AND r.isBooked
|
||||||
AND r.companyFk = vSelf
|
AND r.companyFk = vSelf
|
||||||
ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
|
ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
|
||||||
-- Now, we calculate the outstanding amount for each receipt in descending order
|
-- Now, we calculate the outstanding amount for each receipt in descending order
|
||||||
SET @risk := 0.0;
|
SET @risk := 0.0;
|
||||||
SET @supplier := 0.0;
|
SET @supplier := 0.0;
|
||||||
SET @company := 0.0;
|
SET @company := 0.0;
|
||||||
SET @moneda := 0.0;
|
SET @moneda := 0.0;
|
||||||
SET @pending := 0.0;
|
SET @pending := 0.0;
|
||||||
SET @day := util.VN_CURDATE();
|
SET @day := util.VN_CURDATE();
|
||||||
|
|
||||||
UPDATE tPendingDuedates vp
|
UPDATE tPendingDuedates vp
|
||||||
LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk
|
LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk
|
||||||
AND vp.supplierFk = si.supplierFk
|
AND vp.supplierFk = si.supplierFk
|
||||||
AND vp.currencyFk = si.currencyFk
|
AND vp.currencyFk = si.currencyFk
|
||||||
SET vp.balance = @risk := (
|
SET vp.balance = @risk := (
|
||||||
IF (
|
IF (
|
||||||
@company <> vp.companyFk
|
@company <> vp.companyFk
|
||||||
OR @supplier <> vp.supplierFk
|
OR @supplier <> vp.supplierFk
|
||||||
OR @moneda <> vp.currencyFk,
|
OR @moneda <> vp.currencyFk,
|
||||||
IFNULL(si.openingBalances, 0),
|
IFNULL(si.openingBalances, 0),
|
||||||
@risk
|
@risk
|
||||||
) +
|
) +
|
||||||
vp.amount
|
vp.amount
|
||||||
),
|
),
|
||||||
-- if there is a change of company or supplier or currency, the balance is reset
|
-- if there is a change of company or supplier or currency, the balance is reset
|
||||||
vp.pending = @pending := IF (
|
vp.pending = @pending := IF (
|
||||||
@company <> vp.companyFk
|
@company <> vp.companyFk
|
||||||
OR @supplier <> vp.supplierFk
|
OR @supplier <> vp.supplierFk
|
||||||
OR @moneda <> vp.currencyFk
|
OR @moneda <> vp.currencyFk
|
||||||
OR @day <> vp.dated,
|
OR @day <> vp.dated,
|
||||||
vp.amount * (NOT vp.isPayment),
|
vp.amount * (NOT vp.isPayment),
|
||||||
@pending + vp.amount
|
@pending + vp.amount
|
||||||
),
|
),
|
||||||
vp.companyFk = @company := vp.companyFk,
|
vp.companyFk = @company := vp.companyFk,
|
||||||
vp.supplierFk = @supplier := vp.supplierFk,
|
vp.supplierFk = @supplier := vp.supplierFk,
|
||||||
vp.currencyFk = @moneda := vp.currencyFk,
|
vp.currencyFk = @moneda := vp.currencyFk,
|
||||||
vp.dated = @day := vp.dated,
|
vp.dated = @day := vp.dated,
|
||||||
vp.balance = @risk,
|
vp.balance = @risk,
|
||||||
vp.pending = @pending;
|
vp.pending = @pending;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY
|
CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY
|
||||||
SELECT expirationId,
|
SELECT expirationId,
|
||||||
dated,
|
dated,
|
||||||
supplierFk,
|
supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
balance
|
balance
|
||||||
FROM tPendingDuedates
|
FROM tPendingDuedates
|
||||||
WHERE balance < vInvalidBalances
|
WHERE balance < vInvalidBalances
|
||||||
AND balance > - vInvalidBalances;
|
AND balance > - vInvalidBalances;
|
||||||
|
|
||||||
DELETE vp.*
|
DELETE vp.*
|
||||||
FROM tPendingDuedates vp
|
FROM tPendingDuedates vp
|
||||||
JOIN tRowsToDelete rd ON (
|
JOIN tRowsToDelete rd ON (
|
||||||
vp.dated < rd.dated
|
vp.dated < rd.dated
|
||||||
OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId)
|
OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId)
|
||||||
)
|
)
|
||||||
AND vp.supplierFk = rd.supplierFk
|
AND vp.supplierFk = rd.supplierFk
|
||||||
AND vp.companyFk = rd.companyFk
|
AND vp.companyFk = rd.companyFk
|
||||||
AND vp.currencyFk = rd.currencyFk
|
AND vp.currencyFk = rd.currencyFk
|
||||||
WHERE NOT vp.isPayment;
|
WHERE NOT vp.isPayment;
|
||||||
|
|
||||||
SELECT vp.expirationId,
|
SELECT vp.expirationId,
|
||||||
vp.dated,
|
vp.dated,
|
||||||
vp.supplierFk,
|
vp.supplierFk,
|
||||||
vp.companyFk,
|
vp.companyFk,
|
||||||
vp.currencyFk,
|
vp.currencyFk,
|
||||||
vp.amount,
|
vp.amount,
|
||||||
vp.pending,
|
vp.pending,
|
||||||
vp.balance,
|
vp.balance,
|
||||||
s.payMethodFk,
|
s.payMethodFk,
|
||||||
vp.isPayment,
|
vp.isPayment,
|
||||||
vp.isReconciled,
|
vp.isReconciled,
|
||||||
vp.endingBalance,
|
vp.endingBalance,
|
||||||
cr.amount clientRiskAmount,
|
cr.amount clientRiskAmount,
|
||||||
co.CEE
|
co.CEE
|
||||||
FROM tPendingDuedates vp
|
FROM tPendingDuedates vp
|
||||||
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
||||||
LEFT JOIN client c ON c.fi = s.nif
|
LEFT JOIN client c ON c.fi = s.nif
|
||||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
JOIN clientRisk cr ON cr.clientFk = c.id
|
||||||
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
AND cr.companyFk = vp.companyFk
|
||||||
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
||||||
LEFT JOIN country co ON co.id = be.countryFk
|
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
||||||
AND cr.companyFk = vp.companyFk;
|
LEFT JOIN country co ON co.id = be.countryFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tOpeningBalances;
|
DROP TEMPORARY TABLE tOpeningBalances;
|
||||||
DROP TEMPORARY TABLE tPendingDuedates;
|
DROP TEMPORARY TABLE tPendingDuedates;
|
||||||
DROP TEMPORARY TABLE tRowsToDelete;
|
DROP TEMPORARY TABLE tRowsToDelete;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -116,7 +116,7 @@ BEGIN
|
||||||
freightValue decimal(10,3) DEFAULT '0.000',
|
freightValue decimal(10,3) DEFAULT '0.000',
|
||||||
packing int(11) DEFAULT '1',
|
packing int(11) DEFAULT '1',
|
||||||
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
|
`grouping` smallint(5) unsigned NOT NULL DEFAULT '1',
|
||||||
groupingMode tinyint(4) NOT NULL DEFAULT 0 ,
|
groupingMode enum('grouping', 'packing') DEFAULT NULL,
|
||||||
comissionValue decimal(10,3) DEFAULT '0.000',
|
comissionValue decimal(10,3) DEFAULT '0.000',
|
||||||
packageValue decimal(10,3) DEFAULT '0.000',
|
packageValue decimal(10,3) DEFAULT '0.000',
|
||||||
packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
|
packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--',
|
||||||
|
|
|
@ -10,6 +10,8 @@ BEGIN
|
||||||
DECLARE vLines INT;
|
DECLARE vLines INT;
|
||||||
DECLARE vHasDistinctTransactions INT;
|
DECLARE vHasDistinctTransactions INT;
|
||||||
|
|
||||||
|
CALL invoiceIn_checkBooked(vInvoiceInFk);
|
||||||
|
|
||||||
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
|
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vLines
|
SELECT COUNT(*) INTO vLines
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba si una factura recibida está contabilizada,
|
||||||
|
* y si lo está retorna un throw.
|
||||||
|
*
|
||||||
|
* @param vSelf Id invoiceIn
|
||||||
|
*/
|
||||||
|
DECLARE vIsBooked BOOL;
|
||||||
|
|
||||||
|
SELECT isBooked INTO vIsBooked
|
||||||
|
FROM invoiceIn
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
IF vIsBooked THEN
|
||||||
|
CALL util.throw('InvoiceIn is already booked');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -61,8 +61,8 @@ BEGIN
|
||||||
a.available,
|
a.available,
|
||||||
IFNULL(ip.counter, 0) `counter`,
|
IFNULL(ip.counter, 0) `counter`,
|
||||||
CASE
|
CASE
|
||||||
WHEN b.groupingMode = 1 THEN b.grouping
|
WHEN b.groupingMode = 'grouping' THEN b.grouping
|
||||||
WHEN b.groupingMode = 2 THEN b.packing
|
WHEN b.groupingMode = 'packing' THEN b.packing
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END AS minQuantity,
|
END AS minQuantity,
|
||||||
iss.visible located
|
iss.visible located
|
||||||
|
|
|
@ -13,6 +13,7 @@ BEGIN
|
||||||
* @param vQuantity a dar de alta/baja
|
* @param vQuantity a dar de alta/baja
|
||||||
* @param vAddressFk id address
|
* @param vAddressFk id address
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
DECLARE vClientFk INT;
|
DECLARE vClientFk INT;
|
||||||
DECLARE vDefaultCompanyFk INT;
|
DECLARE vDefaultCompanyFk INT;
|
||||||
|
@ -23,17 +24,17 @@ BEGIN
|
||||||
|
|
||||||
SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk
|
SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk
|
||||||
FROM vn.ticket LIMIT 1;
|
FROM vn.ticket LIMIT 1;
|
||||||
|
|
||||||
IF vAddressFk IS NULL THEN
|
IF vAddressFk IS NULL THEN
|
||||||
SELECT pc.shortageAddressFk INTO vAddressShortage
|
SELECT pc.shortageAddressFk INTO vAddressShortage
|
||||||
FROM productionConfig pc ;
|
FROM productionConfig pc ;
|
||||||
ELSE
|
ELSE
|
||||||
SET vAddressShortage = vAddressFk;
|
SET vAddressShortage = vAddressFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT a.clientFk INTO vClientFk
|
SELECT a.clientFk INTO vClientFk
|
||||||
FROM address a
|
FROM address a
|
||||||
WHERE a.id = vAddressFk;
|
WHERE a.id = vAddressShortage;
|
||||||
|
|
||||||
SELECT t.id INTO vTicketFk
|
SELECT t.id INTO vTicketFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
|
@ -65,7 +66,7 @@ BEGIN
|
||||||
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
|
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
|
||||||
SELECT vTicketFk,
|
SELECT vTicketFk,
|
||||||
vItemFk,
|
vItemFk,
|
||||||
CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
|
name,
|
||||||
vQuantity
|
vQuantity
|
||||||
FROM item
|
FROM item
|
||||||
WHERE id = vItemFk;
|
WHERE id = vItemFk;
|
||||||
|
|
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
DECLARE vWarehouseFk SMALLINT;
|
DECLARE vWarehouseFk SMALLINT;
|
||||||
DECLARE vDate DATE;
|
DECLARE vDate DATE;
|
||||||
DECLARE vGrouping INT;
|
DECLARE vGrouping INT;
|
||||||
DECLARE vGroupingModeFk INT;
|
DECLARE vGroupingMode VARCHAR(255);
|
||||||
DECLARE vPacking INT;
|
DECLARE vPacking INT;
|
||||||
DECLARE vRoundQuantity INT DEFAULT 1;
|
DECLARE vRoundQuantity INT DEFAULT 1;
|
||||||
DECLARE vLanded DATE;
|
DECLARE vLanded DATE;
|
||||||
|
@ -23,8 +23,6 @@ BEGIN
|
||||||
DECLARE vOldPrice DECIMAL(10,2);
|
DECLARE vOldPrice DECIMAL(10,2);
|
||||||
DECLARE vOption VARCHAR(255);
|
DECLARE vOption VARCHAR(255);
|
||||||
DECLARE vNewSaleFk INT;
|
DECLARE vNewSaleFk INT;
|
||||||
DECLARE vForceToGrouping INT DEFAULT 1;
|
|
||||||
DECLARE vForceToPacking INT DEFAULT 2;
|
|
||||||
DECLARE vFinalPrice DECIMAL(10,2);
|
DECLARE vFinalPrice DECIMAL(10,2);
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
@ -58,15 +56,15 @@ BEGIN
|
||||||
CALL buyUltimate(vWarehouseFk, vDate);
|
CALL buyUltimate(vWarehouseFk, vDate);
|
||||||
|
|
||||||
SELECT `grouping`, groupingMode, packing
|
SELECT `grouping`, groupingMode, packing
|
||||||
INTO vGrouping,vGroupingModeFk,vPacking
|
INTO vGrouping,vGroupingMode,vPacking
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
|
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
|
||||||
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
|
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN
|
IF vGroupingMode = 'packing' AND vPacking > 0 THEN
|
||||||
SET vRoundQuantity = vPacking;
|
SET vRoundQuantity = vPacking;
|
||||||
END IF;
|
END IF;
|
||||||
IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN
|
IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN
|
||||||
SET vRoundQuantity = vGrouping;
|
SET vRoundQuantity = vGrouping;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -81,10 +79,6 @@ BEGIN
|
||||||
ORDER BY (vQuantity % `grouping`) ASC
|
ORDER BY (vQuantity % `grouping`) ASC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF vNewPrice IS NULL THEN
|
|
||||||
CALL util.throw('price retrieval failed');
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF vNewPrice > vOldPrice THEN
|
IF vNewPrice > vOldPrice THEN
|
||||||
SET vFinalPrice = vOldPrice;
|
SET vFinalPrice = vOldPrice;
|
||||||
SET vOption = 'substitution';
|
SET vOption = 'substitution';
|
||||||
|
|
|
@ -6,7 +6,7 @@ trig: BEGIN
|
||||||
DECLARE vWarehouse INT;
|
DECLARE vWarehouse INT;
|
||||||
DECLARE vLanding DATE;
|
DECLARE vLanding DATE;
|
||||||
DECLARE vGrouping INT;
|
DECLARE vGrouping INT;
|
||||||
DECLARE vGroupingMode TINYINT;
|
DECLARE vGroupingMode VARCHAR(255);
|
||||||
DECLARE vGenericFk INT;
|
DECLARE vGenericFk INT;
|
||||||
DECLARE vGenericInDate BOOL;
|
DECLARE vGenericInDate BOOL;
|
||||||
DECLARE vBuyerFk INT;
|
DECLARE vBuyerFk INT;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeDelete`
|
||||||
|
BEFORE DELETE ON `invoiceInCorrection`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.correctingFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeInsert`
|
||||||
|
BEFORE INSERT ON `invoiceInCorrection`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(NEW.correctingFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeUpdate`
|
||||||
|
BEFORE UPDATE ON `invoiceInCorrection`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.correctingFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeDelete`
|
||||||
|
BEFORE DELETE ON `invoiceInDueDay`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vIsNotified BOOLEAN;
|
DECLARE vIsNotified BOOLEAN;
|
||||||
|
|
||||||
|
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT isNotified INTO vIsNotified
|
SELECT isNotified INTO vIsNotified
|
||||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vIsNotified BOOLEAN;
|
DECLARE vIsNotified BOOLEAN;
|
||||||
|
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT isNotified INTO vIsNotified
|
SELECT isNotified INTO vIsNotified
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeDelete`
|
||||||
|
BEFORE DELETE ON `invoiceInIntrastat`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert`
|
||||||
|
BEFORE INSERT ON `invoiceInIntrastat`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeUpdate`
|
||||||
|
BEFORE UPDATE ON `invoiceInIntrastat`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDelete`
|
||||||
|
BEFORE DELETE ON `invoiceInTax`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp
|
||||||
BEFORE UPDATE ON `invoiceInTax`
|
BEFORE UPDATE ON `invoiceInTax`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||||
|
|
||||||
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
|
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
|
||||||
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
|
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate
|
||||||
AFTER UPDATE ON `invoiceIn`
|
AFTER UPDATE ON `invoiceIn`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
IF NEW.issued != OLD.issued
|
IF NEW.issued != OLD.issued
|
||||||
OR NEW.currencyFk != OLD.currencyFk THEN
|
OR NEW.currencyFk != OLD.currencyFk THEN
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete`
|
||||||
|
BEFORE DELETE ON `invoiceIn`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.id);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -5,6 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vWithholdingSageFk INT;
|
DECLARE vWithholdingSageFk INT;
|
||||||
|
|
||||||
|
IF NEW.isBooked = OLD.isBooked THEN
|
||||||
|
CALL invoiceIn_checkBooked(OLD.id);
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||||
CALL util.throw('The invoiceIn reference contains invalid characters');
|
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker";
|
||||||
|
|
||||||
|
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,16 @@
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SET @isTriggerDisabled = TRUE;
|
||||||
|
|
||||||
|
ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode;
|
||||||
|
|
||||||
|
UPDATE vn.buy SET groupingMode2 = 'packing' WHERE groupingMode = 2;
|
||||||
|
UPDATE vn.buy SET groupingMode2 = 'grouping' WHERE groupingMode = 1;
|
||||||
|
|
||||||
|
ALTER TABLE vn.buy DROP COLUMN groupingMode;
|
||||||
|
ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
SET @isTriggerDisabled = FALSE;
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js';
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
import getBrowser from '../../helpers/puppeteer';
|
||||||
|
|
||||||
describe('Worker summary path', () => {
|
describe('Worker summary path', () => {
|
||||||
const workerId = 3;
|
|
||||||
let browser;
|
let browser;
|
||||||
let page;
|
let page;
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
|
@ -10,7 +9,7 @@ describe('Worker summary path', () => {
|
||||||
page = browser.page;
|
page = browser.page;
|
||||||
await page.loginAndModule('employee', 'worker');
|
await page.loginAndModule('employee', 'worker');
|
||||||
const httpDataResponse = page.waitForResponse(response => {
|
const httpDataResponse = page.waitForResponse(response => {
|
||||||
return response.status() === 200 && response.url().includes(`Workers/${workerId}`);
|
return response.status() === 200 && response.url().includes(`Workers/summary`);
|
||||||
});
|
});
|
||||||
await page.accessToSearchResult('agencyNick');
|
await page.accessToSearchResult('agencyNick');
|
||||||
await httpDataResponse;
|
await httpDataResponse;
|
||||||
|
|
|
@ -86,8 +86,7 @@ export default class Auth {
|
||||||
return this.$http.get('VnUsers/ShareToken', {
|
return this.$http.get('VnUsers/ShareToken', {
|
||||||
headers: {Authorization: json.data.token}
|
headers: {Authorization: json.data.token}
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
// Usar data.multimediaToken.id cuando el resto de sistemas lo tengan completado
|
this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember);
|
||||||
this.vnToken.set(json.data.token, json.data.token, now, json.data.ttl, remember);
|
|
||||||
this.loadAcls().then(() => {
|
this.loadAcls().then(() => {
|
||||||
let continueHash = this.$state.params.continue;
|
let continueHash = this.$state.params.continue;
|
||||||
if (continueHash)
|
if (continueHash)
|
||||||
|
|
|
@ -59,8 +59,7 @@ export default class Token {
|
||||||
|
|
||||||
getStorage(storage) {
|
getStorage(storage) {
|
||||||
this.token = storage.getItem('vnToken');
|
this.token = storage.getItem('vnToken');
|
||||||
// Cambio realizado temporalmente
|
this.tokenMultimedia = storage.getItem('vnTokenMultimedia');
|
||||||
this.tokenMultimedia = this.token; // storage.getItem('vnTokenMultimedia');
|
|
||||||
if (!this.token) return;
|
if (!this.token) return;
|
||||||
const created = storage.getItem('vnTokenCreated');
|
const created = storage.getItem('vnTokenCreated');
|
||||||
this.created = created && new Date(created);
|
this.created = created && new Date(created);
|
||||||
|
|
|
@ -352,5 +352,6 @@
|
||||||
"The line could not be marked": "La linea no puede ser marcada",
|
"The line could not be marked": "La linea no puede ser marcada",
|
||||||
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
|
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
|
||||||
"They're not your subordinate": "No es tu subordinado/a.",
|
"They're not your subordinate": "No es tu subordinado/a.",
|
||||||
"No results found": "No se han encontrado resultados"
|
"No results found": "No se han encontrado resultados",
|
||||||
|
"InvoiceIn is already booked": "La factura recibida está contabilizada"
|
||||||
}
|
}
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
||||||
path: '/:id/claim-pickup-pdf',
|
path: '/:id/claim-pickup-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order');
|
Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order');
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
||||||
path: `/:id/downloadFile`,
|
path: `/:id/downloadFile`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadFile = async function(ctx, id) {
|
Self.downloadFile = async function(ctx, id) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = Self => {
|
||||||
if (ticket.ticketFk != claim.ticketFk)
|
if (ticket.ticketFk != claim.ticketFk)
|
||||||
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
|
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
|
||||||
}
|
}
|
||||||
// await claimIsEditable(ctx);
|
await claimIsEditable(ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before delete', async ctx => {
|
Self.observe('before delete', async ctx => {
|
||||||
|
@ -36,7 +36,7 @@ module.exports = Self => {
|
||||||
if (ctx.options && ctx.options.transaction)
|
if (ctx.options && ctx.options.transaction)
|
||||||
myOptions.transaction = ctx.options.transaction;
|
myOptions.transaction = ctx.options.transaction;
|
||||||
|
|
||||||
const claimBeginning = await Self.findById(ctx.where.id);
|
const claimBeginning = ctx.instance ?? await Self.findById(ctx.where.id);
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {id: claimBeginning.claimFk},
|
where: {id: claimBeginning.claimFk},
|
||||||
|
|
|
@ -46,7 +46,7 @@ module.exports = Self => {
|
||||||
path: '/:id/campaign-metrics-pdf',
|
path: '/:id/campaign-metrics-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics');
|
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics');
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = Self => {
|
||||||
path: '/:id/entry-order-pdf',
|
path: '/:id/entry-order-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order');
|
Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order');
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"groupingMode": {
|
"groupingMode": {
|
||||||
"type": "number"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"comissionValue": {
|
"comissionValue": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
|
|
@ -119,13 +119,13 @@
|
||||||
<append>
|
<append>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
pointer
|
pointer
|
||||||
ng-show="buy.groupingMode == '2'"
|
ng-show="buy.groupingMode == 'packing'"
|
||||||
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
||||||
icon="lock">
|
icon="lock">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
pointer
|
pointer
|
||||||
ng-show="buy.groupingMode != '2'"
|
ng-show="buy.groupingMode != 'packing'"
|
||||||
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
||||||
icon="lock_open">
|
icon="lock_open">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
|
@ -140,13 +140,13 @@
|
||||||
<append>
|
<append>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
pointer
|
pointer
|
||||||
ng-show="buy.groupingMode == '1'"
|
ng-show="buy.groupingMode == 'grouping'"
|
||||||
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
||||||
icon="lock">
|
icon="lock">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
pointer
|
pointer
|
||||||
ng-show="buy.groupingMode != '1'"
|
ng-show="buy.groupingMode != 'grouping'"
|
||||||
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
||||||
icon="lock_open">
|
icon="lock_open">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
|
|
|
@ -53,12 +53,8 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleGroupingMode(buy, mode) {
|
toggleGroupingMode(buy, mode) {
|
||||||
const grouping = 1;
|
const groupingMode = mode === 'grouping' ? mode : 'packing';
|
||||||
const packing = 2;
|
const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode;
|
||||||
const groupingMode = mode === 'grouping' ? grouping : packing;
|
|
||||||
|
|
||||||
const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode;
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
groupingMode: newGroupingMode
|
groupingMode: newGroupingMode
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,45 +57,34 @@ describe('Entry buy', () => {
|
||||||
|
|
||||||
describe('toggleGroupingMode()', () => {
|
describe('toggleGroupingMode()', () => {
|
||||||
it(`should toggle grouping mode from grouping to packing`, () => {
|
it(`should toggle grouping mode from grouping to packing`, () => {
|
||||||
const grouping = 1;
|
const buy = {id: 999, groupingMode: 'grouping'};
|
||||||
const packing = 2;
|
|
||||||
const buy = {id: 999, groupingMode: grouping};
|
|
||||||
|
|
||||||
const query = `Buys/${buy.id}`;
|
const query = `Buys/${buy.id}`;
|
||||||
$httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200);
|
$httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200);
|
||||||
controller.toggleGroupingMode(buy, 'packing');
|
controller.toggleGroupingMode(buy, 'packing');
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should toggle grouping mode from packing to grouping`, () => {
|
it(`should toggle grouping mode from packing to grouping`, () => {
|
||||||
const grouping = 1;
|
const buy = {id: 999, groupingMode: 'packing'};
|
||||||
const packing = 2;
|
|
||||||
const buy = {id: 999, groupingMode: packing};
|
|
||||||
|
|
||||||
const query = `Buys/${buy.id}`;
|
const query = `Buys/${buy.id}`;
|
||||||
$httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200);
|
$httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200);
|
||||||
controller.toggleGroupingMode(buy, 'grouping');
|
controller.toggleGroupingMode(buy, 'grouping');
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should toggle off the grouping mode if it was packing to packing`, () => {
|
it(`should toggle off the grouping mode if it was packing to packing`, () => {
|
||||||
const noGrouping = 0;
|
const buy = {id: 999, groupingMode: 'packing'};
|
||||||
const packing = 2;
|
|
||||||
const buy = {id: 999, groupingMode: packing};
|
|
||||||
|
|
||||||
const query = `Buys/${buy.id}`;
|
const query = `Buys/${buy.id}`;
|
||||||
$httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200);
|
$httpBackend.expectPATCH(query, {groupingMode: null}).respond(200);
|
||||||
controller.toggleGroupingMode(buy, 'packing');
|
controller.toggleGroupingMode(buy, 'packing');
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should toggle off the grouping mode if it was grouping to grouping`, () => {
|
it(`should toggle off the grouping mode if it was grouping to grouping`, () => {
|
||||||
const noGrouping = 0;
|
const buy = {id: 999, groupingMode: 'grouping'};
|
||||||
const grouping = 1;
|
|
||||||
const buy = {id: 999, groupingMode: grouping};
|
|
||||||
|
|
||||||
const query = `Buys/${buy.id}`;
|
const query = `Buys/${buy.id}`;
|
||||||
$httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200);
|
$httpBackend.expectPATCH(query, {groupingMode: null}).respond(200);
|
||||||
controller.toggleGroupingMode(buy, 'grouping');
|
controller.toggleGroupingMode(buy, 'grouping');
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
|
@ -143,12 +143,12 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td number>
|
<td number>
|
||||||
<vn-chip class="transparent" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}">
|
<vn-chip class="transparent" translate-attr="buy.groupingMode == 'packing' ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 'packing'}">
|
||||||
<span>{{::buy.packing | dashIfEmpty}}</span>
|
<span>{{::buy.packing | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</td>
|
</td>
|
||||||
<td number>
|
<td number>
|
||||||
<vn-chip class="transparent" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}">
|
<vn-chip class="transparent" translate-attr="buy.groupingMode == 'grouping' ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 'grouping'}">
|
||||||
<span>{{::buy.grouping | dashIfEmpty}}</span>
|
<span>{{::buy.grouping | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -121,12 +121,12 @@
|
||||||
<td center title="{{::line.packagingFk | dashIfEmpty}}">{{::line.packagingFk | dashIfEmpty}}</td>
|
<td center title="{{::line.packagingFk | dashIfEmpty}}">{{::line.packagingFk | dashIfEmpty}}</td>
|
||||||
<td center title="{{::line.weight}}">{{::line.weight}}</td>
|
<td center title="{{::line.weight}}">{{::line.weight}}</td>
|
||||||
<td center>
|
<td center>
|
||||||
<vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
|
<vn-chip class="transparent" translate-attr="line.groupingMode == 'packing' ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 'packing'}">
|
||||||
<span>{{::line.packing | dashIfEmpty}}</span>
|
<span>{{::line.packing | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</td>
|
</td>
|
||||||
<td center>
|
<td center>
|
||||||
<vn-chip class="transparent" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
|
<vn-chip class="transparent" translate-attr="line.groupingMode == 'grouping' ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 'grouping'}">
|
||||||
<span>{{::line.grouping | dashIfEmpty}}</span>
|
<span>{{::line.grouping | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
|
|
@ -13,11 +13,10 @@ describe('invoiceInDueDay new()', () => {
|
||||||
|
|
||||||
it('should correctly create a new due day', async() => {
|
it('should correctly create a new due day', async() => {
|
||||||
const userId = 9;
|
const userId = 9;
|
||||||
const invoiceInFk = 6;
|
const invoiceInFk = 3;
|
||||||
|
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {
|
req: {
|
||||||
|
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => {
|
||||||
|
|
||||||
const result = await models.InvoiceIn.filter(ctx, {}, options);
|
const result = await models.InvoiceIn.filter(ctx, {}, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toEqual(4);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
||||||
path: '/:id/download',
|
path: '/:id/download',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.download = async function(ctx, id, options) {
|
Self.download = async function(ctx, id, options) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = Self => {
|
||||||
path: '/downloadZip',
|
path: '/downloadZip',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadZip = async function(ctx, ids, options) {
|
Self.downloadZip = async function(ctx, ids, options) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
||||||
path: '/:reference/exportation-pdf',
|
path: '/:reference/exportation-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation');
|
Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation');
|
||||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
||||||
path: '/:reference/invoice-csv',
|
path: '/:reference/invoice-csv',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.invoiceCsv = async reference => {
|
Self.invoiceCsv = async reference => {
|
||||||
|
|
|
@ -40,7 +40,7 @@ module.exports = Self => {
|
||||||
path: '/negativeBasesCsv',
|
path: '/negativeBasesCsv',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.negativeBasesCsv = async(ctx, options) => {
|
Self.negativeBasesCsv = async(ctx, options) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ module.exports = Self => {
|
||||||
path: `/download`,
|
path: `/download`,
|
||||||
verb: 'POST',
|
verb: 'POST',
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.download = async() => {
|
Self.download = async() => {
|
||||||
|
|
|
@ -71,12 +71,12 @@
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
<vn-td number class="expendable">{{entry.stickers | dashIfEmpty}}</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 2}">
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{'message': entry.groupingMode == 'packing'}">
|
||||||
<span>{{::entry.packing | dashIfEmpty}}</span>
|
<span>{{::entry.packing | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
<vn-td number>
|
<vn-td number>
|
||||||
<vn-chip translate-attr="{title: 'Grouping'}" ng-class="{'message': entry.groupingMode == 1}">
|
<vn-chip translate-attr="{title: 'Grouping'}" ng-class="{'message': entry.groupingMode == 'grouping'}">
|
||||||
<span>{{::entry.grouping | dashIfEmpty}}</span>
|
<span>{{::entry.grouping | dashIfEmpty}}</span>
|
||||||
</vn-chip>
|
</vn-chip>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
|
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
||||||
http: {
|
http: {
|
||||||
path: '/:id/cmr',
|
path: '/:id/cmr',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
}
|
},
|
||||||
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr');
|
Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr');
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
||||||
path: '/downloadCmrsZip',
|
path: '/downloadCmrsZip',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadCmrsZip = async function(ctx, ids, options) {
|
Self.downloadCmrsZip = async function(ctx, ids, options) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
||||||
path: '/downloadZip',
|
path: '/downloadZip',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadZip = async function(ctx, id, options) {
|
Self.downloadZip = async function(ctx, id, options) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = Self => {
|
||||||
path: '/:id/driver-route-pdf',
|
path: '/:id/driver-route-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
||||||
path: '/:id/campaign-metrics-pdf',
|
path: '/:id/campaign-metrics-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
// accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics');
|
Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics');
|
||||||
|
|
|
@ -38,7 +38,7 @@ module.exports = Self => {
|
||||||
path: '/:id/delivery-note-csv',
|
path: '/:id/delivery-note-csv',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deliveryNoteCsv = async id => {
|
Self.deliveryNoteCsv = async id => {
|
||||||
|
|
|
@ -42,7 +42,7 @@ module.exports = Self => {
|
||||||
path: '/:id/delivery-note-pdf',
|
path: '/:id/delivery-note-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note');
|
Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note');
|
||||||
|
|
|
@ -79,7 +79,7 @@ module.exports = Self => {
|
||||||
path: '/extra-community-pdf',
|
path: '/extra-community-pdf',
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community');
|
Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community');
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
||||||
path: `/:id/downloadFile`,
|
path: `/:id/downloadFile`,
|
||||||
verb: 'GET'
|
verb: 'GET'
|
||||||
},
|
},
|
||||||
//accessScopes: ['read:multimedia']
|
accessScopes: ['read:multimedia']
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.downloadFile = async function(ctx, id) {
|
Self.downloadFile = async function(ctx, id) {
|
||||||
|
|
|
@ -92,5 +92,87 @@
|
||||||
"model": "WorkerTeamCollegues",
|
"model": "WorkerTeamCollegues",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "workerFk"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scopes":{
|
||||||
|
"summary": {
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "user",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["email", "name", "nickname", "roleFk"],
|
||||||
|
"include": [
|
||||||
|
{
|
||||||
|
"relation": "role",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["name"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"relation": "emailUser",
|
||||||
|
"scope": {
|
||||||
|
"fields": ["email"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"relation": "department",
|
||||||
|
"scope": {
|
||||||
|
"include": {
|
||||||
|
"relation": "department"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"relation": "boss"
|
||||||
|
}, {
|
||||||
|
"relation": "client",
|
||||||
|
"scope": {
|
||||||
|
"fields": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"fi",
|
||||||
|
"socialName",
|
||||||
|
"contact",
|
||||||
|
"street",
|
||||||
|
"city",
|
||||||
|
"postcode",
|
||||||
|
"email",
|
||||||
|
"mobile",
|
||||||
|
"isActive",
|
||||||
|
"credit",
|
||||||
|
"creditInsurance",
|
||||||
|
"iban",
|
||||||
|
"dueDay",
|
||||||
|
"isEqualizated",
|
||||||
|
"isFreezed",
|
||||||
|
"hasToInvoiceByAddress",
|
||||||
|
"hasToInvoice",
|
||||||
|
"isToBeMailed",
|
||||||
|
"hasSepaVnl",
|
||||||
|
"hasLcr",
|
||||||
|
"hasCoreVnl",
|
||||||
|
"hasCoreVnh",
|
||||||
|
"hasIncoterms",
|
||||||
|
"isTaxDataChecked",
|
||||||
|
"eypbc",
|
||||||
|
"quality",
|
||||||
|
"isVies",
|
||||||
|
"isRelevant",
|
||||||
|
"accountingAccount",
|
||||||
|
"created",
|
||||||
|
"sageTaxTypeFk",
|
||||||
|
"sageTransactionTypeFk",
|
||||||
|
"businessTypeFk",
|
||||||
|
"salesPersonFk",
|
||||||
|
"hasElectronicInvoice",
|
||||||
|
"rating",
|
||||||
|
"recommendedCredit"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"relation": "sip"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card';
|
||||||
class Controller extends ModuleCard {
|
class Controller extends ModuleCard {
|
||||||
reload() {
|
reload() {
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
where: {
|
||||||
{
|
id: this.$params.id}
|
||||||
relation: 'user',
|
|
||||||
scope: {
|
|
||||||
fields: ['name', 'emailVerified'],
|
|
||||||
include: {
|
|
||||||
relation: 'emailUser',
|
|
||||||
scope: {
|
|
||||||
fields: ['email']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'sip',
|
|
||||||
scope: {
|
|
||||||
fields: ['extension', 'secret']
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'department',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'department'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
this.$http.get(`Workers/${this.$params.id}`, {filter})
|
this.$http.get(`Workers/summary`, {filter})
|
||||||
.then(res => this.worker = res.data),
|
.then(res => this.worker = res.data[0]),
|
||||||
this.$http.get(`Workers/${this.$params.id}/activeContract`)
|
this.$http.get(`Workers/${this.$params.id}/activeContract`)
|
||||||
.then(res => this.hasWorkCenter = res.data?.workCenterFk)
|
.then(res => this.hasWorkCenter = res.data?.workCenterFk)
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -37,41 +37,11 @@ class Controller extends Descriptor {
|
||||||
|
|
||||||
loadData() {
|
loadData() {
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
where: {id: this.id},
|
||||||
{
|
|
||||||
relation: 'user',
|
|
||||||
scope: {
|
|
||||||
fields: ['name', 'emailVerified'],
|
|
||||||
include: {
|
|
||||||
relation: 'emailUser',
|
|
||||||
scope: {
|
|
||||||
fields: ['email']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'client',
|
|
||||||
scope: {
|
|
||||||
fields: ['fi']
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'sip',
|
|
||||||
scope: {
|
|
||||||
fields: ['extension']
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'department',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'department'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.getData(`Workers/${this.id}`, {filter})
|
return this.getData(`Workers/summary`, {filter})
|
||||||
.then(res => this.entity = res.data);
|
.then(res => this.entity = res.data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPassRequirements() {
|
getPassRequirements() {
|
||||||
|
|
|
@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => {
|
||||||
describe('loadData()', () => {
|
describe('loadData()', () => {
|
||||||
it(`should perform a get query to store the worker data into the controller`, () => {
|
it(`should perform a get query to store the worker data into the controller`, () => {
|
||||||
const id = 1;
|
const id = 1;
|
||||||
const response = 'foo';
|
const response = ['foo'];
|
||||||
|
|
||||||
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
|
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
|
||||||
$httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
|
$httpBackend.expectRoute('GET', `Workers/summary`).respond(response);
|
||||||
controller.id = id;
|
controller.id = id;
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.worker).toEqual(response);
|
expect([controller.worker]).toEqual(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,53 +10,14 @@ class Controller extends Summary {
|
||||||
this.$.worker = null;
|
this.$.worker = null;
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
|
|
||||||
const query = `Workers/${value.id}`;
|
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
where: {
|
||||||
{
|
id: value.id
|
||||||
relation: 'user',
|
}
|
||||||
scope: {
|
|
||||||
fields: ['name', 'roleFk'],
|
|
||||||
include: [{
|
|
||||||
relation: 'role',
|
|
||||||
scope: {
|
|
||||||
fields: ['name']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'emailUser',
|
|
||||||
scope: {
|
|
||||||
fields: ['email']
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'client',
|
|
||||||
scope: {fields: ['fi', 'phone']}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'boss',
|
|
||||||
scope: {fields: ['id', 'name']}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'sip',
|
|
||||||
scope: {fields: ['extension']}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'department',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'department',
|
|
||||||
scope: {fields: ['id', 'code', 'name']}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$http.get(query, {params: {filter}}).then(res => {
|
this.$http.get(`Workers/summary`, {filter}).then(res => {
|
||||||
this.$.worker = res.data;
|
this.$.worker = res.data[0];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue