diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js new file mode 100644 index 000000000..b4ee706a0 --- /dev/null +++ b/.husky/addReferenceTag.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const path = require('path'); + +function getCurrentBranchName(p = process.cwd()) { + if (!fs.existsSync(p)) return false; + + const gitHeadPath = path.join(p, '.git', 'HEAD'); + + if (!fs.existsSync(gitHeadPath)) + return getCurrentBranchName(path.resolve(p, '..')); + + const headContent = fs.readFileSync(gitHeadPath, 'utf-8'); + return headContent.trim().split('/')[2]; +} + +const branchName = getCurrentBranchName(); + +if (branchName) { + const msgPath = `.git/COMMIT_EDITMSG`; + const msg = fs.readFileSync(msgPath, 'utf-8'); + const reference = branchName.match(/^\d+/); + + const referenceTag = `refs #${reference}`; + if (!msg.includes(referenceTag) && reference) { + const splitedMsg = msg.split(':'); + + if (splitedMsg.length > 1) { + const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':'); + fs.writeFileSync(msgPath, finalMsg); + } + } +} + diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 000000000..0c9a94c64 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,8 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +echo "Running husky commit-msg hook" +npx --no-install commitlint --edit +echo "Adding reference tag to commit message" +node .husky/addReferenceTag.js + diff --git a/CHANGELOG.md b/CHANGELOG.md index c031a3874..b2be92faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [24.18.01] - 2024-05-02 + ## [24.16.01] - 2024-04-18 ## [2414.01] - 2024-04-04 diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index 6f2451505..9290188a1 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index 4aa40197f..eb575236d 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -43,7 +43,7 @@ module.exports = Self => { path: `/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 9ac06f30b..e0fcb0951 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -48,7 +48,7 @@ module.exports = Self => { path: `/:collection/:size/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/back/methods/notification/getList.js b/back/methods/notification/getList.js index 3881f0f63..cd9cfcd1d 100644 --- a/back/methods/notification/getList.js +++ b/back/methods/notification/getList.js @@ -45,7 +45,6 @@ module.exports = Self => { }); availableNotificationsMap.delete(active.notificationFk); } - return { active: [...activeNotificationsMap.entries()], available: [...availableNotificationsMap.entries()] diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index 6c60d3505..a3eb45786 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -4,8 +4,8 @@ describe('NotificationSubscription getList()', () => { it('should return a list of available and active notifications of a user', async() => { const userId = 9; const {active, available} = await models.NotificationSubscription.getList(userId); - const notifications = await models.Notification.find({}); - const totalAvailable = notifications.length - active.length; + const notifications = await models.NotificationSubscription.getAvailable(userId); + const totalAvailable = notifications.size - active.length; expect(active.length).toEqual(3); expect(available.length).toEqual(totalAvailable); diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index d00085d8a..2fd1f43c0 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -33,16 +33,23 @@ module.exports = Self => { // Schedule to remove current token setTimeout(async() => { try { - await Self.logout(token.id); + const exists = await models.AccessToken.findById(token.id); + exists && await Self.logout(token.id); } catch (err) { // eslint-disable-next-line no-console console.error(err); } }, courtesyTime * 1000); + // Get scopes + + let createTokenOptions = {}; + const {scopes} = token; + if (scopes) + createTokenOptions = {scopes: [scopes[0]]}; // Create new accessToken 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}; }; diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8d9bbf11c..70e7473d1 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -28,11 +28,25 @@ describe('Renew Token', () => { }); it('should renew token', async() => { + const {courtesyTime} = await models.AccessTokenConfig.findOne({ + fields: ['courtesyTime'] + }); const mockDate = new Date(startingTime + 26600000); jasmine.clock().mockDate(mockDate); const {id} = await models.VnUser.renewToken(ctx); expect(id).not.toEqual(ctx.req.accessToken.id); + + await models.VnUser.logout(ctx.req.accessToken.id); + jasmine.clock().tick((courtesyTime + 10) * 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() => { diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js index aaa83817c..e072a4fa8 100644 --- a/back/methods/vn-user/specs/share-token.spec.js +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -1,6 +1,9 @@ const {models} = require('vn-loopback/server/server'); +const TOKEN_MULTIMEDIA = 'read:multimedia'; describe('Share Token', () => { let ctx = null; + const startingTime = Date.now(); + let multimediaToken = null; beforeAll(async() => { const unAuthCtx = { req: { @@ -17,11 +20,45 @@ describe('Share Token', () => { ctx = {req: {accessToken: accessToken}}; }); - it('should renew token', async() => { - const multimediaToken = await models.VnUser.shareToken(ctx); + beforeEach(async() => { + 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(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); }); }); diff --git a/back/model-config.json b/back/model-config.json index f48ec11e6..ebcdb7bce 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -174,5 +174,8 @@ }, "WorkerActivityType": { "dataSource": "vn" + }, + "ProductionConfig": { + "dataSource": "vn" } } \ No newline at end of file diff --git a/back/models/production-config.json b/back/models/production-config.json new file mode 100644 index 000000000..3800dbbf2 --- /dev/null +++ b/back/models/production-config.json @@ -0,0 +1,19 @@ +{ + "name": "ProductionConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "productionConfig" + } + }, + "properties": { + "id": { + "type": "number", + "required": true, + "id": true + }, + "backupPrinterNotificationDelay": { + "type": "string" + } + } +} diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index c2adcbc59..33badfd91 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -41,8 +41,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - const notificationSubscriptionId = 2; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 2}, options); await tx.rollback(); } catch (e) { @@ -76,8 +75,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - const notificationSubscriptionId = 6; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 6}, options); await tx.rollback(); } catch (e) { @@ -111,8 +109,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 19}}; - const notificationSubscriptionId = 4; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 4}, options); await tx.rollback(); } catch (e) { diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 000000000..3347cb961 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/db/.editorconfig b/db/.editorconfig new file mode 100644 index 000000000..c97043430 --- /dev/null +++ b/db/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index cc66c4bf5..523f41bfb 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -9,6 +9,10 @@ SET foreign_key_checks = 0; INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); + +INSERT INTO util.binlogQueue (code,logName, `position`) + VALUES ('mylogger', 'bin.000001', 4); + /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) VALUES(1, NULL, 1, 300, 1); @@ -113,9 +117,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF (100, 4, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 4, NULL, 1, 567, 1, '2022-07-12', 0, 0, 6, NULL, NULL, NULL, NULL, NULL), (100, 5, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 5, NULL, 1, 567, 1, '2022-07-12', 0, 0, 1, NULL, NULL, NULL, NULL, NULL); */ -INSERT INTO vn.sector (description,warehouseFk) VALUES - ('Sector One',1); - INSERT INTO vn.saleGroup (userFk,parkingFk,sectorFk) VALUES (100,1,1); @@ -156,16 +157,6 @@ INSERT INTO `vn`.`occupationCode` (`code`, `name`) ('b', 'Representantes de comercio'), ('c', 'Personal de oficios en trabajos de construcción en general, y en instalac.,edificios y obras'); -INSERT INTO `vn2008`.`payroll_employee` (`CodTrabajador`,`codempresa`) - VALUES - (36,20), - (43,20), - (76,20), - (1106,20), - (1107,20), - (1108,20), - (1109,20), - (1110,20); INSERT INTO `vn`.`trainingCourseType` (`id`, `name`) VALUES diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 052619a7c..ff58af2e2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -198,7 +198,7 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); -UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; +UPDATE `vn`.`sector` SET `backupPrinterFk` = 1 WHERE id = 1; INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) @@ -527,7 +527,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) (4, 'SalesPerson', 'salesPerson'), (5, 'Administrative', 'administrative'), (6, 'Weight', 'weight'), - (7, 'InvoiceOut', 'invoiceOut'); + (7, 'InvoiceOut', 'invoiceOut'), + (8, 'DropOff', 'dropOff'); INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES @@ -1492,21 +1493,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`) 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), - (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), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()), - (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()); + (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, '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, 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, 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, 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, '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, '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, '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, '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, '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, '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, '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, '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, '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, '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`) VALUES @@ -1827,9 +1828,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`) VALUES - (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11), + (1, util.VN_CURDATE(), 1, 1101, 19, 3, 0, util.VN_CURDATE(), 0, 11), (2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16), - (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7), + (3, util.VN_CURDATE(), 3, 1101, 19, 1, 1, util.VN_CURDATE(), 5, 7), (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8); INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) @@ -2551,15 +2552,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) VALUES (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), (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), - (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 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), - (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 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); + (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, 0, 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, 0, 442, 1); INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`) VALUES @@ -2614,13 +2615,33 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); -INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT t.id - FROM vn.ticket t - LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id - WHERE tr.ticketFk IS NULL; +UPDATE `vn`.`invoiceIn` + SET isBooked = TRUE + WHERE id IN (5, 7, 8, 9, 10); -CALL `vn`.`ticket_doRecalc`(); +DELIMITER $$ +CREATE PROCEDURE `tmp`.`ticket_recalc`() +BEGIN + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE cTickets CURSOR FOR SELECT id FROM vn.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cTickets; + myLoop: LOOP + SET vDone = FALSE; + FETCH cTickets INTO vTicketFk; + IF vDone THEN LEAVE myLoop; END IF; + CALL vn.ticket_recalc(vTicketFk, NULL); + END LOOP; + CLOSE cTickets; +END$$ +DELIMITER ; + +CALL tmp.ticket_recalc; +DROP PROCEDURE tmp.ticket_recalc; UPDATE `vn`.`ticket` SET refFk = 'T1111111' @@ -2822,7 +2843,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), (6, 'book-entry-deleted', 'accounting entries deleted'), - (7, 'zone-included','An email to notify zoneCollisions'); + (7, 'zone-included','An email to notify zoneCollisions'), + (8, 'backup-printer-selected','A backup printer has been selected'); TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) @@ -2834,7 +2856,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (4, 1), (5, 9), (6, 9), - (7, 9); + (7, 9), + (8, 66); TRUNCATE `util`.`notificationQueue`; INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) @@ -2854,15 +2877,16 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (1, 9), (1, 3), (6, 9), - (7, 9); + (7, 9), + (8, 66); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES (1, 9); -INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`) +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`) VALUES - (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6); + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600); INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) VALUES @@ -3232,7 +3256,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3270,7 +3294,7 @@ INSERT INTO vn.buy stickers = 1, packing = 40, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3308,7 +3332,7 @@ INSERT INTO vn.buy stickers = 2, packing = 10, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3354,7 +3378,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 4, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3392,7 +3416,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3431,7 +3455,7 @@ INSERT INTO vn.buy stickers = 1, packing = 200, `grouping` = 30, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3470,7 +3494,7 @@ INSERT INTO vn.buy stickers = 1, packing = 500, `grouping` = 10, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3509,7 +3533,7 @@ INSERT INTO vn.buy stickers = 2, packing = 300, `grouping` = 50, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3548,7 +3572,7 @@ INSERT INTO vn.buy stickers = 2, packing = 50, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3588,7 +3612,7 @@ INSERT vn.buy stickers = 1, packing = 5, `grouping` = 2, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, @@ -3627,7 +3651,7 @@ INSERT vn.buy stickers = 1, packing = 100, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, @@ -3745,7 +3769,7 @@ INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,new INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`) VALUES (1, 10, 9); -INSERT INTO `vn`.`accountReconciliation` (supplierAccountFk,operationDated,valueDated,amount,concept,debitCredit,calculatedCode,created) +INSERT INTO `vn`.`accountReconciliation` (supplierAccountFk,operationDated,valueDated,amount,concept,debitCredit,calculatedCode,created) VALUES (241,'2023-12-13 00:00:00.000','2023-12-07 00:00:00.000',19.36,'BEL 1','debit','2','2023-12-14 08:39:53.000'), (241,'2023-12-13 00:00:00.000','2023-12-07 00:00:00.000',30226.43,'BEL 2','debit','1','2023-12-14 08:39:53.000'), @@ -3756,5 +3780,10 @@ INSERT INTO `vn`.`accountReconciliation` (supplierAccountFk,operationDated,value (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',3210.5,'RCBO.VOLVO','debit','121','2023-12-14 08:39:53.000'), (241,'2023-12-13 00:00:00.000','2023-12-13 00:00:00.000',6513.7,'RCBO.ENERPLUS','debit','120','2023-12-14 08:39:53.000'); -INSERT INTO `vn`.`accountReconciliationConfig`(currencyFk, warehouseFk) +INSERT INTO `vn`.`accountReconciliationConfig`(currencyFk, warehouseFk) VALUES (1, 1); + + +INSERT INTO vn.workerTeam(id, team, workerFk) + VALUES + (8, 1, 19); diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql index 1d4bf4355..c5b077f29 100644 --- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql +++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql @@ -92,12 +92,12 @@ BEGIN UPDATE bi.Greuge_Evolution ge JOIN ( SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento - WHERE t.Fecha >= datFEC - AND t.Fecha < datFEC_TOMORROW + WHERE t.shipped >= datFEC + AND t.shipped < datFEC_TOMORROW AND mc.Id_Componente = 17 -- Recobro GROUP BY cs.Id_Cliente ) sub using(Id_Cliente) diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index 6d357275a..228660d07 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`analisis_ventas_update`() BEGIN DECLARE vLastMonth DATE; @@ -10,18 +10,18 @@ BEGIN OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); INSERT INTO analisis_ventas ( - Familia, - Reino, - Comercial, - Comprador, - Provincia, - almacen, - Año, - Mes, - Semana, - Vista, - Importe - ) + Familia, + Reino, + Comercial, + Comprador, + Provincia, + almacen, + Año, + Mes, + Semana, + Vista, + Importe + ) SELECT tp.Tipo AS Familia, r.reino AS Reino, @@ -35,19 +35,19 @@ BEGIN dm.description AS Vista, bt.importe AS Importe FROM bs.ventas bt - LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id - LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador - LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador - JOIN vn2008.time tm ON tm.date = bt.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento - LEFT JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista - LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn2008.province p ON p.province_id = cs.province_id - LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id - WHERE bt.fecha >= vLastMonth AND r.mercancia; -END$$ -DELIMITER ; + LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador + LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador + JOIN vn2008.time tm ON tm.date = bt.fecha + JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento + LEFT JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista + LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk + LEFT JOIN vn2008.province p ON p.province_id = cs.province_id + LEFT JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE bt.fecha >= vLastMonth AND r.mercancia; +END$$ +DELIMITER ; diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 10cb717cf..83d70c867 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,18 +59,18 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.Id_Ticket + SELECT DISTINCT t.id Id_Ticket FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Tickets_state ts ON ts.Id_Ticket = t.Id_Ticket - JOIN vn.ticketTracking tt ON tt.id = ts.inter_id - JOIN vn2008.state s ON s.id = tt.stateFk + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn.ticketLastState ts ON ts.ticketFk = t.id + JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN vn.state s ON s.id = tt.stateFk WHERE mc.Id_Componente = 17 AND mc.greuge = 0 - AND t.Fecha >= '2016-10-01' - AND t.Fecha < util.VN_CURDATE() - AND s.alert_level >= 3; + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND s.alertLevel >= 3; DELETE g.* FROM vn.greuge g @@ -79,18 +79,18 @@ BEGIN INSERT INTO vn.greuge(clientFk, description, amount,shipped, greugeTypeFk, ticketFk) - SELECT Id_Cliente + SELECT t.clientFk ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif - ,date(t.Fecha) + ,date(t.shipped) , 2 ,tt.Id_Ticket FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc ON mc.Id_Movimiento = m.Id_Movimiento AND mc.Id_Componente = 17 - GROUP BY t.Id_Ticket + GROUP BY t.id HAVING ABS(dif) > 1; UPDATE vn2008.Movimientos_componentes mc diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql index 4297c8aff..ac06798db 100644 --- a/db/routines/bi/procedures/comparativa_add.sql +++ b/db/routines/bi/procedures/comparativa_add.sql @@ -15,17 +15,17 @@ BEGIN IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3 - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END IF; END$$ diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql index 281e15b23..2b05b1277 100644 --- a/db/routines/bi/procedures/comparativa_add_manual.sql +++ b/db/routines/bi/procedures/comparativa_add_manual.sql @@ -25,16 +25,16 @@ BEGIN WHERE Periodo BETWEEN periodStart AND periodEnd; INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN periodStart AND periodEnd - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END$$ DELIMITER ; diff --git a/db/routines/bi/views/v_ventas_contables.sql b/db/routines/bi/views/v_ventas_contables.sql index 373fcdd3f..82bbeeaac 100644 --- a/db/routines/bi/views/v_ventas_contables.sql +++ b/db/routines/bi/views/v_ventas_contables.sql @@ -11,13 +11,13 @@ AS SELECT `time`.`year` AS `year`, FROM ( ( ( - `vn2008`.`Tickets` `t` - JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`) + `vn`.`ticket` `t` + JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`) ) - JOIN `vn2008`.`Movimientos` `m` ON(`t`.`Id_Ticket` = `m`.`Id_Ticket`) + JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`) ) - JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`Fecha` AS date)) + JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date)) ) -WHERE `t`.`Fecha` >= '2014-01-01' +WHERE `t`.`shipped` >= '2014-01-01' GROUP BY `time`.`year`, `time`.`month` diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 101173740..96cab5b4f 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,23 +70,23 @@ BEGIN AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT t.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + (SELECT t.clientFk Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND t.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) + AND t.shipped BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente LEFT JOIN - (SELECT MAX(t.Fecha) LastTicket, c.Id_Cliente - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente + (SELECT MAX(t.shipped) LastTicket, c.Id_Cliente + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_cliente = t.clientFk LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente + GROUP BY t.clientFk) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente LEFT JOIN ( SELECT SUM(importe) peso, c.Id_Cliente diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index 2038f976a..f53d293b3 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -68,13 +68,13 @@ BEGIN FROM ( SELECT cs.Id_Cliente, Cantidad * Valor as mana - FROM vn2008.Tickets t + FROM vn.ticket t JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) - AND t.Fecha > vFromDated - AND date(t.Fecha) <= vToDated + AND t.shipped > vFromDated + AND date(t.shipped) <= vToDated UNION ALL SELECT r.Id_Cliente, - Entregado FROM vn2008.Recibos r diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 66c012a19..ad4e80a06 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -19,11 +19,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) + (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.`ref` = t.Factura + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.`ref` = t.refFk WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , a.expenseFk + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,19 +54,19 @@ BEGIN ) * 100000 + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn2008.Articles a on m.Id_Article = a.Id_Article - JOIN vn2008.empresa e on e.id = t.empresa_id + JOIN vn2008.empresa e on e.id = t.companyFk LEFT JOIN vn2008.empresa e2 on e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp on tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 931653e6e..ed3773cf7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,38 +10,38 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + (PRIMARY KEY (id)) + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.id = t.refFk WHERE year(io.issued) = vYear - AND month(io.issued) = vMonth; - + AND month(io.issued) = vMonth; + SELECT vYear Año, vMonth Mes, - t.Id_Cliente, + t.clientFk Id_Cliente, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, IF(e2.empresa_grupo,2,0)) AS grupo, - t.empresa_id empresa + t.companyFk empresa FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c ON c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt ON tt.id = t.id JOIN vn2008.Articles a ON m.Id_Article = a.Id_Article - JOIN vn2008.empresa e ON e.id = t.empresa_id + JOIN vn2008.empresa e ON e.id = t.companyFk LEFT JOIN vn2008.empresa e2 ON e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != 188 - GROUP BY t.Id_Cliente, grupo,t.empresa_id; - + GROUP BY t.clientFk, grupo,t.companyFk; + DROP TEMPORARY TABLE tmp.ticket_list; - + END$$ DELIMITER ; diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index 08ecddf1d..9ec0c81d4 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -14,7 +14,6 @@ proc:BEGIN DECLARE vPackage INT; DECLARE vPutOrderFk INT; DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vEntryFk INT; DECLARE vHasToChangePackagingFk BOOLEAN; DECLARE vIsFloramondoDirect BOOLEAN; @@ -150,7 +149,7 @@ proc:BEGIN @pac := GREATEST(1, IFNULL(i.stemMultiplier, 1) * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, - vForceToPacking, + 'packing', IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk), (IFNULL(i.weightByPiece, 0) * @pac) / 1000 FROM ekt e diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 26e09ebaf..18d3f8b7e 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; DECLARE vDone INT DEFAULT FALSE; @@ -417,7 +417,7 @@ proc: BEGIN o.NumberOfUnits etiquetas, o.NumberOfItemsPerCask packing, GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 2, -- Obliga al Packing + 'packing', o.embalageCode, o.diId FROM edi.offer o @@ -518,5 +518,5 @@ proc: BEGIN fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql new file mode 100644 index 000000000..aca6ca4d6 --- /dev/null +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -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 ; diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index e45fa7ddf..32624f383 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, READS SQL DATA proc:BEGIN /** - * Returns list, price and all the stuff regarding the floranet items + * Returns list, price and all the stuff regarding the floranet items. * * @param vLanded Delivery date * @param vPostalCode Delivery address postal code diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql index 044c22c6f..2ca25b87d 100644 --- a/db/routines/floranet/procedures/contact_request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -11,7 +11,7 @@ PROCEDURE floranet.contact_request( READS SQL DATA BEGIN /** - * Set actions for contact request. + * Set actions for contact request * * @param vPostalCode Delivery address postal code */ diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 29751ebe4..75e9d6257 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPosta READS SQL DATA BEGIN /** - * Returns available dates for this postalCode, in the next seven days + * Returns available dates for this postalCode, in the next seven days. * * @param vPostalCode Delivery address postal code */ diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index fed123663..b6aec033d 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -7,7 +7,7 @@ CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk I READS SQL DATA BEGIN -/** Update order.isPaid field +/** Update order.isPaid field. * * @param vCatalogueFk floranet.catalogue.id * diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index c26cef19a..979588f8f 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -1,41 +1,21 @@ -DROP PROCEDURE IF EXISTS floranet.order_put; - DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON) READS SQL DATA BEGIN /** - * Get and process an order + * Get and process an order. * - * @param vOrder Data of the order - * - * Customer data: , , - * - * Item data: , - * - * Delivery data: ,
, - * + * @param vJsonData The order data in json format */ - INSERT IGNORE INTO `order`( - catalogueFk, - customerName, - email, - customerPhone, - message, - deliveryName, - address, - 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')) - ); + INSERT INTO `order` + SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), + customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), + email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), + customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')), + message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), + deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), + address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); SELECT LAST_INSERT_ID() orderFk; END$$ diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql index bd791dec7..0e4aa297a 100644 --- a/db/routines/floranet/procedures/sliders_get.sql +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get() READS SQL DATA BEGIN /** - * Returns list of url for sliders + * Returns list of url for sliders. */ SELECT CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql deleted file mode 100644 index bbc61924f..000000000 --- a/db/routines/hedera/events/order_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `hedera`.`order_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2019-08-29 14:18:04.000' - ON COMPLETION PRESERVE - DISABLE -DO CALL order_doRecalc$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_doRecalc.sql b/db/routines/hedera/procedures/order_doRecalc.sql deleted file mode 100644 index 4c0ee0499..000000000 --- a/db/routines/hedera/procedures/order_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_doRecalc`() -proc: BEGIN -/** - * Recalculates modified orders. - */ - DECLARE vDone BOOL; - DECLARE vOrderFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT orderFk FROM tOrder; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('hedera.order_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('hedera.order_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tOrder; - CREATE TEMPORARY TABLE tOrder - ENGINE = MEMORY - SELECT id, orderFk FROM orderRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vOrderFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL order_recalc(vOrderFk); - END LOOP; - - CLOSE cCur; - - DELETE o FROM orderRecalc o JOIN tOrder t ON t.id = o.id; - - DROP TEMPORARY TABLE tOrder; - - DO RELEASE_LOCK('hedera.order_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql deleted file mode 100644 index 990894bb6..000000000 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the order total. - * - * @param vSelf The order identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - -- #4409 Disable order recalc - -- INSERT INTO orderRecalc SET orderFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterDelete.sql b/db/routines/hedera/triggers/orderRow_afterDelete.sql deleted file mode 100644 index 10b5ae9e3..000000000 --- a/db/routines/hedera/triggers/orderRow_afterDelete.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterDelete` - AFTER DELETE ON `orderRow` - FOR EACH ROW -BEGIN - CALL stock.log_add('orderRow', NULL, OLD.id); - CALL order_requestRecalc(OLD.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql deleted file mode 100644 index 7e8d5f341..000000000 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert` - AFTER INSERT ON `orderRow` - FOR EACH ROW -BEGIN - CALL stock.log_add('orderRow', NEW.id, NULL); - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterUpdate.sql b/db/routines/hedera/triggers/orderRow_afterUpdate.sql deleted file mode 100644 index 33f4ae84e..000000000 --- a/db/routines/hedera/triggers/orderRow_afterUpdate.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterUpdate` - AFTER UPDATE ON `orderRow` - FOR EACH ROW -BEGIN - CALL stock.log_add('orderRow', NEW.id, OLD.id); - CALL order_requestRecalc(OLD.orderFk); - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql index a4549549a..25f51b3f0 100644 --- a/db/routines/hedera/triggers/order_afterUpdate.sql +++ b/db/routines/hedera/triggers/order_afterUpdate.sql @@ -2,23 +2,15 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate` AFTER UPDATE ON `order` FOR EACH ROW -BEGIN - CALL stock.log_add('order', NEW.id, OLD.id); - - IF !(OLD.address_id <=> NEW.address_id) - OR !(OLD.company_id <=> NEW.company_id) - OR !(OLD.customer_id <=> NEW.customer_id) THEN - CALL order_requestRecalc(NEW.id); - END IF; - - IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN - -- Fallo que se actualiza no se sabe como tickets en este cliente - CALL vn.mail_insert( - 'jgallego@verdnatura.es', - 'noreply@verdnatura.es', - 'Actualizada order al address 2850', - CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) - ); - END IF; +BEGIN + IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN + -- Fallo que se actualiza no se sabe como tickets en este cliente + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Actualizada order al address 2850', + CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) + ); + END IF; END$$ DELIMITER ; diff --git a/db/routines/stock/procedures/inbound_addPick.sql b/db/routines/stock/procedures/inbound_addPick.sql index d867b5641..41b93a986 100644 --- a/db/routines/stock/procedures/inbound_addPick.sql +++ b/db/routines/stock/procedures/inbound_addPick.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_addPick`( vSelf INT, - vOutboundFk INT, - vQuantity INT + vOutboundFk INT, + vQuantity INT ) BEGIN INSERT INTO inboundPick diff --git a/db/routines/stock/procedures/inbound_removePick.sql b/db/routines/stock/procedures/inbound_removePick.sql index e125ee8a7..e183e1171 100644 --- a/db/routines/stock/procedures/inbound_removePick.sql +++ b/db/routines/stock/procedures/inbound_removePick.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_removePick`( vSelf INT, - vOutboundFk INT, - vQuantity INT, - vTotalQuantity INT + vOutboundFk INT, + vQuantity INT, + vTotalQuantity INT ) BEGIN IF vQuantity < vTotalQuantity THEN diff --git a/db/routines/stock/procedures/inbound_requestQuantity.sql b/db/routines/stock/procedures/inbound_requestQuantity.sql index 5d814ce2c..1cbc1908b 100644 --- a/db/routines/stock/procedures/inbound_requestQuantity.sql +++ b/db/routines/stock/procedures/inbound_requestQuantity.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_requestQuantity`( vSelf INT, - vRequested INT, - vDated DATETIME, - OUT vSupplied INT) + vRequested INT, + vDated DATETIME, + OUT vSupplied INT) BEGIN /** * Disassociates inbound picks after the given date until the @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSupplied = 0; OPEN vPicks; @@ -45,7 +45,7 @@ BEGIN SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity); SET vSupplied = vSupplied + vPickGranted; CALL inbound_removePick(vSelf, vOutboundFk, vPickGranted, vPickQuantity); - + UPDATE outbound SET isSync = FALSE, lack = lack + vPickGranted diff --git a/db/routines/stock/procedures/inbound_sync.sql b/db/routines/stock/procedures/inbound_sync.sql index fc672d920..77d3e42f7 100644 --- a/db/routines/stock/procedures/inbound_sync.sql +++ b/db/routines/stock/procedures/inbound_sync.sql @@ -23,7 +23,7 @@ BEGIN SELECT id, lack, lack < quantity FROM outbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated >= vDated AND (vExpired IS NULL OR dated < vExpired) ORDER BY dated, created; @@ -51,8 +51,8 @@ BEGIN END IF; SET vSupplied = LEAST(vAvailable, vLack); - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN SET vAvailable = vAvailable - vSupplied; UPDATE outbound SET lack = lack - vSupplied @@ -64,8 +64,8 @@ BEGIN SET vSupplied = vSupplied + vSuppliedFromRequest; SET vAvailable = vAvailable - vSuppliedFromRequest; END IF; - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN CALL inbound_addPick(vSelf, vOutboundFk, vSupplied); END IF; diff --git a/db/routines/stock/procedures/log_add.sql b/db/routines/stock/procedures/log_add.sql deleted file mode 100644 index 2b75c7f72..000000000 --- a/db/routines/stock/procedures/log_add.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255)) -proc: BEGIN - -- XXX: Disabled while testing - LEAVE proc; - - IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vOldId, - operation = 'delete'; - END IF; - - IF vNewId IS NOT NULL THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vNewId, - operation = 'insert'; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/stock/procedures/log_refreshAll.sql b/db/routines/stock/procedures/log_refreshAll.sql index eab91f8e9..3eaad07f2 100644 --- a/db/routines/stock/procedures/log_refreshAll.sql +++ b/db/routines/stock/procedures/log_refreshAll.sql @@ -10,7 +10,7 @@ BEGIN DO RELEASE_LOCK('stock.log_sync'); RESIGNAL; END; - + IF !GET_LOCK('stock.log_sync', 30) THEN CALL util.throw('Lock timeout exceeded'); END IF; diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql index 62fa73435..488c00a28 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshBuy`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues @@ -11,7 +11,7 @@ BEGIN e.id entryFk, t.id travelFk, b.itemFk, - e.isRaid, + e.isRaid, ADDTIME(t.shipped, IFNULL(t.shipmentHour, '00:00:00')) shipped, t.warehouseOutFk, @@ -24,7 +24,7 @@ BEGIN ABS(b.quantity) quantity, b.created, b.quantity > 0 isIn, - t.shipped < vn.getInventoryDate() lessThanInventory + t.shipped < vn.getInventoryDate() lessThanInventory FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel t ON t.id = e.travelFk @@ -52,7 +52,7 @@ BEGIN quantity, IF(isIn, isReceived, isDelivered) AND !isRaid FROM tValues - WHERE isIn OR !lessThanInventory; + WHERE isIn OR !lessThanInventory; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, @@ -67,7 +67,7 @@ BEGIN quantity, IF(isIn, isDelivered, isReceived) AND !isRaid FROM tValues - WHERE !isIn OR !lessThanInventory; + WHERE !isIn OR !lessThanInventory; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshOrder.sql b/db/routines/stock/procedures/log_refreshOrder.sql index 49225ddf0..ce5b31cc8 100644 --- a/db/routines/stock/procedures/log_refreshOrder.sql +++ b/db/routines/stock/procedures/log_refreshOrder.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshOrder`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DECLARE vExpireTime INT DEFAULT 20; DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT r.id rowFk, @@ -23,24 +23,24 @@ BEGIN OR (vTableName = 'order' AND o.id = vTableId) OR (vTableName = 'orderRow' AND r.id = vTableId) ) - AND !o.confirmed - AND r.shipment >= vn.getInventoryDate() + AND !o.confirmed + AND r.shipment >= vn.getInventoryDate() AND r.created >= vExpired AND r.amount != 0; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, expired, quantity + itemFk, created, expired, quantity ) - SELECT 'orderRow', + SELECT 'orderRow', rowFk, warehouseFk, shipped, itemFk, created, - TIMESTAMPADD(MINUTE, vExpireTime, created), + TIMESTAMPADD(MINUTE, vExpireTime, created), quantity - FROM tValues; + FROM tValues; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql index 0499fc711..983616dca 100644 --- a/db/routines/stock/procedures/log_refreshSale.sql +++ b/db/routines/stock/procedures/log_refreshSale.sql @@ -1,10 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshSale`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT m.id saleFk, @@ -14,7 +14,7 @@ BEGIN t.shipped, ABS(m.quantity) quantity, m.created, - TIMESTAMPADD(DAY, tp.life, t.shipped) expired, + TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, m.isPicked OR s.alertLevel > 1 isPicked FROM vn.sale m @@ -32,33 +32,33 @@ BEGIN REPLACE INTO inbound ( tableName, tableId, warehouseFk, dated, - itemFk, expired, quantity, isPicked + itemFk, expired, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, - expired, + expired, quantity, - isPicked - FROM tValues - WHERE isIn; + isPicked + FROM tValues + WHERE isIn; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, quantity, isPicked + itemFk, created, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, created, quantity, - isPicked - FROM tValues - WHERE !isIn; + isPicked + FROM tValues + WHERE !isIn; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/outbound_sync.sql b/db/routines/stock/procedures/outbound_sync.sql index c79bde45f..0de352176 100644 --- a/db/routines/stock/procedures/outbound_sync.sql +++ b/db/routines/stock/procedures/outbound_sync.sql @@ -7,7 +7,7 @@ BEGIN * @param vSelf The outbound reference */ DECLARE vDated DATETIME; - DECLARE vItem INT; + DECLARE vItem INT; DECLARE vWarehouse INT; DECLARE vLack INT; DECLARE vSupplied INT; @@ -21,7 +21,7 @@ BEGIN SELECT id, available, available < quantity FROM inbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated <= vDated AND (expired IS NULL OR expired > vDated) ORDER BY dated; diff --git a/db/routines/stock/procedures/visible_log.sql b/db/routines/stock/procedures/visible_log.sql index 2867f1186..cc88d3205 100644 --- a/db/routines/stock/procedures/visible_log.sql +++ b/db/routines/stock/procedures/visible_log.sql @@ -1,16 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`visible_log`( vIsPicked BOOL, - vWarehouseFk INT, - vItemFk INT, - vQuantity INT + vWarehouseFk INT, + vItemFk INT, + vQuantity INT ) proc: BEGIN IF !vIsPicked THEN LEAVE proc; END IF; - INSERT INTO visible + INSERT INTO visible SET itemFk = vItemFk, warehouseFk = vWarehouseFk, quantity = vQuantity diff --git a/db/routines/stock/triggers/inbound_afterDelete.sql b/db/routines/stock/triggers/inbound_afterDelete.sql index b485299b0..451dcc599 100644 --- a/db/routines/stock/triggers/inbound_afterDelete.sql +++ b/db/routines/stock/triggers/inbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE inboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - -OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + -OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/inbound_beforeInsert.sql b/db/routines/stock/triggers/inbound_beforeInsert.sql index 8aabb0682..723cb3222 100644 --- a/db/routines/stock/triggers/inbound_beforeInsert.sql +++ b/db/routines/stock/triggers/inbound_beforeInsert.sql @@ -4,12 +4,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`inbound_beforeInse FOR EACH ROW BEGIN SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_afterDelete.sql b/db/routines/stock/triggers/outbound_afterDelete.sql index dce0aed7a..e7d756871 100644 --- a/db/routines/stock/triggers/outbound_afterDelete.sql +++ b/db/routines/stock/triggers/outbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE outboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_beforeInsert.sql b/db/routines/stock/triggers/outbound_beforeInsert.sql index e41edae43..86546413e 100644 --- a/db/routines/stock/triggers/outbound_beforeInsert.sql +++ b/db/routines/stock/triggers/outbound_beforeInsert.sql @@ -5,12 +5,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_beforeIns BEGIN SET NEW.lack = NEW.quantity; SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - -NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + -NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql new file mode 100644 index 000000000..d6cf49377 --- /dev/null +++ b/db/routines/util/functions/binlogQueue_getDelay.sql @@ -0,0 +1,46 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255)) + RETURNS BIGINT + READS SQL DATA + NOT DETERMINISTIC +BEGIN +/** + * Returns the difference between the current position of the binary log and + * the passed queue. + * + * @param vCode The queue code + * @return The difference in MB + */ + DECLARE vCurLogName VARCHAR(255); + DECLARE vCurPosition BIGINT; + DECLARE vQueueLogName VARCHAR(255); + DECLARE vQueuePosition BIGINT; + DECLARE vDelay BIGINT; + + SELECT VARIABLE_VALUE INTO vCurLogName + FROM information_schema.GLOBAL_STATUS + WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_FILE'; + + SELECT VARIABLE_VALUE INTO vCurPosition + FROM information_schema.GLOBAL_STATUS + WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_POSITION'; + + SELECT logName, `position` + INTO vQueueLogName, vQueuePosition + FROM binlogQueue + WHERE code = vCode; + + IF vQueuePosition IS NULL THEN + RETURN NULL; + END IF; + + SET vDelay = + vCurPosition - CAST(vQueuePosition AS SIGNED) + + @@max_binlog_size * ( + CAST(REGEXP_SUBSTR(vCurLogName, '[0-9]+') AS SIGNED) - + CAST(REGEXP_SUBSTR(vQueueLogName, '[0-9]+') AS SIGNED) + ); + + RETURN ROUND(vDelay / POW(1024, 2)); +END$$ +DELIMITER ; diff --git a/db/routines/vn2008/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql similarity index 65% rename from db/routines/vn2008/events/raidUpdate.sql rename to db/routines/vn/events/raidUpdate.sql index aacfd6dcd..619dadb48 100644 --- a/db/routines/vn2008/events/raidUpdate.sql +++ b/db/routines/vn/events/raidUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn2008`.`raidUpdate` +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`raidUpdate` ON SCHEDULE EVERY 1 DAY STARTS '2017-12-29 00:05:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/ticket_doRecalc.sql b/db/routines/vn/events/ticket_doRecalc.sql deleted file mode 100644 index 9209c5715..000000000 --- a/db/routines/vn/events/ticket_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`ticket_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2022-01-28 09:29:18.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL ticket_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/events/travel_doRecalc.sql b/db/routines/vn/events/travel_doRecalc.sql deleted file mode 100644 index a08ecc068..000000000 --- a/db/routines/vn/events/travel_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_doRecalc` - ON SCHEDULE EVERY 15 SECOND - STARTS '2019-05-17 10:52:29.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL travel_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index 6a14d80d4..f1a8ac4cc 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -11,9 +11,9 @@ BEGIN SELECT a.Vista INTO vDeliveryType - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - WHERE Id_Ticket = vTicket; + FROM ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + WHERE t.id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS @@ -23,11 +23,11 @@ BEGIN SET vCode = 'ON_DELIVERY'; ELSE -- MERCADO, OTROS - SELECT t.warehouse_id <> w.warehouse_id INTO isWaitingForPickUp - FROM vn2008.Tickets t + SELECT t.warehouseFk <> w.warehouse_id INTO isWaitingForPickUp + FROM ticket t LEFT JOIN vn2008.warehouse_pickup w - ON w.agency_id = t.Id_Agencia AND w.warehouse_id = t.warehouse_id - WHERE t.Id_Ticket = vTicket; + ON w.agency_id = t.agencyModeFk AND w.warehouse_id = t.warehouseFk + WHERE t.id = vTicket; IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 9bd2c110e..9a3bb4a0e 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -28,10 +28,10 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) SELECT (ag.`name` = 'VN_VALENCIA') INTO vIsValenciaPath - FROM vn2008.Rutas r - JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia + FROM `route` r + JOIN vn2008.Agencias a on a.Id_Agencia = r.agencyModeFk JOIN vn2008.agency ag on ag.agency_id = a.agency_id - WHERE r.Id_Ruta = vMyPath; + WHERE r.id = vMyPath; IF vIsValenciaPath THEN -- Rutas Valencia diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 1af0ff9eb..4b860103d 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -48,7 +48,7 @@ BEGIN 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.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + b.groupingMode groupingMode, tl.buyFk, i.typeFk, IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping @@ -252,14 +252,15 @@ BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 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)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk 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; INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) diff --git a/db/routines/vn/procedures/client_getDebt.sql b/db/routines/vn/procedures/client_getDebt.sql index ad7b5b7d2..3eaace4e9 100644 --- a/db/routines/vn/procedures/client_getDebt.sql +++ b/db/routines/vn/procedures/client_getDebt.sql @@ -17,15 +17,15 @@ BEGIN SET vEnded = util.dayEnd(IFNULL(vDate, util.VN_CURDATE())); - CREATE OR REPLACE TEMPORARY TABLE tClientRisk + CREATE OR REPLACE TEMPORARY TABLE tClientRisk ENGINE = MEMORY - SELECT cr.clientFk, SUM(cr.amount) amount + SELECT cr.clientFk, SUM(cr.amount) amount FROM clientRisk cr JOIN tmp.clientGetDebt c ON c.clientFk = cr.clientFk GROUP BY cr.clientFk; INSERT INTO tClientRisk - SELECT c.clientFk, SUM(r.amountPaid) + SELECT c.clientFk, SUM(r.amountPaid) FROM receipt r JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk WHERE r.payed > vEnded diff --git a/db/routines/vn/procedures/client_getRisk.sql b/db/routines/vn/procedures/client_getRisk.sql new file mode 100644 index 000000000..7fbade303 --- /dev/null +++ b/db/routines/vn/procedures/client_getRisk.sql @@ -0,0 +1,35 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`( + vDate DATE +) +BEGIN +/** + * Retorna el riesgo de los clientes activos. + * + * @param vDate Fecha a calcular + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT id clientFk + FROM client + WHERE isActive; + + CALL client_getDebt(vDate); + + SELECT c.socialName, + r.clientFk, + c.credit, + CAST(r.risk AS DECIMAL (10,2)) risk, + CAST(c.credit - r.risk AS DECIMAL (10,2)) difference, + co.country + FROM client c + JOIN tmp.risk r ON r.clientFk = c.id + JOIN country co ON co.id = c.countryFk + GROUP BY c.id; + + DROP TEMPORARY TABLE + tmp.risk, + tmp.clientGetDebt; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 3641ba705..3fb3339e7 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -40,8 +40,8 @@ BEGIN ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing + WHEN NULL THEN 1 + WHEN 'packing' THEN b.packing ELSE b.`grouping` END `grouping` FROM buy b diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql index 8028dc5fb..8ddb9d721 100644 --- a/db/routines/vn/procedures/creditInsurance_getRisk.sql +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -2,41 +2,41 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() BEGIN /** - * Devuelve el riesgo de los clientes que estan asegurados - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * FROM ( - SELECT cc.client Id_Cliente, ci.grade - FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification - WHERE dateEnd IS NULL - ORDER BY ci.creationDate DESC - LIMIT 10000000000000000000) t1 - GROUP BY Id_Cliente; +* Devuelve el riesgo de los clientes que estan asegurados +*/ + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT cc.client clientFk, ci.grade + FROM creditClassification cc + JOIN creditInsurance ci ON cc.id = ci.creditClassification + WHERE dateEnd IS NULL + ORDER BY ci.creationDate DESC + LIMIT 10000000000000000000) t1 + GROUP BY clientFk; - CALL vn2008.risk_vs_client_list(util.VN_CURDATE()); + CALL client_getDebt(util.VN_CURDATE()); - SELECT - c.id, - c.name, - c.credit clientCredit, - c.creditInsurance solunion, - CAST(r.risk AS DECIMAL(10,0)) risk, - CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive, - cac.invoiced billedAnnually, - c.dueDay, - ci.grade, - c2.country - FROM tmp.client_list ci - LEFT JOIN tmp.risk r ON r.Id_Cliente = ci.Id_Cliente - JOIN client c ON c.id = ci.Id_Cliente - JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk - JOIN country c2 ON c2.id = c.countryFk - GROUP BY c.id; + SELECT c.id, + c.name, + c.credit clientCredit, + c.creditInsurance solunion, + CAST(r.risk AS DECIMAL(10,0)) risk, + CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive, + cac.invoiced billedAnnually, + c.dueDay, + cgd.grade, + c2.country + FROM tmp.clientGetDebt cgd + LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk + JOIN client c ON c.id = cgd.clientFk + JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk + JOIN country c2 ON c2.id = c.countryFk + GROUP BY c.id; - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE + tmp.risk, + tmp.clientGetDebt; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql new file mode 100644 index 000000000..687d652dd --- /dev/null +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() +BEGIN +/** + * Actualiza el crédito de los clientes + */ + + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE `client` c + JOIN payMethod pm ON pm.id = c.payMethodFk + SET c.credit = 0 + WHERE pm.`code` = 'card'; + + DROP TEMPORARY TABLE IF EXISTS tCreditClients; + CREATE TEMPORARY TABLE tCreditClients + SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit + FROM ( + SELECT r.clientFk, + r.amount recovery, + (sub2.created + INTERVAL r.period DAY) deadLine, + sub2.amount credit + FROM recovery r + JOIN ( + SELECT clientFk, amount, created + FROM ( + SELECT clientFk, amount, created + FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub + GROUP BY clientFk + ) sub2 ON sub2.clientFk = r.clientFk + WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() + GROUP BY r.clientFk + HAVING deadLine <= util.VN_CURDATE() + ) sub3 + WHERE credit > 0; + + UPDATE client c + JOIN tCreditClients cc ON cc.clientFk = c.id + SET c.credit = newCredit; + + DROP TEMPORARY TABLE tCreditClients; + COMMIT; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index c50d75b05..b7ea377d2 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -116,7 +116,7 @@ BEGIN freightValue decimal(10,3) DEFAULT '0.000', packing int(11) 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', packageValue decimal(10,3) DEFAULT '0.000', packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bde7afd8c..2879460ce 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -8,12 +8,15 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; - CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets WHERE (Fecha BETWEEN vMinDateTicket - AND vMaxTicketDate) AND Id_Consigna = vAddress - AND Factura IS NULL AND empresa_id = vCompany; + ENGINE = MEMORY + SELECT id + FROM ticket + WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) + AND addressFk = vAddress + AND refFk IS NULL + AND companyFk = vCompany; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 60ec34696..43d54c28c 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -10,6 +10,8 @@ BEGIN DECLARE vLines INT; DECLARE vHasDistinctTransactions INT; + CALL invoiceIn_checkBooked(vInvoiceInFk); + SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; SELECT COUNT(*) INTO vLines diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index 5a53b7543..631b8f31c 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -4,16 +4,9 @@ BEGIN DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - DECLARE vIsBooked BOOLEAN DEFAULT FALSE; - SELECT isBooked INTO vIsBooked - FROM invoiceIn ii - WHERE id = vInvoiceInFk; + CALL invoiceIn_checkBooked(vInvoiceInFk); - IF vIsBooked THEN - CALL util.throw('A booked invoice cannot be modified'); - END IF; - SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql new file mode 100644 index 000000000..862870eb4 --- /dev/null +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -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 ; diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index e576a6c16..6f275de86 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -61,8 +61,8 @@ BEGIN a.available, IFNULL(ip.counter, 0) `counter`, CASE - WHEN b.groupingMode = 1 THEN b.grouping - WHEN b.groupingMode = 2 THEN b.packing + WHEN b.groupingMode = 'grouping' THEN b.grouping + WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END AS minQuantity, iss.visible located, diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1cc2a8871..0a6c54971 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -13,6 +13,7 @@ BEGIN * @param vQuantity a dar de alta/baja * @param vAddressFk id address */ + DECLARE vTicketFk INT; DECLARE vClientFk INT; DECLARE vDefaultCompanyFk INT; @@ -23,17 +24,17 @@ BEGIN SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk FROM vn.ticket LIMIT 1; - - IF vAddressFk IS NULL THEN + + IF vAddressFk IS NULL THEN SELECT pc.shortageAddressFk INTO vAddressShortage FROM productionConfig pc ; - ELSE + ELSE SET vAddressShortage = vAddressFk; END IF; SELECT a.clientFk INTO vClientFk FROM address a - WHERE a.id = vAddressFk; + WHERE a.id = vAddressShortage; SELECT t.id INTO vTicketFk FROM ticket t @@ -65,7 +66,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + name, vQuantity FROM item WHERE id = vItemFk; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql new file mode 100644 index 000000000..703c14e5c --- /dev/null +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -0,0 +1,31 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() +BEGIN +/** + * Actualiza el travel de las entradas de redadas + */ + UPDATE entry e + JOIN entryVirtual ev ON ev.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN ( + SELECT * + FROM ( + SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk + FROM travel t + JOIN ( + SELECT t.warehouseInFk, t.warehouseOutFk + FROM entryVirtual ev + JOIN entry e ON e.id = ev.entryFk + JOIN travel t ON t.id = e.travelFk + GROUP BY t.warehouseInFk, t.warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + WHERE shipped > util.VN_CURDATE() AND NOT isDelivered + ORDER BY t.landed + LIMIT 10000000000000000000 + ) t + GROUP BY t.warehouseInFk, t.warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + SET e.travelFk = t.id; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql new file mode 100644 index 000000000..d840aa9d5 --- /dev/null +++ b/db/routines/vn/procedures/rateView.sql @@ -0,0 +1,38 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() +BEGIN +/** + * Muestra información sobre tasas de cambio de Dolares + */ + SELECT + t.year año, + t.month mes, + pay.dollars dolares, + pay.changePractical cambioPractico, + CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4))cambioTeorico, + pay.changeOfficial cambioOficial + FROM invoiceIn ii + JOIN time t ON t.dated = ii.issued + JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk + JOIN + ( SELECT + t.year, + t.month, + CAST(SUM(p.divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(p.divisa) / SUM(p.amount) AS DECIMAL(5,4)) changePractical, + CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial + FROM payment p + JOIN time t ON t.dated = p.received + JOIN referenceRate rr ON rr.dated = p.received + JOIN currency c ON c.id = rr.currencyFk + WHERE p.divisa + AND c.code = 'USD' + GROUP BY t.year, t.month + ) pay ON t.year = pay.year AND t.month = pay.month + JOIN currency c ON c.id = ii.currencyFk + WHERE c.code = 'USD' + AND iit.foreignValue + AND iit.taxableBase + GROUP BY t.year, t.month; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql deleted file mode 100644 index 66c0a0dd5..000000000 --- a/db/routines/vn/procedures/riskAllClients.sql +++ /dev/null @@ -1,29 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT id Id_Cliente, null grade FROM vn.client; - - CALL vn2008.risk_vs_client_list(maxRiskDate); - - SELECT - c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais - FROM - vn2008.Clientes c - JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente - JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente - GROUP BY c.Id_cliente; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 1d9f6ff71..056397274 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk INT; + DECLARE vGroupingMode VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -23,8 +23,6 @@ BEGIN DECLARE vOldPrice DECIMAL(10,2); DECLARE vOption VARCHAR(255); DECLARE vNewSaleFk INT; - DECLARE vForceToGrouping INT DEFAULT 1; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vFinalPrice DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION @@ -58,15 +56,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing - INTO vGrouping,vGroupingModeFk,vPacking + INTO vGrouping,vGroupingMode,vPacking FROM buy b JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk 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; END IF; - IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN + IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; diff --git a/db/routines/vn/procedures/ticket_doRecalc.sql b/db/routines/vn/procedures/ticket_doRecalc.sql deleted file mode 100644 index 1dd2a05cb..000000000 --- a/db/routines/vn/procedures/ticket_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRecalc`() -proc: BEGIN -/** - * Recalculates modified ticket. - */ - DECLARE vDone BOOL; - DECLARE vTicketFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT ticketFk FROM tTicket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('vn.ticket_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tTicket; - CREATE TEMPORARY TABLE tTicket - ENGINE = MEMORY - SELECT id, ticketFk FROM ticketRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vTicketFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL ticket_recalc(vTicketFk, NULL); - END LOOP; - - CLOSE cCur; - - DELETE tr FROM ticketRecalc tr JOIN tTicket t ON tr.id = t.id; - - DROP TEMPORARY TABLE tTicket; - - DO RELEASE_LOCK('vn.ticket_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql new file mode 100644 index 000000000..41105fe23 --- /dev/null +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -0,0 +1,40 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcByScope`( + vScope VARCHAR(255), + vId INT +) +BEGIN +/** + * Recalculates tickets in an scope. + * + * @param vScope The scope name + * @param vId The scope id + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE cTickets CURSOR FOR + SELECT id FROM ticket + WHERE refFk IS NULL + AND ((vScope = 'client' AND clientFk = vId) + OR (vScope = 'address' AND addressFk = vId)); + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cTickets; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cTickets INTO vTicketFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL ticket_recalc(vTicketFk, NULL); + END LOOP; + + CLOSE cTickets; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_requestRecalc.sql b/db/routines/vn/procedures/ticket_requestRecalc.sql deleted file mode 100644 index 6636e4c0f..000000000 --- a/db/routines/vn/procedures/ticket_requestRecalc.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the ticket total. - * - * @param vSelf The ticket identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - INSERT INTO ticketRecalc SET ticketFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_doRecalc.sql b/db/routines/vn/procedures/travel_doRecalc.sql deleted file mode 100644 index 5d877174c..000000000 --- a/db/routines/vn/procedures/travel_doRecalc.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_doRecalc`() -proc: BEGIN -/** -* Recounts the number of entries of changed travels. -*/ - DECLARE vTravelFk INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - END; - - IF !GET_LOCK('vn.travel_doRecalc', 0) THEN - LEAVE proc; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tTravel - ENGINE = MEMORY - SELECT travelFk FROM travelRecalc; - - UPDATE travel t - JOIN tTravel tt ON tt.travelFk = t.id - SET t.totalEntries = ( - SELECT COUNT(e.id) - FROM entry e - WHERE e.travelFk = t.id - ); - - DELETE tr FROM travelRecalc tr JOIN tTravel t ON tr.travelFk = t.travelFk; - DROP TEMPORARY TABLE tTravel; - DO RELEASE_LOCK('vn.travel_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_recalc.sql b/db/routines/vn/procedures/travel_recalc.sql new file mode 100644 index 000000000..46d1cdc4f --- /dev/null +++ b/db/routines/vn/procedures/travel_recalc.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) +proc: BEGIN +/** + * Updates the number of entries assigned to the travel. + * + * @param vSelf The travel id + */ + UPDATE travel + SET totalEntries = ( + SELECT COUNT(id) + FROM entry + WHERE travelFk = vSelf + ) + WHERE id = vSelf; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/travel_requestRecalc.sql b/db/routines/vn/procedures/travel_requestRecalc.sql deleted file mode 100644 index 5797f2397..000000000 --- a/db/routines/vn/procedures/travel_requestRecalc.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recount the number of entries for the travel. - * - * @param vSelf The travel reference - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - INSERT IGNORE INTO travelRecalc SET travelFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/address_afterUpdate.sql b/db/routines/vn/triggers/address_afterUpdate.sql index 6160aa2a5..ab5e03882 100644 --- a/db/routines/vn/triggers/address_afterUpdate.sql +++ b/db/routines/vn/triggers/address_afterUpdate.sql @@ -5,36 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterUpdate` BEGIN -- Recargos de equivalencia distintos implican facturacion por consignatario IF NEW.isEqualizated != OLD.isEqualizated THEN - IF + IF (SELECT COUNT(*) FROM ( SELECT DISTINCT (isEqualizated = FALSE) as Equ - FROM address + FROM address WHERE clientFk = NEW.clientFk ) t1 ) > 1 - THEN - UPDATE client + THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; END IF; END IF; + IF NEW.isDefaultAddress AND NEW.isActive = FALSE THEN CALL util.throw ('Cannot desactivate the default address'); END IF; - IF NOT (NEW.isEqualizated <=> OLD.isEqualizated) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.addressFk = NEW.id - AND t.refFk IS NULL; - END IF; - - IF (NEW.clientFk <> OLD.clientFk OR NEW.isActive <> OLD.isActive OR NOT (NEW.provinceFk <=> OLD.provinceFk)) - AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN - UPDATE client + IF (NEW.clientFk <> OLD.clientFk + OR NEW.isActive <> OLD.isActive + OR NOT (NEW.provinceFk <=> OLD.provinceFk)) + AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; - END IF; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterDelete.sql b/db/routines/vn/triggers/buy_afterDelete.sql index 2fcb0852d..5daaefa33 100644 --- a/db/routines/vn/triggers/buy_afterDelete.sql +++ b/db/routines/vn/triggers/buy_afterDelete.sql @@ -3,19 +3,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW trig: BEGIN - DECLARE vValues VARCHAR(255); - IF @isModeInventory OR @isTriggerDisabled THEN LEAVE trig; END IF; - CALL stock.log_add('buy', NULL, OLD.id); - INSERT INTO entryLog SET `action` = 'delete', `changedModel` = 'Buy', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterInsert.sql b/db/routines/vn/triggers/buy_afterInsert.sql index 25682f1bb..b39842d35 100644 --- a/db/routines/vn/triggers/buy_afterInsert.sql +++ b/db/routines/vn/triggers/buy_afterInsert.sql @@ -7,8 +7,6 @@ trig: BEGIN LEAVE trig; END IF; - CALL stock.log_add('buy', NEW.id, NULL); - CALL buy_afterUpsert(NEW.id); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterUpdate.sql b/db/routines/vn/triggers/buy_afterUpdate.sql index 9866f5bb8..fc7ca152d 100644 --- a/db/routines/vn/triggers/buy_afterUpdate.sql +++ b/db/routines/vn/triggers/buy_afterUpdate.sql @@ -12,14 +12,6 @@ trig: BEGIN LEAVE trig; END IF; - IF !(NEW.id <=> OLD.id) - OR !(NEW.entryFk <=> OLD.entryFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) THEN - CALL stock.log_add('buy', NEW.id, OLD.id); - END IF; - CALL buy_afterUpsert(NEW.id); SELECT w.isBuyerToBeEmailed, t.landed diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index bc51ac852..6ad72916b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -6,7 +6,7 @@ trig: BEGIN DECLARE vWarehouse INT; DECLARE vLanding DATE; DECLARE vGrouping INT; - DECLARE vGroupingMode TINYINT; + DECLARE vGroupingMode VARCHAR(255); DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; DECLARE vBuyerFk INT; diff --git a/db/routines/vn/triggers/client_afterUpdate.sql b/db/routines/vn/triggers/client_afterUpdate.sql index 481b00007..8bca36d63 100644 --- a/db/routines/vn/triggers/client_afterUpdate.sql +++ b/db/routines/vn/triggers/client_afterUpdate.sql @@ -4,20 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate` FOR EACH ROW BEGIN IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN - UPDATE `address` SET isDefaultAddress = 0 + UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; - - UPDATE `address` SET isDefaultAddress = 1 - WHERE id = NEW.defaultAddressFk; + + UPDATE `address` SET isDefaultAddress = TRUE + WHERE id = NEW.defaultAddressFk; END IF; - IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.clientFk = NEW.id - AND t.refFk IS NULL; - END IF; - IF NOT NEW.isActive THEN UPDATE account.`user` SET active = FALSE diff --git a/db/routines/vn/triggers/entry_afterDelete.sql b/db/routines/vn/triggers/entry_afterDelete.sql index 5c246651d..c723930fa 100644 --- a/db/routines/vn/triggers/entry_afterDelete.sql +++ b/db/routines/vn/triggers/entry_afterDelete.sql @@ -8,7 +8,5 @@ BEGIN `changedModel` = 'Entry', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL travel_requestRecalc(OLD.travelFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterInsert.sql b/db/routines/vn/triggers/entry_afterInsert.sql deleted file mode 100644 index 79563c17f..000000000 --- a/db/routines/vn/triggers/entry_afterInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterInsert` - AFTER INSERT ON `entry` - FOR EACH ROW -BEGIN - CALL travel_requestRecalc(NEW.travelFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index 60adc0003..47d61ed30 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -3,24 +3,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF NOT(NEW.id <=> OLD.id) - OR NOT(NEW.travelFk <=> OLD.travelFk) - OR NOT(NEW.isRaid <=> OLD.isRaid) THEN - CALL stock.log_add('entry', NEW.id, OLD.id); - END IF; - - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - CALL travel_requestRecalc(OLD.travelFk); - CALL travel_requestRecalc(NEW.travelFk); - END IF; - - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id FROM buy b WHERE b.entryFk = NEW.id; - + CALL buy_checkItem(); END IF; END$$ diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql new file mode 100644 index 000000000..f4df48dcd --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql new file mode 100644 index 000000000..aec58a265 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql new file mode 100644 index 000000000..bd324863b --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql new file mode 100644 index 000000000..10c9d0b52 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..95b227616 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(NEW.invoiceInFk); + SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql index 2452ff0d1..5d58ef28b 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql new file mode 100644 index 000000000..412b091f4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql new file mode 100644 index 000000000..d6c25c505 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql new file mode 100644 index 000000000..649c9ef30 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql new file mode 100644 index 000000000..a43f602b4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 30918b7c5..3e5ecf030 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); + IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); END IF; diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index b1308393c..1a9105c9e 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued OR NEW.currencyFk != OLD.currencyFk THEN diff --git a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql new file mode 100644 index 000000000..2ffff923a --- /dev/null +++ b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql @@ -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 ; diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 4503c7dbd..d0762de96 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,6 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN 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 CALL util.throw('The invoiceIn reference contains invalid characters'); END IF; diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index fab1c52cd..6365208b2 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -12,9 +12,6 @@ BEGIN `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - CALL stock.log_add('sale', NULL, OLD.id); - CALL ticket_requestRecalc(OLD.ticketFk); - SELECT account.myUser_getName() INTO vUserRole; SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index d4c2d60f5..b5b28257f 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -7,11 +7,7 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - CALL stock.log_add('sale', NEW.id, NULL); - CALL ticket_requestRecalc(NEW.ticketFk); - IF NEW.quantity > 0 THEN - UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 0d21f08d7..3f59c9188 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -6,24 +6,6 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - IF !(NEW.id <=> OLD.id) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) - OR !(NEW.isPicked <=> OLD.isPicked) THEN - CALL stock.log_add('sale', NEW.id, OLD.id); - END IF; - - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.discount <=> OLD.discount) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; - IF !(OLD.ticketFk <=> NEW.ticketFk) THEN UPDATE ticketRequest SET ticketFk = NEW.ticketFk WHERE saleFk = NEW.id; diff --git a/db/routines/vn/triggers/ticketService_afterDelete.sql b/db/routines/vn/triggers/ticketService_afterDelete.sql index 11d5aaf24..ca2675ce8 100644 --- a/db/routines/vn/triggers/ticketService_afterDelete.sql +++ b/db/routines/vn/triggers/ticketService_afterDelete.sql @@ -8,8 +8,5 @@ BEGIN `changedModel` = 'TicketService', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL ticket_requestRecalc(OLD.ticketFk); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterInsert.sql b/db/routines/vn/triggers/ticketService_afterInsert.sql deleted file mode 100644 index b9142ff72..000000000 --- a/db/routines/vn/triggers/ticketService_afterInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterInsert` - AFTER INSERT ON `ticketService` - FOR EACH ROW -BEGIN - - CALL ticket_requestRecalc(NEW.ticketFk); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterUpdate.sql b/db/routines/vn/triggers/ticketService_afterUpdate.sql deleted file mode 100644 index ecc9e9a5a..000000000 --- a/db/routines/vn/triggers/ticketService_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterUpdate` - AFTER UPDATE ON `ticketService` - FOR EACH ROW -BEGIN - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.quantity <=> OLD.quantity) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index df939c9d1..f1ad394ef 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -3,24 +3,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN - CALL stock.log_add('ticket', NEW.id, OLD.id); - END IF; - - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); - END IF; - IF NEW.routeFk <> OLD.routeFk THEN - UPDATE expedition + UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index 38cd3ba13..7cfe865f3 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -3,10 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate` AFTER UPDATE ON `travel` FOR EACH ROW BEGIN - CALL stock.log_add('travel', NEW.id, OLD.id); - IF NOT(NEW.shipped <=> OLD.shipped) THEN - UPDATE entry + UPDATE entry SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; END IF; @@ -15,11 +13,11 @@ BEGIN IF (SELECT hasWeightVolumetric FROM agencyMode WHERE id = NEW.agencyModeFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id - FROM entry e + FROM entry e JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk WHERE e.travelFk = NEW.id; - + CALL buy_checkItem(); END IF; END IF; diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index d612c8742..26b928ac4 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -1,8 +1,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketMRW` -AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, - `Tickets`.`empresa_id` AS `empresa_id`, +AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`, + `ticket`.`companyFk` AS `empresa_id`, `Consignatarios`.`consignatario` AS `Consignatario`, `Consignatarios`.`domicilio` AS `DOMICILIO`, `Consignatarios`.`poblacion` AS `POBLACION`, @@ -19,13 +19,13 @@ AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, 0 ) AS `movil`, `Clientes`.`if` AS `IF`, - `Tickets`.`Id_Ticket` AS `Id_Ticket`, - `Tickets`.`warehouse_id` AS `warehouse_id`, + `ticket`.`id` AS `Id_Ticket`, + `ticket`.`warehouseFk` AS `warehouse_id`, `Consignatarios`.`id_consigna` AS `Id_Consigna`, `Paises`.`Codigo` AS `CodigoPais`, - `Tickets`.`Fecha` AS `Fecha`, + `ticket`.`shipped` AS `Fecha`, `province`.`province_id` AS `province_id`, - `Tickets`.`landing` AS `landing` + `ticket`.`landed` AS `landing` FROM ( ( ( @@ -35,8 +35,8 @@ FROM ( `Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente` ) ) - JOIN `vn2008`.`Tickets` ON( - `Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna` + JOIN `vn`.`ticket` ON( + `Consignatarios`.`id_consigna` = `ticket`.`addressFk` ) ) JOIN `vn2008`.`province` ON( @@ -44,4 +44,4 @@ FROM ( ) ) JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ) + ); diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql index a3d2c8bea..42a7c51c9 100644 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ b/db/routines/vn2008/procedures/availableTraslate.sql @@ -18,7 +18,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT inventoried INTO vDatedInventory FROM vn.config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; diff --git a/db/routines/vn2008/procedures/raidUpdate.sql b/db/routines/vn2008/procedures/raidUpdate.sql deleted file mode 100644 index 9746f3cf9..000000000 --- a/db/routines/vn2008/procedures/raidUpdate.sql +++ /dev/null @@ -1,28 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`raidUpdate`() -BEGIN - - UPDATE Entradas e - JOIN Entradas_Auto ea USING (Id_Entrada) - JOIN travel t ON t.id = e.travel_id - JOIN ( - SELECT * - FROM ( - SELECT id, landing, warehouse_id, warehouse_id_out - FROM travel - JOIN ( - SELECT warehouse_id, warehouse_id_out - FROM Entradas_Auto ea - JOIN Entradas e USING(Id_Entrada) - JOIN travel t ON t.id = e.travel_id - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - WHERE shipment > util.VN_CURDATE() AND delivered = FALSE - ORDER BY landing - LIMIT 10000000000000000000 - ) t - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - SET e.travel_id = t.id; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/rateView.sql b/db/routines/vn2008/procedures/rateView.sql deleted file mode 100644 index 91e317be6..000000000 --- a/db/routines/vn2008/procedures/rateView.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`rateView`() -BEGIN - - SELECT - t.year as año, - t.month as mes, - pagos.dolares, - pagos.cambioPractico, - CAST(sum(divisa) / sum(bi) as DECIMAL(5,4)) as cambioTeorico, - pagos.cambioOficial - FROM recibida r - JOIN time t ON t.date = r.fecha - JOIN recibida_iva ri ON r.id = ri.recibida_id - JOIN - ( - SELECT - t.year as Año, - t.month as Mes, - cast(sum(divisa) as DECIMAL(10,2)) as dolares, - cast(sum(divisa) / sum(importe) as DECIMAL(5,4)) as cambioPractico, - cast(rr.rate * 0.998 as DECIMAL(5,4)) as cambioOficial - FROM pago p - JOIN time t ON t.date = p.fecha - JOIN reference_rate rr ON rr.date = p.fecha AND moneda_id = 2 - WHERE divisa - AND fecha >= '2015-01-11' - GROUP BY t.year, t.month - ) pagos ON t.year = pagos.Año AND t.month = pagos.Mes - WHERE moneda_id = 2 - AND fecha >= '2015-01-01' - AND divisa - AND bi - GROUP BY t.year, t.month; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql deleted file mode 100644 index 3657f2b9b..000000000 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recobro_credito`() -BEGIN - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - UPDATE vn.`client` c - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - SET credit = 0 - WHERE pm.`code` = 'card'; - - DROP TEMPORARY TABLE IF EXISTS clientes_credit; - CREATE TEMPORARY TABLE clientes_credit - SELECT Id_Cliente, if (Credito > Recobro ,Credito - Recobro,0) AS newCredit - FROM ( - SELECT r.Id_Cliente, r.amount AS Recobro, - timestampadd(DAY, period, UltimaFecha) AS Deadline, sub2.amount AS Credito - FROM vn2008.recovery r - JOIN ( - SELECT Id_Cliente, amount , odbc_date AS UltimaFecha - FROM ( - SELECT * FROM credit - ORDER BY odbc_date DESC - LIMIT 10000000000000000000 - ) sub - GROUP BY Id_Cliente - ) sub2 USING(Id_Cliente) - WHERE dend IS NULL or dend >= util.VN_CURDATE() - GROUP BY Id_Cliente - HAVING Deadline <= util.VN_CURDATE() - ) sub3 - WHERE Credito > 0; - - UPDATE Clientes - JOIN clientes_credit USING(Id_Cliente) - SET Clientes.Credito = newCredit; - - DROP TEMPORARY TABLE clientes_credit; - COMMIT; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql deleted file mode 100644 index 92f94eb9f..000000000 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ /dev/null @@ -1,84 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE) -BEGIN -/** - * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list - * - * @deprecated usar vn.client_getDebt - * @param maxRiskDate Fecha maxima de los registros - * @return table tmp.risk - */ - DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE()); - DECLARE endingDate DATETIME; - DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; - - SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE()); - SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2; - CREATE TEMPORARY TABLE tmp.client_list_2 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3; - CREATE TEMPORARY TABLE tmp.client_list_3 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar; - CREATE TEMPORARY TABLE tmp.tickets_sin_facturar - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total - FROM Movimientos m - JOIN Tickets t on m.Id_Ticket = t.Id_Ticket - JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente - JOIN vn.client cl ON cl.id = t.Id_Cliente - WHERE Factura IS NULL - AND Fecha BETWEEN startingDate AND endingDate - GROUP BY t.Id_Cliente; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - CREATE TEMPORARY TABLE tmp.risk - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo - FROM Clientes c - JOIN ( - SELECT clientFk, SUM(amount) amount,SUM(amount) saldo - FROM vn.clientRisk - JOIN tmp.client_list on Id_Cliente = clientFk - GROUP BY clientFk - UNION ALL - SELECT Id_Cliente, SUM(Entregado),SUM(Entregado) - FROM Recibos - JOIN tmp.client_list_2 using(Id_Cliente) - WHERE Fechacobro > endingDate - GROUP BY Id_Cliente - UNION ALL - SELECT Id_Cliente, total,0 - FROM tmp.tickets_sin_facturar - UNION ALL - SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction t - JOIN tmp.client_list_3 on Id_Cliente = t.clientFk - WHERE t.receiptFk IS NULL - AND t.status = 'ok' - GROUP BY t.clientFk - ) t ON c.Id_Cliente = t.clientFk - WHERE c.activo != FALSE - GROUP BY c.Id_Cliente; - - DELETE r.* - FROM tmp.risk r - JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente - JOIN vn2008.pay_met pm on pm.id = c.pay_met_id - WHERE IFNULL(r.saldo,0) < 10 - AND r.risk <= MAX_RISK_ALLOWED - AND pm.`name` = 'TARJETA'; -END$$ -DELIMITER ; diff --git a/db/versions/10895-pinkArborvitae/00-firstScript.sql b/db/versions/10895-pinkArborvitae/00-firstScript.sql new file mode 100644 index 000000000..2387fda08 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/00-firstScript.sql @@ -0,0 +1,11 @@ +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_4`; +ALTER TABLE `vn`.`arcRead` DROP FOREIGN KEY IF EXISTS `worker_printer_FK`; +ALTER TABLE `vn`.`host` DROP FOREIGN KEY IF EXISTS `configHost_FK`; +ALTER TABLE `vn`.`operator` DROP FOREIGN KEY IF EXISTS `operator_FK_5`; +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_1`; +ALTER TABLE `vn`.`printQueue` DROP FOREIGN KEY IF EXISTS `printQueue_printerFk`; +ALTER TABLE `vn`.`sector` DROP FOREIGN KEY IF EXISTS `sector_FK_1`; +ALTER TABLE `vn`.`worker` DROP FOREIGN KEY IF EXISTS `worker_FK`; +ALTER TABLE dipole.printer DROP FOREIGN KEY IF EXISTS printer_FK; +ALTER TABLE dipole.expedition_PrintOut DROP FOREIGN KEY IF EXISTS expedition_PrintOut_FK; + diff --git a/db/versions/10895-pinkArborvitae/01-secondScript.sql b/db/versions/10895-pinkArborvitae/01-secondScript.sql new file mode 100644 index 000000000..03f1aeccb --- /dev/null +++ b/db/versions/10895-pinkArborvitae/01-secondScript.sql @@ -0,0 +1,28 @@ +ALTER TABLE `vn`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned auto_increment NOT NULL; + +ALTER TABLE `vn`.`arcRead` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`arcRead` ADD CONSTRAINT `arcRead_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`host` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`host` ADD CONSTRAINT `host_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`operator` MODIFY COLUMN IF EXISTS `labelerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`operator` ADD CONSTRAINT `operator_FK_4` FOREIGN KEY IF NOT EXISTS (labelerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_1` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE RESTRICT; + +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerRfidFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_4` FOREIGN KEY IF NOT EXISTS(printerRfidFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`printQueue` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`sector` MODIFY COLUMN IF EXISTS `mainPrinterFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`sector` ADD CONSTRAINT `sector_FK` FOREIGN KEY IF NOT EXISTS (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `dipole`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned DEFAULT NULL NULL; +ALTER TABLE `dipole`.`printer` ADD CONSTRAINT `vnPrinter_FK` FOREIGN KEY IF NOT EXISTS (id) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `dipole`.`expedition_PrintOut` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT 0 NOT NULL; +ALTER TABLE `dipole`.`expedition_PrintOut` ADD CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES printer(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10895-pinkArborvitae/02-thirdScript.sql b/db/versions/10895-pinkArborvitae/02-thirdScript.sql new file mode 100644 index 000000000..142ec06b1 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/02-thirdScript.sql @@ -0,0 +1,17 @@ + +ALTER TABLE `vn`.`productionConfig` ADD IF NOT EXISTS backupPrinterNotificationDelay int unsigned NULL + COMMENT 'Minimum seconds Interval to Prevent Spam from Same-Type Notifications'; + +ALTER TABLE vn.sector DROP FOREIGN KEY IF EXISTS sector_FK; + +ALTER TABLE `vn`.`sector` CHANGE IF EXISTS `mainPrinterFk` `backupPrinterFk` int unsigned DEFAULT NULL NULL; + +ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY IF EXISTS `notificationSubscription_ibfk_1`; +ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY IF EXISTS `nnotificationQueue_ibfk_1`; +ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY IF EXISTS `notificationAcl_ibfk_1`; + +ALTER TABLE `util`.`notification` MODIFY COLUMN IF EXISTS `id` int(11) auto_increment NOT NULL; + +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql new file mode 100644 index 000000000..9dc3c0f60 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql @@ -0,0 +1,12 @@ +INSERT IGNORE INTO util.notification (name, description) + VALUES ('backup-printer-selected','A backup printer has been selected'); + +INSERT IGNORE INTO util.notificationSubscription (notificationFk, userFk) + SELECT id, 10435 + FROM util.notification + WHERE name = 'backup-printer-selected'; + +INSERT IGNORE INTO util.notificationAcl (notificationFk, roleFk) + SELECT id, 66 + FROM util.notification + WHERE name = 'backup-printer-selected'; \ No newline at end of file diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql new file mode 100644 index 000000000..2d61cde90 --- /dev/null +++ b/db/versions/10944-tealLaurel/00-firstScript.sql @@ -0,0 +1,8 @@ +REVOKE UPDATE ON vn.entry FROM entryEditor; +GRANT UPDATE ON vn.entry TO administrative; +GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable, + isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk, + currencyFk,companyFk, gestDocFk, invoiceInFk, loadPriority, + kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, + observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked +) ON vn.entry TO entryEditor; diff --git a/db/versions/10950-greenArborvitae/00-firstScript.sql b/db/versions/10950-greenArborvitae/00-firstScript.sql new file mode 100644 index 000000000..e8d4e31f2 --- /dev/null +++ b/db/versions/10950-greenArborvitae/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.packaging +MODIFY COLUMN volume decimal(10,2) CHECK (volume >= COALESCE(width, 1) * COALESCE(depth, 1) * COALESCE(height, 1)); diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql new file mode 100644 index 000000000..c08462d75 --- /dev/null +++ b/db/versions/10984-navyDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +UPDATE bs.nightTask SET `schema`='vn' WHERE `procedure`='raidUpdate'; + +UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE `procedure` ='recobro_credito'; \ No newline at end of file diff --git a/db/versions/10987-tealMonstera/00-firstScript.vn.sql b/db/versions/10987-tealMonstera/00-firstScript.vn.sql new file mode 100644 index 000000000..d24ddd5de --- /dev/null +++ b/db/versions/10987-tealMonstera/00-firstScript.vn.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +USE vn; +INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff'); \ No newline at end of file diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql new file mode 100644 index 000000000..56b1541fb --- /dev/null +++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql @@ -0,0 +1,11 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`() +BEGIN +END; + +GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financial; + +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +BEGIN +END; + +GRANT EXECUTE ON PROCEDURE vn.creditInsurance_getRisk TO financial; diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql new file mode 100644 index 000000000..905f67aba --- /dev/null +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -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'); \ No newline at end of file diff --git a/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql new file mode 100644 index 000000000..13216936b --- /dev/null +++ b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql @@ -0,0 +1 @@ +DROP TABLE hedera.orderRecalc; diff --git a/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql new file mode 100644 index 000000000..e7c765e91 --- /dev/null +++ b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.ticketRecalc; diff --git a/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql new file mode 100644 index 000000000..49b26f83f --- /dev/null +++ b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.travelRecalc; diff --git a/db/versions/10997-crimsonCyca/00-groupingMode.sql b/db/versions/10997-crimsonCyca/00-groupingMode.sql new file mode 100644 index 000000000..dd4896cc1 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-groupingMode.sql @@ -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; \ No newline at end of file diff --git a/db/versions/11003-greenRoebelini/00-firstScript.sql b/db/versions/11003-greenRoebelini/00-firstScript.sql new file mode 100644 index 000000000..97c5f355f --- /dev/null +++ b/db/versions/11003-greenRoebelini/00-firstScript.sql @@ -0,0 +1 @@ +DROP SCHEMA IF EXISTS rfid; diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js index 51992b41d..3c6149726 100644 --- a/e2e/paths/03-worker/01_summary.spec.js +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Worker summary path', () => { - const workerId = 3; let browser; let page; beforeAll(async() => { @@ -10,7 +9,7 @@ describe('Worker summary path', () => { page = browser.page; await page.loginAndModule('employee', 'worker'); 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 httpDataResponse; diff --git a/e2e/paths/12-entry/05_basicData.spec.js b/e2e/paths/12-entry/05_basicData.spec.js index 15282820e..f1f14f8da 100644 --- a/e2e/paths/12-entry/05_basicData.spec.js +++ b/e2e/paths/12-entry/05_basicData.spec.js @@ -76,6 +76,6 @@ describe('Entry basic data path', () => { expect(confirmed).toBe('checked'); expect(inventory).toBe('checked'); expect(raid).toBe('checked'); - expect(booked).toBe('checked'); + expect(booked).toBe('unchecked'); }); }); diff --git a/front/core/services/auth.js b/front/core/services/auth.js index d77966aca..753bc3fba 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -86,8 +86,7 @@ export default class Auth { return this.$http.get('VnUsers/ShareToken', { headers: {Authorization: json.data.token} }).then(({data}) => { - // Usar data.multimediaToken.id cuando el resto de sistemas lo tengan completado - this.vnToken.set(json.data.token, json.data.token, now, json.data.ttl, remember); + this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); this.loadAcls().then(() => { let continueHash = this.$state.params.continue; if (continueHash) diff --git a/front/core/services/token.js b/front/core/services/token.js index 028ebd841..125de6b9a 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -59,8 +59,7 @@ export default class Token { getStorage(storage) { this.token = storage.getItem('vnToken'); - // Cambio realizado temporalmente - this.tokenMultimedia = this.token; // storage.getItem('vnTokenMultimedia'); + this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a0e60550f..9a3a1f52a 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -1,217 +1,217 @@ { - "State cannot be blank": "State cannot be blank", - "Cannot be blank": "Cannot be blank", - "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", - "Invalid email": "Invalid email", - "Name cannot be blank": "Name cannot be blank", - "Phone cannot be blank": "Phone cannot be blank", - "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", - "Period cannot be blank": "Period cannot be blank", - "Sample type cannot be blank": "Sample type cannot be blank", - "That payment method requires an IBAN": "That payment method requires an IBAN", - "That payment method requires a BIC": "That payment method requires a BIC", - "The default consignee can not be unchecked": "The default consignee can not be unchecked", - "Enter an integer different to zero": "Enter an integer different to zero", - "Package cannot be blank": "Package cannot be blank", - "The price of the item changed": "The price of the item changed", - "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", - "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", - "You can't create an order for a frozen client": "You can't create an order for a frozen client", - "This address doesn't exist": "This address doesn't exist", - "Warehouse cannot be blank": "Warehouse cannot be blank", - "Agency cannot be blank": "Agency cannot be blank", - "The IBAN does not have the correct format": "The IBAN does not have the correct format", - "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", - "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", - "Worker cannot be blank": "Worker cannot be blank", - "You must delete the claim id %d first": "You must delete the claim id %d first", - "You don't have enough privileges": "You don't have enough privileges", - "Tag value cannot be blank": "Tag value cannot be blank", - "A client with that Web User name already exists": "A client with that Web User name already exists", - "The warehouse can't be repeated": "The warehouse can't be repeated", - "Barcode must be unique": "Barcode must be unique", - "You don't have enough privileges to do that": "You don't have enough privileges to do that", - "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", - "can't be blank": "can't be blank", - "Street cannot be empty": "Street cannot be empty", - "City cannot be empty": "City cannot be empty", - "EXTENSION_INVALID_FORMAT": "Invalid extension", - "The secret can't be blank": "The secret can't be blank", - "Invalid TIN": "Invalid Tax number", - "This ticket can't be invoiced": "This ticket can't be invoiced", - "The value should be a number": "The value should be a number", - "The current ticket can't be modified": "The current ticket can't be modified", - "Extension format is invalid": "Extension format is invalid", - "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", - "This client can't be invoiced": "This client can't be invoiced", - "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", - "The introduced hour already exists": "The introduced hour already exists", - "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", - "Concept cannot be blank": "Concept cannot be blank", - "Ticket id cannot be blank": "Ticket id cannot be blank", - "Weekday cannot be blank": "Weekday cannot be blank", - "This ticket can not be modified": "This ticket can not be modified", - "You can't delete a confirmed order": "You can't delete a confirmed order", - "Value has an invalid format": "Value has an invalid format", - "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", - "Swift / BIC can't be empty": "Swift / BIC can't be empty", - "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", - "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", - "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", - "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", - "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", - "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", - "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", - "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", - "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "The grade must be similar to the last one": "The grade must be similar to the last one", - "agencyModeFk": "Agency", - "clientFk": "Client", - "zoneFk": "Zone", - "warehouseFk": "Warehouse", - "shipped": "Shipped", - "landed": "Landed", - "addressFk": "Address", - "companyFk": "Company", - "agency": "Agency", - "delivery": "Delivery", - "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", - "The social name cannot be empty": "The social name cannot be empty", - "The nif cannot be empty": "The nif cannot be empty", - "Amount cannot be zero": "Amount cannot be zero", - "Company has to be official": "Company has to be official", - "Unable to clone this travel": "Unable to clone this travel", - "The observation type can't be repeated": "The observation type can't be repeated", - "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", - "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", - "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", - "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "None", - "error densidad = 0": "error densidad = 0", - "This document already exists on this ticket": "This document already exists on this ticket", - "serial non editable": "This serial doesn't allow to set a reference", - "nickname": "nickname", - "State": "State", - "regular": "regular", - "reserved": "reserved", - "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", - "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", - "This client is not invoiceable": "This client is not invoiceable", - "INACTIVE_PROVIDER": "Inactive provider", - "reference duplicated": "reference duplicated", - "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", - "This item is not available": "This item is not available", - "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", - "The type of business must be filled in basic data": "The type of business must be filled in basic data", - "The worker has hours recorded that day": "The worker has hours recorded that day", - "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk", - "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", - "Can't change the password of another worker": "Can't change the password of another worker", - "No hay un contrato en vigor": "There is no existing contract", - "No está permitido trabajar": "Not allowed to work", - "Dirección incorrecta": "Wrong direction", - "No se permite fichar a futuro": "It is not allowed to sign in the future", - "Descanso diario 12h.": "Daily rest 12h.", - "Fichadas impares": "Odd signs", - "Descanso diario 9h.": "Daily rest 9h.", - "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", - "Verify email": "Verify email", - "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", - "Password does not meet requirements": "Password does not meet requirements", - "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", - "Not enough privileges to edit a client": "Not enough privileges to edit a client", - "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", - "You don't have grant privilege": "You don't have grant privilege", - "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", - "Email verify": "Email verify", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "App locked": "App locked by user {{userId}}", - "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", - "Receipt's bank was not found": "Receipt's bank was not found", - "This receipt was not compensated": "This receipt was not compensated", - "Client's email was not found": "Client's email was not found", - "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", - "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", - "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", - "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", - "Warehouse inventory not set": "Almacén inventario no está establecido", - "Component cost not set": "Componente coste no está estabecido", - "Description cannot be blank": "Description cannot be blank", - "company": "Company", - "country": "Country", - "clientId": "Id client", - "clientSocialName": "Client", - "amount": "Amount", - "taxableBase": "Taxable base", - "ticketFk": "Id ticket", - "isActive": "Active", - "hasToInvoice": "Invoice", - "isTaxDataChecked": "Data checked", - "comercialId": "Id Comercial", - "comercialName": "Comercial", - "Added observation": "Added observation", - "Comment added to client": "Comment added to client", - "This ticket is already a refund": "This ticket is already a refund", - "A claim with that sale already exists": "A claim with that sale already exists", - "Pass expired": "The password has expired, change it from Salix", - "Can't transfer claimed sales": "Can't transfer claimed sales", - "Invalid quantity": "Invalid quantity", - "Failed to upload delivery note": "Error to upload delivery note {{id}}", - "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", - "The renew period has not been exceeded": "The renew period has not been exceeded", - "You can not use the same password": "You can not use the same password", - "Valid priorities": "Valid priorities: %d", - "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", - "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", - "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", - "Social name should be uppercase": "Social name should be uppercase", - "Street should be uppercase": "Street should be uppercase", - "You don't have enough privileges.": "You don't have enough privileges.", - "This ticket is locked": "This ticket is locked", - "This ticket is not editable.": "This ticket is not editable.", - "The ticket doesn't exist.": "The ticket doesn't exist.", - "The sales do not exists": "The sales do not exists", - "Ticket without Route": "Ticket without route", - "Select a different client": "Select a different client", - "Fill all the fields": "Fill all the fields", - "Error while generating PDF": "Error while generating PDF", - "Can't invoice to future": "Can't invoice to future", - "This ticket is already invoiced": "This ticket is already invoiced", - "Negative basis of tickets: 23": "Negative basis of tickets: 23", - "Booking completed": "Booking complete", - "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", - "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", - "Bank entity must be specified": "Bank entity must be specified", - "Try again": "Try again", - "keepPrice": "keepPrice", - "Cannot past travels with entries": "Cannot past travels with entries", - "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", - "Incorrect pin": "Incorrect pin.", - "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", - "Name should be uppercase": "Name should be uppercase", - "You cannot update these fields": "You cannot update these fields", - "CountryFK cannot be empty": "Country cannot be empty", - "You are not allowed to modify the alias": "You are not allowed to modify the alias", - "You already have the mailAlias": "You already have the mailAlias", + "State cannot be blank": "State cannot be blank", + "Cannot be blank": "Cannot be blank", + "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", + "The grade must be an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", + "Invalid email": "Invalid email", + "Name cannot be blank": "Name cannot be blank", + "Phone cannot be blank": "Phone cannot be blank", + "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", + "Period cannot be blank": "Period cannot be blank", + "Sample type cannot be blank": "Sample type cannot be blank", + "That payment method requires an IBAN": "That payment method requires an IBAN", + "That payment method requires a BIC": "That payment method requires a BIC", + "The default consignee can not be unchecked": "The default consignee can not be unchecked", + "Enter an integer different to zero": "Enter an integer different to zero", + "Package cannot be blank": "Package cannot be blank", + "The price of the item changed": "The price of the item changed", + "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", + "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", + "You can't create an order for a frozen client": "You can't create an order for a frozen client", + "This address doesn't exist": "This address doesn't exist", + "Warehouse cannot be blank": "Warehouse cannot be blank", + "Agency cannot be blank": "Agency cannot be blank", + "The IBAN does not have the correct format": "The IBAN does not have the correct format", + "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", + "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", + "Worker cannot be blank": "Worker cannot be blank", + "You must delete the claim id %d first": "You must delete the claim id %d first", + "You don't have enough privileges": "You don't have enough privileges", + "Tag value cannot be blank": "Tag value cannot be blank", + "A client with that Web User name already exists": "A client with that Web User name already exists", + "The warehouse can't be repeated": "The warehouse can't be repeated", + "Barcode must be unique": "Barcode must be unique", + "You don't have enough privileges to do that": "You don't have enough privileges to do that", + "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", + "can't be blank": "can't be blank", + "Street cannot be empty": "Street cannot be empty", + "City cannot be empty": "City cannot be empty", + "EXTENSION_INVALID_FORMAT": "Invalid extension", + "The secret can't be blank": "The secret can't be blank", + "Invalid TIN": "Invalid Tax number", + "This ticket can't be invoiced": "This ticket can't be invoiced", + "The value should be a number": "The value should be a number", + "The current ticket can't be modified": "The current ticket can't be modified", + "Extension format is invalid": "Extension format is invalid", + "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", + "This client can't be invoiced": "This client can't be invoiced", + "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", + "The introduced hour already exists": "The introduced hour already exists", + "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", + "Concept cannot be blank": "Concept cannot be blank", + "Ticket id cannot be blank": "Ticket id cannot be blank", + "Weekday cannot be blank": "Weekday cannot be blank", + "This ticket can not be modified": "This ticket can not be modified", + "You can't delete a confirmed order": "You can't delete a confirmed order", + "Value has an invalid format": "Value has an invalid format", + "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", + "Swift / BIC can't be empty": "Swift / BIC can't be empty", + "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", + "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", + "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", + "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", + "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", + "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", + "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", + "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", + "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", + "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "The grade must be similar to the last one": "The grade must be similar to the last one", + "agencyModeFk": "Agency", + "clientFk": "Client", + "zoneFk": "Zone", + "warehouseFk": "Warehouse", + "shipped": "Shipped", + "landed": "Landed", + "addressFk": "Address", + "companyFk": "Company", + "agency": "Agency", + "delivery": "Delivery", + "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", + "The social name cannot be empty": "The social name cannot be empty", + "The nif cannot be empty": "The nif cannot be empty", + "Amount cannot be zero": "Amount cannot be zero", + "Company has to be official": "Company has to be official", + "Unable to clone this travel": "Unable to clone this travel", + "The observation type can't be repeated": "The observation type can't be repeated", + "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", + "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", + "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", + "Role name must be written in camelCase": "Role name must be written in camelCase", + "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "None", + "error densidad = 0": "error densidad = 0", + "This document already exists on this ticket": "This document already exists on this ticket", + "serial non editable": "This serial doesn't allow to set a reference", + "nickname": "nickname", + "State": "State", + "regular": "regular", + "reserved": "reserved", + "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", + "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", + "This client is not invoiceable": "This client is not invoiceable", + "INACTIVE_PROVIDER": "Inactive provider", + "reference duplicated": "reference duplicated", + "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", + "This item is not available": "This item is not available", + "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", + "The type of business must be filled in basic data": "The type of business must be filled in basic data", + "The worker has hours recorded that day": "The worker has hours recorded that day", + "isWithoutNegatives": "isWithoutNegatives", + "routeFk": "routeFk", + "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", + "Can't change the password of another worker": "Can't change the password of another worker", + "No hay un contrato en vigor": "There is no existing contract", + "No está permitido trabajar": "Not allowed to work", + "Dirección incorrecta": "Wrong direction", + "No se permite fichar a futuro": "It is not allowed to sign in the future", + "Descanso diario 12h.": "Daily rest 12h.", + "Fichadas impares": "Odd signs", + "Descanso diario 9h.": "Daily rest 9h.", + "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", + "Verify email": "Verify email", + "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", + "Password does not meet requirements": "Password does not meet requirements", + "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", + "Not enough privileges to edit a client": "Not enough privileges to edit a client", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", + "You don't have grant privilege": "You don't have grant privilege", + "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", + "Email verify": "Email verify", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "App locked": "App locked by user {{userId}}", + "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", + "Receipt's bank was not found": "Receipt's bank was not found", + "This receipt was not compensated": "This receipt was not compensated", + "Client's email was not found": "Client's email was not found", + "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", + "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", + "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Warehouse inventory not set": "Almacén inventario no está establecido", + "Component cost not set": "Componente coste no está estabecido", + "Description cannot be blank": "Description cannot be blank", + "company": "Company", + "country": "Country", + "clientId": "Id client", + "clientSocialName": "Client", + "amount": "Amount", + "taxableBase": "Taxable base", + "ticketFk": "Id ticket", + "isActive": "Active", + "hasToInvoice": "Invoice", + "isTaxDataChecked": "Data checked", + "comercialId": "Id Comercial", + "comercialName": "Comercial", + "Added observation": "Added observation", + "Comment added to client": "Comment added to client", + "This ticket is already a refund": "This ticket is already a refund", + "A claim with that sale already exists": "A claim with that sale already exists", + "Pass expired": "The password has expired, change it from Salix", + "Can't transfer claimed sales": "Can't transfer claimed sales", + "Invalid quantity": "Invalid quantity", + "Failed to upload delivery note": "Error to upload delivery note {{id}}", + "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", + "The renew period has not been exceeded": "The renew period has not been exceeded", + "You can not use the same password": "You can not use the same password", + "Valid priorities": "Valid priorities: %d", + "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", + "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", + "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", + "Social name should be uppercase": "Social name should be uppercase", + "Street should be uppercase": "Street should be uppercase", + "You don't have enough privileges.": "You don't have enough privileges.", + "This ticket is locked": "This ticket is locked", + "This ticket is not editable.": "This ticket is not editable.", + "The ticket doesn't exist.": "The ticket doesn't exist.", + "The sales do not exists": "The sales do not exists", + "Ticket without Route": "Ticket without route", + "Select a different client": "Select a different client", + "Fill all the fields": "Fill all the fields", + "Error while generating PDF": "Error while generating PDF", + "Can't invoice to future": "Can't invoice to future", + "This ticket is already invoiced": "This ticket is already invoiced", + "Negative basis of tickets: 23": "Negative basis of tickets: 23", + "Booking completed": "Booking complete", + "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", + "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", + "Bank entity must be specified": "Bank entity must be specified", + "Try again": "Try again", + "keepPrice": "keepPrice", + "Cannot past travels with entries": "Cannot past travels with entries", + "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", + "Incorrect pin": "Incorrect pin.", + "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", + "Name should be uppercase": "Name should be uppercase", + "You cannot update these fields": "You cannot update these fields", + "CountryFK cannot be empty": "Country cannot be empty", + "You are not allowed to modify the alias": "You are not allowed to modify the alias", + "You already have the mailAlias": "You already have the mailAlias", "This machine is already in use.": "This machine is already in use.", "the plate does not exist": "The plate {{plate}} does not exist", "We do not have availability for the selected item": "We do not have availability for the selected item", @@ -223,6 +223,7 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate" -} + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", + "InvoiceIn is already booked": "InvoiceIn is already booked" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8b02f3048..d7f9564fe 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -352,5 +352,6 @@ "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", "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" } \ No newline at end of file diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 390be33b9..232c134f6 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/claim-pickup-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 7e49708f5..ffcf51367 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -33,7 +33,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 2daee6413..f60b6572e 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -79,7 +79,12 @@ module.exports = Self => { type: 'number', description: 'The claimResponsible id', http: {source: 'query'} - } + }, + { + arg: 'myTeam', + type: 'boolean', + description: `Team partners` + }, ], returns: { type: ['object'], @@ -92,6 +97,7 @@ module.exports = Self => { }); Self.filter = async(ctx, filter, options) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const conn = Self.dataSource.connector; const args = ctx.args; @@ -121,7 +127,23 @@ module.exports = Self => { claimIdsByClaimResponsibleFk = claims.map(claim => claim.claimFk); } - const where = buildFilter(args, (param, value) => { + // Apply filter by team + const teamMembersId = []; + if (args.myTeam != null) { + const worker = await models.Worker.findById(userId, { + include: { + relation: 'collegues' + } + }, myOptions); + const collegues = worker.collegues() || []; + for (let collegue of collegues) + teamMembersId.push(collegue.collegueFk); + + if (teamMembersId.length == 0) + teamMembersId.push(userId); + } + + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -152,6 +174,11 @@ module.exports = Self => { to.setHours(23, 59, 59, 999); return {'cl.created': {between: [value, to]}}; + case 'myTeam': + if (value) + return {'cl.workerFk': {inq: teamMembersId}}; + else + return {'cl.workerFk': {nin: teamMembersId}}; } }); diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 49e258505..872f49aa3 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,13 +1,25 @@ const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('claim filter()', () => { + let ctx; + beforeEach(() => { + ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'} + } + }; + }); + it('should return 1 result filtering by id', async() => { const tx = await app.models.Claim.beginTransaction({}); try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 1}}, null, options); + ctx.args = {search: 1}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(1); @@ -25,7 +37,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options); + ctx.args = {search: 'Tony Stark'}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); @@ -43,7 +56,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, workerFk: 18}}, null, options); + ctx.args = {workerFk: 18}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(4); expect(result[0].id).toEqual(1); @@ -64,7 +78,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, itemFk: 2}}, null, options); + ctx.args = {itemFk: 2}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(1); @@ -84,7 +99,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, claimResponsibleFk: 7}}, null, options); + ctx.args = {claimResponsibleFk: 7}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(2); @@ -97,4 +113,22 @@ describe('claim filter()', () => { throw e; } }); + + it('should now return claims from the worker team', async() => { + const tx = await models.Claim.beginTransaction({}); + + try { + const options = {transaction: tx}; + + ctx.args = {itemFk: null, myTeam: true}; + const result = await app.models.Claim.filter(ctx, null, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index fbc527d60..260f86801 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -70,6 +70,13 @@ label="Responsible"> + + + diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index 14ae8646d..dc89a6802 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -46,7 +46,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index 2f6489d3f..7a432123e 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -34,7 +34,7 @@ module.exports = Self => { path: '/:id/entry-order-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index fa804f4d8..35861fd81 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -34,7 +34,7 @@ "type": "number" }, "groupingMode": { - "type": "number" + "type": "string" }, "comissionValue": { "type": "number" diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 6bccb0b5f..57de1c5f7 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -123,7 +123,9 @@ + ng-model="$ctrl.entry.isBooked" + vn-acl="administrative" + > diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index 203d6c522..0e0c69788 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -119,13 +119,13 @@ @@ -140,13 +140,13 @@ diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index c991b745b..9131c31f6 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -53,12 +53,8 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const grouping = 1; - const packing = 2; - const groupingMode = mode === 'grouping' ? grouping : packing; - - const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; - + const groupingMode = mode === 'grouping' ? mode : 'packing'; + const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; const params = { groupingMode: newGroupingMode }; diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9d5fab51..f5c6d1bdb 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -57,45 +57,34 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: grouping}; + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was packing to packing`, () => { - const noGrouping = 0; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const noGrouping = 0; - const grouping = 1; - const buy = {id: 999, groupingMode: grouping}; - + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 16e039cf0..2e6de83b9 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -143,12 +143,12 @@ - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 655dcd66f..baa310bb6 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -121,12 +121,12 @@ {{::line.packagingFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}} diff --git a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js index c188a511d..f21dad9f2 100644 --- a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js @@ -13,11 +13,10 @@ describe('invoiceInDueDay new()', () => { it('should correctly create a new due day', async() => { const userId = 9; - const invoiceInFk = 6; + const invoiceInFk = 3; const ctx = { req: { - accessToken: {userId: userId}, } }; diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 9834989fc..ff2164783 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { @@ -180,7 +180,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(5); expect(result[0].isBooked).toBeTruthy(); await tx.rollback(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 24fb9fde3..748e2df17 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/:id/download', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 13305f6ed..8d6e7c6d9 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index a2d877189..6c4845c11 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:reference/exportation-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index 6208d0625..fd754d51b 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:reference/invoice-csv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.invoiceCsv = async reference => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 6970bf368..3e466d1f4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -40,7 +40,7 @@ module.exports = Self => { path: '/negativeBasesCsv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index 354771071..001a2b950 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,7 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async() => { diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 429955ef5..e3b84655c 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -71,12 +71,12 @@ {{entry.stickers | dashIfEmpty}} - + {{::entry.packing | dashIfEmpty}} - + {{::entry.grouping | dashIfEmpty}} diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index cd7ef57ce..5033dee2f 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/:id/cmr', verb: 'GET' - } + }, + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 1ef25d175..c6934edca 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadCmrsZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index b226cf7f8..8eecf62e4 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index 9469356bb..69b26d846 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/driver-route-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 7c2225dc9..5b13a9004 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -67,6 +67,12 @@ module.exports = Self => { type: 'string', description: 'The description filter', http: {source: 'query'} + }, + { + arg: 'isOk', + type: 'boolean', + description: 'The isOk filter', + http: {source: 'query'} } ], returns: { @@ -102,6 +108,8 @@ module.exports = Self => { case 'agencyModeFk': param = `r.${param}`; return {[param]: value}; + case 'isOk': + return {'r.isOk': value}; } }); diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 59ba389ed..0e7c9fe20 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -33,50 +33,54 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT - t.id, - t.packages, - t.warehouseFk, - t.nickname, - t.clientFk, - t.priority, - t.addressFk, - st.code ticketStateCode, - st.name ticketStateName, - wh.name warehouseName, - tob.description ticketObservation, - a.street, - a.postalCode, - a.city, - am.name agencyModeName, - u.nickname userNickname, - vn.ticketTotalVolume(t.id) volume, - tob.description, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, - c.phone clientPhone, - c.mobile clientMobile, - a.phone addressPhone, - a.mobile addressMobile, - a.longitude, - a.latitude, - wm.mediaValue salePersonPhone, - t.cmrFk, - t.isSigned signed - FROM vn.route r - JOIN ticket t ON t.routeFk = r.id - JOIN client c ON t.clientFk = c.id - LEFT JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN warehouse wh ON wh.id = t.warehouseFk - LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = ot.id - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN account.user u ON u.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` + t.id, + t.packages, + t.warehouseFk, + t.nickname, + t.clientFk, + t.priority, + t.addressFk, + st.code ticketStateCode, + st.name ticketStateName, + wh.name warehouseName, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id observationId, + a.street, + a.postalCode, + a.city, + am.name agencyModeName, + u.nickname userNickname, + vn.ticketTotalVolume(t.id) volume, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + c.phone clientPhone, + c.mobile clientMobile, + a.phone addressPhone, + a.mobile addressMobile, + a.longitude, + a.latitude, + wm.mediaValue salePersonPhone, + t.cmrFk, + t.isSigned signed + FROM vn.route r + JOIN ticket t ON t.routeFk = r.id + JOIN client c ON t.clientFk = c.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN observationType ot ON ot.code = 'delivery' + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN account.user u ON u.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` ); if (!filter.where) filter.where = {}; diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 56f7a49b9..8269bf118 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -81,7 +81,7 @@ City PC Client - Warehouse + State Packages Packaging @@ -109,7 +109,7 @@ {{ticket.nickname}} - {{ticket.warehouseName}} + {{ticket.ticketStateName}} {{ticket.packages}} {{ticket.volume}} {{ticket.ipt}} diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 5ff67491b..61d8d0628 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -48,7 +48,7 @@ "type": "number", "required": false }, - "mainPrinterFk": { + "backupPrinterFk": { "type": "number", "required": false }, diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 55767e9c6..58282747d 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -45,7 +45,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket-observation/addDropOff.js b/modules/ticket/back/methods/ticket-observation/addDropOff.js new file mode 100644 index 000000000..5f773f593 --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/addDropOff.js @@ -0,0 +1,42 @@ + +module.exports = Self => { + Self.remoteMethod('addDropOff', { + description: 'Add a dropOff note in a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'ticketFk', + type: 'number', + required: true, + description: 'ticket ID' + }, { + arg: 'note', + type: 'string', + required: true, + description: 'note text' + }], + + http: { + path: `/addDropOff`, + verb: 'post' + } + }); + + Self.addDropOff = async(ticketFk, note, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const observationTypeDropOff = await models.ObservationType.findOne({ + where: {code: 'dropOff'} + }, myOptions); + + await models.TicketObservation.create({ + ticketFk: ticketFk, + observationTypeFk: observationTypeDropOff.id, + description: note + + }, myOptions); + }; +}; diff --git a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js new file mode 100644 index 000000000..82c692946 --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js @@ -0,0 +1,31 @@ +const {models} = require('vn-loopback/server/server'); + +describe('ticketObservation addDropOff()', () => { + const ticketFk = 5; + const note = 'DropOff note'; + const code = 'dropOff'; + + it('should return a dropOff note', async() => { + const tx = await models.TicketObservation.beginTransaction({}); + + try { + const options = {transaction: tx}; + await models.TicketObservation.addDropOff( + ticketFk, note, options); + + const observationTypeDropOff = await models.TicketObservation.find({ + where: { + ticketFk, + code + } + }, options); + + expect(observationTypeDropOff.length).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 29a859842..f02debba8 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:id/delivery-note-csv', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNoteCsv = async id => { diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 6155ff81e..205f4ba7b 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -42,7 +42,7 @@ module.exports = Self => { path: '/:id/delivery-note-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/ticket/back/models/ticket-observation.js b/modules/ticket/back/models/ticket-observation.js index 77d15d85c..3076484bf 100644 --- a/modules/ticket/back/models/ticket-observation.js +++ b/modules/ticket/back/models/ticket-observation.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { + require('../methods/ticket-observation/addDropOff')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`The observation type can't be repeated`); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 0c7f0a682..459e74d69 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -79,7 +79,7 @@ module.exports = Self => { path: '/extra-community-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 1253be474..8a7d05298 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -3,60 +3,80 @@ const models = require('vn-loopback/server/server').models; describe('Operator', () => { const authorFk = 9; const sectorId = 1; - const mainPrinter = 1; - const notificationName = 'not-main-printer-configured'; - const operator = { - workerFk: 1, - trainFk: 1, - itemPackingTypeFk: 'H', - warehouseFk: 1, - sectorFk: sectorId - }; + const labeler = 1; + const notificationName = 'backup-printer-selected'; + const sentStatus = 'sent'; - async function createOperator(labelerFk, options) { - operator.labelerFk = labelerFk; - await models.Operator.create(operator, options); - return models.NotificationQueue.findOne({ - where: { - notificationFk: notificationName - } - }, options); + beforeEach(async() => { + await deleteNotification(); + }); + + afterAll(async() => { + await deleteNotification(); + }); + + async function deleteNotification() { + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); } - it('should create notification when configured a not main printer in the sector', async() => { - const tx = await models.Operator.beginTransaction({}); + async function updateOperatorAndFindNotification(labelerFk = labeler) { + await models.Operator.updateAll({id: authorFk}, {workerFk: authorFk, labelerFk: labelerFk, sectorFk: sectorId}); + return models.NotificationQueue.findOne({order: 'id DESC'}); + } + it('should create notification when configured a backup printer in the sector', async() => { + const notificationQueue = await updateOperatorAndFindNotification(); + const params = JSON.parse(notificationQueue.params); + + expect(notificationQueue.notificationFk).toEqual(notificationName); + expect(notificationQueue.authorFk).toEqual(authorFk); + expect(params.labelerId).toEqual(1); + expect(params.sectorId).toEqual(1); + expect(params.workerId).toEqual(9); + }); + + it('should not create notification when configured a non backup printer in the sector', async() => { + const notificationQueue = await updateOperatorAndFindNotification(2); + + expect(notificationQueue?.notificationFk).not.toEqual(notificationName); + }); + + it('should create notification when delay is null', async() => { + const config = await models.ProductionConfig.findOne(); + const delay = config.backupPrinterNotificationDelay; + await config.updateAttributes({backupPrinterNotificationDelay: null}); + const lastNotification = await updateOperatorAndFindNotification(); + await config.updateAttributes({backupPrinterNotificationDelay: delay}); + + expect(lastNotification.notificationFk).toEqual(notificationName); + }); + + it('should not sent notification when is already notified by another worker', async() => { try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(2, options); - const params = JSON.parse(notificationQueue.params); - - expect(notificationQueue.notificationFk).toEqual(notificationName); - expect(notificationQueue.authorFk).toEqual(authorFk); - expect(params.labelerId).toEqual(2); - expect(params.sectorId).toEqual(1); - expect(params.workerId).toEqual(9); - - await tx.rollback(); + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), + created: '2001-01-01 12:30:00', + status: sentStatus + }); + await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}); } catch (e) { - await tx.rollback(); - throw e; + expect(e.message).toEqual('Previous notification sended with the same parameters'); } }); - it('should not create notification when configured the main printer in the sector', async() => { - const tx = await models.Operator.beginTransaction({}); + it('should send a notification when the previous one has distinct params', async() => { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': 2, 'workerId': 1}), + created: '2001-01-01 12:30:00', + status: sentStatus + }); + const lastNotification = await updateOperatorAndFindNotification(); - try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(mainPrinter, options); - - expect(notificationQueue).toEqual(null); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(lastNotification.notificationFk).toEqual(notificationName); }); }); + diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index 871bbffde..93d685429 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index cf6c198b6..1ebc1643c 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -1,19 +1,41 @@ module.exports = Self => { - Self.observe('after save', async function(ctx) { + Self.observe('after save', async ctx => { const instance = ctx.data || ctx.instance; const models = Self.app.models; const options = ctx.options; + const notificationName = 'backup-printer-selected'; + const userId = ctx.options.accessToken?.userId || instance.workerFk; if (!instance?.sectorFk || !instance?.labelerFk) return; const sector = await models.Sector.findById(instance.sectorFk, { - fields: ['mainPrinterFk'] + fields: ['backupPrinterFk'] }, options); - if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) { - const userId = ctx.options.accessToken.userId; + if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { + const {labelerFk, sectorFk} = instance; + + const {backupPrinterNotificationDelay} = await models.ProductionConfig.findOne(); + if (backupPrinterNotificationDelay) { + const notifications = await models.NotificationQueue.find( + {where: {created: {gte: Date.vnNow() - (backupPrinterNotificationDelay * 1000) + (3600 * 1000)}, + notificationFk: notificationName, + status: 'sent' + } + }); + + const criteria = {labelerId: labelerFk, sectorId: sectorFk}; + const filteredNotifications = notifications.filter(notification => { + const paramsObj = JSON.parse(notification.params); + return Object.keys(criteria).every(key => criteria[key] === paramsObj?.[key]); + }); + + if (filteredNotifications.length >= 1) + throw new Error('Previous notification sended with the same parameters'); + } + await models.NotificationQueue.create({ - notificationFk: 'not-main-printer-configured', + notificationFk: notificationName, authorFk: userId, params: JSON.stringify( { @@ -22,7 +44,8 @@ module.exports = Self => { 'workerId': userId } ) - }, options); + }); } }); }; + diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index ed430f133..c203f6e09 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -92,5 +92,87 @@ "model": "WorkerTeamCollegues", "foreignKey": "workerFk" } + }, + "scopes":{ + "summary": { + "include": [ + { + "relation": "user", + "scope": { + "fields": ["email", "name", "nickname", "roleFk", "emailVerified"], + "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" + } + ] + } } } diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..1aa548db9 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'sip', - scope: { - fields: ['extension', 'secret'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: { + id: this.$params.id} }; return Promise.all([ - this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data), + this.$http.get(`Workers/summary`, {filter}) + .then(res => this.worker = res.data[0]), this.$http.get(`Workers/${this.$params.id}/activeContract`) .then(res => this.hasWorkCenter = res.data?.workCenterFk) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 75265acb4..9263b857b 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -37,41 +37,11 @@ class Controller extends Descriptor { loadData() { const filter = { - include: [ - { - 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' - } - } - } - ] + where: {id: this.id}, }; - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData(`Workers/summary`, {filter}) + .then(res => this.entity = res.data[0]); } getPassRequirements() { diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index 4f7fa6a05..cee8b0def 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = 'foo'; + const response = ['foo']; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + $httpBackend.expectRoute('GET', `Workers/summary`).respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect([controller.worker]).toEqual(response); }); }); diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 212609f58..d1a27a6d4 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -10,53 +10,14 @@ class Controller extends Summary { this.$.worker = null; if (!value) return; - const query = `Workers/${value.id}`; const filter = { - include: [ - { - 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']} - } - } - } - ] + where: { + id: value.id + } }; - this.$http.get(query, {params: {filter}}).then(res => { - this.$.worker = res.data; + this.$http.get(`Workers/summary`, {filter}).then(res => { + this.$.worker = res.data[0]; }); } diff --git a/myt.config.yml b/myt.config.yml index 2ac8b8e5e..d94913b05 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -15,7 +15,6 @@ schemas: - hedera - pbx - psico - - rfid - sage - salix - srt diff --git a/package.json b/package.json index 39c5e15b7..aa2aa2238 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.16.0", + "version": "24.18.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", @@ -56,6 +56,8 @@ "@babel/plugin-syntax-dynamic-import": "^7.7.4", "@babel/preset-env": "^7.11.0", "@babel/register": "^7.7.7", + "@commitlint/cli": "^19.2.1", + "@commitlint/config-conventional": "^19.1.0", "@verdnatura/myt": "^1.6.9", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", @@ -82,6 +84,7 @@ "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", + "husky": "^8.0.0", "identity-obj-proxy": "^3.0.0", "jasmine": "^5.0.2", "jasmine-reporters": "^2.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f0473929..d3959ac03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,7 +94,7 @@ dependencies: version: 1.3.0 puppeteer: specifier: 21.11.0 - version: 21.11.0 + version: 21.11.0(typescript@5.4.4) read-chunk: specifier: ^3.2.0 version: 3.2.0 @@ -130,6 +130,12 @@ devDependencies: '@babel/register': specifier: ^7.7.7 version: 7.23.7(@babel/core@7.23.9) + '@commitlint/cli': + specifier: ^19.2.1 + version: 19.2.1(@types/node@20.11.16)(typescript@5.4.4) + '@commitlint/config-conventional': + specifier: ^19.1.0 + version: 19.1.0 '@verdnatura/myt': specifier: ^1.6.9 version: 1.6.9 @@ -208,6 +214,9 @@ devDependencies: html-webpack-plugin: specifier: ^5.5.1 version: 5.6.0(webpack@5.90.1) + husky: + specifier: ^8.0.0 + version: 8.0.3 identity-obj-proxy: specifier: ^3.0.0 version: 3.0.0 @@ -1502,6 +1511,169 @@ packages: minimist: 1.2.8 dev: true + /@commitlint/cli@19.2.1(@types/node@20.11.16)(typescript@5.4.4): + resolution: {integrity: sha512-cbkYUJsLqRomccNxvoJTyv5yn0bSy05BBizVyIcLACkRbVUqYorC351Diw/XFSWC/GtpwiwT2eOvQgFZa374bg==} + engines: {node: '>=v18'} + hasBin: true + dependencies: + '@commitlint/format': 19.0.3 + '@commitlint/lint': 19.1.0 + '@commitlint/load': 19.2.0(@types/node@20.11.16)(typescript@5.4.4) + '@commitlint/read': 19.2.1 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + yargs: 17.7.2 + transitivePeerDependencies: + - '@types/node' + - typescript + dev: true + + /@commitlint/config-conventional@19.1.0: + resolution: {integrity: sha512-KIKD2xrp6Uuk+dcZVj3++MlzIr/Su6zLE8crEDQCZNvWHNQSeeGbzOlNtsR32TUy6H3JbP7nWgduAHCaiGQ6EA==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + conventional-changelog-conventionalcommits: 7.0.2 + dev: true + + /@commitlint/config-validator@19.0.3: + resolution: {integrity: sha512-2D3r4PKjoo59zBc2auodrSCaUnCSALCx54yveOFwwP/i2kfEAQrygwOleFWswLqK0UL/F9r07MFi5ev2ohyM4Q==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + ajv: 8.12.0 + dev: true + + /@commitlint/ensure@19.0.3: + resolution: {integrity: sha512-SZEpa/VvBLoT+EFZVb91YWbmaZ/9rPH3ESrINOl0HD2kMYsjvl0tF7nMHh0EpTcv4+gTtZBAe1y/SS6/OhfZzQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + lodash.camelcase: 4.3.0 + lodash.kebabcase: 4.1.1 + lodash.snakecase: 4.1.1 + lodash.startcase: 4.4.0 + lodash.upperfirst: 4.3.1 + dev: true + + /@commitlint/execute-rule@19.0.0: + resolution: {integrity: sha512-mtsdpY1qyWgAO/iOK0L6gSGeR7GFcdW7tIjcNFxcWkfLDF5qVbPHKuGATFqRMsxcO8OUKNj0+3WOHB7EHm4Jdw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/format@19.0.3: + resolution: {integrity: sha512-QjjyGyoiVWzx1f5xOteKHNLFyhyweVifMgopozSgx1fGNrGV8+wp7k6n1t6StHdJ6maQJ+UUtO2TcEiBFRyR6Q==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + chalk: 5.3.0 + dev: true + + /@commitlint/is-ignored@19.0.3: + resolution: {integrity: sha512-MqDrxJaRSVSzCbPsV6iOKG/Lt52Y+PVwFVexqImmYYFhe51iVJjK2hRhOG2jUAGiUHk4jpdFr0cZPzcBkSzXDQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + semver: 7.6.0 + dev: true + + /@commitlint/lint@19.1.0: + resolution: {integrity: sha512-ESjaBmL/9cxm+eePyEr6SFlBUIYlYpI80n+Ltm7IA3MAcrmiP05UMhJdAD66sO8jvo8O4xdGn/1Mt2G5VzfZKw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/is-ignored': 19.0.3 + '@commitlint/parse': 19.0.3 + '@commitlint/rules': 19.0.3 + '@commitlint/types': 19.0.3 + dev: true + + /@commitlint/load@19.2.0(@types/node@20.11.16)(typescript@5.4.4): + resolution: {integrity: sha512-XvxxLJTKqZojCxaBQ7u92qQLFMMZc4+p9qrIq/9kJDy8DOrEa7P1yx7Tjdc2u2JxIalqT4KOGraVgCE7eCYJyQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/config-validator': 19.0.3 + '@commitlint/execute-rule': 19.0.0 + '@commitlint/resolve-extends': 19.1.0 + '@commitlint/types': 19.0.3 + chalk: 5.3.0 + cosmiconfig: 9.0.0(typescript@5.4.4) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.16)(cosmiconfig@9.0.0)(typescript@5.4.4) + lodash.isplainobject: 4.0.6 + lodash.merge: 4.6.2 + lodash.uniq: 4.5.0 + transitivePeerDependencies: + - '@types/node' + - typescript + dev: true + + /@commitlint/message@19.0.0: + resolution: {integrity: sha512-c9czf6lU+9oF9gVVa2lmKaOARJvt4soRsVmbR7Njwp9FpbBgste5i7l/2l5o8MmbwGh4yE1snfnsy2qyA2r/Fw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/parse@19.0.3: + resolution: {integrity: sha512-Il+tNyOb8VDxN3P6XoBBwWJtKKGzHlitEuXA5BP6ir/3loWlsSqDr5aecl6hZcC/spjq4pHqNh0qPlfeWu38QA==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + conventional-changelog-angular: 7.0.0 + conventional-commits-parser: 5.0.0 + dev: true + + /@commitlint/read@19.2.1: + resolution: {integrity: sha512-qETc4+PL0EUv7Q36lJbPG+NJiBOGg7SSC7B5BsPWOmei+Dyif80ErfWQ0qXoW9oCh7GTpTNRoaVhiI8RbhuaNw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/top-level': 19.0.0 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + git-raw-commits: 4.0.0 + minimist: 1.2.8 + dev: true + + /@commitlint/resolve-extends@19.1.0: + resolution: {integrity: sha512-z2riI+8G3CET5CPgXJPlzftH+RiWYLMYv4C9tSLdLXdr6pBNimSKukYP9MS27ejmscqCTVA4almdLh0ODD2KYg==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/config-validator': 19.0.3 + '@commitlint/types': 19.0.3 + global-directory: 4.0.1 + import-meta-resolve: 4.0.0 + lodash.mergewith: 4.6.2 + resolve-from: 5.0.0 + dev: true + + /@commitlint/rules@19.0.3: + resolution: {integrity: sha512-TspKb9VB6svklxNCKKwxhELn7qhtY1rFF8ls58DcFd0F97XoG07xugPjjbVnLqmMkRjZDbDIwBKt9bddOfLaPw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/ensure': 19.0.3 + '@commitlint/message': 19.0.0 + '@commitlint/to-lines': 19.0.0 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + dev: true + + /@commitlint/to-lines@19.0.0: + resolution: {integrity: sha512-vkxWo+VQU5wFhiP9Ub9Sre0FYe019JxFikrALVoD5UGa8/t3yOJEpEhxC5xKiENKKhUkTpEItMTRAjHw2SCpZw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/top-level@19.0.0: + resolution: {integrity: sha512-KKjShd6u1aMGNkCkaX4aG1jOGdn7f8ZI8TR1VEuNqUOjWTOdcDSsmglinglJ18JTjuBX5I1PtjrhQCRcixRVFQ==} + engines: {node: '>=v18'} + dependencies: + find-up: 7.0.0 + dev: true + + /@commitlint/types@19.0.3: + resolution: {integrity: sha512-tpyc+7i6bPG9mvaBbtKUeghfyZSDgWquIDfMgqYtTbmZ9Y9VzEm2je9EYcQ0aoz5o7NvGS+rcDec93yO08MHYA==} + engines: {node: '>=v18'} + dependencies: + '@types/conventional-commits-parser': 5.0.0 + chalk: 5.3.0 + dev: true + /@discoveryjs/json-ext@0.5.7: resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} @@ -2433,6 +2605,12 @@ packages: '@types/node': 20.11.16 dev: false + /@types/conventional-commits-parser@5.0.0: + resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==} + dependencies: + '@types/node': 20.11.16 + dev: true + /@types/eslint-scope@3.7.7: resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} dependencies: @@ -2814,7 +2992,6 @@ packages: dependencies: jsonparse: 1.3.1 through: 2.3.8 - dev: false /abab@2.0.6: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} @@ -3161,6 +3338,10 @@ packages: resolution: {integrity: sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==} dev: true + /array-ify@1.0.0: + resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} + dev: true + /array-initial@1.1.0: resolution: {integrity: sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==} engines: {node: '>=0.10.0'} @@ -4002,6 +4183,11 @@ packages: ansi-styles: 4.3.0 supports-color: 7.2.0 + /chalk@5.3.0: + resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: true + /char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} @@ -4299,6 +4485,13 @@ packages: /commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + /compare-func@2.0.0: + resolution: {integrity: sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==} + dependencies: + array-ify: 1.0.0 + dot-prop: 5.3.0 + dev: true + /component-emitter@1.3.1: resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} dev: true @@ -4559,6 +4752,31 @@ packages: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} + /conventional-changelog-angular@7.0.0: + resolution: {integrity: sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==} + engines: {node: '>=16'} + dependencies: + compare-func: 2.0.0 + dev: true + + /conventional-changelog-conventionalcommits@7.0.2: + resolution: {integrity: sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==} + engines: {node: '>=16'} + dependencies: + compare-func: 2.0.0 + dev: true + + /conventional-commits-parser@5.0.0: + resolution: {integrity: sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA==} + engines: {node: '>=16'} + hasBin: true + dependencies: + JSONStream: 1.3.5 + is-text-path: 2.0.0 + meow: 12.1.1 + split2: 4.2.0 + dev: true + /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} dev: true @@ -4613,7 +4831,21 @@ packages: /core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - /cosmiconfig@9.0.0: + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.16)(cosmiconfig@9.0.0)(typescript@5.4.4): + resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} + engines: {node: '>=v16'} + peerDependencies: + '@types/node': '*' + cosmiconfig: '>=8.2' + typescript: '>=4' + dependencies: + '@types/node': 20.11.16 + cosmiconfig: 9.0.0(typescript@5.4.4) + jiti: 1.21.0 + typescript: 5.4.4 + dev: true + + /cosmiconfig@9.0.0(typescript@5.4.4): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} peerDependencies: @@ -4626,7 +4858,7 @@ packages: import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 - dev: false + typescript: 5.4.4 /cross-fetch@4.0.0: resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==} @@ -4746,6 +4978,11 @@ packages: engines: {node: '>=4'} dev: true + /dargs@8.1.0: + resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} + engines: {node: '>=12'} + dev: true + /dashdash@1.14.1: resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==} engines: {node: '>=0.10'} @@ -5170,6 +5407,13 @@ packages: is-obj: 1.0.1 dev: false + /dot-prop@5.3.0: + resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} + engines: {node: '>=8'} + dependencies: + is-obj: 2.0.0 + dev: true + /duplex-child-process@0.0.5: resolution: {integrity: sha512-3WVvFnyEYmFYXi2VB9z9XG8y4MbCMEPYrSGYROY3Pp7TT5qsyrdv+rZS6ydjQvTegHMc00pbrl4V/OOwrzo1KQ==} dev: false @@ -5648,6 +5892,21 @@ packages: signal-exit: 3.0.7 strip-final-newline: 2.0.0 + /execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 + dev: true + /exit@0.1.2: resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} engines: {node: '>= 0.8.0'} @@ -5990,6 +6249,15 @@ packages: path-exists: 4.0.0 dev: true + /find-up@7.0.0: + resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} + engines: {node: '>=18'} + dependencies: + locate-path: 7.2.0 + path-exists: 5.0.0 + unicorn-magic: 0.1.0 + dev: true + /findup-sync@2.0.0: resolution: {integrity: sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==} engines: {node: '>= 0.10'} @@ -6406,6 +6674,11 @@ packages: dependencies: pump: 3.0.0 + /get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + dev: true + /get-uri@6.0.2: resolution: {integrity: sha512-5KLucCJobh8vBY1K07EFV4+cPZH3mrV9YeAruUseCQKHB58SGjjT2l9/eA9LD082IiuMjSlFJEcdJ27TXvbZNw==} engines: {node: '>= 14'} @@ -6432,6 +6705,16 @@ packages: dependencies: assert-plus: 1.0.0 + /git-raw-commits@4.0.0: + resolution: {integrity: sha512-ICsMM1Wk8xSGMowkOmPrzo2Fgmfo4bMHLNX6ytHjajRJUqvHOw/TFapQ+QG75c3X/tTDDhOSRPGC52dDbNM8FQ==} + engines: {node: '>=16'} + hasBin: true + dependencies: + dargs: 8.1.0 + meow: 12.1.1 + split2: 4.2.0 + dev: true + /github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} requiresBuild: true @@ -6538,6 +6821,13 @@ packages: once: 1.4.0 dev: true + /global-directory@4.0.1: + resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} + engines: {node: '>=18'} + dependencies: + ini: 4.1.1 + dev: true + /global-modules@1.0.0: resolution: {integrity: sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==} engines: {node: '>=0.10.0'} @@ -7382,12 +7672,23 @@ packages: resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} engines: {node: '>=8.12.0'} + /human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} + dev: true + /humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} dependencies: ms: 2.1.3 dev: true + /husky@8.0.3: + resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} + engines: {node: '>=14'} + hasBin: true + dev: true + /i18n@0.8.6: resolution: {integrity: sha512-aMsJq8i1XXrb+BBsgmJBwak9mr69zPEIAUPb6c5yw2G/O4k1Q52lBxL+agZdQDN/RGf1ylQzrCswsOOgIiC1FA==} engines: {node: '>=0.10.0'} @@ -7495,6 +7796,10 @@ packages: resolve-cwd: 3.0.0 dev: true + /import-meta-resolve@4.0.0: + resolution: {integrity: sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==} + dev: true + /imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} @@ -7774,6 +8079,11 @@ packages: engines: {node: '>=0.10.0'} dev: false + /is-obj@2.0.0: + resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==} + engines: {node: '>=8'} + dev: true + /is-path-cwd@1.0.0: resolution: {integrity: sha512-cnS56eR9SPAscL77ik76ATVqoPARTqPIVkMDVxRaWH06zT+6+CzIroYRJ0VVvm0Z1zfAvxvz9i/D3Ppjaqt5Nw==} engines: {node: '>=0.10.0'} @@ -7862,6 +8172,18 @@ packages: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} + /is-stream@3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + + /is-text-path@2.0.0: + resolution: {integrity: sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==} + engines: {node: '>=8'} + dependencies: + text-extensions: 2.4.0 + dev: true + /is-typed-array@1.1.13: resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} engines: {node: '>= 0.4'} @@ -8536,6 +8858,11 @@ packages: - utf-8-validate dev: true + /jiti@1.21.0: + resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} + hasBin: true + dev: true + /jmespath@0.16.0: resolution: {integrity: sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==} engines: {node: '>= 0.6.0'} @@ -8695,7 +9022,6 @@ packages: /jsonparse@1.3.1: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} - dev: false /jsprim@1.4.2: resolution: {integrity: sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==} @@ -8929,6 +9255,13 @@ packages: p-locate: 4.1.0 dev: true + /locate-path@7.2.0: + resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-locate: 6.0.0 + dev: true + /lodash._basecopy@3.0.1: resolution: {integrity: sha512-rFR6Vpm4HeCK1WPGvjZSJ+7yik8d8PVUdCJx5rT2pogG4Ve/2ZS7kfmO5l5T2o5V2mqlNIfSF5MZlr1+xOoYQQ==} dev: true @@ -8965,6 +9298,10 @@ packages: resolution: {integrity: sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==} dev: true + /lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: true + /lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} dev: true @@ -8987,6 +9324,14 @@ packages: resolution: {integrity: sha512-JwObCrNJuT0Nnbuecmqr5DgtuBppuCvGD9lxjFpAzwnVtdGoDQ1zig+5W8k5/6Gcn0gZ3936HDAlGd28i7sOGQ==} dev: true + /lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + dev: true + + /lodash.kebabcase@4.1.1: + resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==} + dev: true + /lodash.keys@3.1.2: resolution: {integrity: sha512-CuBsapFjcubOGMn3VD+24HOAPxM79tH+V6ivJL3CHYjtrawauDJHUk//Yew9Hvc6e9rbCrURGk8z6PC+8WJBfQ==} dependencies: @@ -9007,6 +9352,14 @@ packages: resolution: {integrity: sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw==} dev: true + /lodash.snakecase@4.1.1: + resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} + dev: true + + /lodash.startcase@4.4.0: + resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + dev: true + /lodash.template@3.6.2: resolution: {integrity: sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==} dependencies: @@ -9032,6 +9385,14 @@ packages: resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} dev: true + /lodash.uniq@4.5.0: + resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} + dev: true + + /lodash.upperfirst@4.3.1: + resolution: {integrity: sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==} + dev: true + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -9484,6 +9845,11 @@ packages: readable-stream: 2.3.8 dev: true + /meow@12.1.1: + resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} + engines: {node: '>=16.10'} + dev: true + /meow@9.0.0: resolution: {integrity: sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==} engines: {node: '>=10'} @@ -9593,6 +9959,11 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} + /mimic-fn@4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + dev: true + /mimic-response@1.0.1: resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==} engines: {node: '>=4'} @@ -10361,6 +10732,13 @@ packages: dependencies: path-key: 3.1.1 + /npm-run-path@5.3.0: + resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + path-key: 4.0.0 + dev: true + /npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} dependencies: @@ -10517,6 +10895,13 @@ packages: dependencies: mimic-fn: 2.1.0 + /onetime@6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + dependencies: + mimic-fn: 4.0.0 + dev: true + /opn@5.5.0: resolution: {integrity: sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA==} engines: {node: '>=4'} @@ -10638,6 +11023,13 @@ packages: p-try: 2.2.0 dev: true + /p-limit@4.0.0: + resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + yocto-queue: 1.0.0 + dev: true + /p-locate@3.0.0: resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==} engines: {node: '>=6'} @@ -10652,6 +11044,13 @@ packages: p-limit: 2.3.0 dev: true + /p-locate@6.0.0: + resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-limit: 4.0.0 + dev: true + /p-map@2.1.0: resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} engines: {node: '>=6'} @@ -10809,6 +11208,11 @@ packages: engines: {node: '>=8'} dev: true + /path-exists@5.0.0: + resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + /path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} @@ -10825,6 +11229,11 @@ packages: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} + /path-key@4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + dev: true + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -11241,14 +11650,14 @@ packages: - utf-8-validate dev: false - /puppeteer@21.11.0: + /puppeteer@21.11.0(typescript@5.4.4): resolution: {integrity: sha512-9jTHuYe22TD3sNxy0nEIzC7ZrlRnDgeX3xPkbS7PnbdwYjl2o/z/YuCrRBwezdKpbTDTJ4VqIggzNyeRcKq3cg==} engines: {node: '>=16.13.2'} hasBin: true requiresBuild: true dependencies: '@puppeteer/browsers': 1.9.1 - cosmiconfig: 9.0.0 + cosmiconfig: 9.0.0(typescript@5.4.4) puppeteer-core: 21.11.0 transitivePeerDependencies: - bufferutil @@ -11990,6 +12399,14 @@ packages: dependencies: lru-cache: 6.0.0 + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + dev: true + /send@0.18.0(supports-color@6.1.0): resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} engines: {node: '>= 0.8.0'} @@ -12445,6 +12862,11 @@ packages: extend-shallow: 3.0.2 dev: true + /split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + dev: true + /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} @@ -12705,6 +13127,11 @@ packages: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} + /strip-final-newline@3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + dev: true + /strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -13120,6 +13547,11 @@ packages: minimatch: 3.1.2 dev: true + /text-extensions@2.4.0: + resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==} + engines: {node: '>=8'} + dev: true + /text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true @@ -13420,6 +13852,11 @@ packages: ts-toolbelt: 9.6.0 dev: false + /typescript@5.4.4: + resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==} + engines: {node: '>=14.17'} + hasBin: true + /uglify-js@3.4.10: resolution: {integrity: sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==} engines: {node: '>=0.8.0'} @@ -13514,6 +13951,11 @@ packages: engines: {node: '>=4'} dev: true + /unicorn-magic@0.1.0: + resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} + engines: {node: '>=18'} + dev: true + /union-value@1.0.1: resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} engines: {node: '>=0.10.0'} @@ -14453,3 +14895,8 @@ packages: buffer-crc32: 0.2.13 fd-slicer: 1.1.0 dev: false + + /yocto-queue@1.0.0: + resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} + engines: {node: '>=12.20'} + dev: true diff --git a/print/templates/email/not-main-printer-configured/assets/css/import.js b/print/templates/email/backup-printer-selected/assets/css/import.js similarity index 100% rename from print/templates/email/not-main-printer-configured/assets/css/import.js rename to print/templates/email/backup-printer-selected/assets/css/import.js diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.html b/print/templates/email/backup-printer-selected/backup-printer-selected.html new file mode 100644 index 000000000..51fb41773 --- /dev/null +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.html @@ -0,0 +1,14 @@ + +
+
+

{{ $t('title') }}

+

+

+
+
diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js similarity index 92% rename from print/templates/email/not-main-printer-configured/not-main-printer-configured.js rename to print/templates/email/backup-printer-selected/backup-printer-selected.js index c381991fa..6372d52c0 100755 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -2,15 +2,14 @@ const Component = require(`vn-print/core/component`); const emailBody = new Component('email-body'); module.exports = { - name: 'not-main-printer-configured', + name: 'backup-printer-selected', async serverPrefetch() { this.sector = await this.findOneFromDef('sector', [this.sectorId]); - if (!this.sector) throw new Error('Something went wrong'); this.labeler = await this.findOneFromDef('printer', [this.labelerId]); - this.mainPrinter = await this.findOneFromDef('printer', [this.sector.mainPrinterFk]); + this.mainPrinter = await this.findOneFromDef('printer', [this.sector.backupPrinterFk]); this.worker = await this.findOneFromDef('worker', [this.workerId]); }, components: { @@ -29,5 +28,6 @@ module.exports = { type: Number, required: true } + } }; diff --git a/print/templates/email/backup-printer-selected/locale/en.yml b/print/templates/email/backup-printer-selected/locale/en.yml new file mode 100644 index 000000000..038e16e00 --- /dev/null +++ b/print/templates/email/backup-printer-selected/locale/en.yml @@ -0,0 +1,3 @@ +subject: Not main printer configured +title: Not main printer configured +description: 'The worker {0} is using the backup printer {1} for their sector {2}.' \ No newline at end of file diff --git a/print/templates/email/backup-printer-selected/locale/es.yml b/print/templates/email/backup-printer-selected/locale/es.yml new file mode 100644 index 000000000..d172f2560 --- /dev/null +++ b/print/templates/email/backup-printer-selected/locale/es.yml @@ -0,0 +1,3 @@ +subject: Seleccionada impresora de repuesto +title: Seleccionada impresora de repuesto +description: 'El trabajador {0} esta utilizando la impresora de repuesto {1} del sector {2}.' diff --git a/print/templates/email/not-main-printer-configured/sql/printer.sql b/print/templates/email/backup-printer-selected/sql/printer.sql similarity index 63% rename from print/templates/email/not-main-printer-configured/sql/printer.sql rename to print/templates/email/backup-printer-selected/sql/printer.sql index 265818129..2a98a8f08 100644 --- a/print/templates/email/not-main-printer-configured/sql/printer.sql +++ b/print/templates/email/backup-printer-selected/sql/printer.sql @@ -1,3 +1,4 @@ -SELECT id, name +SELECT id, + name FROM vn.printer WHERE id = ? diff --git a/print/templates/email/backup-printer-selected/sql/sector.sql b/print/templates/email/backup-printer-selected/sql/sector.sql new file mode 100644 index 000000000..9514c4e38 --- /dev/null +++ b/print/templates/email/backup-printer-selected/sql/sector.sql @@ -0,0 +1,5 @@ +SELECT id, + description, + backupPrinterFk + FROM vn.sector + WHERE id = ? diff --git a/print/templates/email/not-main-printer-configured/sql/worker.sql b/print/templates/email/backup-printer-selected/sql/worker.sql similarity index 100% rename from print/templates/email/not-main-printer-configured/sql/worker.sql rename to print/templates/email/backup-printer-selected/sql/worker.sql diff --git a/print/templates/email/not-main-printer-configured/locale/en.yml b/print/templates/email/not-main-printer-configured/locale/en.yml deleted file mode 100644 index 2a3051145..000000000 --- a/print/templates/email/not-main-printer-configured/locale/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -subject: Not main printer configured -title: Not main printer configured -description: 'Printer #{0} {1} has been configured in sector #{2} {3} (the main printer for that sector is #{4} {5}). Ask the worker {6}.' diff --git a/print/templates/email/not-main-printer-configured/locale/es.yml b/print/templates/email/not-main-printer-configured/locale/es.yml deleted file mode 100644 index b6fe5f9a0..000000000 --- a/print/templates/email/not-main-printer-configured/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -subject: Configurada impresora no principal -title: Configurada impresora no principal -description: 'Se ha configurado la impresora #{0} {1} en el sector #{2} {3} (la impresora principal de ese sector es la #{4} {5}). Preguntar al trabajador {6}.' diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html deleted file mode 100644 index 1e9ffed7a..000000000 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-
-

{{ $t('title') }}

-

-
-
-
diff --git a/print/templates/email/not-main-printer-configured/sql/sector.sql b/print/templates/email/not-main-printer-configured/sql/sector.sql deleted file mode 100644 index 5d54eeeb9..000000000 --- a/print/templates/email/not-main-printer-configured/sql/sector.sql +++ /dev/null @@ -1,3 +0,0 @@ -SELECT id, description, mainPrinterFk - FROM vn.sector - WHERE id = ? diff --git a/win/Content.md b/win/Content.md new file mode 100644 index 000000000..eea5b123c --- /dev/null +++ b/win/Content.md @@ -0,0 +1,18 @@ +# win + +In this folder, there are two scripts: +1- 'addRule' : adds a rule to the Windows firewall to accept requests on ports 3000 and 5000. +2- 'redirect' : allows redirecting ports 3000 and 5000 so that our machine processes them with our local Salix server. + + +## Run + +Two ways: + +1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal Powershell with administrator permissions execute addRule.ps1 only one time and execute redirect.ps1 every time you need redirect ports when the project is running. + +2-Search the project of Salix in WSL with the explorer of windows and edit the files with .lnk with the path of your installation of Salix. So , you will have a direct link for execute. + +## Server + +To access your Salix server, you can directly enter the IP or name of your computer along with the corresponding port \ No newline at end of file diff --git a/win/addRule.ps1 b/win/addRule.ps1 new file mode 100644 index 000000000..363f4fee4 --- /dev/null +++ b/win/addRule.ps1 @@ -0,0 +1,26 @@ +# Definir las propiedades de la nueva regla +# Define el nombre de la regla +$ruleName = "salixRule" + +# Define el perfil de la regla (Dominio, Privado, P�blico) +$profile = "Domain,Private,Public" + +# Define la acción (Permitir/Bloquear) +$action = "Allow" + +# Define el protocolo (TCP/UDP) +$protocol = "TCP" + +# Define el puerto local +$port = 3000, 5000 + +# Define una descripción (opcional) +$description = "Permitir tráfico HTTP.Frontend y backend Salix." + +# Crea la regla de firewall +New-NetFirewallRule -DisplayName $ruleName -Profile $profile -Action $action -Protocol $protocol -LocalPort $port -Description $description + +# Imprime un mensaje de confirmación +Write-Host "Regla de firewall creada exitosamente: $ruleName" + +pause diff --git a/win/powershellAddRule.lnk b/win/powershellAddRule.lnk new file mode 100644 index 000000000..bb462149a Binary files /dev/null and b/win/powershellAddRule.lnk differ diff --git a/win/powershellRedirect.lnk b/win/powershellRedirect.lnk new file mode 100644 index 000000000..e5cc78862 Binary files /dev/null and b/win/powershellRedirect.lnk differ diff --git a/win/redirect.ps1 b/win/redirect.ps1 new file mode 100644 index 000000000..431e569b2 --- /dev/null +++ b/win/redirect.ps1 @@ -0,0 +1,5 @@ +# Redireccionar ports + +$wslip = ((wsl hostname -I) -split " ")[0] +netsh interface portproxy set v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=$wslip +netsh interface portproxy set v4tov4 listenport=5000 listenaddress=0.0.0.0 connectport=5000 connectaddress=$wslip